documentation.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. /**
  408. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  684. static readonly GEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export class ShaderCodeTestNode extends ShaderCodeNode {
  1191. testExpression: ShaderDefineExpression;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1200. define: string;
  1201. not: boolean;
  1202. constructor(define: string, not?: boolean);
  1203. isTrue(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1211. leftOperand: ShaderDefineExpression;
  1212. rightOperand: ShaderDefineExpression;
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. }
  1217. }
  1218. declare module BABYLON {
  1219. /** @hidden */
  1220. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1221. leftOperand: ShaderDefineExpression;
  1222. rightOperand: ShaderDefineExpression;
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module BABYLON {
  1229. /** @hidden */
  1230. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1231. define: string;
  1232. operand: string;
  1233. testValue: string;
  1234. constructor(define: string, operand: string, testValue: string);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module BABYLON {
  1241. /**
  1242. * Class used to enable access to offline support
  1243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1244. */
  1245. export interface IOfflineProvider {
  1246. /**
  1247. * Gets a boolean indicating if scene must be saved in the database
  1248. */
  1249. enableSceneOffline: boolean;
  1250. /**
  1251. * Gets a boolean indicating if textures must be saved in the database
  1252. */
  1253. enableTexturesOffline: boolean;
  1254. /**
  1255. * Open the offline support and make it available
  1256. * @param successCallback defines the callback to call on success
  1257. * @param errorCallback defines the callback to call on error
  1258. */
  1259. open(successCallback: () => void, errorCallback: () => void): void;
  1260. /**
  1261. * Loads an image from the offline support
  1262. * @param url defines the url to load from
  1263. * @param image defines the target DOM image
  1264. */
  1265. loadImage(url: string, image: HTMLImageElement): void;
  1266. /**
  1267. * Loads a file from offline support
  1268. * @param url defines the URL to load from
  1269. * @param sceneLoaded defines a callback to call on success
  1270. * @param progressCallBack defines a callback to call when progress changed
  1271. * @param errorCallback defines a callback to call on error
  1272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1273. */
  1274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1275. }
  1276. }
  1277. declare module BABYLON {
  1278. /**
  1279. * Class used to help managing file picking and drag'n'drop
  1280. * File Storage
  1281. */
  1282. export class FilesInputStore {
  1283. /**
  1284. * List of files ready to be loaded
  1285. */
  1286. static FilesToLoad: {
  1287. [key: string]: File;
  1288. };
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /**
  1293. * Class used to define a retry strategy when error happens while loading assets
  1294. */
  1295. export class RetryStrategy {
  1296. /**
  1297. * Function used to defines an exponential back off strategy
  1298. * @param maxRetries defines the maximum number of retries (3 by default)
  1299. * @param baseInterval defines the interval between retries
  1300. * @returns the strategy function to use
  1301. */
  1302. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * @ignore
  1308. * Application error to support additional information when loading a file
  1309. */
  1310. export abstract class BaseError extends Error {
  1311. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /** @ignore */
  1316. export class LoadFileError extends BaseError {
  1317. request?: WebRequest;
  1318. file?: File;
  1319. /**
  1320. * Creates a new LoadFileError
  1321. * @param message defines the message of the error
  1322. * @param request defines the optional web request
  1323. * @param file defines the optional file
  1324. */
  1325. constructor(message: string, object?: WebRequest | File);
  1326. }
  1327. /** @ignore */
  1328. export class RequestFileError extends BaseError {
  1329. request: WebRequest;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. */
  1335. constructor(message: string, request: WebRequest);
  1336. }
  1337. /** @ignore */
  1338. export class ReadFileError extends BaseError {
  1339. file: File;
  1340. /**
  1341. * Creates a new ReadFileError
  1342. * @param message defines the message of the error
  1343. * @param file defines the optional file
  1344. */
  1345. constructor(message: string, file: File);
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export class FileTools {
  1351. /**
  1352. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1353. */
  1354. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1355. /**
  1356. * Gets or sets the base URL to use to load assets
  1357. */
  1358. static BaseUrl: string;
  1359. /**
  1360. * Default behaviour for cors in the application.
  1361. * It can be a string if the expected behavior is identical in the entire app.
  1362. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1363. */
  1364. static CorsBehavior: string | ((url: string | string[]) => string);
  1365. /**
  1366. * Gets or sets a function used to pre-process url before using them to load assets
  1367. */
  1368. static PreprocessUrl: (url: string) => string;
  1369. /**
  1370. * Removes unwanted characters from an url
  1371. * @param url defines the url to clean
  1372. * @returns the cleaned url
  1373. */
  1374. private static _CleanUrl;
  1375. /**
  1376. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1377. * @param url define the url we are trying
  1378. * @param element define the dom element where to configure the cors policy
  1379. */
  1380. static SetCorsBehavior(url: string | string[], element: {
  1381. crossOrigin: string | null;
  1382. }): void;
  1383. /**
  1384. * Loads an image as an HTMLImageElement.
  1385. * @param input url string, ArrayBuffer, or Blob to load
  1386. * @param onLoad callback called when the image successfully loads
  1387. * @param onError callback called when the image fails to load
  1388. * @param offlineProvider offline provider for caching
  1389. * @param mimeType optional mime type
  1390. * @returns the HTMLImageElement of the loaded image
  1391. */
  1392. 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>;
  1393. /**
  1394. * Reads a file from a File object
  1395. * @param file defines the file to load
  1396. * @param onSuccess defines the callback to call when data is loaded
  1397. * @param onProgress defines the callback to call during loading process
  1398. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1399. * @param onError defines the callback to call when an error occurs
  1400. * @returns a file request object
  1401. */
  1402. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1403. /**
  1404. * Loads a file from a url
  1405. * @param url url to load
  1406. * @param onSuccess callback called when the file successfully loads
  1407. * @param onProgress callback called while file is loading (if the server supports this mode)
  1408. * @param offlineProvider defines the offline provider for caching
  1409. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1410. * @param onError callback called when the file fails to load
  1411. * @returns a file request object
  1412. */
  1413. 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;
  1414. /**
  1415. * Loads a file
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1420. * @param onError callback called when the file fails to load
  1421. * @param onOpened callback called when the web request is opened
  1422. * @returns a file request object
  1423. */
  1424. 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;
  1425. /**
  1426. * Checks if the loaded document was accessed via `file:`-Protocol.
  1427. * @returns boolean
  1428. */
  1429. static IsFileURL(): boolean;
  1430. }
  1431. }
  1432. declare module BABYLON {
  1433. /** @hidden */
  1434. export class ShaderProcessor {
  1435. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1436. private static _ProcessPrecision;
  1437. private static _ExtractOperation;
  1438. private static _BuildSubExpression;
  1439. private static _BuildExpression;
  1440. private static _MoveCursorWithinIf;
  1441. private static _MoveCursor;
  1442. private static _EvaluatePreProcessors;
  1443. private static _PreparePreProcessors;
  1444. private static _ProcessShaderConversion;
  1445. private static _ProcessIncludes;
  1446. /**
  1447. * Loads a file from a url
  1448. * @param url url to load
  1449. * @param onSuccess callback called when the file successfully loads
  1450. * @param onProgress callback called while file is loading (if the server supports this mode)
  1451. * @param offlineProvider defines the offline provider for caching
  1452. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1453. * @param onError callback called when the file fails to load
  1454. * @returns a file request object
  1455. * @hidden
  1456. */
  1457. 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;
  1458. }
  1459. }
  1460. declare module BABYLON {
  1461. /**
  1462. * @hidden
  1463. */
  1464. export interface IColor4Like {
  1465. r: float;
  1466. g: float;
  1467. b: float;
  1468. a: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor3Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. }
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IVector4Like {
  1482. x: float;
  1483. y: float;
  1484. z: float;
  1485. w: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector3Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector2Like {
  1499. x: float;
  1500. y: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IMatrixLike {
  1506. toArray(): DeepImmutable<Float32Array>;
  1507. updateFlag: int;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IViewportLike {
  1513. x: float;
  1514. y: float;
  1515. width: float;
  1516. height: float;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IPlaneLike {
  1522. normal: IVector3Like;
  1523. d: float;
  1524. normalize(): void;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /**
  1529. * Interface used to define common properties for effect fallbacks
  1530. */
  1531. export interface IEffectFallbacks {
  1532. /**
  1533. * Removes the defines that should be removed when falling back.
  1534. * @param currentDefines defines the current define statements for the shader.
  1535. * @param effect defines the current effect we try to compile
  1536. * @returns The resulting defines with defines of the current rank removed.
  1537. */
  1538. reduce(currentDefines: string, effect: Effect): string;
  1539. /**
  1540. * Removes the fallback from the bound mesh.
  1541. */
  1542. unBindMesh(): void;
  1543. /**
  1544. * Checks to see if more fallbacks are still availible.
  1545. */
  1546. hasMoreFallbacks: boolean;
  1547. }
  1548. }
  1549. declare module BABYLON {
  1550. /**
  1551. * Class used to evalaute queries containing `and` and `or` operators
  1552. */
  1553. export class AndOrNotEvaluator {
  1554. /**
  1555. * Evaluate a query
  1556. * @param query defines the query to evaluate
  1557. * @param evaluateCallback defines the callback used to filter result
  1558. * @returns true if the query matches
  1559. */
  1560. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1561. private static _HandleParenthesisContent;
  1562. private static _SimplifyNegation;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /**
  1567. * Class used to store custom tags
  1568. */
  1569. export class Tags {
  1570. /**
  1571. * Adds support for tags on the given object
  1572. * @param obj defines the object to use
  1573. */
  1574. static EnableFor(obj: any): void;
  1575. /**
  1576. * Removes tags support
  1577. * @param obj defines the object to use
  1578. */
  1579. static DisableFor(obj: any): void;
  1580. /**
  1581. * Gets a boolean indicating if the given object has tags
  1582. * @param obj defines the object to use
  1583. * @returns a boolean
  1584. */
  1585. static HasTags(obj: any): boolean;
  1586. /**
  1587. * Gets the tags available on a given object
  1588. * @param obj defines the object to use
  1589. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1590. * @returns the tags
  1591. */
  1592. static GetTags(obj: any, asString?: boolean): any;
  1593. /**
  1594. * Adds tags to an object
  1595. * @param obj defines the object to use
  1596. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1597. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1598. */
  1599. static AddTagsTo(obj: any, tagsString: string): void;
  1600. /**
  1601. * @hidden
  1602. */
  1603. static _AddTagTo(obj: any, tag: string): void;
  1604. /**
  1605. * Removes specific tags from a specific object
  1606. * @param obj defines the object to use
  1607. * @param tagsString defines the tags to remove
  1608. */
  1609. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1610. /**
  1611. * @hidden
  1612. */
  1613. static _RemoveTagFrom(obj: any, tag: string): void;
  1614. /**
  1615. * Defines if tags hosted on an object match a given query
  1616. * @param obj defines the object to use
  1617. * @param tagsQuery defines the tag query
  1618. * @returns a boolean
  1619. */
  1620. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1621. }
  1622. }
  1623. declare module BABYLON {
  1624. /**
  1625. * Scalar computation library
  1626. */
  1627. export class Scalar {
  1628. /**
  1629. * Two pi constants convenient for computation.
  1630. */
  1631. static TwoPi: number;
  1632. /**
  1633. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1634. * @param a number
  1635. * @param b number
  1636. * @param epsilon (default = 1.401298E-45)
  1637. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. */
  1639. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1640. /**
  1641. * Returns a string : the upper case translation of the number i to hexadecimal.
  1642. * @param i number
  1643. * @returns the upper case translation of the number i to hexadecimal.
  1644. */
  1645. static ToHex(i: number): string;
  1646. /**
  1647. * Returns -1 if value is negative and +1 is value is positive.
  1648. * @param value the value
  1649. * @returns the value itself if it's equal to zero.
  1650. */
  1651. static Sign(value: number): number;
  1652. /**
  1653. * Returns the value itself if it's between min and max.
  1654. * Returns min if the value is lower than min.
  1655. * Returns max if the value is greater than max.
  1656. * @param value the value to clmap
  1657. * @param min the min value to clamp to (default: 0)
  1658. * @param max the max value to clamp to (default: 1)
  1659. * @returns the clamped value
  1660. */
  1661. static Clamp(value: number, min?: number, max?: number): number;
  1662. /**
  1663. * the log2 of value.
  1664. * @param value the value to compute log2 of
  1665. * @returns the log2 of value.
  1666. */
  1667. static Log2(value: number): number;
  1668. /**
  1669. * Loops the value, so that it is never larger than length and never smaller than 0.
  1670. *
  1671. * This is similar to the modulo operator but it works with floating point numbers.
  1672. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1673. * With t = 5 and length = 2.5, the result would be 0.0.
  1674. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1675. * @param value the value
  1676. * @param length the length
  1677. * @returns the looped value
  1678. */
  1679. static Repeat(value: number, length: number): number;
  1680. /**
  1681. * Normalize the value between 0.0 and 1.0 using min and max values
  1682. * @param value value to normalize
  1683. * @param min max to normalize between
  1684. * @param max min to normalize between
  1685. * @returns the normalized value
  1686. */
  1687. static Normalize(value: number, min: number, max: number): number;
  1688. /**
  1689. * Denormalize the value from 0.0 and 1.0 using min and max values
  1690. * @param normalized value to denormalize
  1691. * @param min max to denormalize between
  1692. * @param max min to denormalize between
  1693. * @returns the denormalized value
  1694. */
  1695. static Denormalize(normalized: number, min: number, max: number): number;
  1696. /**
  1697. * Calculates the shortest difference between two given angles given in degrees.
  1698. * @param current current angle in degrees
  1699. * @param target target angle in degrees
  1700. * @returns the delta
  1701. */
  1702. static DeltaAngle(current: number, target: number): number;
  1703. /**
  1704. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1705. * @param tx value
  1706. * @param length length
  1707. * @returns The returned value will move back and forth between 0 and length
  1708. */
  1709. static PingPong(tx: number, length: number): number;
  1710. /**
  1711. * Interpolates between min and max with smoothing at the limits.
  1712. *
  1713. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1714. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1715. * @param from from
  1716. * @param to to
  1717. * @param tx value
  1718. * @returns the smooth stepped value
  1719. */
  1720. static SmoothStep(from: number, to: number, tx: number): number;
  1721. /**
  1722. * Moves a value current towards target.
  1723. *
  1724. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1725. * Negative values of maxDelta pushes the value away from target.
  1726. * @param current current value
  1727. * @param target target value
  1728. * @param maxDelta max distance to move
  1729. * @returns resulting value
  1730. */
  1731. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1732. /**
  1733. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1734. *
  1735. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1736. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1737. * @param current current value
  1738. * @param target target value
  1739. * @param maxDelta max distance to move
  1740. * @returns resulting angle
  1741. */
  1742. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1743. /**
  1744. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1745. * @param start start value
  1746. * @param end target value
  1747. * @param amount amount to lerp between
  1748. * @returns the lerped value
  1749. */
  1750. static Lerp(start: number, end: number, amount: number): number;
  1751. /**
  1752. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1753. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  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 LerpAngle(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1762. * @param a start value
  1763. * @param b target value
  1764. * @param value value between a and b
  1765. * @returns the inverseLerp value
  1766. */
  1767. static InverseLerp(a: number, b: number, value: number): number;
  1768. /**
  1769. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1770. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1771. * @param value1 spline value
  1772. * @param tangent1 spline value
  1773. * @param value2 spline value
  1774. * @param tangent2 spline value
  1775. * @param amount input value
  1776. * @returns hermite result
  1777. */
  1778. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1779. /**
  1780. * Returns a random float number between and min and max values
  1781. * @param min min value of random
  1782. * @param max max value of random
  1783. * @returns random value
  1784. */
  1785. static RandomRange(min: number, max: number): number;
  1786. /**
  1787. * This function returns percentage of a number in a given range.
  1788. *
  1789. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1790. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1791. * @param number to convert to percentage
  1792. * @param min min range
  1793. * @param max max range
  1794. * @returns the percentage
  1795. */
  1796. static RangeToPercent(number: number, min: number, max: number): number;
  1797. /**
  1798. * This function returns number that corresponds to the percentage in a given range.
  1799. *
  1800. * PercentToRange(0.34,0,100) will return 34.
  1801. * @param percent to convert to number
  1802. * @param min min range
  1803. * @param max max range
  1804. * @returns the number
  1805. */
  1806. static PercentToRange(percent: number, min: number, max: number): number;
  1807. /**
  1808. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1809. * @param angle The angle to normalize in radian.
  1810. * @return The converted angle.
  1811. */
  1812. static NormalizeRadians(angle: number): number;
  1813. }
  1814. }
  1815. declare module BABYLON {
  1816. /**
  1817. * Constant used to convert a value to gamma space
  1818. * @ignorenaming
  1819. */
  1820. export const ToGammaSpace: number;
  1821. /**
  1822. * Constant used to convert a value to linear space
  1823. * @ignorenaming
  1824. */
  1825. export const ToLinearSpace = 2.2;
  1826. /**
  1827. * Constant used to define the minimal number value in Babylon.js
  1828. * @ignorenaming
  1829. */
  1830. let Epsilon: number;
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Class used to represent a viewport on screen
  1835. */
  1836. export class Viewport {
  1837. /** viewport left coordinate */
  1838. x: number;
  1839. /** viewport top coordinate */
  1840. y: number;
  1841. /**viewport width */
  1842. width: number;
  1843. /** viewport height */
  1844. height: number;
  1845. /**
  1846. * Creates a Viewport object located at (x, y) and sized (width, height)
  1847. * @param x defines viewport left coordinate
  1848. * @param y defines viewport top coordinate
  1849. * @param width defines the viewport width
  1850. * @param height defines the viewport height
  1851. */
  1852. constructor(
  1853. /** viewport left coordinate */
  1854. x: number,
  1855. /** viewport top coordinate */
  1856. y: number,
  1857. /**viewport width */
  1858. width: number,
  1859. /** viewport height */
  1860. height: number);
  1861. /**
  1862. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1863. * @param renderWidth defines the rendering width
  1864. * @param renderHeight defines the rendering height
  1865. * @returns a new Viewport
  1866. */
  1867. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1868. /**
  1869. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @param ref defines the target viewport
  1873. * @returns the current viewport
  1874. */
  1875. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1876. /**
  1877. * Returns a new Viewport copied from the current one
  1878. * @returns a new Viewport
  1879. */
  1880. clone(): Viewport;
  1881. }
  1882. }
  1883. declare module BABYLON {
  1884. /**
  1885. * Class containing a set of static utilities functions for arrays.
  1886. */
  1887. export class ArrayTools {
  1888. /**
  1889. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1890. * @param size the number of element to construct and put in the array
  1891. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1892. * @returns a new array filled with new objects
  1893. */
  1894. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1895. }
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class representing a vector containing 2 coordinates
  1900. */
  1901. export class Vector2 {
  1902. /** defines the first coordinate */
  1903. x: number;
  1904. /** defines the second coordinate */
  1905. y: number;
  1906. /**
  1907. * Creates a new Vector2 from the given x and y coordinates
  1908. * @param x defines the first coordinate
  1909. * @param y defines the second coordinate
  1910. */
  1911. constructor(
  1912. /** defines the first coordinate */
  1913. x?: number,
  1914. /** defines the second coordinate */
  1915. y?: number);
  1916. /**
  1917. * Gets a string with the Vector2 coordinates
  1918. * @returns a string with the Vector2 coordinates
  1919. */
  1920. toString(): string;
  1921. /**
  1922. * Gets class name
  1923. * @returns the string "Vector2"
  1924. */
  1925. getClassName(): string;
  1926. /**
  1927. * Gets current vector hash code
  1928. * @returns the Vector2 hash code as a number
  1929. */
  1930. getHashCode(): number;
  1931. /**
  1932. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1933. * @param array defines the source array
  1934. * @param index defines the offset in source array
  1935. * @returns the current Vector2
  1936. */
  1937. toArray(array: FloatArray, index?: number): Vector2;
  1938. /**
  1939. * Copy the current vector to an array
  1940. * @returns a new array with 2 elements: the Vector2 coordinates.
  1941. */
  1942. asArray(): number[];
  1943. /**
  1944. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1945. * @param source defines the source Vector2
  1946. * @returns the current updated Vector2
  1947. */
  1948. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1949. /**
  1950. * Sets the Vector2 coordinates with the given floats
  1951. * @param x defines the first coordinate
  1952. * @param y defines the second coordinate
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFromFloats(x: number, y: number): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. set(x: number, y: number): Vector2;
  1963. /**
  1964. * Add another vector with the current one
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1967. */
  1968. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1984. * @param otherVector defines the other vector
  1985. * @returns a new Vector2
  1986. */
  1987. addVector3(otherVector: Vector3): Vector2;
  1988. /**
  1989. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. subtract(otherVector: Vector2): Vector2;
  1994. /**
  1995. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2003. * @param otherVector defines the other vector
  2004. * @returns the current updated Vector2
  2005. */
  2006. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2007. /**
  2008. * Multiplies in place the current Vector2 coordinates by the given ones
  2009. * @param otherVector defines the other vector
  2010. * @returns the current updated Vector2
  2011. */
  2012. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2015. * @param otherVector defines the other vector
  2016. * @returns a new Vector2
  2017. */
  2018. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2021. * @param otherVector defines the other vector
  2022. * @param result defines the target vector
  2023. * @returns the unmodified current Vector2
  2024. */
  2025. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2026. /**
  2027. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2028. * @param x defines the first coordinate
  2029. * @param y defines the second coordinate
  2030. * @returns a new Vector2
  2031. */
  2032. multiplyByFloats(x: number, y: number): Vector2;
  2033. /**
  2034. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2035. * @param otherVector defines the other vector
  2036. * @returns a new Vector2
  2037. */
  2038. divide(otherVector: Vector2): Vector2;
  2039. /**
  2040. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2041. * @param otherVector defines the other vector
  2042. * @param result defines the target vector
  2043. * @returns the unmodified current Vector2
  2044. */
  2045. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2046. /**
  2047. * Divides the current Vector2 coordinates by the given ones
  2048. * @param otherVector defines the other vector
  2049. * @returns the current updated Vector2
  2050. */
  2051. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Gets a new Vector2 with current Vector2 negated coordinates
  2054. * @returns a new Vector2
  2055. */
  2056. negate(): Vector2;
  2057. /**
  2058. * Negate this vector in place
  2059. * @returns this
  2060. */
  2061. negateInPlace(): Vector2;
  2062. /**
  2063. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2064. * @param result defines the Vector3 object where to store the result
  2065. * @returns the current Vector2
  2066. */
  2067. negateToRef(result: Vector2): Vector2;
  2068. /**
  2069. * Multiply the Vector2 coordinates by scale
  2070. * @param scale defines the scaling factor
  2071. * @returns the current updated Vector2
  2072. */
  2073. scaleInPlace(scale: number): Vector2;
  2074. /**
  2075. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2076. * @param scale defines the scaling factor
  2077. * @returns a new Vector2
  2078. */
  2079. scale(scale: number): Vector2;
  2080. /**
  2081. * Scale the current Vector2 values by a factor to a given Vector2
  2082. * @param scale defines the scale factor
  2083. * @param result defines the Vector2 object where to store the result
  2084. * @returns the unmodified current Vector2
  2085. */
  2086. scaleToRef(scale: number, result: Vector2): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Gets a boolean if two vectors are equals
  2096. * @param otherVector defines the other vector
  2097. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2098. */
  2099. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2100. /**
  2101. * Gets a boolean if two vectors are equals (using an epsilon value)
  2102. * @param otherVector defines the other vector
  2103. * @param epsilon defines the minimal distance to consider equality
  2104. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2105. */
  2106. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2107. /**
  2108. * Gets a new Vector2 from current Vector2 floored values
  2109. * @returns a new Vector2
  2110. */
  2111. floor(): Vector2;
  2112. /**
  2113. * Gets a new Vector2 from current Vector2 floored values
  2114. * @returns a new Vector2
  2115. */
  2116. fract(): Vector2;
  2117. /**
  2118. * Gets the length of the vector
  2119. * @returns the vector length (float)
  2120. */
  2121. length(): number;
  2122. /**
  2123. * Gets the vector squared length
  2124. * @returns the vector squared length (float)
  2125. */
  2126. lengthSquared(): number;
  2127. /**
  2128. * Normalize the vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. normalize(): Vector2;
  2132. /**
  2133. * Gets a new Vector2 copied from the Vector2
  2134. * @returns a new Vector2
  2135. */
  2136. clone(): Vector2;
  2137. /**
  2138. * Gets a new Vector2(0, 0)
  2139. * @returns a new Vector2
  2140. */
  2141. static Zero(): Vector2;
  2142. /**
  2143. * Gets a new Vector2(1, 1)
  2144. * @returns a new Vector2
  2145. */
  2146. static One(): Vector2;
  2147. /**
  2148. * Gets a new Vector2 set from the given index element of the given array
  2149. * @param array defines the data source
  2150. * @param offset defines the offset in the data source
  2151. * @returns a new Vector2
  2152. */
  2153. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2154. /**
  2155. * Sets "result" from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @param result defines the target vector
  2159. */
  2160. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2161. /**
  2162. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2163. * @param value1 defines 1st point of control
  2164. * @param value2 defines 2nd point of control
  2165. * @param value3 defines 3rd point of control
  2166. * @param value4 defines 4th point of control
  2167. * @param amount defines the interpolation factor
  2168. * @returns a new Vector2
  2169. */
  2170. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2171. /**
  2172. * 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".
  2173. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2174. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2175. * @param value defines the value to clamp
  2176. * @param min defines the lower limit
  2177. * @param max defines the upper limit
  2178. * @returns a new Vector2
  2179. */
  2180. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2183. * @param value1 defines the 1st control point
  2184. * @param tangent1 defines the outgoing tangent
  2185. * @param value2 defines the 2nd control point
  2186. * @param tangent2 defines the incoming tangent
  2187. * @param amount defines the interpolation factor
  2188. * @returns a new Vector2
  2189. */
  2190. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2193. * @param start defines the start vector
  2194. * @param end defines the end vector
  2195. * @param amount defines the interpolation factor
  2196. * @returns a new Vector2
  2197. */
  2198. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2199. /**
  2200. * Gets the dot product of the vector "left" and the vector "right"
  2201. * @param left defines first vector
  2202. * @param right defines second vector
  2203. * @returns the dot product (float)
  2204. */
  2205. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2206. /**
  2207. * Returns a new Vector2 equal to the normalized given vector
  2208. * @param vector defines the vector to normalize
  2209. * @returns a new Vector2
  2210. */
  2211. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2214. * @param left defines 1st vector
  2215. * @param right defines 2nd vector
  2216. * @returns a new Vector2
  2217. */
  2218. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2228. * @param vector defines the vector to transform
  2229. * @param transformation defines the matrix to apply
  2230. * @returns a new Vector2
  2231. */
  2232. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2233. /**
  2234. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @param result defines the target vector
  2238. */
  2239. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2240. /**
  2241. * Determines if a given vector is included in a triangle
  2242. * @param p defines the vector to test
  2243. * @param p0 defines 1st triangle point
  2244. * @param p1 defines 2nd triangle point
  2245. * @param p2 defines 3rd triangle point
  2246. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2247. */
  2248. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2249. /**
  2250. * Gets the distance between the vectors "value1" and "value2"
  2251. * @param value1 defines first vector
  2252. * @param value2 defines second vector
  2253. * @returns the distance between vectors
  2254. */
  2255. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2256. /**
  2257. * Returns the squared distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the squared distance between vectors
  2261. */
  2262. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns a new Vector2
  2268. */
  2269. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2270. /**
  2271. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2272. * @param p defines the middle point
  2273. * @param segA defines one point of the segment
  2274. * @param segB defines the other point of the segment
  2275. * @returns the shortest distance
  2276. */
  2277. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2278. }
  2279. /**
  2280. * Class used to store (x,y,z) vector representation
  2281. * A Vector3 is the main object used in 3D geometry
  2282. * It can represent etiher the coordinates of a point the space, either a direction
  2283. * Reminder: js uses a left handed forward facing system
  2284. */
  2285. export class Vector3 {
  2286. /**
  2287. * Defines the first coordinates (on X axis)
  2288. */
  2289. x: number;
  2290. /**
  2291. * Defines the second coordinates (on Y axis)
  2292. */
  2293. y: number;
  2294. /**
  2295. * Defines the third coordinates (on Z axis)
  2296. */
  2297. z: number;
  2298. private static _UpReadOnly;
  2299. private static _ZeroReadOnly;
  2300. /**
  2301. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2302. * @param x defines the first coordinates (on X axis)
  2303. * @param y defines the second coordinates (on Y axis)
  2304. * @param z defines the third coordinates (on Z axis)
  2305. */
  2306. constructor(
  2307. /**
  2308. * Defines the first coordinates (on X axis)
  2309. */
  2310. x?: number,
  2311. /**
  2312. * Defines the second coordinates (on Y axis)
  2313. */
  2314. y?: number,
  2315. /**
  2316. * Defines the third coordinates (on Z axis)
  2317. */
  2318. z?: number);
  2319. /**
  2320. * Creates a string representation of the Vector3
  2321. * @returns a string with the Vector3 coordinates.
  2322. */
  2323. toString(): string;
  2324. /**
  2325. * Gets the class name
  2326. * @returns the string "Vector3"
  2327. */
  2328. getClassName(): string;
  2329. /**
  2330. * Creates the Vector3 hash code
  2331. * @returns a number which tends to be unique between Vector3 instances
  2332. */
  2333. getHashCode(): number;
  2334. /**
  2335. * Creates an array containing three elements : the coordinates of the Vector3
  2336. * @returns a new array of numbers
  2337. */
  2338. asArray(): number[];
  2339. /**
  2340. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2341. * @param array defines the destination array
  2342. * @param index defines the offset in the destination array
  2343. * @returns the current Vector3
  2344. */
  2345. toArray(array: FloatArray, index?: number): Vector3;
  2346. /**
  2347. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2348. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2349. */
  2350. toQuaternion(): Quaternion;
  2351. /**
  2352. * Adds the given vector to the current Vector3
  2353. * @param otherVector defines the second operand
  2354. * @returns the current updated Vector3
  2355. */
  2356. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2357. /**
  2358. * Adds the given coordinates to the current Vector3
  2359. * @param x defines the x coordinate of the operand
  2360. * @param y defines the y coordinate of the operand
  2361. * @param z defines the z coordinate of the operand
  2362. * @returns the current updated Vector3
  2363. */
  2364. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2365. /**
  2366. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2367. * @param otherVector defines the second operand
  2368. * @returns the resulting Vector3
  2369. */
  2370. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2373. * @param otherVector defines the second operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2378. /**
  2379. * Subtract the given vector from the current Vector3
  2380. * @param otherVector defines the second operand
  2381. * @returns the current updated Vector3
  2382. */
  2383. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2384. /**
  2385. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the resulting Vector3
  2388. */
  2389. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2392. * @param otherVector defines the second operand
  2393. * @param result defines the Vector3 object where to store the result
  2394. * @returns the current Vector3
  2395. */
  2396. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2397. /**
  2398. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the resulting Vector3
  2403. */
  2404. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2407. * @param x defines the x coordinate of the operand
  2408. * @param y defines the y coordinate of the operand
  2409. * @param z defines the z coordinate of the operand
  2410. * @param result defines the Vector3 object where to store the result
  2411. * @returns the current Vector3
  2412. */
  2413. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2414. /**
  2415. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2416. * @returns a new Vector3
  2417. */
  2418. negate(): Vector3;
  2419. /**
  2420. * Negate this vector in place
  2421. * @returns this
  2422. */
  2423. negateInPlace(): Vector3;
  2424. /**
  2425. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. negateToRef(result: Vector3): Vector3;
  2430. /**
  2431. * Multiplies the Vector3 coordinates by the float "scale"
  2432. * @param scale defines the multiplier factor
  2433. * @returns the current updated Vector3
  2434. */
  2435. scaleInPlace(scale: number): Vector3;
  2436. /**
  2437. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2438. * @param scale defines the multiplier factor
  2439. * @returns a new Vector3
  2440. */
  2441. scale(scale: number): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2444. * @param scale defines the multiplier factor
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. scaleToRef(scale: number, result: Vector3): Vector3;
  2449. /**
  2450. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2451. * @param scale defines the scale factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the unmodified current Vector3
  2454. */
  2455. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2458. * @param otherVector defines the second operand
  2459. * @returns true if both vectors are equals
  2460. */
  2461. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2462. /**
  2463. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2464. * @param otherVector defines the second operand
  2465. * @param epsilon defines the minimal distance to define values as equals
  2466. * @returns true if both vectors are distant less than epsilon
  2467. */
  2468. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 coordinates equals the given floats
  2471. * @param x defines the x coordinate of the operand
  2472. * @param y defines the y coordinate of the operand
  2473. * @param z defines the z coordinate of the operand
  2474. * @returns true if both vectors are equals
  2475. */
  2476. equalsToFloats(x: number, y: number, z: number): boolean;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the given ones
  2479. * @param otherVector defines the second operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2483. /**
  2484. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the new Vector3
  2487. */
  2488. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the new Vector3
  2502. */
  2503. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2506. * @param otherVector defines the second operand
  2507. * @returns the new Vector3
  2508. */
  2509. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2510. /**
  2511. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2512. * @param otherVector defines the second operand
  2513. * @param result defines the Vector3 object where to store the result
  2514. * @returns the current Vector3
  2515. */
  2516. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones.
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. divideInPlace(otherVector: Vector3): Vector3;
  2523. /**
  2524. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2525. * @param other defines the second operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2531. * @param other defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2537. * @param x defines the x coordinate of the operand
  2538. * @param y defines the y coordinate of the operand
  2539. * @param z defines the z coordinate of the operand
  2540. * @returns the current updated Vector3
  2541. */
  2542. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2543. /**
  2544. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2545. * @param x defines the x coordinate of the operand
  2546. * @param y defines the y coordinate of the operand
  2547. * @param z defines the z coordinate of the operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2551. /**
  2552. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2553. * Check if is non uniform within a certain amount of decimal places to account for this
  2554. * @param epsilon the amount the values can differ
  2555. * @returns if the the vector is non uniform to a certain number of decimal places
  2556. */
  2557. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2558. /**
  2559. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2560. */
  2561. get isNonUniform(): boolean;
  2562. /**
  2563. * Gets a new Vector3 from current Vector3 floored values
  2564. * @returns a new Vector3
  2565. */
  2566. floor(): Vector3;
  2567. /**
  2568. * Gets a new Vector3 from current Vector3 floored values
  2569. * @returns a new Vector3
  2570. */
  2571. fract(): Vector3;
  2572. /**
  2573. * Gets the length of the Vector3
  2574. * @returns the length of the Vector3
  2575. */
  2576. length(): number;
  2577. /**
  2578. * Gets the squared length of the Vector3
  2579. * @returns squared length of the Vector3
  2580. */
  2581. lengthSquared(): number;
  2582. /**
  2583. * Normalize the current Vector3.
  2584. * Please note that this is an in place operation.
  2585. * @returns the current updated Vector3
  2586. */
  2587. normalize(): Vector3;
  2588. /**
  2589. * Reorders the x y z properties of the vector in place
  2590. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2591. * @returns the current updated vector
  2592. */
  2593. reorderInPlace(order: string): this;
  2594. /**
  2595. * Rotates the vector around 0,0,0 by a quaternion
  2596. * @param quaternion the rotation quaternion
  2597. * @param result vector to store the result
  2598. * @returns the resulting vector
  2599. */
  2600. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2601. /**
  2602. * Rotates a vector around a given point
  2603. * @param quaternion the rotation quaternion
  2604. * @param point the point to rotate around
  2605. * @param result vector to store the result
  2606. * @returns the resulting vector
  2607. */
  2608. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2609. /**
  2610. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2611. * The cross product is then orthogonal to both current and "other"
  2612. * @param other defines the right operand
  2613. * @returns the cross product
  2614. */
  2615. cross(other: Vector3): Vector3;
  2616. /**
  2617. * Normalize the current Vector3 with the given input length.
  2618. * Please note that this is an in place operation.
  2619. * @param len the length of the vector
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalizeFromLength(len: number): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 to a new vector
  2625. * @returns the new Vector3
  2626. */
  2627. normalizeToNew(): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 to the reference
  2630. * @param reference define the Vector3 to update
  2631. * @returns the updated Vector3
  2632. */
  2633. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2634. /**
  2635. * Creates a new Vector3 copied from the current Vector3
  2636. * @returns the new Vector3
  2637. */
  2638. clone(): Vector3;
  2639. /**
  2640. * Copies the given vector coordinates to the current Vector3 ones
  2641. * @param source defines the source Vector3
  2642. * @returns the current updated Vector3
  2643. */
  2644. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2645. /**
  2646. * Copies the given floats to the current Vector3 coordinates
  2647. * @param x defines the x coordinate of the operand
  2648. * @param y defines the y coordinate of the operand
  2649. * @param z defines the z coordinate of the operand
  2650. * @returns the current updated Vector3
  2651. */
  2652. copyFromFloats(x: number, y: number, z: number): Vector3;
  2653. /**
  2654. * Copies the given floats to the current Vector3 coordinates
  2655. * @param x defines the x coordinate of the operand
  2656. * @param y defines the y coordinate of the operand
  2657. * @param z defines the z coordinate of the operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. set(x: number, y: number, z: number): Vector3;
  2661. /**
  2662. * Copies the given float to the current Vector3 coordinates
  2663. * @param v defines the x, y and z coordinates of the operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. setAll(v: number): Vector3;
  2667. /**
  2668. * Get the clip factor between two vectors
  2669. * @param vector0 defines the first operand
  2670. * @param vector1 defines the second operand
  2671. * @param axis defines the axis to use
  2672. * @param size defines the size along the axis
  2673. * @returns the clip factor
  2674. */
  2675. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2676. /**
  2677. * Get angle between two vectors
  2678. * @param vector0 angle between vector0 and vector1
  2679. * @param vector1 angle between vector0 and vector1
  2680. * @param normal direction of the normal
  2681. * @return the angle between vector0 and vector1
  2682. */
  2683. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2684. /**
  2685. * Returns a new Vector3 set from the index "offset" of the given array
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @returns the new Vector3
  2689. */
  2690. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. * @deprecated Please use FromArray instead.
  2697. */
  2698. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2699. /**
  2700. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @param result defines the Vector3 where to store the result
  2704. */
  2705. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. * @deprecated Please use FromArrayToRef instead.
  2712. */
  2713. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2714. /**
  2715. * Sets the given vector "result" with the given floats.
  2716. * @param x defines the x coordinate of the source
  2717. * @param y defines the y coordinate of the source
  2718. * @param z defines the z coordinate of the source
  2719. * @param result defines the Vector3 where to store the result
  2720. */
  2721. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2724. * @returns a new empty Vector3
  2725. */
  2726. static Zero(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2729. * @returns a new unit Vector3
  2730. */
  2731. static One(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2734. * @returns a new up Vector3
  2735. */
  2736. static Up(): Vector3;
  2737. /**
  2738. * Gets a up Vector3 that must not be updated
  2739. */
  2740. static get UpReadOnly(): DeepImmutable<Vector3>;
  2741. /**
  2742. * Gets a zero Vector3 that must not be updated
  2743. */
  2744. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2747. * @returns a new down Vector3
  2748. */
  2749. static Down(): Vector3;
  2750. /**
  2751. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2752. * @returns a new forward Vector3
  2753. */
  2754. static Forward(): Vector3;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2757. * @returns a new forward Vector3
  2758. */
  2759. static Backward(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2762. * @returns a new right Vector3
  2763. */
  2764. static Right(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2767. * @returns a new left Vector3
  2768. */
  2769. static Left(): Vector3;
  2770. /**
  2771. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2772. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2773. * @param vector defines the Vector3 to transform
  2774. * @param transformation defines the transformation matrix
  2775. * @returns the transformed Vector3
  2776. */
  2777. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2778. /**
  2779. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2780. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2781. * @param vector defines the Vector3 to transform
  2782. * @param transformation defines the transformation matrix
  2783. * @param result defines the Vector3 where to store the result
  2784. */
  2785. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2786. /**
  2787. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2788. * This method computes tranformed coordinates only, not transformed direction vectors
  2789. * @param x define the x coordinate of the source vector
  2790. * @param y define the y coordinate of the source vector
  2791. * @param z define the z coordinate of the source vector
  2792. * @param transformation defines the transformation matrix
  2793. * @param result defines the Vector3 where to store the result
  2794. */
  2795. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2796. /**
  2797. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2798. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2799. * @param vector defines the Vector3 to transform
  2800. * @param transformation defines the transformation matrix
  2801. * @returns the new Vector3
  2802. */
  2803. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2804. /**
  2805. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2806. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2807. * @param vector defines the Vector3 to transform
  2808. * @param transformation defines the transformation matrix
  2809. * @param result defines the Vector3 where to store the result
  2810. */
  2811. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2812. /**
  2813. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2814. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2815. * @param x define the x coordinate of the source vector
  2816. * @param y define the y coordinate of the source vector
  2817. * @param z define the z coordinate of the source vector
  2818. * @param transformation defines the transformation matrix
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2824. * @param value1 defines the first control point
  2825. * @param value2 defines the second control point
  2826. * @param value3 defines the third control point
  2827. * @param value4 defines the fourth control point
  2828. * @param amount defines the amount on the spline to use
  2829. * @returns the new Vector3
  2830. */
  2831. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2832. /**
  2833. * 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"
  2834. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2835. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2836. * @param value defines the current value
  2837. * @param min defines the lower range value
  2838. * @param max defines the upper range value
  2839. * @returns the new Vector3
  2840. */
  2841. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2842. /**
  2843. * 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"
  2844. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2845. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2846. * @param value defines the current value
  2847. * @param min defines the lower range value
  2848. * @param max defines the upper range value
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2852. /**
  2853. * Checks if a given vector is inside a specific range
  2854. * @param v defines the vector to test
  2855. * @param min defines the minimum range
  2856. * @param max defines the maximum range
  2857. */
  2858. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2861. * @param value1 defines the first control point
  2862. * @param tangent1 defines the first tangent vector
  2863. * @param value2 defines the second control point
  2864. * @param tangent2 defines the second tangent vector
  2865. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2866. * @returns the new Vector3
  2867. */
  2868. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2871. * @param start defines the start value
  2872. * @param end defines the end value
  2873. * @param amount max defines amount between both (between 0 and 1)
  2874. * @returns the new Vector3
  2875. */
  2876. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2879. * @param start defines the start value
  2880. * @param end defines the end value
  2881. * @param amount max defines amount between both (between 0 and 1)
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2885. /**
  2886. * Returns the dot product (float) between the vectors "left" and "right"
  2887. * @param left defines the left operand
  2888. * @param right defines the right operand
  2889. * @returns the dot product
  2890. */
  2891. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2892. /**
  2893. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2894. * The cross product is then orthogonal to both "left" and "right"
  2895. * @param left defines the left operand
  2896. * @param right defines the right operand
  2897. * @returns the cross product
  2898. */
  2899. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2900. /**
  2901. * Sets the given vector "result" with the cross product of "left" and "right"
  2902. * The cross product is then orthogonal to both "left" and "right"
  2903. * @param left defines the left operand
  2904. * @param right defines the right operand
  2905. * @param result defines the Vector3 where to store the result
  2906. */
  2907. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2908. /**
  2909. * Returns a new Vector3 as the normalization of the given vector
  2910. * @param vector defines the Vector3 to normalize
  2911. * @returns the new Vector3
  2912. */
  2913. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the normalization of the given first vector
  2916. * @param vector defines the Vector3 to normalize
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2920. /**
  2921. * Project a Vector3 onto screen space
  2922. * @param vector defines the Vector3 to project
  2923. * @param world defines the world matrix to use
  2924. * @param transform defines the transform (view x projection) matrix to use
  2925. * @param viewport defines the screen viewport to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2929. /** @hidden */
  2930. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2931. /**
  2932. * Unproject from screen space to object space
  2933. * @param source defines the screen space Vector3 to use
  2934. * @param viewportWidth defines the current width of the viewport
  2935. * @param viewportHeight defines the current height of the viewport
  2936. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2937. * @param transform defines the transform (view x projection) matrix to use
  2938. * @returns the new Vector3
  2939. */
  2940. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2941. /**
  2942. * Unproject from screen space to object space
  2943. * @param source defines the screen space Vector3 to use
  2944. * @param viewportWidth defines the current width of the viewport
  2945. * @param viewportHeight defines the current height of the viewport
  2946. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2947. * @param view defines the view matrix to use
  2948. * @param projection defines the projection matrix to use
  2949. * @returns the new Vector3
  2950. */
  2951. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2952. /**
  2953. * Unproject from screen space to object space
  2954. * @param source defines the screen space Vector3 to use
  2955. * @param viewportWidth defines the current width of the viewport
  2956. * @param viewportHeight defines the current height of the viewport
  2957. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2958. * @param view defines the view matrix to use
  2959. * @param projection defines the projection matrix to use
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param sourceX defines the screen space x coordinate to use
  2966. * @param sourceY defines the screen space y coordinate to use
  2967. * @param sourceZ defines the screen space z coordinate to use
  2968. * @param viewportWidth defines the current width of the viewport
  2969. * @param viewportHeight defines the current height of the viewport
  2970. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2971. * @param view defines the view matrix to use
  2972. * @param projection defines the projection matrix to use
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Gets the minimal coordinate values between two Vector3
  2978. * @param left defines the first operand
  2979. * @param right defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Gets the maximal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Returns the distance between the vectors "value1" and "value2"
  2992. * @param value1 defines the first operand
  2993. * @param value2 defines the second operand
  2994. * @returns the distance
  2995. */
  2996. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2997. /**
  2998. * Returns the squared distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the squared distance
  3002. */
  3003. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns a new Vector3 located at the center between "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the new Vector3
  3009. */
  3010. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3011. /**
  3012. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3013. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3014. * to something in order to rotate it from its local system to the given target system
  3015. * Note: axis1, axis2 and axis3 are normalized during this operation
  3016. * @param axis1 defines the first axis
  3017. * @param axis2 defines the second axis
  3018. * @param axis3 defines the third axis
  3019. * @returns a new Vector3
  3020. */
  3021. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3024. * @param axis1 defines the first axis
  3025. * @param axis2 defines the second axis
  3026. * @param axis3 defines the third axis
  3027. * @param ref defines the Vector3 where to store the result
  3028. */
  3029. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3030. }
  3031. /**
  3032. * Vector4 class created for EulerAngle class conversion to Quaternion
  3033. */
  3034. export class Vector4 {
  3035. /** x value of the vector */
  3036. x: number;
  3037. /** y value of the vector */
  3038. y: number;
  3039. /** z value of the vector */
  3040. z: number;
  3041. /** w value of the vector */
  3042. w: number;
  3043. /**
  3044. * Creates a Vector4 object from the given floats.
  3045. * @param x x value of the vector
  3046. * @param y y value of the vector
  3047. * @param z z value of the vector
  3048. * @param w w value of the vector
  3049. */
  3050. constructor(
  3051. /** x value of the vector */
  3052. x: number,
  3053. /** y value of the vector */
  3054. y: number,
  3055. /** z value of the vector */
  3056. z: number,
  3057. /** w value of the vector */
  3058. w: number);
  3059. /**
  3060. * Returns the string with the Vector4 coordinates.
  3061. * @returns a string containing all the vector values
  3062. */
  3063. toString(): string;
  3064. /**
  3065. * Returns the string "Vector4".
  3066. * @returns "Vector4"
  3067. */
  3068. getClassName(): string;
  3069. /**
  3070. * Returns the Vector4 hash code.
  3071. * @returns a unique hash code
  3072. */
  3073. getHashCode(): number;
  3074. /**
  3075. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3076. * @returns the resulting array
  3077. */
  3078. asArray(): number[];
  3079. /**
  3080. * Populates the given array from the given index with the Vector4 coordinates.
  3081. * @param array array to populate
  3082. * @param index index of the array to start at (default: 0)
  3083. * @returns the Vector4.
  3084. */
  3085. toArray(array: FloatArray, index?: number): Vector4;
  3086. /**
  3087. * Adds the given vector to the current Vector4.
  3088. * @param otherVector the vector to add
  3089. * @returns the updated Vector4.
  3090. */
  3091. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3092. /**
  3093. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3094. * @param otherVector the vector to add
  3095. * @returns the resulting vector
  3096. */
  3097. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3098. /**
  3099. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3100. * @param otherVector the vector to add
  3101. * @param result the vector to store the result
  3102. * @returns the current Vector4.
  3103. */
  3104. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3105. /**
  3106. * Subtract in place the given vector from the current Vector4.
  3107. * @param otherVector the vector to subtract
  3108. * @returns the updated Vector4.
  3109. */
  3110. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3111. /**
  3112. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3113. * @param otherVector the vector to add
  3114. * @returns the new vector with the result
  3115. */
  3116. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3117. /**
  3118. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @param result the vector to store the result
  3121. * @returns the current Vector4.
  3122. */
  3123. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3124. /**
  3125. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3126. */
  3127. /**
  3128. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3129. * @param x value to subtract
  3130. * @param y value to subtract
  3131. * @param z value to subtract
  3132. * @param w value to subtract
  3133. * @returns new vector containing the result
  3134. */
  3135. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3136. /**
  3137. * Sets the given vector "result" 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. * @param result the vector to store the result in
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3148. * @returns a new vector with the negated values
  3149. */
  3150. negate(): Vector4;
  3151. /**
  3152. * Negate this vector in place
  3153. * @returns this
  3154. */
  3155. negateInPlace(): Vector4;
  3156. /**
  3157. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3158. * @param result defines the Vector3 object where to store the result
  3159. * @returns the current Vector4
  3160. */
  3161. negateToRef(result: Vector4): Vector4;
  3162. /**
  3163. * Multiplies the current Vector4 coordinates by scale (float).
  3164. * @param scale the number to scale with
  3165. * @returns the updated Vector4.
  3166. */
  3167. scaleInPlace(scale: number): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3170. * @param scale the number to scale with
  3171. * @returns a new vector with the result
  3172. */
  3173. scale(scale: number): Vector4;
  3174. /**
  3175. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3176. * @param scale the number to scale with
  3177. * @param result a vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. scaleToRef(scale: number, result: Vector4): Vector4;
  3181. /**
  3182. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3183. * @param scale defines the scale factor
  3184. * @param result defines the Vector4 object where to store the result
  3185. * @returns the unmodified current Vector4
  3186. */
  3187. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3190. * @param otherVector the vector to compare against
  3191. * @returns true if they are equal
  3192. */
  3193. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3194. /**
  3195. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3196. * @param otherVector vector to compare against
  3197. * @param epsilon (Default: very small number)
  3198. * @returns true if they are equal
  3199. */
  3200. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3201. /**
  3202. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3203. * @param x x value to compare against
  3204. * @param y y value to compare against
  3205. * @param z z value to compare against
  3206. * @param w w value to compare against
  3207. * @returns true if equal
  3208. */
  3209. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3210. /**
  3211. * Multiplies in place the current Vector4 by the given one.
  3212. * @param otherVector vector to multiple with
  3213. * @returns the updated Vector4.
  3214. */
  3215. multiplyInPlace(otherVector: Vector4): Vector4;
  3216. /**
  3217. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3218. * @param otherVector vector to multiple with
  3219. * @returns resulting new vector
  3220. */
  3221. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3222. /**
  3223. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3224. * @param otherVector vector to multiple with
  3225. * @param result vector to store the result
  3226. * @returns the current Vector4.
  3227. */
  3228. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3229. /**
  3230. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3231. * @param x x value multiply with
  3232. * @param y y value multiply with
  3233. * @param z z value multiply with
  3234. * @param w w value multiply with
  3235. * @returns resulting new vector
  3236. */
  3237. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3240. * @param otherVector vector to devide with
  3241. * @returns resulting new vector
  3242. */
  3243. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3246. * @param otherVector vector to devide with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Divides the current Vector3 coordinates by the given ones.
  3253. * @param otherVector vector to devide with
  3254. * @returns the updated Vector3.
  3255. */
  3256. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3257. /**
  3258. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3259. * @param other defines the second operand
  3260. * @returns the current updated Vector4
  3261. */
  3262. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3265. * @param other defines the second operand
  3266. * @returns the current updated Vector4
  3267. */
  3268. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3269. /**
  3270. * Gets a new Vector4 from current Vector4 floored values
  3271. * @returns a new Vector4
  3272. */
  3273. floor(): Vector4;
  3274. /**
  3275. * Gets a new Vector4 from current Vector3 floored values
  3276. * @returns a new Vector4
  3277. */
  3278. fract(): Vector4;
  3279. /**
  3280. * Returns the Vector4 length (float).
  3281. * @returns the length
  3282. */
  3283. length(): number;
  3284. /**
  3285. * Returns the Vector4 squared length (float).
  3286. * @returns the length squared
  3287. */
  3288. lengthSquared(): number;
  3289. /**
  3290. * Normalizes in place the Vector4.
  3291. * @returns the updated Vector4.
  3292. */
  3293. normalize(): Vector4;
  3294. /**
  3295. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3296. * @returns this converted to a new vector3
  3297. */
  3298. toVector3(): Vector3;
  3299. /**
  3300. * Returns a new Vector4 copied from the current one.
  3301. * @returns the new cloned vector
  3302. */
  3303. clone(): Vector4;
  3304. /**
  3305. * Updates the current Vector4 with the given one coordinates.
  3306. * @param source the source vector to copy from
  3307. * @returns the updated Vector4.
  3308. */
  3309. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3310. /**
  3311. * Updates the current Vector4 coordinates with the given floats.
  3312. * @param x float to copy from
  3313. * @param y float to copy from
  3314. * @param z float to copy from
  3315. * @param w float to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to set from
  3322. * @param y float to set from
  3323. * @param z float to set from
  3324. * @param w float to set from
  3325. * @returns the updated Vector4.
  3326. */
  3327. set(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Copies the given float to the current Vector3 coordinates
  3330. * @param v defines the x, y, z and w coordinates of the operand
  3331. * @returns the current updated Vector3
  3332. */
  3333. setAll(v: number): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set from the starting index of the given array.
  3336. * @param array the array to pull values from
  3337. * @param offset the offset into the array to start at
  3338. * @returns the new vector
  3339. */
  3340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3341. /**
  3342. * Updates the given vector "result" from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @param result the vector to store the result in
  3346. */
  3347. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given Float32Array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" coordinates from the given floats.
  3357. * @param x float to set from
  3358. * @param y float to set from
  3359. * @param z float to set from
  3360. * @param w float to set from
  3361. * @param result the vector to the floats in
  3362. */
  3363. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3364. /**
  3365. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3366. * @returns the new vector
  3367. */
  3368. static Zero(): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3371. * @returns the new vector
  3372. */
  3373. static One(): Vector4;
  3374. /**
  3375. * Returns a new normalized Vector4 from the given one.
  3376. * @param vector the vector to normalize
  3377. * @returns the vector
  3378. */
  3379. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3380. /**
  3381. * Updates the given vector "result" from the normalization of the given one.
  3382. * @param vector the vector to normalize
  3383. * @param result the vector to store the result in
  3384. */
  3385. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3386. /**
  3387. * Returns a vector with the minimum values from the left and right vectors
  3388. * @param left left vector to minimize
  3389. * @param right right vector to minimize
  3390. * @returns a new vector with the minimum of the left and right vector values
  3391. */
  3392. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3393. /**
  3394. * Returns a vector with the maximum values from the left and right vectors
  3395. * @param left left vector to maximize
  3396. * @param right right vector to maximize
  3397. * @returns a new vector with the maximum of the left and right vector values
  3398. */
  3399. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns the distance (float) between the vectors "value1" and "value2".
  3402. * @param value1 value to calulate the distance between
  3403. * @param value2 value to calulate the distance between
  3404. * @return the distance between the two vectors
  3405. */
  3406. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3407. /**
  3408. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors squared
  3412. */
  3413. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the center between
  3417. * @param value2 value to calulate the center between
  3418. * @return the center between the two vectors
  3419. */
  3420. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3421. /**
  3422. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3423. * This methods computes transformed normalized direction vectors only.
  3424. * @param vector the vector to transform
  3425. * @param transformation the transformation matrix to apply
  3426. * @returns the new vector
  3427. */
  3428. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3429. /**
  3430. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3431. * This methods computes transformed normalized direction vectors only.
  3432. * @param vector the vector to transform
  3433. * @param transformation the transformation matrix to apply
  3434. * @param result the vector to store the result in
  3435. */
  3436. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3437. /**
  3438. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3439. * This methods computes transformed normalized direction vectors only.
  3440. * @param x value to transform
  3441. * @param y value to transform
  3442. * @param z value to transform
  3443. * @param w value to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @param result the vector to store the results in
  3446. */
  3447. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3448. /**
  3449. * Creates a new Vector4 from a Vector3
  3450. * @param source defines the source data
  3451. * @param w defines the 4th component (default is 0)
  3452. * @returns a new Vector4
  3453. */
  3454. static FromVector3(source: Vector3, w?: number): Vector4;
  3455. }
  3456. /**
  3457. * Class used to store quaternion data
  3458. * @see https://en.wikipedia.org/wiki/Quaternion
  3459. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3460. */
  3461. export class Quaternion {
  3462. /** defines the first component (0 by default) */
  3463. x: number;
  3464. /** defines the second component (0 by default) */
  3465. y: number;
  3466. /** defines the third component (0 by default) */
  3467. z: number;
  3468. /** defines the fourth component (1.0 by default) */
  3469. w: number;
  3470. /**
  3471. * Creates a new Quaternion from the given floats
  3472. * @param x defines the first component (0 by default)
  3473. * @param y defines the second component (0 by default)
  3474. * @param z defines the third component (0 by default)
  3475. * @param w defines the fourth component (1.0 by default)
  3476. */
  3477. constructor(
  3478. /** defines the first component (0 by default) */
  3479. x?: number,
  3480. /** defines the second component (0 by default) */
  3481. y?: number,
  3482. /** defines the third component (0 by default) */
  3483. z?: number,
  3484. /** defines the fourth component (1.0 by default) */
  3485. w?: number);
  3486. /**
  3487. * Gets a string representation for the current quaternion
  3488. * @returns a string with the Quaternion coordinates
  3489. */
  3490. toString(): string;
  3491. /**
  3492. * Gets the class name of the quaternion
  3493. * @returns the string "Quaternion"
  3494. */
  3495. getClassName(): string;
  3496. /**
  3497. * Gets a hash code for this quaternion
  3498. * @returns the quaternion hash code
  3499. */
  3500. getHashCode(): number;
  3501. /**
  3502. * Copy the quaternion to an array
  3503. * @returns a new array populated with 4 elements from the quaternion coordinates
  3504. */
  3505. asArray(): number[];
  3506. /**
  3507. * Check if two quaternions are equals
  3508. * @param otherQuaternion defines the second operand
  3509. * @return true if the current quaternion and the given one coordinates are strictly equals
  3510. */
  3511. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3512. /**
  3513. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3514. * @param otherQuaternion defines the other quaternion
  3515. * @param epsilon defines the minimal distance to consider equality
  3516. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3517. */
  3518. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3519. /**
  3520. * Clone the current quaternion
  3521. * @returns a new quaternion copied from the current one
  3522. */
  3523. clone(): Quaternion;
  3524. /**
  3525. * Copy a quaternion to the current one
  3526. * @param other defines the other quaternion
  3527. * @returns the updated current quaternion
  3528. */
  3529. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3530. /**
  3531. * Updates the current quaternion with the given float coordinates
  3532. * @param x defines the x coordinate
  3533. * @param y defines the y coordinate
  3534. * @param z defines the z coordinate
  3535. * @param w defines the w coordinate
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3539. /**
  3540. * Updates the current quaternion from 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. set(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Adds two quaternions
  3550. * @param other defines the second operand
  3551. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3552. */
  3553. add(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Add a quaternion to the current one
  3556. * @param other defines the quaternion to add
  3557. * @returns the current quaternion
  3558. */
  3559. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3560. /**
  3561. * Subtract two quaternions
  3562. * @param other defines the second operand
  3563. * @returns a new quaternion as the subtraction result of the given one from the current one
  3564. */
  3565. subtract(other: Quaternion): Quaternion;
  3566. /**
  3567. * Multiplies the current quaternion by a scale factor
  3568. * @param value defines the scale factor
  3569. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3570. */
  3571. scale(value: number): Quaternion;
  3572. /**
  3573. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3574. * @param scale defines the scale factor
  3575. * @param result defines the Quaternion object where to store the result
  3576. * @returns the unmodified current quaternion
  3577. */
  3578. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3579. /**
  3580. * Multiplies in place the current quaternion by a scale factor
  3581. * @param value defines the scale factor
  3582. * @returns the current modified quaternion
  3583. */
  3584. scaleInPlace(value: number): Quaternion;
  3585. /**
  3586. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3587. * @param scale defines the scale factor
  3588. * @param result defines the Quaternion object where to store the result
  3589. * @returns the unmodified current quaternion
  3590. */
  3591. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3592. /**
  3593. * Multiplies two quaternions
  3594. * @param q1 defines the second operand
  3595. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3596. */
  3597. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3598. /**
  3599. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3600. * @param q1 defines the second operand
  3601. * @param result defines the target quaternion
  3602. * @returns the current quaternion
  3603. */
  3604. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3605. /**
  3606. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @returns the currentupdated quaternion
  3609. */
  3610. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3611. /**
  3612. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3613. * @param ref defines the target quaternion
  3614. * @returns the current quaternion
  3615. */
  3616. conjugateToRef(ref: Quaternion): Quaternion;
  3617. /**
  3618. * Conjugates in place (1-q) the current quaternion
  3619. * @returns the current updated quaternion
  3620. */
  3621. conjugateInPlace(): Quaternion;
  3622. /**
  3623. * Conjugates in place (1-q) the current quaternion
  3624. * @returns a new quaternion
  3625. */
  3626. conjugate(): Quaternion;
  3627. /**
  3628. * Gets length of current quaternion
  3629. * @returns the quaternion length (float)
  3630. */
  3631. length(): number;
  3632. /**
  3633. * Normalize in place the current quaternion
  3634. * @returns the current updated quaternion
  3635. */
  3636. normalize(): Quaternion;
  3637. /**
  3638. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3639. * @param order is a reserved parameter and is ignore for now
  3640. * @returns a new Vector3 containing the Euler angles
  3641. */
  3642. toEulerAngles(order?: string): Vector3;
  3643. /**
  3644. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3645. * @param result defines the vector which will be filled with the Euler angles
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toEulerAnglesToRef(result: Vector3): Quaternion;
  3650. /**
  3651. * Updates the given rotation matrix with the current quaternion values
  3652. * @param result defines the target matrix
  3653. * @returns the current unchanged quaternion
  3654. */
  3655. toRotationMatrix(result: Matrix): Quaternion;
  3656. /**
  3657. * Updates the current quaternion from the given rotation matrix values
  3658. * @param matrix defines the source matrix
  3659. * @returns the current updated quaternion
  3660. */
  3661. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Creates a new quaternion from a rotation matrix
  3664. * @param matrix defines the source matrix
  3665. * @returns a new quaternion created from the given rotation matrix values
  3666. */
  3667. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3668. /**
  3669. * Updates the given quaternion with the given rotation matrix values
  3670. * @param matrix defines the source matrix
  3671. * @param result defines the target quaternion
  3672. */
  3673. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3674. /**
  3675. * Returns the dot product (float) between the quaternions "left" and "right"
  3676. * @param left defines the left operand
  3677. * @param right defines the right operand
  3678. * @returns the dot product
  3679. */
  3680. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3681. /**
  3682. * Checks if the two quaternions are close to each other
  3683. * @param quat0 defines the first quaternion to check
  3684. * @param quat1 defines the second quaternion to check
  3685. * @returns true if the two quaternions are close to each other
  3686. */
  3687. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3688. /**
  3689. * Creates an empty quaternion
  3690. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3691. */
  3692. static Zero(): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @returns a new quaternion as the inverted current quaternion
  3697. */
  3698. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3699. /**
  3700. * Inverse a given quaternion
  3701. * @param q defines the source quaternion
  3702. * @param result the quaternion the result will be stored in
  3703. * @returns the result quaternion
  3704. */
  3705. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3706. /**
  3707. * Creates an identity quaternion
  3708. * @returns the identity quaternion
  3709. */
  3710. static Identity(): Quaternion;
  3711. /**
  3712. * Gets a boolean indicating if the given quaternion is identity
  3713. * @param quaternion defines the quaternion to check
  3714. * @returns true if the quaternion is identity
  3715. */
  3716. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3717. /**
  3718. * Creates a quaternion from a rotation around an axis
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle to use
  3721. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3722. */
  3723. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3724. /**
  3725. * Creates a rotation around an axis and stores it into the given quaternion
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @param result defines the target quaternion
  3729. * @returns the target quaternion
  3730. */
  3731. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Creates a new quaternion from data stored into an array
  3734. * @param array defines the data source
  3735. * @param offset defines the offset in the source array where the data starts
  3736. * @returns a new quaternion
  3737. */
  3738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3739. /**
  3740. * Updates the given quaternion "result" from the starting index of the given array.
  3741. * @param array the array to pull values from
  3742. * @param offset the offset into the array to start at
  3743. * @param result the quaternion to store the result in
  3744. */
  3745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * 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)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * 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
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. 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;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. 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;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  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. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * 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"
  4402. * This function works in right 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. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * 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".
  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. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given 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. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  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 PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given 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. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given 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. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * 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.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * 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)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @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
  4923. * @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
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1: number;
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1: number;
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2: number;
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2: number;
  5259. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): 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. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @returns a string containing the hexadecimal representation of the Color4 object
  5780. */
  5781. toHexString(): string;
  5782. /**
  5783. * Computes a new Color4 converted from the current one to linear space
  5784. * @returns a new Color4 object
  5785. */
  5786. toLinearSpace(): Color4;
  5787. /**
  5788. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5789. * @param convertedColor defines the Color4 object where to store the linear space version
  5790. * @returns the unmodified Color4
  5791. */
  5792. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to gamma space
  5795. * @returns a new Color4 object
  5796. */
  5797. toGammaSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the gamma space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Creates a new Color4 from the string containing valid hexadecimal values
  5806. * @param hex defines a string containing valid hexadecimal values
  5807. * @returns a new Color4 object
  5808. */
  5809. static FromHexString(hex: string): Color4;
  5810. /**
  5811. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @returns a new Color4 object
  5816. */
  5817. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5818. /**
  5819. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5820. * @param left defines the start value
  5821. * @param right defines the end value
  5822. * @param amount defines the gradient factor
  5823. * @param result defines the Color4 object where to store data
  5824. */
  5825. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5826. /**
  5827. * Creates a new Color4 from a Color3 and an alpha value
  5828. * @param color3 defines the source Color3 to read from
  5829. * @param alpha defines the alpha component (1.0 by default)
  5830. * @returns a new Color4 object
  5831. */
  5832. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5833. /**
  5834. * Creates a new Color4 from the starting index element of the given array
  5835. * @param array defines the source array to read from
  5836. * @param offset defines the offset in the source array
  5837. * @returns a new Color4 object
  5838. */
  5839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5840. /**
  5841. * Creates a new Color3 from integer values (< 256)
  5842. * @param r defines the red component to read from (value between 0 and 255)
  5843. * @param g defines the green component to read from (value between 0 and 255)
  5844. * @param b defines the blue component to read from (value between 0 and 255)
  5845. * @param a defines the alpha component to read from (value between 0 and 255)
  5846. * @returns a new Color3 object
  5847. */
  5848. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5849. /**
  5850. * Check the content of a given array and convert it to an array containing RGBA data
  5851. * If the original array was already containing count * 4 values then it is returned directly
  5852. * @param colors defines the array to check
  5853. * @param count defines the number of RGBA data to expect
  5854. * @returns an array containing count * 4 values (RGBA)
  5855. */
  5856. static CheckColors4(colors: number[], count: number): number[];
  5857. }
  5858. /**
  5859. * @hidden
  5860. */
  5861. export class TmpColors {
  5862. static Color3: Color3[];
  5863. static Color4: Color4[];
  5864. }
  5865. }
  5866. declare module BABYLON {
  5867. /**
  5868. * Defines an interface which represents an animation key frame
  5869. */
  5870. export interface IAnimationKey {
  5871. /**
  5872. * Frame of the key frame
  5873. */
  5874. frame: number;
  5875. /**
  5876. * Value at the specifies key frame
  5877. */
  5878. value: any;
  5879. /**
  5880. * The input tangent for the cubic hermite spline
  5881. */
  5882. inTangent?: any;
  5883. /**
  5884. * The output tangent for the cubic hermite spline
  5885. */
  5886. outTangent?: any;
  5887. /**
  5888. * The animation interpolation type
  5889. */
  5890. interpolation?: AnimationKeyInterpolation;
  5891. }
  5892. /**
  5893. * Enum for the animation key frame interpolation type
  5894. */
  5895. export enum AnimationKeyInterpolation {
  5896. /**
  5897. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5898. */
  5899. STEP = 1
  5900. }
  5901. }
  5902. declare module BABYLON {
  5903. /**
  5904. * Represents the range of an animation
  5905. */
  5906. export class AnimationRange {
  5907. /**The name of the animation range**/
  5908. name: string;
  5909. /**The starting frame of the animation */
  5910. from: number;
  5911. /**The ending frame of the animation*/
  5912. to: number;
  5913. /**
  5914. * Initializes the range of an animation
  5915. * @param name The name of the animation range
  5916. * @param from The starting frame of the animation
  5917. * @param to The ending frame of the animation
  5918. */
  5919. constructor(
  5920. /**The name of the animation range**/
  5921. name: string,
  5922. /**The starting frame of the animation */
  5923. from: number,
  5924. /**The ending frame of the animation*/
  5925. to: number);
  5926. /**
  5927. * Makes a copy of the animation range
  5928. * @returns A copy of the animation range
  5929. */
  5930. clone(): AnimationRange;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * Composed of a frame, and an action function
  5936. */
  5937. export class AnimationEvent {
  5938. /** The frame for which the event is triggered **/
  5939. frame: number;
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void;
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined;
  5944. /**
  5945. * Specifies if the animation event is done
  5946. */
  5947. isDone: boolean;
  5948. /**
  5949. * Initializes the animation event
  5950. * @param frame The frame for which the event is triggered
  5951. * @param action The event to perform when triggered
  5952. * @param onlyOnce Specifies if the event should be triggered only once
  5953. */
  5954. constructor(
  5955. /** The frame for which the event is triggered **/
  5956. frame: number,
  5957. /** The event to perform when triggered **/
  5958. action: (currentFrame: number) => void,
  5959. /** Specifies if the event should be triggered only once**/
  5960. onlyOnce?: boolean | undefined);
  5961. /** @hidden */
  5962. _clone(): AnimationEvent;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. /**
  5967. * Interface used to define a behavior
  5968. */
  5969. export interface Behavior<T> {
  5970. /** gets or sets behavior's name */
  5971. name: string;
  5972. /**
  5973. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5974. */
  5975. init(): void;
  5976. /**
  5977. * Called when the behavior is attached to a target
  5978. * @param target defines the target where the behavior is attached to
  5979. */
  5980. attach(target: T): void;
  5981. /**
  5982. * Called when the behavior is detached from its target
  5983. */
  5984. detach(): void;
  5985. }
  5986. /**
  5987. * Interface implemented by classes supporting behaviors
  5988. */
  5989. export interface IBehaviorAware<T> {
  5990. /**
  5991. * Attach a behavior
  5992. * @param behavior defines the behavior to attach
  5993. * @returns the current host
  5994. */
  5995. addBehavior(behavior: Behavior<T>): T;
  5996. /**
  5997. * Remove a behavior from the current object
  5998. * @param behavior defines the behavior to detach
  5999. * @returns the current host
  6000. */
  6001. removeBehavior(behavior: Behavior<T>): T;
  6002. /**
  6003. * Gets a behavior using its name to search
  6004. * @param name defines the name to search
  6005. * @returns the behavior or null if not found
  6006. */
  6007. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * Defines an array and its length.
  6013. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6014. */
  6015. export interface ISmartArrayLike<T> {
  6016. /**
  6017. * The data of the array.
  6018. */
  6019. data: Array<T>;
  6020. /**
  6021. * The active length of the array.
  6022. */
  6023. length: number;
  6024. }
  6025. /**
  6026. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6027. */
  6028. export class SmartArray<T> implements ISmartArrayLike<T> {
  6029. /**
  6030. * The full set of data from the array.
  6031. */
  6032. data: Array<T>;
  6033. /**
  6034. * The active length of the array.
  6035. */
  6036. length: number;
  6037. protected _id: number;
  6038. /**
  6039. * Instantiates a Smart Array.
  6040. * @param capacity defines the default capacity of the array.
  6041. */
  6042. constructor(capacity: number);
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * @param value defines the object to push in the array.
  6046. */
  6047. push(value: T): void;
  6048. /**
  6049. * Iterates over the active data and apply the lambda to them.
  6050. * @param func defines the action to apply on each value.
  6051. */
  6052. forEach(func: (content: T) => void): void;
  6053. /**
  6054. * Sorts the full sets of data.
  6055. * @param compareFn defines the comparison function to apply.
  6056. */
  6057. sort(compareFn: (a: T, b: T) => number): void;
  6058. /**
  6059. * Resets the active data to an empty array.
  6060. */
  6061. reset(): void;
  6062. /**
  6063. * Releases all the data from the array as well as the array.
  6064. */
  6065. dispose(): void;
  6066. /**
  6067. * Concats the active data with a given array.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concat(array: any): void;
  6071. /**
  6072. * Returns the position of a value in the active data.
  6073. * @param value defines the value to find the index for
  6074. * @returns the index if found in the active data otherwise -1
  6075. */
  6076. indexOf(value: T): number;
  6077. /**
  6078. * Returns whether an element is part of the active data.
  6079. * @param value defines the value to look for
  6080. * @returns true if found in the active data otherwise false
  6081. */
  6082. contains(value: T): boolean;
  6083. private static _GlobalId;
  6084. }
  6085. /**
  6086. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6087. * The data in this array can only be present once
  6088. */
  6089. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6090. private _duplicateId;
  6091. /**
  6092. * Pushes a value at the end of the active data.
  6093. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Pushes a value at the end of the active data.
  6099. * If the data is already present, it won t be added again
  6100. * @param value defines the object to push in the array.
  6101. * @returns true if added false if it was already present
  6102. */
  6103. pushNoDuplicate(value: T): boolean;
  6104. /**
  6105. * Resets the active data to an empty array.
  6106. */
  6107. reset(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * This ensures no dupplicate will be present in the result.
  6111. * @param array defines the data to concatenate with.
  6112. */
  6113. concatWithNoDuplicate(array: any): void;
  6114. }
  6115. }
  6116. declare module BABYLON {
  6117. /**
  6118. * @ignore
  6119. * This is a list of all the different input types that are available in the application.
  6120. * Fo instance: ArcRotateCameraGamepadInput...
  6121. */
  6122. export var CameraInputTypes: {};
  6123. /**
  6124. * This is the contract to implement in order to create a new input class.
  6125. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6126. */
  6127. export interface ICameraInput<TCamera extends Camera> {
  6128. /**
  6129. * Defines the camera the input is attached to.
  6130. */
  6131. camera: Nullable<TCamera>;
  6132. /**
  6133. * Gets the class name of the current intput.
  6134. * @returns the class name
  6135. */
  6136. getClassName(): string;
  6137. /**
  6138. * Get the friendly name associated with the input class.
  6139. * @returns the input friendly name
  6140. */
  6141. getSimpleName(): string;
  6142. /**
  6143. * Attach the input controls to a specific dom element to get the input from.
  6144. * @param element Defines the element the controls should be listened from
  6145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6148. /**
  6149. * Detach the current controls from the specified dom element.
  6150. * @param element Defines the element to stop listening the inputs from
  6151. */
  6152. detachControl(element: Nullable<HTMLElement>): void;
  6153. /**
  6154. * Update the current camera state depending on the inputs that have been used this frame.
  6155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6156. */
  6157. checkInputs?: () => void;
  6158. }
  6159. /**
  6160. * Represents a map of input types to input instance or input index to input instance.
  6161. */
  6162. export interface CameraInputsMap<TCamera extends Camera> {
  6163. /**
  6164. * Accessor to the input by input type.
  6165. */
  6166. [name: string]: ICameraInput<TCamera>;
  6167. /**
  6168. * Accessor to the input by input index.
  6169. */
  6170. [idx: number]: ICameraInput<TCamera>;
  6171. }
  6172. /**
  6173. * This represents the input manager used within a camera.
  6174. * It helps dealing with all the different kind of input attached to a camera.
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. */
  6177. export class CameraInputsManager<TCamera extends Camera> {
  6178. /**
  6179. * Defines the list of inputs attahed to the camera.
  6180. */
  6181. attached: CameraInputsMap<TCamera>;
  6182. /**
  6183. * Defines the dom element the camera is collecting inputs from.
  6184. * This is null if the controls have not been attached.
  6185. */
  6186. attachedElement: Nullable<HTMLElement>;
  6187. /**
  6188. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6189. */
  6190. noPreventDefault: boolean;
  6191. /**
  6192. * Defined the camera the input manager belongs to.
  6193. */
  6194. camera: TCamera;
  6195. /**
  6196. * Update the current camera state depending on the inputs that have been used this frame.
  6197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6198. */
  6199. checkInputs: () => void;
  6200. /**
  6201. * Instantiate a new Camera Input Manager.
  6202. * @param camera Defines the camera the input manager blongs to
  6203. */
  6204. constructor(camera: TCamera);
  6205. /**
  6206. * Add an input method to a camera
  6207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6208. * @param input camera input method
  6209. */
  6210. add(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input method from a camera
  6213. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6214. * @param inputToRemove camera input method
  6215. */
  6216. remove(inputToRemove: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Remove a specific input type from a camera
  6219. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6220. * @param inputType the type of the input to remove
  6221. */
  6222. removeByType(inputType: string): void;
  6223. private _addCheckInputs;
  6224. /**
  6225. * Attach the input controls to the currently attached dom element to listen the events from.
  6226. * @param input Defines the input to attach
  6227. */
  6228. attachInput(input: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6235. /**
  6236. * Detach the current manager inputs controls from a specific dom element.
  6237. * @param element Defines the dom element to collect the events from
  6238. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6239. */
  6240. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6241. /**
  6242. * Rebuild the dynamic inputCheck function from the current list of
  6243. * defined inputs in the manager.
  6244. */
  6245. rebuildInputCheck(): void;
  6246. /**
  6247. * Remove all attached input methods from a camera
  6248. */
  6249. clear(): void;
  6250. /**
  6251. * Serialize the current input manager attached to a camera.
  6252. * This ensures than once parsed,
  6253. * the input associated to the camera will be identical to the current ones
  6254. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6255. */
  6256. serialize(serializedCamera: any): void;
  6257. /**
  6258. * Parses an input manager serialized JSON to restore the previous list of inputs
  6259. * and states associated to a camera.
  6260. * @param parsedCamera Defines the JSON to parse
  6261. */
  6262. parse(parsedCamera: any): void;
  6263. }
  6264. }
  6265. declare module BABYLON {
  6266. /**
  6267. * Class used to store data that will be store in GPU memory
  6268. */
  6269. export class Buffer {
  6270. private _engine;
  6271. private _buffer;
  6272. /** @hidden */
  6273. _data: Nullable<DataArray>;
  6274. private _updatable;
  6275. private _instanced;
  6276. private _divisor;
  6277. /**
  6278. * Gets the byte stride.
  6279. */
  6280. readonly byteStride: number;
  6281. /**
  6282. * Constructor
  6283. * @param engine the engine
  6284. * @param data the data to use for this buffer
  6285. * @param updatable whether the data is updatable
  6286. * @param stride the stride (optional)
  6287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6288. * @param instanced whether the buffer is instanced (optional)
  6289. * @param useBytes set to true if the stride in in bytes (optional)
  6290. * @param divisor sets an optional divisor for instances (1 by default)
  6291. */
  6292. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6293. /**
  6294. * Create a new VertexBuffer based on the current buffer
  6295. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6296. * @param offset defines offset in the buffer (0 by default)
  6297. * @param size defines the size in floats of attributes (position is 3 for instance)
  6298. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6299. * @param instanced defines if the vertex buffer contains indexed data
  6300. * @param useBytes defines if the offset and stride are in bytes *
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. * @returns the new vertex buffer
  6303. */
  6304. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6305. /**
  6306. * Gets a boolean indicating if the Buffer is updatable?
  6307. * @returns true if the buffer is updatable
  6308. */
  6309. isUpdatable(): boolean;
  6310. /**
  6311. * Gets current buffer's data
  6312. * @returns a DataArray or null
  6313. */
  6314. getData(): Nullable<DataArray>;
  6315. /**
  6316. * Gets underlying native buffer
  6317. * @returns underlying native buffer
  6318. */
  6319. getBuffer(): Nullable<DataBuffer>;
  6320. /**
  6321. * Gets the stride in float32 units (i.e. byte stride / 4).
  6322. * May not be an integer if the byte stride is not divisible by 4.
  6323. * @returns the stride in float32 units
  6324. * @deprecated Please use byteStride instead.
  6325. */
  6326. getStrideSize(): number;
  6327. /**
  6328. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6329. * @param data defines the data to store
  6330. */
  6331. create(data?: Nullable<DataArray>): void;
  6332. /** @hidden */
  6333. _rebuild(): void;
  6334. /**
  6335. * Update current buffer data
  6336. * @param data defines the data to store
  6337. */
  6338. update(data: DataArray): void;
  6339. /**
  6340. * Updates the data directly.
  6341. * @param data the new data
  6342. * @param offset the new offset
  6343. * @param vertexCount the vertex count (optional)
  6344. * @param useBytes set to true if the offset is in bytes
  6345. */
  6346. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6347. /**
  6348. * Release all resources
  6349. */
  6350. dispose(): void;
  6351. }
  6352. /**
  6353. * Specialized buffer used to store vertex data
  6354. */
  6355. export class VertexBuffer {
  6356. /** @hidden */
  6357. _buffer: Buffer;
  6358. private _kind;
  6359. private _size;
  6360. private _ownsBuffer;
  6361. private _instanced;
  6362. private _instanceDivisor;
  6363. /**
  6364. * The byte type.
  6365. */
  6366. static readonly BYTE: number;
  6367. /**
  6368. * The unsigned byte type.
  6369. */
  6370. static readonly UNSIGNED_BYTE: number;
  6371. /**
  6372. * The short type.
  6373. */
  6374. static readonly SHORT: number;
  6375. /**
  6376. * The unsigned short type.
  6377. */
  6378. static readonly UNSIGNED_SHORT: number;
  6379. /**
  6380. * The integer type.
  6381. */
  6382. static readonly INT: number;
  6383. /**
  6384. * The unsigned integer type.
  6385. */
  6386. static readonly UNSIGNED_INT: number;
  6387. /**
  6388. * The float type.
  6389. */
  6390. static readonly FLOAT: number;
  6391. /**
  6392. * Gets or sets the instance divisor when in instanced mode
  6393. */
  6394. get instanceDivisor(): number;
  6395. set instanceDivisor(value: number);
  6396. /**
  6397. * Gets the byte stride.
  6398. */
  6399. readonly byteStride: number;
  6400. /**
  6401. * Gets the byte offset.
  6402. */
  6403. readonly byteOffset: number;
  6404. /**
  6405. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6406. */
  6407. readonly normalized: boolean;
  6408. /**
  6409. * Gets the data type of each component in the array.
  6410. */
  6411. readonly type: number;
  6412. /**
  6413. * Constructor
  6414. * @param engine the engine
  6415. * @param data the data to use for this vertex buffer
  6416. * @param kind the vertex buffer kind
  6417. * @param updatable whether the data is updatable
  6418. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6419. * @param stride the stride (optional)
  6420. * @param instanced whether the buffer is instanced (optional)
  6421. * @param offset the offset of the data (optional)
  6422. * @param size the number of components (optional)
  6423. * @param type the type of the component (optional)
  6424. * @param normalized whether the data contains normalized data (optional)
  6425. * @param useBytes set to true if stride and offset are in bytes (optional)
  6426. * @param divisor defines the instance divisor to use (1 by default)
  6427. */
  6428. 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);
  6429. /** @hidden */
  6430. _rebuild(): void;
  6431. /**
  6432. * Returns the kind of the VertexBuffer (string)
  6433. * @returns a string
  6434. */
  6435. getKind(): string;
  6436. /**
  6437. * Gets a boolean indicating if the VertexBuffer is updatable?
  6438. * @returns true if the buffer is updatable
  6439. */
  6440. isUpdatable(): boolean;
  6441. /**
  6442. * Gets current buffer's data
  6443. * @returns a DataArray or null
  6444. */
  6445. getData(): Nullable<DataArray>;
  6446. /**
  6447. * Gets underlying native buffer
  6448. * @returns underlying native buffer
  6449. */
  6450. getBuffer(): Nullable<DataBuffer>;
  6451. /**
  6452. * Gets the stride in float32 units (i.e. byte stride / 4).
  6453. * May not be an integer if the byte stride is not divisible by 4.
  6454. * @returns the stride in float32 units
  6455. * @deprecated Please use byteStride instead.
  6456. */
  6457. getStrideSize(): number;
  6458. /**
  6459. * Returns the offset as a multiple of the type byte length.
  6460. * @returns the offset in bytes
  6461. * @deprecated Please use byteOffset instead.
  6462. */
  6463. getOffset(): number;
  6464. /**
  6465. * Returns the number of components per vertex attribute (integer)
  6466. * @returns the size in float
  6467. */
  6468. getSize(): number;
  6469. /**
  6470. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6471. * @returns true if this buffer is instanced
  6472. */
  6473. getIsInstanced(): boolean;
  6474. /**
  6475. * Returns the instancing divisor, zero for non-instanced (integer).
  6476. * @returns a number
  6477. */
  6478. getInstanceDivisor(): number;
  6479. /**
  6480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6481. * @param data defines the data to store
  6482. */
  6483. create(data?: DataArray): void;
  6484. /**
  6485. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6486. * This function will create a new buffer if the current one is not updatable
  6487. * @param data defines the data to store
  6488. */
  6489. update(data: DataArray): void;
  6490. /**
  6491. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6492. * Returns the directly updated WebGLBuffer.
  6493. * @param data the new data
  6494. * @param offset the new offset
  6495. * @param useBytes set to true if the offset is in bytes
  6496. */
  6497. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6498. /**
  6499. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Enumerates each value of this vertex buffer as numbers.
  6504. * @param count the number of values to enumerate
  6505. * @param callback the callback function called for each value
  6506. */
  6507. forEach(count: number, callback: (value: number, index: number) => void): void;
  6508. /**
  6509. * Positions
  6510. */
  6511. static readonly PositionKind: string;
  6512. /**
  6513. * Normals
  6514. */
  6515. static readonly NormalKind: string;
  6516. /**
  6517. * Tangents
  6518. */
  6519. static readonly TangentKind: string;
  6520. /**
  6521. * Texture coordinates
  6522. */
  6523. static readonly UVKind: string;
  6524. /**
  6525. * Texture coordinates 2
  6526. */
  6527. static readonly UV2Kind: string;
  6528. /**
  6529. * Texture coordinates 3
  6530. */
  6531. static readonly UV3Kind: string;
  6532. /**
  6533. * Texture coordinates 4
  6534. */
  6535. static readonly UV4Kind: string;
  6536. /**
  6537. * Texture coordinates 5
  6538. */
  6539. static readonly UV5Kind: string;
  6540. /**
  6541. * Texture coordinates 6
  6542. */
  6543. static readonly UV6Kind: string;
  6544. /**
  6545. * Colors
  6546. */
  6547. static readonly ColorKind: string;
  6548. /**
  6549. * Matrix indices (for bones)
  6550. */
  6551. static readonly MatricesIndicesKind: string;
  6552. /**
  6553. * Matrix weights (for bones)
  6554. */
  6555. static readonly MatricesWeightsKind: string;
  6556. /**
  6557. * Additional matrix indices (for bones)
  6558. */
  6559. static readonly MatricesIndicesExtraKind: string;
  6560. /**
  6561. * Additional matrix weights (for bones)
  6562. */
  6563. static readonly MatricesWeightsExtraKind: string;
  6564. /**
  6565. * Deduces the stride given a kind.
  6566. * @param kind The kind string to deduce
  6567. * @returns The deduced stride
  6568. */
  6569. static DeduceStride(kind: string): number;
  6570. /**
  6571. * Gets the byte length of the given type.
  6572. * @param type the type
  6573. * @returns the number of bytes
  6574. */
  6575. static GetTypeByteLength(type: number): number;
  6576. /**
  6577. * Enumerates each value of the given parameters as numbers.
  6578. * @param data the data to enumerate
  6579. * @param byteOffset the byte offset of the data
  6580. * @param byteStride the byte stride of the data
  6581. * @param componentCount the number of components per element
  6582. * @param componentType the type of the component
  6583. * @param count the number of values to enumerate
  6584. * @param normalized whether the data is normalized
  6585. * @param callback the callback function called for each value
  6586. */
  6587. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6588. private static _GetFloatValue;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * @hidden
  6594. */
  6595. export class IntersectionInfo {
  6596. bu: Nullable<number>;
  6597. bv: Nullable<number>;
  6598. distance: number;
  6599. faceId: number;
  6600. subMeshId: number;
  6601. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6602. }
  6603. }
  6604. declare module BABYLON {
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module BABYLON {
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module BABYLON {
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module BABYLON {
  6944. /** @hidden */
  6945. export class Collider {
  6946. /** Define if a collision was found */
  6947. collisionFound: boolean;
  6948. /**
  6949. * Define last intersection point in local space
  6950. */
  6951. intersectionPoint: Vector3;
  6952. /**
  6953. * Define last collided mesh
  6954. */
  6955. collidedMesh: Nullable<AbstractMesh>;
  6956. private _collisionPoint;
  6957. private _planeIntersectionPoint;
  6958. private _tempVector;
  6959. private _tempVector2;
  6960. private _tempVector3;
  6961. private _tempVector4;
  6962. private _edge;
  6963. private _baseToVertex;
  6964. private _destinationPoint;
  6965. private _slidePlaneNormal;
  6966. private _displacementVector;
  6967. /** @hidden */
  6968. _radius: Vector3;
  6969. /** @hidden */
  6970. _retry: number;
  6971. private _velocity;
  6972. private _basePoint;
  6973. private _epsilon;
  6974. /** @hidden */
  6975. _velocityWorldLength: number;
  6976. /** @hidden */
  6977. _basePointWorld: Vector3;
  6978. private _velocityWorld;
  6979. private _normalizedVelocity;
  6980. /** @hidden */
  6981. _initialVelocity: Vector3;
  6982. /** @hidden */
  6983. _initialPosition: Vector3;
  6984. private _nearestDistance;
  6985. private _collisionMask;
  6986. get collisionMask(): number;
  6987. set collisionMask(mask: number);
  6988. /**
  6989. * Gets the plane normal used to compute the sliding response (in local space)
  6990. */
  6991. get slidePlaneNormal(): Vector3;
  6992. /** @hidden */
  6993. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6994. /** @hidden */
  6995. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6996. /** @hidden */
  6997. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6998. /** @hidden */
  6999. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7000. /** @hidden */
  7001. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7002. /** @hidden */
  7003. _getResponse(pos: Vector3, vel: Vector3): void;
  7004. }
  7005. }
  7006. declare module BABYLON {
  7007. /**
  7008. * Interface for cullable objects
  7009. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7010. */
  7011. export interface ICullable {
  7012. /**
  7013. * Checks if the object or part of the object is in the frustum
  7014. * @param frustumPlanes Camera near/planes
  7015. * @returns true if the object is in frustum otherwise false
  7016. */
  7017. isInFrustum(frustumPlanes: Plane[]): boolean;
  7018. /**
  7019. * Checks if a cullable object (mesh...) is in the camera frustum
  7020. * Unlike isInFrustum this cheks the full bounding box
  7021. * @param frustumPlanes Camera near/planes
  7022. * @returns true if the object is in frustum otherwise false
  7023. */
  7024. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7025. }
  7026. /**
  7027. * Info for a bounding data of a mesh
  7028. */
  7029. export class BoundingInfo implements ICullable {
  7030. /**
  7031. * Bounding box for the mesh
  7032. */
  7033. readonly boundingBox: BoundingBox;
  7034. /**
  7035. * Bounding sphere for the mesh
  7036. */
  7037. readonly boundingSphere: BoundingSphere;
  7038. private _isLocked;
  7039. private static readonly TmpVector3;
  7040. /**
  7041. * Constructs bounding info
  7042. * @param minimum min vector of the bounding box/sphere
  7043. * @param maximum max vector of the bounding box/sphere
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * min vector of the bounding box/sphere
  7056. */
  7057. get minimum(): Vector3;
  7058. /**
  7059. * max vector of the bounding box/sphere
  7060. */
  7061. get maximum(): Vector3;
  7062. /**
  7063. * If the info is locked and won't be updated to avoid perf overhead
  7064. */
  7065. get isLocked(): boolean;
  7066. set isLocked(value: boolean);
  7067. /**
  7068. * Updates the bounding sphere and box
  7069. * @param world world matrix to be used to update
  7070. */
  7071. update(world: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7074. * @param center New center of the bounding info
  7075. * @param extend New extend of the bounding info
  7076. * @returns the current bounding info
  7077. */
  7078. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7079. /**
  7080. * Scale the current bounding info by applying a scale factor
  7081. * @param factor defines the scale factor to apply
  7082. * @returns the current bounding info
  7083. */
  7084. scale(factor: number): BoundingInfo;
  7085. /**
  7086. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7087. * @param frustumPlanes defines the frustum to test
  7088. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7089. * @returns true if the bounding info is in the frustum planes
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7092. /**
  7093. * Gets the world distance between the min and max points of the bounding box
  7094. */
  7095. get diagonalLength(): number;
  7096. /**
  7097. * Checks if a cullable object (mesh...) is in the camera frustum
  7098. * Unlike isInFrustum this cheks the full bounding box
  7099. * @param frustumPlanes Camera near/planes
  7100. * @returns true if the object is in frustum otherwise false
  7101. */
  7102. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7103. /** @hidden */
  7104. _checkCollision(collider: Collider): boolean;
  7105. /**
  7106. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7107. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7108. * @param point the point to check intersection with
  7109. * @returns if the point intersects
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7114. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7115. * @param boundingInfo the bounding info to check intersection with
  7116. * @param precise if the intersection should be done using OBB
  7117. * @returns if the bounding info intersects
  7118. */
  7119. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Extracts minimum and maximum values from a list of indexed positions
  7125. * @param positions defines the positions to use
  7126. * @param indices defines the indices to the positions
  7127. * @param indexStart defines the start index
  7128. * @param indexCount defines the end index
  7129. * @param bias defines bias value to add to the result
  7130. * @return minimum and maximum values
  7131. */
  7132. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7133. minimum: Vector3;
  7134. maximum: Vector3;
  7135. };
  7136. /**
  7137. * Extracts minimum and maximum values from a list of positions
  7138. * @param positions defines the positions to use
  7139. * @param start defines the start index in the positions array
  7140. * @param count defines the number of positions to handle
  7141. * @param bias defines bias value to add to the result
  7142. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7143. * @return minimum and maximum values
  7144. */
  7145. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7146. minimum: Vector3;
  7147. maximum: Vector3;
  7148. };
  7149. }
  7150. declare module BABYLON {
  7151. /** @hidden */
  7152. export class WebGLDataBuffer extends DataBuffer {
  7153. private _buffer;
  7154. constructor(resource: WebGLBuffer);
  7155. get underlyingResource(): any;
  7156. }
  7157. }
  7158. declare module BABYLON {
  7159. /** @hidden */
  7160. export class WebGLPipelineContext implements IPipelineContext {
  7161. engine: ThinEngine;
  7162. program: Nullable<WebGLProgram>;
  7163. context?: WebGLRenderingContext;
  7164. vertexShader?: WebGLShader;
  7165. fragmentShader?: WebGLShader;
  7166. isParallelCompiled: boolean;
  7167. onCompiled?: () => void;
  7168. transformFeedback?: WebGLTransformFeedback | null;
  7169. vertexCompilationError: Nullable<string>;
  7170. fragmentCompilationError: Nullable<string>;
  7171. programLinkError: Nullable<string>;
  7172. programValidationError: Nullable<string>;
  7173. get isAsync(): boolean;
  7174. get isReady(): boolean;
  7175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7176. _getVertexShaderCode(): string | null;
  7177. _getFragmentShaderCode(): string | null;
  7178. }
  7179. }
  7180. declare module BABYLON {
  7181. interface ThinEngine {
  7182. /**
  7183. * Create an uniform buffer
  7184. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7185. * @param elements defines the content of the uniform buffer
  7186. * @returns the webGL uniform buffer
  7187. */
  7188. createUniformBuffer(elements: FloatArray): DataBuffer;
  7189. /**
  7190. * Create a dynamic uniform buffer
  7191. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7192. * @param elements defines the content of the uniform buffer
  7193. * @returns the webGL uniform buffer
  7194. */
  7195. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7196. /**
  7197. * Update an existing uniform buffer
  7198. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7199. * @param uniformBuffer defines the target uniform buffer
  7200. * @param elements defines the content to update
  7201. * @param offset defines the offset in the uniform buffer where update should start
  7202. * @param count defines the size of the data to update
  7203. */
  7204. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7205. /**
  7206. * Bind an uniform buffer to the current webGL context
  7207. * @param buffer defines the buffer to bind
  7208. */
  7209. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7210. /**
  7211. * Bind a buffer to the current webGL context at a given location
  7212. * @param buffer defines the buffer to bind
  7213. * @param location defines the index where to bind the buffer
  7214. */
  7215. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7216. /**
  7217. * Bind a specific block at a given index in a specific shader program
  7218. * @param pipelineContext defines the pipeline context to use
  7219. * @param blockName defines the block name
  7220. * @param index defines the index where to bind the block
  7221. */
  7222. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7223. }
  7224. }
  7225. declare module BABYLON {
  7226. /**
  7227. * Uniform buffer objects.
  7228. *
  7229. * Handles blocks of uniform on the GPU.
  7230. *
  7231. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7232. *
  7233. * For more information, please refer to :
  7234. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7235. */
  7236. export class UniformBuffer {
  7237. private _engine;
  7238. private _buffer;
  7239. private _data;
  7240. private _bufferData;
  7241. private _dynamic?;
  7242. private _uniformLocations;
  7243. private _uniformSizes;
  7244. private _uniformLocationPointer;
  7245. private _needSync;
  7246. private _noUBO;
  7247. private _currentEffect;
  7248. /** @hidden */
  7249. _alreadyBound: boolean;
  7250. private static _MAX_UNIFORM_SIZE;
  7251. private static _tempBuffer;
  7252. /**
  7253. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7254. * This is dynamic to allow compat with webgl 1 and 2.
  7255. * You will need to pass the name of the uniform as well as the value.
  7256. */
  7257. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7258. /**
  7259. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7260. * This is dynamic to allow compat with webgl 1 and 2.
  7261. * You will need to pass the name of the uniform as well as the value.
  7262. */
  7263. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7264. /**
  7265. * Lambda to Update a single float in a uniform buffer.
  7266. * This is dynamic to allow compat with webgl 1 and 2.
  7267. * You will need to pass the name of the uniform as well as the value.
  7268. */
  7269. updateFloat: (name: string, x: number) => void;
  7270. /**
  7271. * Lambda to Update a vec2 of float in a uniform buffer.
  7272. * This is dynamic to allow compat with webgl 1 and 2.
  7273. * You will need to pass the name of the uniform as well as the value.
  7274. */
  7275. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7276. /**
  7277. * Lambda to Update a vec3 of float in a uniform buffer.
  7278. * This is dynamic to allow compat with webgl 1 and 2.
  7279. * You will need to pass the name of the uniform as well as the value.
  7280. */
  7281. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7282. /**
  7283. * Lambda to Update a vec4 of float in a uniform buffer.
  7284. * This is dynamic to allow compat with webgl 1 and 2.
  7285. * You will need to pass the name of the uniform as well as the value.
  7286. */
  7287. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7288. /**
  7289. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7290. * This is dynamic to allow compat with webgl 1 and 2.
  7291. * You will need to pass the name of the uniform as well as the value.
  7292. */
  7293. updateMatrix: (name: string, mat: Matrix) => void;
  7294. /**
  7295. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7296. * This is dynamic to allow compat with webgl 1 and 2.
  7297. * You will need to pass the name of the uniform as well as the value.
  7298. */
  7299. updateVector3: (name: string, vector: Vector3) => void;
  7300. /**
  7301. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7302. * This is dynamic to allow compat with webgl 1 and 2.
  7303. * You will need to pass the name of the uniform as well as the value.
  7304. */
  7305. updateVector4: (name: string, vector: Vector4) => void;
  7306. /**
  7307. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7308. * This is dynamic to allow compat with webgl 1 and 2.
  7309. * You will need to pass the name of the uniform as well as the value.
  7310. */
  7311. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7312. /**
  7313. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7314. * This is dynamic to allow compat with webgl 1 and 2.
  7315. * You will need to pass the name of the uniform as well as the value.
  7316. */
  7317. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7318. /**
  7319. * Instantiates a new Uniform buffer objects.
  7320. *
  7321. * Handles blocks of uniform on the GPU.
  7322. *
  7323. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7324. *
  7325. * For more information, please refer to :
  7326. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7327. * @param engine Define the engine the buffer is associated with
  7328. * @param data Define the data contained in the buffer
  7329. * @param dynamic Define if the buffer is updatable
  7330. */
  7331. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7332. /**
  7333. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7334. * or just falling back on setUniformXXX calls.
  7335. */
  7336. get useUbo(): boolean;
  7337. /**
  7338. * Indicates if the WebGL underlying uniform buffer is in sync
  7339. * with the javascript cache data.
  7340. */
  7341. get isSync(): boolean;
  7342. /**
  7343. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7344. * Also, a dynamic UniformBuffer will disable cache verification and always
  7345. * update the underlying WebGL uniform buffer to the GPU.
  7346. * @returns if Dynamic, otherwise false
  7347. */
  7348. isDynamic(): boolean;
  7349. /**
  7350. * The data cache on JS side.
  7351. * @returns the underlying data as a float array
  7352. */
  7353. getData(): Float32Array;
  7354. /**
  7355. * The underlying WebGL Uniform buffer.
  7356. * @returns the webgl buffer
  7357. */
  7358. getBuffer(): Nullable<DataBuffer>;
  7359. /**
  7360. * std140 layout specifies how to align data within an UBO structure.
  7361. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7362. * for specs.
  7363. */
  7364. private _fillAlignment;
  7365. /**
  7366. * Adds an uniform in the buffer.
  7367. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7368. * for the layout to be correct !
  7369. * @param name Name of the uniform, as used in the uniform block in the shader.
  7370. * @param size Data size, or data directly.
  7371. */
  7372. addUniform(name: string, size: number | number[]): void;
  7373. /**
  7374. * Adds a Matrix 4x4 to the uniform buffer.
  7375. * @param name Name of the uniform, as used in the uniform block in the shader.
  7376. * @param mat A 4x4 matrix.
  7377. */
  7378. addMatrix(name: string, mat: Matrix): void;
  7379. /**
  7380. * Adds a vec2 to the uniform buffer.
  7381. * @param name Name of the uniform, as used in the uniform block in the shader.
  7382. * @param x Define the x component value of the vec2
  7383. * @param y Define the y component value of the vec2
  7384. */
  7385. addFloat2(name: string, x: number, y: number): void;
  7386. /**
  7387. * Adds a vec3 to the uniform buffer.
  7388. * @param name Name of the uniform, as used in the uniform block in the shader.
  7389. * @param x Define the x component value of the vec3
  7390. * @param y Define the y component value of the vec3
  7391. * @param z Define the z component value of the vec3
  7392. */
  7393. addFloat3(name: string, x: number, y: number, z: number): void;
  7394. /**
  7395. * Adds a vec3 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param color Define the vec3 from a Color
  7398. */
  7399. addColor3(name: string, color: Color3): void;
  7400. /**
  7401. * Adds a vec4 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param color Define the rgb components from a Color
  7404. * @param alpha Define the a component of the vec4
  7405. */
  7406. addColor4(name: string, color: Color3, alpha: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param vector Define the vec3 components from a Vector
  7411. */
  7412. addVector3(name: string, vector: Vector3): void;
  7413. /**
  7414. * Adds a Matrix 3x3 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. */
  7417. addMatrix3x3(name: string): void;
  7418. /**
  7419. * Adds a Matrix 2x2 to the uniform buffer.
  7420. * @param name Name of the uniform, as used in the uniform block in the shader.
  7421. */
  7422. addMatrix2x2(name: string): void;
  7423. /**
  7424. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7425. */
  7426. create(): void;
  7427. /** @hidden */
  7428. _rebuild(): void;
  7429. /**
  7430. * Updates the WebGL Uniform Buffer on the GPU.
  7431. * If the `dynamic` flag is set to true, no cache comparison is done.
  7432. * Otherwise, the buffer will be updated only if the cache differs.
  7433. */
  7434. update(): void;
  7435. /**
  7436. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7437. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7438. * @param data Define the flattened data
  7439. * @param size Define the size of the data.
  7440. */
  7441. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7442. private _valueCache;
  7443. private _cacheMatrix;
  7444. private _updateMatrix3x3ForUniform;
  7445. private _updateMatrix3x3ForEffect;
  7446. private _updateMatrix2x2ForEffect;
  7447. private _updateMatrix2x2ForUniform;
  7448. private _updateFloatForEffect;
  7449. private _updateFloatForUniform;
  7450. private _updateFloat2ForEffect;
  7451. private _updateFloat2ForUniform;
  7452. private _updateFloat3ForEffect;
  7453. private _updateFloat3ForUniform;
  7454. private _updateFloat4ForEffect;
  7455. private _updateFloat4ForUniform;
  7456. private _updateMatrixForEffect;
  7457. private _updateMatrixForUniform;
  7458. private _updateVector3ForEffect;
  7459. private _updateVector3ForUniform;
  7460. private _updateVector4ForEffect;
  7461. private _updateVector4ForUniform;
  7462. private _updateColor3ForEffect;
  7463. private _updateColor3ForUniform;
  7464. private _updateColor4ForEffect;
  7465. private _updateColor4ForUniform;
  7466. /**
  7467. * Sets a sampler uniform on the effect.
  7468. * @param name Define the name of the sampler.
  7469. * @param texture Define the texture to set in the sampler
  7470. */
  7471. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7472. /**
  7473. * Directly updates the value of the uniform in the cache AND on the GPU.
  7474. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7475. * @param data Define the flattened data
  7476. */
  7477. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7478. /**
  7479. * Binds this uniform buffer to an effect.
  7480. * @param effect Define the effect to bind the buffer to
  7481. * @param name Name of the uniform block in the shader.
  7482. */
  7483. bindToEffect(effect: Effect, name: string): void;
  7484. /**
  7485. * Disposes the uniform buffer.
  7486. */
  7487. dispose(): void;
  7488. }
  7489. }
  7490. declare module BABYLON {
  7491. /**
  7492. * Enum that determines the text-wrapping mode to use.
  7493. */
  7494. export enum InspectableType {
  7495. /**
  7496. * Checkbox for booleans
  7497. */
  7498. Checkbox = 0,
  7499. /**
  7500. * Sliders for numbers
  7501. */
  7502. Slider = 1,
  7503. /**
  7504. * Vector3
  7505. */
  7506. Vector3 = 2,
  7507. /**
  7508. * Quaternions
  7509. */
  7510. Quaternion = 3,
  7511. /**
  7512. * Color3
  7513. */
  7514. Color3 = 4,
  7515. /**
  7516. * String
  7517. */
  7518. String = 5
  7519. }
  7520. /**
  7521. * Interface used to define custom inspectable properties.
  7522. * This interface is used by the inspector to display custom property grids
  7523. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7524. */
  7525. export interface IInspectable {
  7526. /**
  7527. * Gets the label to display
  7528. */
  7529. label: string;
  7530. /**
  7531. * Gets the name of the property to edit
  7532. */
  7533. propertyName: string;
  7534. /**
  7535. * Gets the type of the editor to use
  7536. */
  7537. type: InspectableType;
  7538. /**
  7539. * Gets the minimum value of the property when using in "slider" mode
  7540. */
  7541. min?: number;
  7542. /**
  7543. * Gets the maximum value of the property when using in "slider" mode
  7544. */
  7545. max?: number;
  7546. /**
  7547. * Gets the setp to use when using in "slider" mode
  7548. */
  7549. step?: number;
  7550. }
  7551. }
  7552. declare module BABYLON {
  7553. /**
  7554. * Class used to provide helper for timing
  7555. */
  7556. export class TimingTools {
  7557. /**
  7558. * Polyfill for setImmediate
  7559. * @param action defines the action to execute after the current execution block
  7560. */
  7561. static SetImmediate(action: () => void): void;
  7562. }
  7563. }
  7564. declare module BABYLON {
  7565. /**
  7566. * Class used to enable instatition of objects by class name
  7567. */
  7568. export class InstantiationTools {
  7569. /**
  7570. * Use this object to register external classes like custom textures or material
  7571. * to allow the laoders to instantiate them
  7572. */
  7573. static RegisteredExternalClasses: {
  7574. [key: string]: Object;
  7575. };
  7576. /**
  7577. * Tries to instantiate a new object from a given class name
  7578. * @param className defines the class name to instantiate
  7579. * @returns the new object or null if the system was not able to do the instantiation
  7580. */
  7581. static Instantiate(className: string): any;
  7582. }
  7583. }
  7584. declare module BABYLON {
  7585. /**
  7586. * Define options used to create a depth texture
  7587. */
  7588. export class DepthTextureCreationOptions {
  7589. /** Specifies whether or not a stencil should be allocated in the texture */
  7590. generateStencil?: boolean;
  7591. /** Specifies whether or not bilinear filtering is enable on the texture */
  7592. bilinearFiltering?: boolean;
  7593. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7594. comparisonFunction?: number;
  7595. /** Specifies if the created texture is a cube texture */
  7596. isCube?: boolean;
  7597. }
  7598. }
  7599. declare module BABYLON {
  7600. interface ThinEngine {
  7601. /**
  7602. * Creates a depth stencil cube texture.
  7603. * This is only available in WebGL 2.
  7604. * @param size The size of face edge in the cube texture.
  7605. * @param options The options defining the cube texture.
  7606. * @returns The cube texture
  7607. */
  7608. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7609. /**
  7610. * Creates a cube texture
  7611. * @param rootUrl defines the url where the files to load is located
  7612. * @param scene defines the current scene
  7613. * @param files defines the list of files to load (1 per face)
  7614. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7615. * @param onLoad defines an optional callback raised when the texture is loaded
  7616. * @param onError defines an optional callback raised if there is an issue to load the texture
  7617. * @param format defines the format of the data
  7618. * @param forcedExtension defines the extension to use to pick the right loader
  7619. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7620. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7621. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7622. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7623. * @returns the cube texture as an InternalTexture
  7624. */
  7625. 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;
  7626. /**
  7627. * Creates a cube texture
  7628. * @param rootUrl defines the url where the files to load is located
  7629. * @param scene defines the current scene
  7630. * @param files defines the list of files to load (1 per face)
  7631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7632. * @param onLoad defines an optional callback raised when the texture is loaded
  7633. * @param onError defines an optional callback raised if there is an issue to load the texture
  7634. * @param format defines the format of the data
  7635. * @param forcedExtension defines the extension to use to pick the right loader
  7636. * @returns the cube texture as an InternalTexture
  7637. */
  7638. 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;
  7639. /**
  7640. * Creates a cube texture
  7641. * @param rootUrl defines the url where the files to load is located
  7642. * @param scene defines the current scene
  7643. * @param files defines the list of files to load (1 per face)
  7644. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7645. * @param onLoad defines an optional callback raised when the texture is loaded
  7646. * @param onError defines an optional callback raised if there is an issue to load the texture
  7647. * @param format defines the format of the data
  7648. * @param forcedExtension defines the extension to use to pick the right loader
  7649. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7650. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7651. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7652. * @returns the cube texture as an InternalTexture
  7653. */
  7654. 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;
  7655. /** @hidden */
  7656. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7657. /** @hidden */
  7658. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7659. /** @hidden */
  7660. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7661. /** @hidden */
  7662. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7663. /**
  7664. * @hidden
  7665. */
  7666. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7667. }
  7668. }
  7669. declare module BABYLON {
  7670. /**
  7671. * Class for creating a cube texture
  7672. */
  7673. export class CubeTexture extends BaseTexture {
  7674. private _delayedOnLoad;
  7675. /**
  7676. * Observable triggered once the texture has been loaded.
  7677. */
  7678. onLoadObservable: Observable<CubeTexture>;
  7679. /**
  7680. * The url of the texture
  7681. */
  7682. url: string;
  7683. /**
  7684. * Gets or sets the center of the bounding box associated with the cube texture.
  7685. * It must define where the camera used to render the texture was set
  7686. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7687. */
  7688. boundingBoxPosition: Vector3;
  7689. private _boundingBoxSize;
  7690. /**
  7691. * Gets or sets the size of the bounding box associated with the cube texture
  7692. * When defined, the cubemap will switch to local mode
  7693. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7694. * @example https://www.babylonjs-playground.com/#RNASML
  7695. */
  7696. set boundingBoxSize(value: Vector3);
  7697. /**
  7698. * Returns the bounding box size
  7699. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7700. */
  7701. get boundingBoxSize(): Vector3;
  7702. protected _rotationY: number;
  7703. /**
  7704. * Sets texture matrix rotation angle around Y axis in radians.
  7705. */
  7706. set rotationY(value: number);
  7707. /**
  7708. * Gets texture matrix rotation angle around Y axis radians.
  7709. */
  7710. get rotationY(): number;
  7711. /**
  7712. * Are mip maps generated for this texture or not.
  7713. */
  7714. get noMipmap(): boolean;
  7715. private _noMipmap;
  7716. private _files;
  7717. protected _forcedExtension: Nullable<string>;
  7718. private _extensions;
  7719. private _textureMatrix;
  7720. private _format;
  7721. private _createPolynomials;
  7722. /** @hidden */
  7723. _prefiltered: boolean;
  7724. /**
  7725. * Creates a cube texture from an array of image urls
  7726. * @param files defines an array of image urls
  7727. * @param scene defines the hosting scene
  7728. * @param noMipmap specifies if mip maps are not used
  7729. * @returns a cube texture
  7730. */
  7731. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7732. /**
  7733. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7734. * @param url defines the url of the prefiltered texture
  7735. * @param scene defines the scene the texture is attached to
  7736. * @param forcedExtension defines the extension of the file if different from the url
  7737. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7738. * @return the prefiltered texture
  7739. */
  7740. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7741. /**
  7742. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7743. * as prefiltered data.
  7744. * @param rootUrl defines the url of the texture or the root name of the six images
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7747. * @param noMipmap defines if mipmaps should be created or not
  7748. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7749. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7750. * @param onError defines a callback triggered in case of error during load
  7751. * @param format defines the internal format to use for the texture once loaded
  7752. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7753. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7754. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7755. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7756. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7757. * @return the cube texture
  7758. */
  7759. 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);
  7760. /**
  7761. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7762. */
  7763. get isPrefiltered(): boolean;
  7764. /**
  7765. * Get the current class name of the texture useful for serialization or dynamic coding.
  7766. * @returns "CubeTexture"
  7767. */
  7768. getClassName(): string;
  7769. /**
  7770. * Update the url (and optional buffer) of this texture if url was null during construction.
  7771. * @param url the url of the texture
  7772. * @param forcedExtension defines the extension to use
  7773. * @param onLoad callback called when the texture is loaded (defaults to null)
  7774. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7775. */
  7776. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7777. /**
  7778. * Delays loading of the cube texture
  7779. * @param forcedExtension defines the extension to use
  7780. */
  7781. delayLoad(forcedExtension?: string): void;
  7782. /**
  7783. * Returns the reflection texture matrix
  7784. * @returns the reflection texture matrix
  7785. */
  7786. getReflectionTextureMatrix(): Matrix;
  7787. /**
  7788. * Sets the reflection texture matrix
  7789. * @param value Reflection texture matrix
  7790. */
  7791. setReflectionTextureMatrix(value: Matrix): void;
  7792. /**
  7793. * Parses text to create a cube texture
  7794. * @param parsedTexture define the serialized text to read from
  7795. * @param scene defines the hosting scene
  7796. * @param rootUrl defines the root url of the cube texture
  7797. * @returns a cube texture
  7798. */
  7799. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7800. /**
  7801. * Makes a clone, or deep copy, of the cube texture
  7802. * @returns a new cube texture
  7803. */
  7804. clone(): CubeTexture;
  7805. }
  7806. }
  7807. declare module BABYLON {
  7808. /**
  7809. * Manages the defines for the Material
  7810. */
  7811. export class MaterialDefines {
  7812. /** @hidden */
  7813. protected _keys: string[];
  7814. private _isDirty;
  7815. /** @hidden */
  7816. _renderId: number;
  7817. /** @hidden */
  7818. _areLightsDirty: boolean;
  7819. /** @hidden */
  7820. _areLightsDisposed: boolean;
  7821. /** @hidden */
  7822. _areAttributesDirty: boolean;
  7823. /** @hidden */
  7824. _areTexturesDirty: boolean;
  7825. /** @hidden */
  7826. _areFresnelDirty: boolean;
  7827. /** @hidden */
  7828. _areMiscDirty: boolean;
  7829. /** @hidden */
  7830. _areImageProcessingDirty: boolean;
  7831. /** @hidden */
  7832. _normals: boolean;
  7833. /** @hidden */
  7834. _uvs: boolean;
  7835. /** @hidden */
  7836. _needNormals: boolean;
  7837. /** @hidden */
  7838. _needUVs: boolean;
  7839. [id: string]: any;
  7840. /**
  7841. * Specifies if the material needs to be re-calculated
  7842. */
  7843. get isDirty(): boolean;
  7844. /**
  7845. * Marks the material to indicate that it has been re-calculated
  7846. */
  7847. markAsProcessed(): void;
  7848. /**
  7849. * Marks the material to indicate that it needs to be re-calculated
  7850. */
  7851. markAsUnprocessed(): void;
  7852. /**
  7853. * Marks the material to indicate all of its defines need to be re-calculated
  7854. */
  7855. markAllAsDirty(): void;
  7856. /**
  7857. * Marks the material to indicate that image processing needs to be re-calculated
  7858. */
  7859. markAsImageProcessingDirty(): void;
  7860. /**
  7861. * Marks the material to indicate the lights need to be re-calculated
  7862. * @param disposed Defines whether the light is dirty due to dispose or not
  7863. */
  7864. markAsLightDirty(disposed?: boolean): void;
  7865. /**
  7866. * Marks the attribute state as changed
  7867. */
  7868. markAsAttributesDirty(): void;
  7869. /**
  7870. * Marks the texture state as changed
  7871. */
  7872. markAsTexturesDirty(): void;
  7873. /**
  7874. * Marks the fresnel state as changed
  7875. */
  7876. markAsFresnelDirty(): void;
  7877. /**
  7878. * Marks the misc state as changed
  7879. */
  7880. markAsMiscDirty(): void;
  7881. /**
  7882. * Rebuilds the material defines
  7883. */
  7884. rebuild(): void;
  7885. /**
  7886. * Specifies if two material defines are equal
  7887. * @param other - A material define instance to compare to
  7888. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7889. */
  7890. isEqual(other: MaterialDefines): boolean;
  7891. /**
  7892. * Clones this instance's defines to another instance
  7893. * @param other - material defines to clone values to
  7894. */
  7895. cloneTo(other: MaterialDefines): void;
  7896. /**
  7897. * Resets the material define values
  7898. */
  7899. reset(): void;
  7900. /**
  7901. * Converts the material define values to a string
  7902. * @returns - String of material define information
  7903. */
  7904. toString(): string;
  7905. }
  7906. }
  7907. declare module BABYLON {
  7908. /**
  7909. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7910. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7911. * 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;
  7912. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7913. */
  7914. export class ColorCurves {
  7915. private _dirty;
  7916. private _tempColor;
  7917. private _globalCurve;
  7918. private _highlightsCurve;
  7919. private _midtonesCurve;
  7920. private _shadowsCurve;
  7921. private _positiveCurve;
  7922. private _negativeCurve;
  7923. private _globalHue;
  7924. private _globalDensity;
  7925. private _globalSaturation;
  7926. private _globalExposure;
  7927. /**
  7928. * Gets the global Hue value.
  7929. * 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).
  7930. */
  7931. get globalHue(): number;
  7932. /**
  7933. * Sets the global Hue value.
  7934. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7935. */
  7936. set globalHue(value: number);
  7937. /**
  7938. * Gets the global Density value.
  7939. * 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.
  7940. * Values less than zero provide a filter of opposite hue.
  7941. */
  7942. get globalDensity(): number;
  7943. /**
  7944. * Sets the global Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. set globalDensity(value: number);
  7949. /**
  7950. * Gets the global Saturation value.
  7951. * 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.
  7952. */
  7953. get globalSaturation(): number;
  7954. /**
  7955. * Sets the global Saturation value.
  7956. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7957. */
  7958. set globalSaturation(value: number);
  7959. /**
  7960. * Gets the global Exposure 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 exposure and negative values decrease exposure.
  7962. */
  7963. get globalExposure(): number;
  7964. /**
  7965. * Sets the global Exposure value.
  7966. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7967. */
  7968. set globalExposure(value: number);
  7969. private _highlightsHue;
  7970. private _highlightsDensity;
  7971. private _highlightsSaturation;
  7972. private _highlightsExposure;
  7973. /**
  7974. * Gets the highlights Hue value.
  7975. * 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).
  7976. */
  7977. get highlightsHue(): number;
  7978. /**
  7979. * Sets the highlights Hue value.
  7980. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7981. */
  7982. set highlightsHue(value: number);
  7983. /**
  7984. * Gets the highlights Density value.
  7985. * 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.
  7986. * Values less than zero provide a filter of opposite hue.
  7987. */
  7988. get highlightsDensity(): number;
  7989. /**
  7990. * Sets the highlights Density value.
  7991. * 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.
  7992. * Values less than zero provide a filter of opposite hue.
  7993. */
  7994. set highlightsDensity(value: number);
  7995. /**
  7996. * Gets the highlights Saturation value.
  7997. * 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.
  7998. */
  7999. get highlightsSaturation(): number;
  8000. /**
  8001. * Sets the highlights Saturation value.
  8002. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8003. */
  8004. set highlightsSaturation(value: number);
  8005. /**
  8006. * Gets the highlights Exposure 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 exposure and negative values decrease exposure.
  8008. */
  8009. get highlightsExposure(): number;
  8010. /**
  8011. * Sets the highlights Exposure value.
  8012. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8013. */
  8014. set highlightsExposure(value: number);
  8015. private _midtonesHue;
  8016. private _midtonesDensity;
  8017. private _midtonesSaturation;
  8018. private _midtonesExposure;
  8019. /**
  8020. * Gets the midtones Hue value.
  8021. * 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).
  8022. */
  8023. get midtonesHue(): number;
  8024. /**
  8025. * Sets the midtones Hue value.
  8026. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8027. */
  8028. set midtonesHue(value: number);
  8029. /**
  8030. * Gets the midtones Density value.
  8031. * 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.
  8032. * Values less than zero provide a filter of opposite hue.
  8033. */
  8034. get midtonesDensity(): number;
  8035. /**
  8036. * Sets the midtones Density value.
  8037. * 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.
  8038. * Values less than zero provide a filter of opposite hue.
  8039. */
  8040. set midtonesDensity(value: number);
  8041. /**
  8042. * Gets the midtones Saturation value.
  8043. * 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.
  8044. */
  8045. get midtonesSaturation(): number;
  8046. /**
  8047. * Sets the midtones Saturation value.
  8048. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8049. */
  8050. set midtonesSaturation(value: number);
  8051. /**
  8052. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  8054. */
  8055. get midtonesExposure(): number;
  8056. /**
  8057. * Sets the midtones Exposure value.
  8058. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8059. */
  8060. set midtonesExposure(value: number);
  8061. private _shadowsHue;
  8062. private _shadowsDensity;
  8063. private _shadowsSaturation;
  8064. private _shadowsExposure;
  8065. /**
  8066. * Gets the shadows Hue value.
  8067. * 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).
  8068. */
  8069. get shadowsHue(): number;
  8070. /**
  8071. * Sets the shadows Hue value.
  8072. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8073. */
  8074. set shadowsHue(value: number);
  8075. /**
  8076. * Gets the shadows Density value.
  8077. * 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.
  8078. * Values less than zero provide a filter of opposite hue.
  8079. */
  8080. get shadowsDensity(): number;
  8081. /**
  8082. * Sets the shadows Density value.
  8083. * 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.
  8084. * Values less than zero provide a filter of opposite hue.
  8085. */
  8086. set shadowsDensity(value: number);
  8087. /**
  8088. * Gets the shadows Saturation value.
  8089. * 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.
  8090. */
  8091. get shadowsSaturation(): number;
  8092. /**
  8093. * Sets the shadows Saturation value.
  8094. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8095. */
  8096. set shadowsSaturation(value: number);
  8097. /**
  8098. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  8100. */
  8101. get shadowsExposure(): number;
  8102. /**
  8103. * Sets the shadows Exposure value.
  8104. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8105. */
  8106. set shadowsExposure(value: number);
  8107. /**
  8108. * Returns the class name
  8109. * @returns The class name
  8110. */
  8111. getClassName(): string;
  8112. /**
  8113. * Binds the color curves to the shader.
  8114. * @param colorCurves The color curve to bind
  8115. * @param effect The effect to bind to
  8116. * @param positiveUniform The positive uniform shader parameter
  8117. * @param neutralUniform The neutral uniform shader parameter
  8118. * @param negativeUniform The negative uniform shader parameter
  8119. */
  8120. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8121. /**
  8122. * Prepare the list of uniforms associated with the ColorCurves effects.
  8123. * @param uniformsList The list of uniforms used in the effect
  8124. */
  8125. static PrepareUniforms(uniformsList: string[]): void;
  8126. /**
  8127. * Returns color grading data based on a hue, density, saturation and exposure value.
  8128. * @param filterHue The hue of the color filter.
  8129. * @param filterDensity The density of the color filter.
  8130. * @param saturation The saturation.
  8131. * @param exposure The exposure.
  8132. * @param result The result data container.
  8133. */
  8134. private getColorGradingDataToRef;
  8135. /**
  8136. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8137. * @param value The input slider value in range [-100,100].
  8138. * @returns Adjusted value.
  8139. */
  8140. private static applyColorGradingSliderNonlinear;
  8141. /**
  8142. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8143. * @param hue The hue (H) input.
  8144. * @param saturation The saturation (S) input.
  8145. * @param brightness The brightness (B) input.
  8146. * @result An RGBA color represented as Vector4.
  8147. */
  8148. private static fromHSBToRef;
  8149. /**
  8150. * Returns a value clamped between min and max
  8151. * @param value The value to clamp
  8152. * @param min The minimum of value
  8153. * @param max The maximum of value
  8154. * @returns The clamped value.
  8155. */
  8156. private static clamp;
  8157. /**
  8158. * Clones the current color curve instance.
  8159. * @return The cloned curves
  8160. */
  8161. clone(): ColorCurves;
  8162. /**
  8163. * Serializes the current color curve instance to a json representation.
  8164. * @return a JSON representation
  8165. */
  8166. serialize(): any;
  8167. /**
  8168. * Parses the color curve from a json representation.
  8169. * @param source the JSON source to parse
  8170. * @return The parsed curves
  8171. */
  8172. static Parse(source: any): ColorCurves;
  8173. }
  8174. }
  8175. declare module BABYLON {
  8176. /**
  8177. * Interface to follow in your material defines to integrate easily the
  8178. * Image proccessing functions.
  8179. * @hidden
  8180. */
  8181. export interface IImageProcessingConfigurationDefines {
  8182. IMAGEPROCESSING: boolean;
  8183. VIGNETTE: boolean;
  8184. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8185. VIGNETTEBLENDMODEOPAQUE: boolean;
  8186. TONEMAPPING: boolean;
  8187. TONEMAPPING_ACES: boolean;
  8188. CONTRAST: boolean;
  8189. EXPOSURE: boolean;
  8190. COLORCURVES: boolean;
  8191. COLORGRADING: boolean;
  8192. COLORGRADING3D: boolean;
  8193. SAMPLER3DGREENDEPTH: boolean;
  8194. SAMPLER3DBGRMAP: boolean;
  8195. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8196. }
  8197. /**
  8198. * @hidden
  8199. */
  8200. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. COLORCURVES: boolean;
  8209. COLORGRADING: boolean;
  8210. COLORGRADING3D: boolean;
  8211. SAMPLER3DGREENDEPTH: boolean;
  8212. SAMPLER3DBGRMAP: boolean;
  8213. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8214. EXPOSURE: boolean;
  8215. constructor();
  8216. }
  8217. /**
  8218. * This groups together the common properties used for image processing either in direct forward pass
  8219. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8220. * or not.
  8221. */
  8222. export class ImageProcessingConfiguration {
  8223. /**
  8224. * Default tone mapping applied in BabylonJS.
  8225. */
  8226. static readonly TONEMAPPING_STANDARD: number;
  8227. /**
  8228. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8229. * to other engines rendering to increase portability.
  8230. */
  8231. static readonly TONEMAPPING_ACES: number;
  8232. /**
  8233. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8234. */
  8235. colorCurves: Nullable<ColorCurves>;
  8236. private _colorCurvesEnabled;
  8237. /**
  8238. * Gets wether the color curves effect is enabled.
  8239. */
  8240. get colorCurvesEnabled(): boolean;
  8241. /**
  8242. * Sets wether the color curves effect is enabled.
  8243. */
  8244. set colorCurvesEnabled(value: boolean);
  8245. private _colorGradingTexture;
  8246. /**
  8247. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8248. */
  8249. get colorGradingTexture(): Nullable<BaseTexture>;
  8250. /**
  8251. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8252. */
  8253. set colorGradingTexture(value: Nullable<BaseTexture>);
  8254. private _colorGradingEnabled;
  8255. /**
  8256. * Gets wether the color grading effect is enabled.
  8257. */
  8258. get colorGradingEnabled(): boolean;
  8259. /**
  8260. * Sets wether the color grading effect is enabled.
  8261. */
  8262. set colorGradingEnabled(value: boolean);
  8263. private _colorGradingWithGreenDepth;
  8264. /**
  8265. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8266. */
  8267. get colorGradingWithGreenDepth(): boolean;
  8268. /**
  8269. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8270. */
  8271. set colorGradingWithGreenDepth(value: boolean);
  8272. private _colorGradingBGR;
  8273. /**
  8274. * Gets wether the color grading texture contains BGR values.
  8275. */
  8276. get colorGradingBGR(): boolean;
  8277. /**
  8278. * Sets wether the color grading texture contains BGR values.
  8279. */
  8280. set colorGradingBGR(value: boolean);
  8281. /** @hidden */
  8282. _exposure: number;
  8283. /**
  8284. * Gets the Exposure used in the effect.
  8285. */
  8286. get exposure(): number;
  8287. /**
  8288. * Sets the Exposure used in the effect.
  8289. */
  8290. set exposure(value: number);
  8291. private _toneMappingEnabled;
  8292. /**
  8293. * Gets wether the tone mapping effect is enabled.
  8294. */
  8295. get toneMappingEnabled(): boolean;
  8296. /**
  8297. * Sets wether the tone mapping effect is enabled.
  8298. */
  8299. set toneMappingEnabled(value: boolean);
  8300. private _toneMappingType;
  8301. /**
  8302. * Gets the type of tone mapping effect.
  8303. */
  8304. get toneMappingType(): number;
  8305. /**
  8306. * Sets the type of tone mapping effect used in BabylonJS.
  8307. */
  8308. set toneMappingType(value: number);
  8309. protected _contrast: number;
  8310. /**
  8311. * Gets the contrast used in the effect.
  8312. */
  8313. get contrast(): number;
  8314. /**
  8315. * Sets the contrast used in the effect.
  8316. */
  8317. set contrast(value: number);
  8318. /**
  8319. * Vignette stretch size.
  8320. */
  8321. vignetteStretch: number;
  8322. /**
  8323. * Vignette centre X Offset.
  8324. */
  8325. vignetteCentreX: number;
  8326. /**
  8327. * Vignette centre Y Offset.
  8328. */
  8329. vignetteCentreY: number;
  8330. /**
  8331. * Vignette weight or intensity of the vignette effect.
  8332. */
  8333. vignetteWeight: number;
  8334. /**
  8335. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8336. * if vignetteEnabled is set to true.
  8337. */
  8338. vignetteColor: Color4;
  8339. /**
  8340. * Camera field of view used by the Vignette effect.
  8341. */
  8342. vignetteCameraFov: number;
  8343. private _vignetteBlendMode;
  8344. /**
  8345. * Gets the vignette blend mode allowing different kind of effect.
  8346. */
  8347. get vignetteBlendMode(): number;
  8348. /**
  8349. * Sets the vignette blend mode allowing different kind of effect.
  8350. */
  8351. set vignetteBlendMode(value: number);
  8352. private _vignetteEnabled;
  8353. /**
  8354. * Gets wether the vignette effect is enabled.
  8355. */
  8356. get vignetteEnabled(): boolean;
  8357. /**
  8358. * Sets wether the vignette effect is enabled.
  8359. */
  8360. set vignetteEnabled(value: boolean);
  8361. private _applyByPostProcess;
  8362. /**
  8363. * Gets wether the image processing is applied through a post process or not.
  8364. */
  8365. get applyByPostProcess(): boolean;
  8366. /**
  8367. * Sets wether the image processing is applied through a post process or not.
  8368. */
  8369. set applyByPostProcess(value: boolean);
  8370. private _isEnabled;
  8371. /**
  8372. * Gets wether the image processing is enabled or not.
  8373. */
  8374. get isEnabled(): boolean;
  8375. /**
  8376. * Sets wether the image processing is enabled or not.
  8377. */
  8378. set isEnabled(value: boolean);
  8379. /**
  8380. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8381. */
  8382. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8383. /**
  8384. * Method called each time the image processing information changes requires to recompile the effect.
  8385. */
  8386. protected _updateParameters(): void;
  8387. /**
  8388. * Gets the current class name.
  8389. * @return "ImageProcessingConfiguration"
  8390. */
  8391. getClassName(): string;
  8392. /**
  8393. * Prepare the list of uniforms associated with the Image Processing effects.
  8394. * @param uniforms The list of uniforms used in the effect
  8395. * @param defines the list of defines currently in use
  8396. */
  8397. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8398. /**
  8399. * Prepare the list of samplers associated with the Image Processing effects.
  8400. * @param samplersList The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of defines associated to the shader.
  8406. * @param defines the list of defines to complete
  8407. * @param forPostProcess Define if we are currently in post process mode or not
  8408. */
  8409. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8410. /**
  8411. * Returns true if all the image processing information are ready.
  8412. * @returns True if ready, otherwise, false
  8413. */
  8414. isReady(): boolean;
  8415. /**
  8416. * Binds the image processing to the shader.
  8417. * @param effect The effect to bind to
  8418. * @param overrideAspectRatio Override the aspect ratio of the effect
  8419. */
  8420. bind(effect: Effect, overrideAspectRatio?: number): void;
  8421. /**
  8422. * Clones the current image processing instance.
  8423. * @return The cloned image processing
  8424. */
  8425. clone(): ImageProcessingConfiguration;
  8426. /**
  8427. * Serializes the current image processing instance to a json representation.
  8428. * @return a JSON representation
  8429. */
  8430. serialize(): any;
  8431. /**
  8432. * Parses the image processing from a json representation.
  8433. * @param source the JSON source to parse
  8434. * @return The parsed image processing
  8435. */
  8436. static Parse(source: any): ImageProcessingConfiguration;
  8437. private static _VIGNETTEMODE_MULTIPLY;
  8438. private static _VIGNETTEMODE_OPAQUE;
  8439. /**
  8440. * Used to apply the vignette as a mix with the pixel color.
  8441. */
  8442. static get VIGNETTEMODE_MULTIPLY(): number;
  8443. /**
  8444. * Used to apply the vignette as a replacement of the pixel color.
  8445. */
  8446. static get VIGNETTEMODE_OPAQUE(): number;
  8447. }
  8448. }
  8449. declare module BABYLON {
  8450. /** @hidden */
  8451. export var postprocessVertexShader: {
  8452. name: string;
  8453. shader: string;
  8454. };
  8455. }
  8456. declare module BABYLON {
  8457. interface ThinEngine {
  8458. /**
  8459. * Creates a new render target texture
  8460. * @param size defines the size of the texture
  8461. * @param options defines the options used to create the texture
  8462. * @returns a new render target texture stored in an InternalTexture
  8463. */
  8464. createRenderTargetTexture(size: number | {
  8465. width: number;
  8466. height: number;
  8467. layers?: number;
  8468. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8469. /**
  8470. * Creates a depth stencil texture.
  8471. * This is only available in WebGL 2 or with the depth texture extension available.
  8472. * @param size The size of face edge in the texture.
  8473. * @param options The options defining the texture.
  8474. * @returns The texture
  8475. */
  8476. createDepthStencilTexture(size: number | {
  8477. width: number;
  8478. height: number;
  8479. layers?: number;
  8480. }, options: DepthTextureCreationOptions): InternalTexture;
  8481. /** @hidden */
  8482. _createDepthStencilTexture(size: number | {
  8483. width: number;
  8484. height: number;
  8485. layers?: number;
  8486. }, options: DepthTextureCreationOptions): InternalTexture;
  8487. }
  8488. }
  8489. declare module BABYLON {
  8490. /** Defines supported spaces */
  8491. export enum Space {
  8492. /** Local (object) space */
  8493. LOCAL = 0,
  8494. /** World space */
  8495. WORLD = 1,
  8496. /** Bone space */
  8497. BONE = 2
  8498. }
  8499. /** Defines the 3 main axes */
  8500. export class Axis {
  8501. /** X axis */
  8502. static X: Vector3;
  8503. /** Y axis */
  8504. static Y: Vector3;
  8505. /** Z axis */
  8506. static Z: Vector3;
  8507. }
  8508. }
  8509. declare module BABYLON {
  8510. /**
  8511. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8512. * This is the base of the follow, arc rotate cameras and Free camera
  8513. * @see http://doc.babylonjs.com/features/cameras
  8514. */
  8515. export class TargetCamera extends Camera {
  8516. private static _RigCamTransformMatrix;
  8517. private static _TargetTransformMatrix;
  8518. private static _TargetFocalPoint;
  8519. /**
  8520. * Define the current direction the camera is moving to
  8521. */
  8522. cameraDirection: Vector3;
  8523. /**
  8524. * Define the current rotation the camera is rotating to
  8525. */
  8526. cameraRotation: Vector2;
  8527. /**
  8528. * When set, the up vector of the camera will be updated by the rotation of the camera
  8529. */
  8530. updateUpVectorFromRotation: boolean;
  8531. private _tmpQuaternion;
  8532. /**
  8533. * Define the current rotation of the camera
  8534. */
  8535. rotation: Vector3;
  8536. /**
  8537. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8538. */
  8539. rotationQuaternion: Quaternion;
  8540. /**
  8541. * Define the current speed of the camera
  8542. */
  8543. speed: number;
  8544. /**
  8545. * Add constraint to the camera to prevent it to move freely in all directions and
  8546. * around all axis.
  8547. */
  8548. noRotationConstraint: boolean;
  8549. /**
  8550. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8551. * panning
  8552. */
  8553. invertRotation: boolean;
  8554. /**
  8555. * Speed multiplier for inverse camera panning
  8556. */
  8557. inverseRotationSpeed: number;
  8558. /**
  8559. * Define the current target of the camera as an object or a position.
  8560. */
  8561. lockedTarget: any;
  8562. /** @hidden */
  8563. _currentTarget: Vector3;
  8564. /** @hidden */
  8565. _initialFocalDistance: number;
  8566. /** @hidden */
  8567. _viewMatrix: Matrix;
  8568. /** @hidden */
  8569. _camMatrix: Matrix;
  8570. /** @hidden */
  8571. _cameraTransformMatrix: Matrix;
  8572. /** @hidden */
  8573. _cameraRotationMatrix: Matrix;
  8574. /** @hidden */
  8575. _referencePoint: Vector3;
  8576. /** @hidden */
  8577. _transformedReferencePoint: Vector3;
  8578. protected _globalCurrentTarget: Vector3;
  8579. protected _globalCurrentUpVector: Vector3;
  8580. /** @hidden */
  8581. _reset: () => void;
  8582. private _defaultUp;
  8583. /**
  8584. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8585. * This is the base of the follow, arc rotate cameras and Free camera
  8586. * @see http://doc.babylonjs.com/features/cameras
  8587. * @param name Defines the name of the camera in the scene
  8588. * @param position Defines the start position of the camera in the scene
  8589. * @param scene Defines the scene the camera belongs to
  8590. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8591. */
  8592. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8593. /**
  8594. * Gets the position in front of the camera at a given distance.
  8595. * @param distance The distance from the camera we want the position to be
  8596. * @returns the position
  8597. */
  8598. getFrontPosition(distance: number): Vector3;
  8599. /** @hidden */
  8600. _getLockedTargetPosition(): Nullable<Vector3>;
  8601. private _storedPosition;
  8602. private _storedRotation;
  8603. private _storedRotationQuaternion;
  8604. /**
  8605. * Store current camera state of the camera (fov, position, rotation, etc..)
  8606. * @returns the camera
  8607. */
  8608. storeState(): Camera;
  8609. /**
  8610. * Restored camera state. You must call storeState() first
  8611. * @returns whether it was successful or not
  8612. * @hidden
  8613. */
  8614. _restoreStateValues(): boolean;
  8615. /** @hidden */
  8616. _initCache(): void;
  8617. /** @hidden */
  8618. _updateCache(ignoreParentClass?: boolean): void;
  8619. /** @hidden */
  8620. _isSynchronizedViewMatrix(): boolean;
  8621. /** @hidden */
  8622. _computeLocalCameraSpeed(): number;
  8623. /**
  8624. * Defines the target the camera should look at.
  8625. * @param target Defines the new target as a Vector or a mesh
  8626. */
  8627. setTarget(target: Vector3): void;
  8628. /**
  8629. * Return the current target position of the camera. This value is expressed in local space.
  8630. * @returns the target position
  8631. */
  8632. getTarget(): Vector3;
  8633. /** @hidden */
  8634. _decideIfNeedsToMove(): boolean;
  8635. /** @hidden */
  8636. _updatePosition(): void;
  8637. /** @hidden */
  8638. _checkInputs(): void;
  8639. protected _updateCameraRotationMatrix(): void;
  8640. /**
  8641. * 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)
  8642. * @returns the current camera
  8643. */
  8644. private _rotateUpVectorWithCameraRotationMatrix;
  8645. private _cachedRotationZ;
  8646. private _cachedQuaternionRotationZ;
  8647. /** @hidden */
  8648. _getViewMatrix(): Matrix;
  8649. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8650. /**
  8651. * @hidden
  8652. */
  8653. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8654. /**
  8655. * @hidden
  8656. */
  8657. _updateRigCameras(): void;
  8658. private _getRigCamPositionAndTarget;
  8659. /**
  8660. * Gets the current object class name.
  8661. * @return the class name
  8662. */
  8663. getClassName(): string;
  8664. }
  8665. }
  8666. declare module BABYLON {
  8667. /**
  8668. * Gather the list of keyboard event types as constants.
  8669. */
  8670. export class KeyboardEventTypes {
  8671. /**
  8672. * The keydown event is fired when a key becomes active (pressed).
  8673. */
  8674. static readonly KEYDOWN: number;
  8675. /**
  8676. * The keyup event is fired when a key has been released.
  8677. */
  8678. static readonly KEYUP: number;
  8679. }
  8680. /**
  8681. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8682. */
  8683. export class KeyboardInfo {
  8684. /**
  8685. * Defines the type of event (KeyboardEventTypes)
  8686. */
  8687. type: number;
  8688. /**
  8689. * Defines the related dom event
  8690. */
  8691. event: KeyboardEvent;
  8692. /**
  8693. * Instantiates a new keyboard info.
  8694. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8695. * @param type Defines the type of event (KeyboardEventTypes)
  8696. * @param event Defines the related dom event
  8697. */
  8698. constructor(
  8699. /**
  8700. * Defines the type of event (KeyboardEventTypes)
  8701. */
  8702. type: number,
  8703. /**
  8704. * Defines the related dom event
  8705. */
  8706. event: KeyboardEvent);
  8707. }
  8708. /**
  8709. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8710. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8711. */
  8712. export class KeyboardInfoPre extends KeyboardInfo {
  8713. /**
  8714. * Defines the type of event (KeyboardEventTypes)
  8715. */
  8716. type: number;
  8717. /**
  8718. * Defines the related dom event
  8719. */
  8720. event: KeyboardEvent;
  8721. /**
  8722. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8723. */
  8724. skipOnPointerObservable: boolean;
  8725. /**
  8726. * Instantiates a new keyboard pre info.
  8727. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8728. * @param type Defines the type of event (KeyboardEventTypes)
  8729. * @param event Defines the related dom event
  8730. */
  8731. constructor(
  8732. /**
  8733. * Defines the type of event (KeyboardEventTypes)
  8734. */
  8735. type: number,
  8736. /**
  8737. * Defines the related dom event
  8738. */
  8739. event: KeyboardEvent);
  8740. }
  8741. }
  8742. declare module BABYLON {
  8743. /**
  8744. * Manage the keyboard inputs to control the movement of a free camera.
  8745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8746. */
  8747. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8748. /**
  8749. * Defines the camera the input is attached to.
  8750. */
  8751. camera: FreeCamera;
  8752. /**
  8753. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8754. */
  8755. keysUp: number[];
  8756. /**
  8757. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8758. */
  8759. keysUpward: number[];
  8760. /**
  8761. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8762. */
  8763. keysDown: number[];
  8764. /**
  8765. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8766. */
  8767. keysDownward: number[];
  8768. /**
  8769. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8770. */
  8771. keysLeft: number[];
  8772. /**
  8773. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8774. */
  8775. keysRight: number[];
  8776. private _keys;
  8777. private _onCanvasBlurObserver;
  8778. private _onKeyboardObserver;
  8779. private _engine;
  8780. private _scene;
  8781. /**
  8782. * Attach the input controls to a specific dom element to get the input from.
  8783. * @param element Defines the element the controls should be listened from
  8784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8785. */
  8786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8787. /**
  8788. * Detach the current controls from the specified dom element.
  8789. * @param element Defines the element to stop listening the inputs from
  8790. */
  8791. detachControl(element: Nullable<HTMLElement>): void;
  8792. /**
  8793. * Update the current camera state depending on the inputs that have been used this frame.
  8794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8795. */
  8796. checkInputs(): void;
  8797. /**
  8798. * Gets the class name of the current intput.
  8799. * @returns the class name
  8800. */
  8801. getClassName(): string;
  8802. /** @hidden */
  8803. _onLostFocus(): void;
  8804. /**
  8805. * Get the friendly name associated with the input class.
  8806. * @returns the input friendly name
  8807. */
  8808. getSimpleName(): string;
  8809. }
  8810. }
  8811. declare module BABYLON {
  8812. /**
  8813. * Interface describing all the common properties and methods a shadow light needs to implement.
  8814. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8815. * as well as binding the different shadow properties to the effects.
  8816. */
  8817. export interface IShadowLight extends Light {
  8818. /**
  8819. * The light id in the scene (used in scene.findLighById for instance)
  8820. */
  8821. id: string;
  8822. /**
  8823. * The position the shdow will be casted from.
  8824. */
  8825. position: Vector3;
  8826. /**
  8827. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8828. */
  8829. direction: Vector3;
  8830. /**
  8831. * The transformed position. Position of the light in world space taking parenting in account.
  8832. */
  8833. transformedPosition: Vector3;
  8834. /**
  8835. * The transformed direction. Direction of the light in world space taking parenting in account.
  8836. */
  8837. transformedDirection: Vector3;
  8838. /**
  8839. * The friendly name of the light in the scene.
  8840. */
  8841. name: string;
  8842. /**
  8843. * Defines the shadow projection clipping minimum z value.
  8844. */
  8845. shadowMinZ: number;
  8846. /**
  8847. * Defines the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8852. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8853. */
  8854. computeTransformedInformation(): boolean;
  8855. /**
  8856. * Gets the scene the light belongs to.
  8857. * @returns The scene
  8858. */
  8859. getScene(): Scene;
  8860. /**
  8861. * Callback defining a custom Projection Matrix Builder.
  8862. * This can be used to override the default projection matrix computation.
  8863. */
  8864. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8865. /**
  8866. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8867. * @param matrix The materix to updated with the projection information
  8868. * @param viewMatrix The transform matrix of the light
  8869. * @param renderList The list of mesh to render in the map
  8870. * @returns The current light
  8871. */
  8872. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8873. /**
  8874. * Gets the current depth scale used in ESM.
  8875. * @returns The scale
  8876. */
  8877. getDepthScale(): number;
  8878. /**
  8879. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8880. * @returns true if a cube texture needs to be use
  8881. */
  8882. needCube(): boolean;
  8883. /**
  8884. * Detects if the projection matrix requires to be recomputed this frame.
  8885. * @returns true if it requires to be recomputed otherwise, false.
  8886. */
  8887. needProjectionMatrixCompute(): boolean;
  8888. /**
  8889. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8890. */
  8891. forceProjectionMatrixCompute(): void;
  8892. /**
  8893. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8894. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8895. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8896. */
  8897. getShadowDirection(faceIndex?: number): Vector3;
  8898. /**
  8899. * Gets the minZ used for shadow according to both the scene and the light.
  8900. * @param activeCamera The camera we are returning the min for
  8901. * @returns the depth min z
  8902. */
  8903. getDepthMinZ(activeCamera: Camera): number;
  8904. /**
  8905. * Gets the maxZ used for shadow according to both the scene and the light.
  8906. * @param activeCamera The camera we are returning the max for
  8907. * @returns the depth max z
  8908. */
  8909. getDepthMaxZ(activeCamera: Camera): number;
  8910. }
  8911. /**
  8912. * Base implementation IShadowLight
  8913. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8914. */
  8915. export abstract class ShadowLight extends Light implements IShadowLight {
  8916. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8917. protected _position: Vector3;
  8918. protected _setPosition(value: Vector3): void;
  8919. /**
  8920. * Sets the position the shadow will be casted from. Also use as the light position for both
  8921. * point and spot lights.
  8922. */
  8923. get position(): Vector3;
  8924. /**
  8925. * Sets the position the shadow will be casted from. Also use as the light position for both
  8926. * point and spot lights.
  8927. */
  8928. set position(value: Vector3);
  8929. protected _direction: Vector3;
  8930. protected _setDirection(value: Vector3): void;
  8931. /**
  8932. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8933. * Also use as the light direction on spot and directional lights.
  8934. */
  8935. get direction(): Vector3;
  8936. /**
  8937. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8938. * Also use as the light direction on spot and directional lights.
  8939. */
  8940. set direction(value: Vector3);
  8941. protected _shadowMinZ: number;
  8942. /**
  8943. * Gets the shadow projection clipping minimum z value.
  8944. */
  8945. get shadowMinZ(): number;
  8946. /**
  8947. * Sets the shadow projection clipping minimum z value.
  8948. */
  8949. set shadowMinZ(value: number);
  8950. protected _shadowMaxZ: number;
  8951. /**
  8952. * Sets the shadow projection clipping maximum z value.
  8953. */
  8954. get shadowMaxZ(): number;
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. set shadowMaxZ(value: number);
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module BABYLON {
  9052. /**
  9053. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9054. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9055. */
  9056. export class EffectFallbacks implements IEffectFallbacks {
  9057. private _defines;
  9058. private _currentRank;
  9059. private _maxRank;
  9060. private _mesh;
  9061. /**
  9062. * Removes the fallback from the bound mesh.
  9063. */
  9064. unBindMesh(): void;
  9065. /**
  9066. * Adds a fallback on the specified property.
  9067. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9068. * @param define The name of the define in the shader
  9069. */
  9070. addFallback(rank: number, define: string): void;
  9071. /**
  9072. * Sets the mesh to use CPU skinning when needing to fallback.
  9073. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9074. * @param mesh The mesh to use the fallbacks.
  9075. */
  9076. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9077. /**
  9078. * Checks to see if more fallbacks are still availible.
  9079. */
  9080. get hasMoreFallbacks(): boolean;
  9081. /**
  9082. * Removes the defines that should be removed when falling back.
  9083. * @param currentDefines defines the current define statements for the shader.
  9084. * @param effect defines the current effect we try to compile
  9085. * @returns The resulting defines with defines of the current rank removed.
  9086. */
  9087. reduce(currentDefines: string, effect: Effect): string;
  9088. }
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * "Static Class" containing the most commonly used helper while dealing with material for
  9093. * rendering purpose.
  9094. *
  9095. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9096. *
  9097. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9098. */
  9099. export class MaterialHelper {
  9100. /**
  9101. * Bind the current view position to an effect.
  9102. * @param effect The effect to be bound
  9103. * @param scene The scene the eyes position is used from
  9104. */
  9105. static BindEyePosition(effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Helps preparing the defines values about the UVs in used in the effect.
  9108. * UVs are shared as much as we can accross channels in the shaders.
  9109. * @param texture The texture we are preparing the UVs for
  9110. * @param defines The defines to update
  9111. * @param key The channel key "diffuse", "specular"... used in the shader
  9112. */
  9113. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9114. /**
  9115. * Binds a texture matrix value to its corrsponding uniform
  9116. * @param texture The texture to bind the matrix for
  9117. * @param uniformBuffer The uniform buffer receivin the data
  9118. * @param key The channel key "diffuse", "specular"... used in the shader
  9119. */
  9120. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9121. /**
  9122. * Gets the current status of the fog (should it be enabled?)
  9123. * @param mesh defines the mesh to evaluate for fog support
  9124. * @param scene defines the hosting scene
  9125. * @returns true if fog must be enabled
  9126. */
  9127. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9128. /**
  9129. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9130. * @param mesh defines the current mesh
  9131. * @param scene defines the current scene
  9132. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9133. * @param pointsCloud defines if point cloud rendering has to be turned on
  9134. * @param fogEnabled defines if fog has to be turned on
  9135. * @param alphaTest defines if alpha testing has to be turned on
  9136. * @param defines defines the current list of defines
  9137. */
  9138. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9139. /**
  9140. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9141. * @param scene defines the current scene
  9142. * @param engine defines the current engine
  9143. * @param defines specifies the list of active defines
  9144. * @param useInstances defines if instances have to be turned on
  9145. * @param useClipPlane defines if clip plane have to be turned on
  9146. */
  9147. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9148. /**
  9149. * Prepares the defines for bones
  9150. * @param mesh The mesh containing the geometry data we will draw
  9151. * @param defines The defines to update
  9152. */
  9153. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9154. /**
  9155. * Prepares the defines for morph targets
  9156. * @param mesh The mesh containing the geometry data we will draw
  9157. * @param defines The defines to update
  9158. */
  9159. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9160. /**
  9161. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9162. * @param mesh The mesh containing the geometry data we will draw
  9163. * @param defines The defines to update
  9164. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9165. * @param useBones Precise whether bones should be used or not (override mesh info)
  9166. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9167. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9168. * @returns false if defines are considered not dirty and have not been checked
  9169. */
  9170. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9171. /**
  9172. * Prepares the defines related to multiview
  9173. * @param scene The scene we are intending to draw
  9174. * @param defines The defines to update
  9175. */
  9176. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9177. /**
  9178. * Prepares the defines related to the light information passed in parameter
  9179. * @param scene The scene we are intending to draw
  9180. * @param mesh The mesh the effect is compiling for
  9181. * @param light The light the effect is compiling for
  9182. * @param lightIndex The index of the light
  9183. * @param defines The defines to update
  9184. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9185. * @param state Defines the current state regarding what is needed (normals, etc...)
  9186. */
  9187. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9188. needNormals: boolean;
  9189. needRebuild: boolean;
  9190. shadowEnabled: boolean;
  9191. specularEnabled: boolean;
  9192. lightmapMode: boolean;
  9193. }): void;
  9194. /**
  9195. * Prepares the defines related to the light information passed in parameter
  9196. * @param scene The scene we are intending to draw
  9197. * @param mesh The mesh the effect is compiling for
  9198. * @param defines The defines to update
  9199. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9200. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9201. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9202. * @returns true if normals will be required for the rest of the effect
  9203. */
  9204. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9205. /**
  9206. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9207. * @param lightIndex defines the light index
  9208. * @param uniformsList The uniform list
  9209. * @param samplersList The sampler list
  9210. * @param projectedLightTexture defines if projected texture must be used
  9211. * @param uniformBuffersList defines an optional list of uniform buffers
  9212. */
  9213. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9214. /**
  9215. * Prepares the uniforms and samplers list to be used in the effect
  9216. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9217. * @param samplersList The sampler list
  9218. * @param defines The defines helping in the list generation
  9219. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9220. */
  9221. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9222. /**
  9223. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9224. * @param defines The defines to update while falling back
  9225. * @param fallbacks The authorized effect fallbacks
  9226. * @param maxSimultaneousLights The maximum number of lights allowed
  9227. * @param rank the current rank of the Effect
  9228. * @returns The newly affected rank
  9229. */
  9230. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9231. private static _TmpMorphInfluencers;
  9232. /**
  9233. * Prepares the list of attributes required for morph targets according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param mesh The mesh to prepare the morph targets attributes for
  9236. * @param influencers The number of influencers
  9237. */
  9238. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9239. /**
  9240. * Prepares the list of attributes required for morph targets according to the effect defines.
  9241. * @param attribs The current list of supported attribs
  9242. * @param mesh The mesh to prepare the morph targets attributes for
  9243. * @param defines The current Defines of the effect
  9244. */
  9245. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9246. /**
  9247. * Prepares the list of attributes required for bones according to the effect defines.
  9248. * @param attribs The current list of supported attribs
  9249. * @param mesh The mesh to prepare the bones attributes for
  9250. * @param defines The current Defines of the effect
  9251. * @param fallbacks The current efffect fallback strategy
  9252. */
  9253. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9254. /**
  9255. * Check and prepare the list of attributes required for instances according to the effect defines.
  9256. * @param attribs The current list of supported attribs
  9257. * @param defines The current MaterialDefines of the effect
  9258. */
  9259. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9260. /**
  9261. * Add the list of attributes required for instances to the attribs array.
  9262. * @param attribs The current list of supported attribs
  9263. */
  9264. static PushAttributesForInstances(attribs: string[]): void;
  9265. /**
  9266. * Binds the light information to the effect.
  9267. * @param light The light containing the generator
  9268. * @param effect The effect we are binding the data to
  9269. * @param lightIndex The light index in the effect used to render
  9270. */
  9271. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9272. /**
  9273. * Binds the lights information from the scene to the effect for the given mesh.
  9274. * @param light Light to bind
  9275. * @param lightIndex Light index
  9276. * @param scene The scene where the light belongs to
  9277. * @param effect The effect we are binding the data to
  9278. * @param useSpecular Defines if specular is supported
  9279. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9280. */
  9281. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9282. /**
  9283. * Binds the lights information from the scene to the effect for the given mesh.
  9284. * @param scene The scene the lights belongs to
  9285. * @param mesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. * @param defines The generated defines for the effect
  9288. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9290. */
  9291. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9292. private static _tempFogColor;
  9293. /**
  9294. * Binds the fog information from the scene to the effect for the given mesh.
  9295. * @param scene The scene the lights belongs to
  9296. * @param mesh The mesh we are binding the information to render
  9297. * @param effect The effect we are binding the data to
  9298. * @param linearSpace Defines if the fog effect is applied in linear space
  9299. */
  9300. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9301. /**
  9302. * Binds the bones information from the mesh to the effect.
  9303. * @param mesh The mesh we are binding the information to render
  9304. * @param effect The effect we are binding the data to
  9305. */
  9306. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9307. /**
  9308. * Binds the morph targets information from the mesh to the effect.
  9309. * @param abstractMesh The mesh we are binding the information to render
  9310. * @param effect The effect we are binding the data to
  9311. */
  9312. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9313. /**
  9314. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9315. * @param defines The generated defines used in the effect
  9316. * @param effect The effect we are binding the data to
  9317. * @param scene The scene we are willing to render with logarithmic scale for
  9318. */
  9319. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9320. /**
  9321. * Binds the clip plane information from the scene to the effect.
  9322. * @param scene The scene the clip plane information are extracted from
  9323. * @param effect The effect we are binding the data to
  9324. */
  9325. static BindClipPlane(effect: Effect, scene: Scene): void;
  9326. }
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var packingFunctions: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var clipPlaneFragmentDeclaration: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /** @hidden */
  9344. export var clipPlaneFragment: {
  9345. name: string;
  9346. shader: string;
  9347. };
  9348. }
  9349. declare module BABYLON {
  9350. /** @hidden */
  9351. export var shadowMapPixelShader: {
  9352. name: string;
  9353. shader: string;
  9354. };
  9355. }
  9356. declare module BABYLON {
  9357. /** @hidden */
  9358. export var bonesDeclaration: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module BABYLON {
  9364. /** @hidden */
  9365. export var morphTargetsVertexGlobalDeclaration: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module BABYLON {
  9371. /** @hidden */
  9372. export var morphTargetsVertexDeclaration: {
  9373. name: string;
  9374. shader: string;
  9375. };
  9376. }
  9377. declare module BABYLON {
  9378. /** @hidden */
  9379. export var instancesDeclaration: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module BABYLON {
  9385. /** @hidden */
  9386. export var helperFunctions: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module BABYLON {
  9392. /** @hidden */
  9393. export var clipPlaneVertexDeclaration: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module BABYLON {
  9399. /** @hidden */
  9400. export var morphTargetsVertex: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module BABYLON {
  9406. /** @hidden */
  9407. export var instancesVertex: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module BABYLON {
  9413. /** @hidden */
  9414. export var bonesVertex: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module BABYLON {
  9420. /** @hidden */
  9421. export var clipPlaneVertex: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module BABYLON {
  9427. /** @hidden */
  9428. export var shadowMapVertexShader: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module BABYLON {
  9434. /** @hidden */
  9435. export var depthBoxBlurPixelShader: {
  9436. name: string;
  9437. shader: string;
  9438. };
  9439. }
  9440. declare module BABYLON {
  9441. /**
  9442. * Class representing a ray with position and direction
  9443. */
  9444. export class Ray {
  9445. /** origin point */
  9446. origin: Vector3;
  9447. /** direction */
  9448. direction: Vector3;
  9449. /** length of the ray */
  9450. length: number;
  9451. private static readonly TmpVector3;
  9452. private _tmpRay;
  9453. /**
  9454. * Creates a new ray
  9455. * @param origin origin point
  9456. * @param direction direction
  9457. * @param length length of the ray
  9458. */
  9459. constructor(
  9460. /** origin point */
  9461. origin: Vector3,
  9462. /** direction */
  9463. direction: Vector3,
  9464. /** length of the ray */
  9465. length?: number);
  9466. /**
  9467. * Checks if the ray intersects a box
  9468. * @param minimum bound of the box
  9469. * @param maximum bound of the box
  9470. * @param intersectionTreshold extra extend to be added to the box in all direction
  9471. * @returns if the box was hit
  9472. */
  9473. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9474. /**
  9475. * Checks if the ray intersects a box
  9476. * @param box the bounding box to check
  9477. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9478. * @returns if the box was hit
  9479. */
  9480. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9481. /**
  9482. * If the ray hits a sphere
  9483. * @param sphere the bounding sphere to check
  9484. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9485. * @returns true if it hits the sphere
  9486. */
  9487. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9488. /**
  9489. * If the ray hits a triange
  9490. * @param vertex0 triangle vertex
  9491. * @param vertex1 triangle vertex
  9492. * @param vertex2 triangle vertex
  9493. * @returns intersection information if hit
  9494. */
  9495. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9496. /**
  9497. * Checks if ray intersects a plane
  9498. * @param plane the plane to check
  9499. * @returns the distance away it was hit
  9500. */
  9501. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9502. /**
  9503. * Calculate the intercept of a ray on a given axis
  9504. * @param axis to check 'x' | 'y' | 'z'
  9505. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9506. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9507. */
  9508. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9509. /**
  9510. * Checks if ray intersects a mesh
  9511. * @param mesh the mesh to check
  9512. * @param fastCheck if only the bounding box should checked
  9513. * @returns picking info of the intersecton
  9514. */
  9515. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9516. /**
  9517. * Checks if ray intersects a mesh
  9518. * @param meshes the meshes to check
  9519. * @param fastCheck if only the bounding box should checked
  9520. * @param results array to store result in
  9521. * @returns Array of picking infos
  9522. */
  9523. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9524. private _comparePickingInfo;
  9525. private static smallnum;
  9526. private static rayl;
  9527. /**
  9528. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9529. * @param sega the first point of the segment to test the intersection against
  9530. * @param segb the second point of the segment to test the intersection against
  9531. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9532. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9533. */
  9534. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9535. /**
  9536. * Update the ray from viewport position
  9537. * @param x position
  9538. * @param y y position
  9539. * @param viewportWidth viewport width
  9540. * @param viewportHeight viewport height
  9541. * @param world world matrix
  9542. * @param view view matrix
  9543. * @param projection projection matrix
  9544. * @returns this ray updated
  9545. */
  9546. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9547. /**
  9548. * Creates a ray with origin and direction of 0,0,0
  9549. * @returns the new ray
  9550. */
  9551. static Zero(): Ray;
  9552. /**
  9553. * Creates a new ray from screen space and viewport
  9554. * @param x position
  9555. * @param y y position
  9556. * @param viewportWidth viewport width
  9557. * @param viewportHeight viewport height
  9558. * @param world world matrix
  9559. * @param view view matrix
  9560. * @param projection projection matrix
  9561. * @returns new ray
  9562. */
  9563. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9564. /**
  9565. * 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
  9566. * transformed to the given world matrix.
  9567. * @param origin The origin point
  9568. * @param end The end point
  9569. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9570. * @returns the new ray
  9571. */
  9572. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9573. /**
  9574. * Transforms a ray by a matrix
  9575. * @param ray ray to transform
  9576. * @param matrix matrix to apply
  9577. * @returns the resulting new ray
  9578. */
  9579. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9580. /**
  9581. * Transforms a ray by a matrix
  9582. * @param ray ray to transform
  9583. * @param matrix matrix to apply
  9584. * @param result ray to store result in
  9585. */
  9586. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9587. /**
  9588. * Unproject a ray from screen space to object space
  9589. * @param sourceX defines the screen space x coordinate to use
  9590. * @param sourceY defines the screen space y coordinate to use
  9591. * @param viewportWidth defines the current width of the viewport
  9592. * @param viewportHeight defines the current height of the viewport
  9593. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9594. * @param view defines the view matrix to use
  9595. * @param projection defines the projection matrix to use
  9596. */
  9597. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9598. }
  9599. /**
  9600. * Type used to define predicate used to select faces when a mesh intersection is detected
  9601. */
  9602. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9603. interface Scene {
  9604. /** @hidden */
  9605. _tempPickingRay: Nullable<Ray>;
  9606. /** @hidden */
  9607. _cachedRayForTransform: Ray;
  9608. /** @hidden */
  9609. _pickWithRayInverseMatrix: Matrix;
  9610. /** @hidden */
  9611. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9612. /** @hidden */
  9613. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9614. }
  9615. }
  9616. declare module BABYLON {
  9617. /**
  9618. * Groups all the scene component constants in one place to ease maintenance.
  9619. * @hidden
  9620. */
  9621. export class SceneComponentConstants {
  9622. static readonly NAME_EFFECTLAYER: string;
  9623. static readonly NAME_LAYER: string;
  9624. static readonly NAME_LENSFLARESYSTEM: string;
  9625. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9626. static readonly NAME_PARTICLESYSTEM: string;
  9627. static readonly NAME_GAMEPAD: string;
  9628. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9629. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9630. static readonly NAME_DEPTHRENDERER: string;
  9631. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9632. static readonly NAME_SPRITE: string;
  9633. static readonly NAME_OUTLINERENDERER: string;
  9634. static readonly NAME_PROCEDURALTEXTURE: string;
  9635. static readonly NAME_SHADOWGENERATOR: string;
  9636. static readonly NAME_OCTREE: string;
  9637. static readonly NAME_PHYSICSENGINE: string;
  9638. static readonly NAME_AUDIO: string;
  9639. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9640. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9641. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9642. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9643. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9644. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9645. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9646. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9647. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9648. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9649. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9650. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9651. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9652. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9653. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9654. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9655. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9656. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9657. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9658. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9659. static readonly STEP_AFTERRENDER_AUDIO: number;
  9660. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9661. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9662. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9663. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9664. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9665. static readonly STEP_POINTERMOVE_SPRITE: number;
  9666. static readonly STEP_POINTERDOWN_SPRITE: number;
  9667. static readonly STEP_POINTERUP_SPRITE: number;
  9668. }
  9669. /**
  9670. * This represents a scene component.
  9671. *
  9672. * This is used to decouple the dependency the scene is having on the different workloads like
  9673. * layers, post processes...
  9674. */
  9675. export interface ISceneComponent {
  9676. /**
  9677. * The name of the component. Each component must have a unique name.
  9678. */
  9679. name: string;
  9680. /**
  9681. * The scene the component belongs to.
  9682. */
  9683. scene: Scene;
  9684. /**
  9685. * Register the component to one instance of a scene.
  9686. */
  9687. register(): void;
  9688. /**
  9689. * Rebuilds the elements related to this component in case of
  9690. * context lost for instance.
  9691. */
  9692. rebuild(): void;
  9693. /**
  9694. * Disposes the component and the associated ressources.
  9695. */
  9696. dispose(): void;
  9697. }
  9698. /**
  9699. * This represents a SERIALIZABLE scene component.
  9700. *
  9701. * This extends Scene Component to add Serialization methods on top.
  9702. */
  9703. export interface ISceneSerializableComponent extends ISceneComponent {
  9704. /**
  9705. * Adds all the elements from the container to the scene
  9706. * @param container the container holding the elements
  9707. */
  9708. addFromContainer(container: AbstractScene): void;
  9709. /**
  9710. * Removes all the elements in the container from the scene
  9711. * @param container contains the elements to remove
  9712. * @param dispose if the removed element should be disposed (default: false)
  9713. */
  9714. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9715. /**
  9716. * Serializes the component data to the specified json object
  9717. * @param serializationObject The object to serialize to
  9718. */
  9719. serialize(serializationObject: any): void;
  9720. }
  9721. /**
  9722. * Strong typing of a Mesh related stage step action
  9723. */
  9724. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9725. /**
  9726. * Strong typing of a Evaluate Sub Mesh related stage step action
  9727. */
  9728. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9729. /**
  9730. * Strong typing of a Active Mesh related stage step action
  9731. */
  9732. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9733. /**
  9734. * Strong typing of a Camera related stage step action
  9735. */
  9736. export type CameraStageAction = (camera: Camera) => void;
  9737. /**
  9738. * Strong typing of a Camera Frame buffer related stage step action
  9739. */
  9740. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9741. /**
  9742. * Strong typing of a Render Target related stage step action
  9743. */
  9744. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9745. /**
  9746. * Strong typing of a RenderingGroup related stage step action
  9747. */
  9748. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9749. /**
  9750. * Strong typing of a Mesh Render related stage step action
  9751. */
  9752. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9753. /**
  9754. * Strong typing of a simple stage step action
  9755. */
  9756. export type SimpleStageAction = () => void;
  9757. /**
  9758. * Strong typing of a render target action.
  9759. */
  9760. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9761. /**
  9762. * Strong typing of a pointer move action.
  9763. */
  9764. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9765. /**
  9766. * Strong typing of a pointer up/down action.
  9767. */
  9768. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9769. /**
  9770. * Representation of a stage in the scene (Basically a list of ordered steps)
  9771. * @hidden
  9772. */
  9773. export class Stage<T extends Function> extends Array<{
  9774. index: number;
  9775. component: ISceneComponent;
  9776. action: T;
  9777. }> {
  9778. /**
  9779. * Hide ctor from the rest of the world.
  9780. * @param items The items to add.
  9781. */
  9782. private constructor();
  9783. /**
  9784. * Creates a new Stage.
  9785. * @returns A new instance of a Stage
  9786. */
  9787. static Create<T extends Function>(): Stage<T>;
  9788. /**
  9789. * Registers a step in an ordered way in the targeted stage.
  9790. * @param index Defines the position to register the step in
  9791. * @param component Defines the component attached to the step
  9792. * @param action Defines the action to launch during the step
  9793. */
  9794. registerStep(index: number, component: ISceneComponent, action: T): void;
  9795. /**
  9796. * Clears all the steps from the stage.
  9797. */
  9798. clear(): void;
  9799. }
  9800. }
  9801. declare module BABYLON {
  9802. interface Scene {
  9803. /** @hidden */
  9804. _pointerOverSprite: Nullable<Sprite>;
  9805. /** @hidden */
  9806. _pickedDownSprite: Nullable<Sprite>;
  9807. /** @hidden */
  9808. _tempSpritePickingRay: Nullable<Ray>;
  9809. /**
  9810. * All of the sprite managers added to this scene
  9811. * @see http://doc.babylonjs.com/babylon101/sprites
  9812. */
  9813. spriteManagers: Array<ISpriteManager>;
  9814. /**
  9815. * An event triggered when sprites rendering is about to start
  9816. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9817. */
  9818. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9819. /**
  9820. * An event triggered when sprites rendering is done
  9821. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9822. */
  9823. onAfterSpritesRenderingObservable: Observable<Scene>;
  9824. /** @hidden */
  9825. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9826. /** Launch a ray to try to pick a sprite in the scene
  9827. * @param x position on screen
  9828. * @param y position on screen
  9829. * @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
  9830. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9831. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9832. * @returns a PickingInfo
  9833. */
  9834. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9835. /** Use the given ray to pick a sprite in the scene
  9836. * @param ray The ray (in world space) to use to pick meshes
  9837. * @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
  9838. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9839. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9840. * @returns a PickingInfo
  9841. */
  9842. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9843. /** @hidden */
  9844. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9845. /** Launch a ray to try to pick sprites in the scene
  9846. * @param x position on screen
  9847. * @param y position on screen
  9848. * @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
  9849. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9850. * @returns a PickingInfo array
  9851. */
  9852. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9853. /** Use the given ray to pick sprites in the scene
  9854. * @param ray The ray (in world space) to use to pick meshes
  9855. * @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
  9856. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9857. * @returns a PickingInfo array
  9858. */
  9859. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9860. /**
  9861. * Force the sprite under the pointer
  9862. * @param sprite defines the sprite to use
  9863. */
  9864. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9865. /**
  9866. * Gets the sprite under the pointer
  9867. * @returns a Sprite or null if no sprite is under the pointer
  9868. */
  9869. getPointerOverSprite(): Nullable<Sprite>;
  9870. }
  9871. /**
  9872. * Defines the sprite scene component responsible to manage sprites
  9873. * in a given scene.
  9874. */
  9875. export class SpriteSceneComponent implements ISceneComponent {
  9876. /**
  9877. * The component name helpfull to identify the component in the list of scene components.
  9878. */
  9879. readonly name: string;
  9880. /**
  9881. * The scene the component belongs to.
  9882. */
  9883. scene: Scene;
  9884. /** @hidden */
  9885. private _spritePredicate;
  9886. /**
  9887. * Creates a new instance of the component for the given scene
  9888. * @param scene Defines the scene to register the component in
  9889. */
  9890. constructor(scene: Scene);
  9891. /**
  9892. * Registers the component in a given scene
  9893. */
  9894. register(): void;
  9895. /**
  9896. * Rebuilds the elements related to this component in case of
  9897. * context lost for instance.
  9898. */
  9899. rebuild(): void;
  9900. /**
  9901. * Disposes the component and the associated ressources.
  9902. */
  9903. dispose(): void;
  9904. private _pickSpriteButKeepRay;
  9905. private _pointerMove;
  9906. private _pointerDown;
  9907. private _pointerUp;
  9908. }
  9909. }
  9910. declare module BABYLON {
  9911. /** @hidden */
  9912. export var fogFragmentDeclaration: {
  9913. name: string;
  9914. shader: string;
  9915. };
  9916. }
  9917. declare module BABYLON {
  9918. /** @hidden */
  9919. export var fogFragment: {
  9920. name: string;
  9921. shader: string;
  9922. };
  9923. }
  9924. declare module BABYLON {
  9925. /** @hidden */
  9926. export var spritesPixelShader: {
  9927. name: string;
  9928. shader: string;
  9929. };
  9930. }
  9931. declare module BABYLON {
  9932. /** @hidden */
  9933. export var fogVertexDeclaration: {
  9934. name: string;
  9935. shader: string;
  9936. };
  9937. }
  9938. declare module BABYLON {
  9939. /** @hidden */
  9940. export var spritesVertexShader: {
  9941. name: string;
  9942. shader: string;
  9943. };
  9944. }
  9945. declare module BABYLON {
  9946. /**
  9947. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9948. */
  9949. export interface ISpriteManager extends IDisposable {
  9950. /**
  9951. * Restricts the camera to viewing objects with the same layerMask.
  9952. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9953. */
  9954. layerMask: number;
  9955. /**
  9956. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9957. */
  9958. isPickable: boolean;
  9959. /**
  9960. * Specifies the rendering group id for this mesh (0 by default)
  9961. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9962. */
  9963. renderingGroupId: number;
  9964. /**
  9965. * Defines the list of sprites managed by the manager.
  9966. */
  9967. sprites: Array<Sprite>;
  9968. /**
  9969. * Tests the intersection of a sprite with a specific ray.
  9970. * @param ray The ray we are sending to test the collision
  9971. * @param camera The camera space we are sending rays in
  9972. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9973. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9974. * @returns picking info or null.
  9975. */
  9976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9977. /**
  9978. * Intersects the sprites with a ray
  9979. * @param ray defines the ray to intersect with
  9980. * @param camera defines the current active camera
  9981. * @param predicate defines a predicate used to select candidate sprites
  9982. * @returns null if no hit or a PickingInfo array
  9983. */
  9984. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9985. /**
  9986. * Renders the list of sprites on screen.
  9987. */
  9988. render(): void;
  9989. }
  9990. /**
  9991. * Class used to manage multiple sprites on the same spritesheet
  9992. * @see http://doc.babylonjs.com/babylon101/sprites
  9993. */
  9994. export class SpriteManager implements ISpriteManager {
  9995. /** defines the manager's name */
  9996. name: string;
  9997. /** Gets the list of sprites */
  9998. sprites: Sprite[];
  9999. /** Gets or sets the rendering group id (0 by default) */
  10000. renderingGroupId: number;
  10001. /** Gets or sets camera layer mask */
  10002. layerMask: number;
  10003. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10004. fogEnabled: boolean;
  10005. /** Gets or sets a boolean indicating if the sprites are pickable */
  10006. isPickable: boolean;
  10007. /** Defines the default width of a cell in the spritesheet */
  10008. cellWidth: number;
  10009. /** Defines the default height of a cell in the spritesheet */
  10010. cellHeight: number;
  10011. /** Associative array from JSON sprite data file */
  10012. private _cellData;
  10013. /** Array of sprite names from JSON sprite data file */
  10014. private _spriteMap;
  10015. /** True when packed cell data from JSON file is ready*/
  10016. private _packedAndReady;
  10017. /**
  10018. * An event triggered when the manager is disposed.
  10019. */
  10020. onDisposeObservable: Observable<SpriteManager>;
  10021. private _onDisposeObserver;
  10022. /**
  10023. * Callback called when the manager is disposed
  10024. */
  10025. set onDispose(callback: () => void);
  10026. private _capacity;
  10027. private _fromPacked;
  10028. private _spriteTexture;
  10029. private _epsilon;
  10030. private _scene;
  10031. private _vertexData;
  10032. private _buffer;
  10033. private _vertexBuffers;
  10034. private _indexBuffer;
  10035. private _effectBase;
  10036. private _effectFog;
  10037. /**
  10038. * Gets or sets the spritesheet texture
  10039. */
  10040. get texture(): Texture;
  10041. set texture(value: Texture);
  10042. private _blendMode;
  10043. /**
  10044. * Blend mode use to render the particle, it can be any of
  10045. * the static Constants.ALPHA_x properties provided in this class.
  10046. * Default value is Constants.ALPHA_COMBINE
  10047. */
  10048. get blendMode(): number;
  10049. set blendMode(blendMode: number);
  10050. /** Disables writing to the depth buffer when rendering the sprites.
  10051. * It can be handy to disable depth writing when using textures without alpha channel
  10052. * and setting some specific blend modes.
  10053. */
  10054. disableDepthWrite: boolean;
  10055. /**
  10056. * Creates a new sprite manager
  10057. * @param name defines the manager's name
  10058. * @param imgUrl defines the sprite sheet url
  10059. * @param capacity defines the maximum allowed number of sprites
  10060. * @param cellSize defines the size of a sprite cell
  10061. * @param scene defines the hosting scene
  10062. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10063. * @param samplingMode defines the smapling mode to use with spritesheet
  10064. * @param fromPacked set to false; do not alter
  10065. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10066. */
  10067. constructor(
  10068. /** defines the manager's name */
  10069. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10070. private _makePacked;
  10071. private _appendSpriteVertex;
  10072. /**
  10073. * Intersects the sprites with a ray
  10074. * @param ray defines the ray to intersect with
  10075. * @param camera defines the current active camera
  10076. * @param predicate defines a predicate used to select candidate sprites
  10077. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10078. * @returns null if no hit or a PickingInfo
  10079. */
  10080. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10081. /**
  10082. * Intersects the sprites with a ray
  10083. * @param ray defines the ray to intersect with
  10084. * @param camera defines the current active camera
  10085. * @param predicate defines a predicate used to select candidate sprites
  10086. * @returns null if no hit or a PickingInfo array
  10087. */
  10088. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10089. /**
  10090. * Render all child sprites
  10091. */
  10092. render(): void;
  10093. /**
  10094. * Release associated resources
  10095. */
  10096. dispose(): void;
  10097. }
  10098. }
  10099. declare module BABYLON {
  10100. /** Interface used by value gradients (color, factor, ...) */
  10101. export interface IValueGradient {
  10102. /**
  10103. * Gets or sets the gradient value (between 0 and 1)
  10104. */
  10105. gradient: number;
  10106. }
  10107. /** Class used to store color4 gradient */
  10108. export class ColorGradient implements IValueGradient {
  10109. /**
  10110. * Gets or sets the gradient value (between 0 and 1)
  10111. */
  10112. gradient: number;
  10113. /**
  10114. * Gets or sets first associated color
  10115. */
  10116. color1: Color4;
  10117. /**
  10118. * Gets or sets second associated color
  10119. */
  10120. color2?: Color4;
  10121. /**
  10122. * Will get a color picked randomly between color1 and color2.
  10123. * If color2 is undefined then color1 will be used
  10124. * @param result defines the target Color4 to store the result in
  10125. */
  10126. getColorToRef(result: Color4): void;
  10127. }
  10128. /** Class used to store color 3 gradient */
  10129. export class Color3Gradient implements IValueGradient {
  10130. /**
  10131. * Gets or sets the gradient value (between 0 and 1)
  10132. */
  10133. gradient: number;
  10134. /**
  10135. * Gets or sets the associated color
  10136. */
  10137. color: Color3;
  10138. }
  10139. /** Class used to store factor gradient */
  10140. export class FactorGradient implements IValueGradient {
  10141. /**
  10142. * Gets or sets the gradient value (between 0 and 1)
  10143. */
  10144. gradient: number;
  10145. /**
  10146. * Gets or sets first associated factor
  10147. */
  10148. factor1: number;
  10149. /**
  10150. * Gets or sets second associated factor
  10151. */
  10152. factor2?: number;
  10153. /**
  10154. * Will get a number picked randomly between factor1 and factor2.
  10155. * If factor2 is undefined then factor1 will be used
  10156. * @returns the picked number
  10157. */
  10158. getFactor(): number;
  10159. }
  10160. /**
  10161. * Helper used to simplify some generic gradient tasks
  10162. */
  10163. export class GradientHelper {
  10164. /**
  10165. * Gets the current gradient from an array of IValueGradient
  10166. * @param ratio defines the current ratio to get
  10167. * @param gradients defines the array of IValueGradient
  10168. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10169. */
  10170. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10171. }
  10172. }
  10173. declare module BABYLON {
  10174. /**
  10175. * Interface for the size containing width and height
  10176. */
  10177. export interface ISize {
  10178. /**
  10179. * Width
  10180. */
  10181. width: number;
  10182. /**
  10183. * Heighht
  10184. */
  10185. height: number;
  10186. }
  10187. /**
  10188. * Size containing widht and height
  10189. */
  10190. export class Size implements ISize {
  10191. /**
  10192. * Width
  10193. */
  10194. width: number;
  10195. /**
  10196. * Height
  10197. */
  10198. height: number;
  10199. /**
  10200. * Creates a Size object from the given width and height (floats).
  10201. * @param width width of the new size
  10202. * @param height height of the new size
  10203. */
  10204. constructor(width: number, height: number);
  10205. /**
  10206. * Returns a string with the Size width and height
  10207. * @returns a string with the Size width and height
  10208. */
  10209. toString(): string;
  10210. /**
  10211. * "Size"
  10212. * @returns the string "Size"
  10213. */
  10214. getClassName(): string;
  10215. /**
  10216. * Returns the Size hash code.
  10217. * @returns a hash code for a unique width and height
  10218. */
  10219. getHashCode(): number;
  10220. /**
  10221. * Updates the current size from the given one.
  10222. * @param src the given size
  10223. */
  10224. copyFrom(src: Size): void;
  10225. /**
  10226. * Updates in place the current Size from the given floats.
  10227. * @param width width of the new size
  10228. * @param height height of the new size
  10229. * @returns the updated Size.
  10230. */
  10231. copyFromFloats(width: number, height: number): Size;
  10232. /**
  10233. * Updates in place the current Size from the given floats.
  10234. * @param width width to set
  10235. * @param height height to set
  10236. * @returns the updated Size.
  10237. */
  10238. set(width: number, height: number): Size;
  10239. /**
  10240. * Multiplies the width and height by numbers
  10241. * @param w factor to multiple the width by
  10242. * @param h factor to multiple the height by
  10243. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10244. */
  10245. multiplyByFloats(w: number, h: number): Size;
  10246. /**
  10247. * Clones the size
  10248. * @returns a new Size copied from the given one.
  10249. */
  10250. clone(): Size;
  10251. /**
  10252. * True if the current Size and the given one width and height are strictly equal.
  10253. * @param other the other size to compare against
  10254. * @returns True if the current Size and the given one width and height are strictly equal.
  10255. */
  10256. equals(other: Size): boolean;
  10257. /**
  10258. * The surface of the Size : width * height (float).
  10259. */
  10260. get surface(): number;
  10261. /**
  10262. * Create a new size of zero
  10263. * @returns a new Size set to (0.0, 0.0)
  10264. */
  10265. static Zero(): Size;
  10266. /**
  10267. * Sums the width and height of two sizes
  10268. * @param otherSize size to add to this size
  10269. * @returns a new Size set as the addition result of the current Size and the given one.
  10270. */
  10271. add(otherSize: Size): Size;
  10272. /**
  10273. * Subtracts the width and height of two
  10274. * @param otherSize size to subtract to this size
  10275. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10276. */
  10277. subtract(otherSize: Size): Size;
  10278. /**
  10279. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10280. * @param start starting size to lerp between
  10281. * @param end end size to lerp between
  10282. * @param amount amount to lerp between the start and end values
  10283. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10284. */
  10285. static Lerp(start: Size, end: Size, amount: number): Size;
  10286. }
  10287. }
  10288. declare module BABYLON {
  10289. interface ThinEngine {
  10290. /**
  10291. * Creates a dynamic texture
  10292. * @param width defines the width of the texture
  10293. * @param height defines the height of the texture
  10294. * @param generateMipMaps defines if the engine should generate the mip levels
  10295. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10296. * @returns the dynamic texture inside an InternalTexture
  10297. */
  10298. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10299. /**
  10300. * Update the content of a dynamic texture
  10301. * @param texture defines the texture to update
  10302. * @param canvas defines the canvas containing the source
  10303. * @param invertY defines if data must be stored with Y axis inverted
  10304. * @param premulAlpha defines if alpha is stored as premultiplied
  10305. * @param format defines the format of the data
  10306. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10307. */
  10308. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10309. }
  10310. }
  10311. declare module BABYLON {
  10312. /**
  10313. * Helper class used to generate a canvas to manipulate images
  10314. */
  10315. export class CanvasGenerator {
  10316. /**
  10317. * Create a new canvas (or offscreen canvas depending on the context)
  10318. * @param width defines the expected width
  10319. * @param height defines the expected height
  10320. * @return a new canvas or offscreen canvas
  10321. */
  10322. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10323. }
  10324. }
  10325. declare module BABYLON {
  10326. /**
  10327. * A class extending Texture allowing drawing on a texture
  10328. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10329. */
  10330. export class DynamicTexture extends Texture {
  10331. private _generateMipMaps;
  10332. private _canvas;
  10333. private _context;
  10334. private _engine;
  10335. /**
  10336. * Creates a DynamicTexture
  10337. * @param name defines the name of the texture
  10338. * @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
  10339. * @param scene defines the scene where you want the texture
  10340. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10341. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10342. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10343. */
  10344. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10345. /**
  10346. * Get the current class name of the texture useful for serialization or dynamic coding.
  10347. * @returns "DynamicTexture"
  10348. */
  10349. getClassName(): string;
  10350. /**
  10351. * Gets the current state of canRescale
  10352. */
  10353. get canRescale(): boolean;
  10354. private _recreate;
  10355. /**
  10356. * Scales the texture
  10357. * @param ratio the scale factor to apply to both width and height
  10358. */
  10359. scale(ratio: number): void;
  10360. /**
  10361. * Resizes the texture
  10362. * @param width the new width
  10363. * @param height the new height
  10364. */
  10365. scaleTo(width: number, height: number): void;
  10366. /**
  10367. * Gets the context of the canvas used by the texture
  10368. * @returns the canvas context of the dynamic texture
  10369. */
  10370. getContext(): CanvasRenderingContext2D;
  10371. /**
  10372. * Clears the texture
  10373. */
  10374. clear(): void;
  10375. /**
  10376. * Updates the texture
  10377. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10378. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10379. */
  10380. update(invertY?: boolean, premulAlpha?: boolean): void;
  10381. /**
  10382. * Draws text onto the texture
  10383. * @param text defines the text to be drawn
  10384. * @param x defines the placement of the text from the left
  10385. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10386. * @param font defines the font to be used with font-style, font-size, font-name
  10387. * @param color defines the color used for the text
  10388. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10389. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10390. * @param update defines whether texture is immediately update (default is true)
  10391. */
  10392. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10393. /**
  10394. * Clones the texture
  10395. * @returns the clone of the texture.
  10396. */
  10397. clone(): DynamicTexture;
  10398. /**
  10399. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10400. * @returns a serialized dynamic texture object
  10401. */
  10402. serialize(): any;
  10403. /** @hidden */
  10404. _rebuild(): void;
  10405. }
  10406. }
  10407. declare module BABYLON {
  10408. interface Engine {
  10409. /**
  10410. * Creates a raw texture
  10411. * @param data defines the data to store in the texture
  10412. * @param width defines the width of the texture
  10413. * @param height defines the height of the texture
  10414. * @param format defines the format of the data
  10415. * @param generateMipMaps defines if the engine should generate the mip levels
  10416. * @param invertY defines if data must be stored with Y axis inverted
  10417. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10418. * @param compression defines the compression used (null by default)
  10419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10420. * @returns the raw texture inside an InternalTexture
  10421. */
  10422. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10423. /**
  10424. * Update a raw texture
  10425. * @param texture defines the texture to update
  10426. * @param data defines the data to store in the texture
  10427. * @param format defines the format of the data
  10428. * @param invertY defines if data must be stored with Y axis inverted
  10429. */
  10430. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10431. /**
  10432. * Update a raw texture
  10433. * @param texture defines the texture to update
  10434. * @param data defines the data to store in the texture
  10435. * @param format defines the format of the data
  10436. * @param invertY defines if data must be stored with Y axis inverted
  10437. * @param compression defines the compression used (null by default)
  10438. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10439. */
  10440. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10441. /**
  10442. * Creates a new raw cube texture
  10443. * @param data defines the array of data to use to create each face
  10444. * @param size defines the size of the textures
  10445. * @param format defines the format of the data
  10446. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10447. * @param generateMipMaps defines if the engine should generate the mip levels
  10448. * @param invertY defines if data must be stored with Y axis inverted
  10449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10450. * @param compression defines the compression used (null by default)
  10451. * @returns the cube texture as an InternalTexture
  10452. */
  10453. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10454. /**
  10455. * Update a raw cube texture
  10456. * @param texture defines the texture to udpdate
  10457. * @param data defines the data to store
  10458. * @param format defines the data format
  10459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10460. * @param invertY defines if data must be stored with Y axis inverted
  10461. */
  10462. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10463. /**
  10464. * Update a raw cube texture
  10465. * @param texture defines the texture to udpdate
  10466. * @param data defines the data to store
  10467. * @param format defines the data format
  10468. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10469. * @param invertY defines if data must be stored with Y axis inverted
  10470. * @param compression defines the compression used (null by default)
  10471. */
  10472. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10473. /**
  10474. * Update a raw cube texture
  10475. * @param texture defines the texture to udpdate
  10476. * @param data defines the data to store
  10477. * @param format defines the data format
  10478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10479. * @param invertY defines if data must be stored with Y axis inverted
  10480. * @param compression defines the compression used (null by default)
  10481. * @param level defines which level of the texture to update
  10482. */
  10483. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10484. /**
  10485. * Creates a new raw cube texture from a specified url
  10486. * @param url defines the url where the data is located
  10487. * @param scene defines the current scene
  10488. * @param size defines the size of the textures
  10489. * @param format defines the format of the data
  10490. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10491. * @param noMipmap defines if the engine should avoid generating the mip levels
  10492. * @param callback defines a callback used to extract texture data from loaded data
  10493. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10494. * @param onLoad defines a callback called when texture is loaded
  10495. * @param onError defines a callback called if there is an error
  10496. * @returns the cube texture as an InternalTexture
  10497. */
  10498. 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;
  10499. /**
  10500. * Creates a new raw cube texture from a specified url
  10501. * @param url defines the url where the data is located
  10502. * @param scene defines the current scene
  10503. * @param size defines the size of the textures
  10504. * @param format defines the format of the data
  10505. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10506. * @param noMipmap defines if the engine should avoid generating the mip levels
  10507. * @param callback defines a callback used to extract texture data from loaded data
  10508. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10509. * @param onLoad defines a callback called when texture is loaded
  10510. * @param onError defines a callback called if there is an error
  10511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10512. * @param invertY defines if data must be stored with Y axis inverted
  10513. * @returns the cube texture as an InternalTexture
  10514. */
  10515. 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;
  10516. /**
  10517. * Creates a new raw 3D texture
  10518. * @param data defines the data used to create the texture
  10519. * @param width defines the width of the texture
  10520. * @param height defines the height of the texture
  10521. * @param depth defines the depth of the texture
  10522. * @param format defines the format of the texture
  10523. * @param generateMipMaps defines if the engine must generate mip levels
  10524. * @param invertY defines if data must be stored with Y axis inverted
  10525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10526. * @param compression defines the compressed used (can be null)
  10527. * @param textureType defines the compressed used (can be null)
  10528. * @returns a new raw 3D texture (stored in an InternalTexture)
  10529. */
  10530. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10531. /**
  10532. * Update a raw 3D texture
  10533. * @param texture defines the texture to update
  10534. * @param data defines the data to store
  10535. * @param format defines the data format
  10536. * @param invertY defines if data must be stored with Y axis inverted
  10537. */
  10538. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10539. /**
  10540. * Update a raw 3D texture
  10541. * @param texture defines the texture to update
  10542. * @param data defines the data to store
  10543. * @param format defines the data format
  10544. * @param invertY defines if data must be stored with Y axis inverted
  10545. * @param compression defines the used compression (can be null)
  10546. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10547. */
  10548. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10549. /**
  10550. * Creates a new raw 2D array texture
  10551. * @param data defines the data used to create the texture
  10552. * @param width defines the width of the texture
  10553. * @param height defines the height of the texture
  10554. * @param depth defines the number of layers of the texture
  10555. * @param format defines the format of the texture
  10556. * @param generateMipMaps defines if the engine must generate mip levels
  10557. * @param invertY defines if data must be stored with Y axis inverted
  10558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10559. * @param compression defines the compressed used (can be null)
  10560. * @param textureType defines the compressed used (can be null)
  10561. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10562. */
  10563. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10564. /**
  10565. * Update a raw 2D array texture
  10566. * @param texture defines the texture to update
  10567. * @param data defines the data to store
  10568. * @param format defines the data format
  10569. * @param invertY defines if data must be stored with Y axis inverted
  10570. */
  10571. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10572. /**
  10573. * Update a raw 2D array texture
  10574. * @param texture defines the texture to update
  10575. * @param data defines the data to store
  10576. * @param format defines the data format
  10577. * @param invertY defines if data must be stored with Y axis inverted
  10578. * @param compression defines the used compression (can be null)
  10579. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10580. */
  10581. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10582. }
  10583. }
  10584. declare module BABYLON {
  10585. /**
  10586. * Raw texture can help creating a texture directly from an array of data.
  10587. * This can be super useful if you either get the data from an uncompressed source or
  10588. * if you wish to create your texture pixel by pixel.
  10589. */
  10590. export class RawTexture extends Texture {
  10591. /**
  10592. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10593. */
  10594. format: number;
  10595. private _engine;
  10596. /**
  10597. * Instantiates a new RawTexture.
  10598. * Raw texture can help creating a texture directly from an array of data.
  10599. * This can be super useful if you either get the data from an uncompressed source or
  10600. * if you wish to create your texture pixel by pixel.
  10601. * @param data define the array of data to use to create the texture
  10602. * @param width define the width of the texture
  10603. * @param height define the height of the texture
  10604. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10605. * @param scene define the scene the texture belongs to
  10606. * @param generateMipMaps define whether mip maps should be generated or not
  10607. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10608. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10609. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10610. */
  10611. constructor(data: ArrayBufferView, width: number, height: number,
  10612. /**
  10613. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10614. */
  10615. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10616. /**
  10617. * Updates the texture underlying data.
  10618. * @param data Define the new data of the texture
  10619. */
  10620. update(data: ArrayBufferView): void;
  10621. /**
  10622. * Creates a luminance texture from some data.
  10623. * @param data Define the texture data
  10624. * @param width Define the width of the texture
  10625. * @param height Define the height of the texture
  10626. * @param scene Define the scene the texture belongs to
  10627. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10630. * @returns the luminance texture
  10631. */
  10632. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10633. /**
  10634. * Creates a luminance alpha texture from some data.
  10635. * @param data Define the texture data
  10636. * @param width Define the width of the texture
  10637. * @param height Define the height of the texture
  10638. * @param scene Define the scene the texture belongs to
  10639. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10640. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10641. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10642. * @returns the luminance alpha texture
  10643. */
  10644. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10645. /**
  10646. * Creates an alpha texture from some data.
  10647. * @param data Define the texture data
  10648. * @param width Define the width of the texture
  10649. * @param height Define the height of the texture
  10650. * @param scene Define the scene the texture belongs to
  10651. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10652. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10653. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10654. * @returns the alpha texture
  10655. */
  10656. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10657. /**
  10658. * Creates a RGB texture from some data.
  10659. * @param data Define the texture data
  10660. * @param width Define the width of the texture
  10661. * @param height Define the height of the texture
  10662. * @param scene Define the scene the texture belongs to
  10663. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10667. * @returns the RGB alpha texture
  10668. */
  10669. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10670. /**
  10671. * Creates a RGBA texture from some data.
  10672. * @param data Define the texture data
  10673. * @param width Define the width of the texture
  10674. * @param height Define the height of the texture
  10675. * @param scene Define the scene the texture belongs to
  10676. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10677. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10678. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10679. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10680. * @returns the RGBA texture
  10681. */
  10682. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10683. /**
  10684. * Creates a R texture from some data.
  10685. * @param data Define the texture data
  10686. * @param width Define the width of the texture
  10687. * @param height Define the height of the texture
  10688. * @param scene Define the scene the texture belongs to
  10689. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10692. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10693. * @returns the R texture
  10694. */
  10695. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10696. }
  10697. }
  10698. declare module BABYLON {
  10699. interface AbstractScene {
  10700. /**
  10701. * The list of procedural textures added to the scene
  10702. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10703. */
  10704. proceduralTextures: Array<ProceduralTexture>;
  10705. }
  10706. /**
  10707. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10708. * in a given scene.
  10709. */
  10710. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10711. /**
  10712. * The component name helpfull to identify the component in the list of scene components.
  10713. */
  10714. readonly name: string;
  10715. /**
  10716. * The scene the component belongs to.
  10717. */
  10718. scene: Scene;
  10719. /**
  10720. * Creates a new instance of the component for the given scene
  10721. * @param scene Defines the scene to register the component in
  10722. */
  10723. constructor(scene: Scene);
  10724. /**
  10725. * Registers the component in a given scene
  10726. */
  10727. register(): void;
  10728. /**
  10729. * Rebuilds the elements related to this component in case of
  10730. * context lost for instance.
  10731. */
  10732. rebuild(): void;
  10733. /**
  10734. * Disposes the component and the associated ressources.
  10735. */
  10736. dispose(): void;
  10737. private _beforeClear;
  10738. }
  10739. }
  10740. declare module BABYLON {
  10741. interface ThinEngine {
  10742. /**
  10743. * Creates a new render target cube texture
  10744. * @param size defines the size of the texture
  10745. * @param options defines the options used to create the texture
  10746. * @returns a new render target cube texture stored in an InternalTexture
  10747. */
  10748. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10749. }
  10750. }
  10751. declare module BABYLON {
  10752. /** @hidden */
  10753. export var proceduralVertexShader: {
  10754. name: string;
  10755. shader: string;
  10756. };
  10757. }
  10758. declare module BABYLON {
  10759. /**
  10760. * 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.
  10761. * This is the base class of any Procedural texture and contains most of the shareable code.
  10762. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10763. */
  10764. export class ProceduralTexture extends Texture {
  10765. isCube: boolean;
  10766. /**
  10767. * Define if the texture is enabled or not (disabled texture will not render)
  10768. */
  10769. isEnabled: boolean;
  10770. /**
  10771. * Define if the texture must be cleared before rendering (default is true)
  10772. */
  10773. autoClear: boolean;
  10774. /**
  10775. * Callback called when the texture is generated
  10776. */
  10777. onGenerated: () => void;
  10778. /**
  10779. * Event raised when the texture is generated
  10780. */
  10781. onGeneratedObservable: Observable<ProceduralTexture>;
  10782. /** @hidden */
  10783. _generateMipMaps: boolean;
  10784. /** @hidden **/
  10785. _effect: Effect;
  10786. /** @hidden */
  10787. _textures: {
  10788. [key: string]: Texture;
  10789. };
  10790. private _size;
  10791. private _currentRefreshId;
  10792. private _frameId;
  10793. private _refreshRate;
  10794. private _vertexBuffers;
  10795. private _indexBuffer;
  10796. private _uniforms;
  10797. private _samplers;
  10798. private _fragment;
  10799. private _floats;
  10800. private _ints;
  10801. private _floatsArrays;
  10802. private _colors3;
  10803. private _colors4;
  10804. private _vectors2;
  10805. private _vectors3;
  10806. private _matrices;
  10807. private _fallbackTexture;
  10808. private _fallbackTextureUsed;
  10809. private _engine;
  10810. private _cachedDefines;
  10811. private _contentUpdateId;
  10812. private _contentData;
  10813. /**
  10814. * Instantiates a new procedural texture.
  10815. * 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.
  10816. * This is the base class of any Procedural texture and contains most of the shareable code.
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10818. * @param name Define the name of the texture
  10819. * @param size Define the size of the texture to create
  10820. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10821. * @param scene Define the scene the texture belongs to
  10822. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10823. * @param generateMipMaps Define if the texture should creates mip maps or not
  10824. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10825. */
  10826. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10827. /**
  10828. * The effect that is created when initializing the post process.
  10829. * @returns The created effect corresponding the the postprocess.
  10830. */
  10831. getEffect(): Effect;
  10832. /**
  10833. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10834. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10835. */
  10836. getContent(): Nullable<ArrayBufferView>;
  10837. private _createIndexBuffer;
  10838. /** @hidden */
  10839. _rebuild(): void;
  10840. /**
  10841. * Resets the texture in order to recreate its associated resources.
  10842. * This can be called in case of context loss
  10843. */
  10844. reset(): void;
  10845. protected _getDefines(): string;
  10846. /**
  10847. * Is the texture ready to be used ? (rendered at least once)
  10848. * @returns true if ready, otherwise, false.
  10849. */
  10850. isReady(): boolean;
  10851. /**
  10852. * Resets the refresh counter of the texture and start bak from scratch.
  10853. * Could be useful to regenerate the texture if it is setup to render only once.
  10854. */
  10855. resetRefreshCounter(): void;
  10856. /**
  10857. * Set the fragment shader to use in order to render the texture.
  10858. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10859. */
  10860. setFragment(fragment: any): void;
  10861. /**
  10862. * Define the refresh rate of the texture or the rendering frequency.
  10863. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10864. */
  10865. get refreshRate(): number;
  10866. set refreshRate(value: number);
  10867. /** @hidden */
  10868. _shouldRender(): boolean;
  10869. /**
  10870. * Get the size the texture is rendering at.
  10871. * @returns the size (texture is always squared)
  10872. */
  10873. getRenderSize(): number;
  10874. /**
  10875. * Resize the texture to new value.
  10876. * @param size Define the new size the texture should have
  10877. * @param generateMipMaps Define whether the new texture should create mip maps
  10878. */
  10879. resize(size: number, generateMipMaps: boolean): void;
  10880. private _checkUniform;
  10881. /**
  10882. * Set a texture in the shader program used to render.
  10883. * @param name Define the name of the uniform samplers as defined in the shader
  10884. * @param texture Define the texture to bind to this sampler
  10885. * @return the texture itself allowing "fluent" like uniform updates
  10886. */
  10887. setTexture(name: string, texture: Texture): ProceduralTexture;
  10888. /**
  10889. * Set a float in the shader.
  10890. * @param name Define the name of the uniform as defined in the shader
  10891. * @param value Define the value to give to the uniform
  10892. * @return the texture itself allowing "fluent" like uniform updates
  10893. */
  10894. setFloat(name: string, value: number): ProceduralTexture;
  10895. /**
  10896. * Set a int in the shader.
  10897. * @param name Define the name of the uniform as defined in the shader
  10898. * @param value Define the value to give to the uniform
  10899. * @return the texture itself allowing "fluent" like uniform updates
  10900. */
  10901. setInt(name: string, value: number): ProceduralTexture;
  10902. /**
  10903. * Set an array of floats in the shader.
  10904. * @param name Define the name of the uniform as defined in the shader
  10905. * @param value Define the value to give to the uniform
  10906. * @return the texture itself allowing "fluent" like uniform updates
  10907. */
  10908. setFloats(name: string, value: number[]): ProceduralTexture;
  10909. /**
  10910. * Set a vec3 in the shader from a Color3.
  10911. * @param name Define the name of the uniform as defined in the shader
  10912. * @param value Define the value to give to the uniform
  10913. * @return the texture itself allowing "fluent" like uniform updates
  10914. */
  10915. setColor3(name: string, value: Color3): ProceduralTexture;
  10916. /**
  10917. * Set a vec4 in the shader from a Color4.
  10918. * @param name Define the name of the uniform as defined in the shader
  10919. * @param value Define the value to give to the uniform
  10920. * @return the texture itself allowing "fluent" like uniform updates
  10921. */
  10922. setColor4(name: string, value: Color4): ProceduralTexture;
  10923. /**
  10924. * Set a vec2 in the shader from a Vector2.
  10925. * @param name Define the name of the uniform as defined in the shader
  10926. * @param value Define the value to give to the uniform
  10927. * @return the texture itself allowing "fluent" like uniform updates
  10928. */
  10929. setVector2(name: string, value: Vector2): ProceduralTexture;
  10930. /**
  10931. * Set a vec3 in the shader from a Vector3.
  10932. * @param name Define the name of the uniform as defined in the shader
  10933. * @param value Define the value to give to the uniform
  10934. * @return the texture itself allowing "fluent" like uniform updates
  10935. */
  10936. setVector3(name: string, value: Vector3): ProceduralTexture;
  10937. /**
  10938. * Set a mat4 in the shader from a MAtrix.
  10939. * @param name Define the name of the uniform as defined in the shader
  10940. * @param value Define the value to give to the uniform
  10941. * @return the texture itself allowing "fluent" like uniform updates
  10942. */
  10943. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10944. /**
  10945. * Render the texture to its associated render target.
  10946. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10947. */
  10948. render(useCameraPostProcess?: boolean): void;
  10949. /**
  10950. * Clone the texture.
  10951. * @returns the cloned texture
  10952. */
  10953. clone(): ProceduralTexture;
  10954. /**
  10955. * Dispose the texture and release its asoociated resources.
  10956. */
  10957. dispose(): void;
  10958. }
  10959. }
  10960. declare module BABYLON {
  10961. /**
  10962. * This represents the base class for particle system in Babylon.
  10963. * 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.
  10964. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10965. * @example https://doc.babylonjs.com/babylon101/particles
  10966. */
  10967. export class BaseParticleSystem {
  10968. /**
  10969. * Source color is added to the destination color without alpha affecting the result
  10970. */
  10971. static BLENDMODE_ONEONE: number;
  10972. /**
  10973. * Blend current color and particle color using particle’s alpha
  10974. */
  10975. static BLENDMODE_STANDARD: number;
  10976. /**
  10977. * Add current color and particle color multiplied by particle’s alpha
  10978. */
  10979. static BLENDMODE_ADD: number;
  10980. /**
  10981. * Multiply current color with particle color
  10982. */
  10983. static BLENDMODE_MULTIPLY: number;
  10984. /**
  10985. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10986. */
  10987. static BLENDMODE_MULTIPLYADD: number;
  10988. /**
  10989. * List of animations used by the particle system.
  10990. */
  10991. animations: Animation[];
  10992. /**
  10993. * The id of the Particle system.
  10994. */
  10995. id: string;
  10996. /**
  10997. * The friendly name of the Particle system.
  10998. */
  10999. name: string;
  11000. /**
  11001. * The rendering group used by the Particle system to chose when to render.
  11002. */
  11003. renderingGroupId: number;
  11004. /**
  11005. * The emitter represents the Mesh or position we are attaching the particle system to.
  11006. */
  11007. emitter: Nullable<AbstractMesh | Vector3>;
  11008. /**
  11009. * The maximum number of particles to emit per frame
  11010. */
  11011. emitRate: number;
  11012. /**
  11013. * If you want to launch only a few particles at once, that can be done, as well.
  11014. */
  11015. manualEmitCount: number;
  11016. /**
  11017. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11018. */
  11019. updateSpeed: number;
  11020. /**
  11021. * The amount of time the particle system is running (depends of the overall update speed).
  11022. */
  11023. targetStopDuration: number;
  11024. /**
  11025. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11026. */
  11027. disposeOnStop: boolean;
  11028. /**
  11029. * Minimum power of emitting particles.
  11030. */
  11031. minEmitPower: number;
  11032. /**
  11033. * Maximum power of emitting particles.
  11034. */
  11035. maxEmitPower: number;
  11036. /**
  11037. * Minimum life time of emitting particles.
  11038. */
  11039. minLifeTime: number;
  11040. /**
  11041. * Maximum life time of emitting particles.
  11042. */
  11043. maxLifeTime: number;
  11044. /**
  11045. * Minimum Size of emitting particles.
  11046. */
  11047. minSize: number;
  11048. /**
  11049. * Maximum Size of emitting particles.
  11050. */
  11051. maxSize: number;
  11052. /**
  11053. * Minimum scale of emitting particles on X axis.
  11054. */
  11055. minScaleX: number;
  11056. /**
  11057. * Maximum scale of emitting particles on X axis.
  11058. */
  11059. maxScaleX: number;
  11060. /**
  11061. * Minimum scale of emitting particles on Y axis.
  11062. */
  11063. minScaleY: number;
  11064. /**
  11065. * Maximum scale of emitting particles on Y axis.
  11066. */
  11067. maxScaleY: number;
  11068. /**
  11069. * Gets or sets the minimal initial rotation in radians.
  11070. */
  11071. minInitialRotation: number;
  11072. /**
  11073. * Gets or sets the maximal initial rotation in radians.
  11074. */
  11075. maxInitialRotation: number;
  11076. /**
  11077. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11078. */
  11079. minAngularSpeed: number;
  11080. /**
  11081. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11082. */
  11083. maxAngularSpeed: number;
  11084. /**
  11085. * The texture used to render each particle. (this can be a spritesheet)
  11086. */
  11087. particleTexture: Nullable<Texture>;
  11088. /**
  11089. * The layer mask we are rendering the particles through.
  11090. */
  11091. layerMask: number;
  11092. /**
  11093. * This can help using your own shader to render the particle system.
  11094. * The according effect will be created
  11095. */
  11096. customShader: any;
  11097. /**
  11098. * By default particle system starts as soon as they are created. This prevents the
  11099. * automatic start to happen and let you decide when to start emitting particles.
  11100. */
  11101. preventAutoStart: boolean;
  11102. private _noiseTexture;
  11103. /**
  11104. * Gets or sets a texture used to add random noise to particle positions
  11105. */
  11106. get noiseTexture(): Nullable<ProceduralTexture>;
  11107. set noiseTexture(value: Nullable<ProceduralTexture>);
  11108. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11109. noiseStrength: Vector3;
  11110. /**
  11111. * Callback triggered when the particle animation is ending.
  11112. */
  11113. onAnimationEnd: Nullable<() => void>;
  11114. /**
  11115. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11116. */
  11117. blendMode: number;
  11118. /**
  11119. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11120. * to override the particles.
  11121. */
  11122. forceDepthWrite: boolean;
  11123. /** 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 */
  11124. preWarmCycles: number;
  11125. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11126. preWarmStepOffset: number;
  11127. /**
  11128. * 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)
  11129. */
  11130. spriteCellChangeSpeed: number;
  11131. /**
  11132. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11133. */
  11134. startSpriteCellID: number;
  11135. /**
  11136. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11137. */
  11138. endSpriteCellID: number;
  11139. /**
  11140. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11141. */
  11142. spriteCellWidth: number;
  11143. /**
  11144. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11145. */
  11146. spriteCellHeight: number;
  11147. /**
  11148. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11149. */
  11150. spriteRandomStartCell: boolean;
  11151. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11152. translationPivot: Vector2;
  11153. /** @hidden */
  11154. protected _isAnimationSheetEnabled: boolean;
  11155. /**
  11156. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11157. */
  11158. beginAnimationOnStart: boolean;
  11159. /**
  11160. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11161. */
  11162. beginAnimationFrom: number;
  11163. /**
  11164. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11165. */
  11166. beginAnimationTo: number;
  11167. /**
  11168. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11169. */
  11170. beginAnimationLoop: boolean;
  11171. /**
  11172. * Gets or sets a world offset applied to all particles
  11173. */
  11174. worldOffset: Vector3;
  11175. /**
  11176. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11177. */
  11178. get isAnimationSheetEnabled(): boolean;
  11179. set isAnimationSheetEnabled(value: boolean);
  11180. /**
  11181. * Get hosting scene
  11182. * @returns the scene
  11183. */
  11184. getScene(): Scene;
  11185. /**
  11186. * You can use gravity if you want to give an orientation to your particles.
  11187. */
  11188. gravity: Vector3;
  11189. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11190. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11191. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11192. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11193. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11194. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11195. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11196. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11197. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11198. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11199. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11200. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11201. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11202. /**
  11203. * Defines the delay in milliseconds before starting the system (0 by default)
  11204. */
  11205. startDelay: number;
  11206. /**
  11207. * Gets the current list of drag gradients.
  11208. * You must use addDragGradient and removeDragGradient to udpate this list
  11209. * @returns the list of drag gradients
  11210. */
  11211. getDragGradients(): Nullable<Array<FactorGradient>>;
  11212. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11213. limitVelocityDamping: number;
  11214. /**
  11215. * Gets the current list of limit velocity gradients.
  11216. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11217. * @returns the list of limit velocity gradients
  11218. */
  11219. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11220. /**
  11221. * Gets the current list of color gradients.
  11222. * You must use addColorGradient and removeColorGradient to udpate this list
  11223. * @returns the list of color gradients
  11224. */
  11225. getColorGradients(): Nullable<Array<ColorGradient>>;
  11226. /**
  11227. * Gets the current list of size gradients.
  11228. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11229. * @returns the list of size gradients
  11230. */
  11231. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11232. /**
  11233. * Gets the current list of color remap gradients.
  11234. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11235. * @returns the list of color remap gradients
  11236. */
  11237. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11238. /**
  11239. * Gets the current list of alpha remap gradients.
  11240. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11241. * @returns the list of alpha remap gradients
  11242. */
  11243. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11244. /**
  11245. * Gets the current list of life time gradients.
  11246. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11247. * @returns the list of life time gradients
  11248. */
  11249. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11250. /**
  11251. * Gets the current list of angular speed gradients.
  11252. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11253. * @returns the list of angular speed gradients
  11254. */
  11255. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11256. /**
  11257. * Gets the current list of velocity gradients.
  11258. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11259. * @returns the list of velocity gradients
  11260. */
  11261. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11262. /**
  11263. * Gets the current list of start size gradients.
  11264. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11265. * @returns the list of start size gradients
  11266. */
  11267. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11268. /**
  11269. * Gets the current list of emit rate gradients.
  11270. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11271. * @returns the list of emit rate gradients
  11272. */
  11273. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11274. /**
  11275. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11276. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11277. */
  11278. get direction1(): Vector3;
  11279. set direction1(value: Vector3);
  11280. /**
  11281. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11283. */
  11284. get direction2(): Vector3;
  11285. set direction2(value: Vector3);
  11286. /**
  11287. * 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.
  11288. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11289. */
  11290. get minEmitBox(): Vector3;
  11291. set minEmitBox(value: Vector3);
  11292. /**
  11293. * 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.
  11294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11295. */
  11296. get maxEmitBox(): Vector3;
  11297. set maxEmitBox(value: Vector3);
  11298. /**
  11299. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11300. */
  11301. color1: Color4;
  11302. /**
  11303. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11304. */
  11305. color2: Color4;
  11306. /**
  11307. * Color the particle will have at the end of its lifetime
  11308. */
  11309. colorDead: Color4;
  11310. /**
  11311. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11312. */
  11313. textureMask: Color4;
  11314. /**
  11315. * The particle emitter type defines the emitter used by the particle system.
  11316. * It can be for example box, sphere, or cone...
  11317. */
  11318. particleEmitterType: IParticleEmitterType;
  11319. /** @hidden */
  11320. _isSubEmitter: boolean;
  11321. /**
  11322. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11323. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11324. */
  11325. billboardMode: number;
  11326. protected _isBillboardBased: boolean;
  11327. /**
  11328. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11329. */
  11330. get isBillboardBased(): boolean;
  11331. set isBillboardBased(value: boolean);
  11332. /**
  11333. * The scene the particle system belongs to.
  11334. */
  11335. protected _scene: Scene;
  11336. /**
  11337. * Local cache of defines for image processing.
  11338. */
  11339. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11340. /**
  11341. * Default configuration related to image processing available in the standard Material.
  11342. */
  11343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11344. /**
  11345. * Gets the image processing configuration used either in this material.
  11346. */
  11347. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11348. /**
  11349. * Sets the Default image processing configuration used either in the this material.
  11350. *
  11351. * If sets to null, the scene one is in use.
  11352. */
  11353. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11354. /**
  11355. * Attaches a new image processing configuration to the Standard Material.
  11356. * @param configuration
  11357. */
  11358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11359. /** @hidden */
  11360. protected _reset(): void;
  11361. /** @hidden */
  11362. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11363. /**
  11364. * Instantiates a particle system.
  11365. * 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.
  11366. * @param name The name of the particle system
  11367. */
  11368. constructor(name: string);
  11369. /**
  11370. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11373. * @returns the emitter
  11374. */
  11375. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11376. /**
  11377. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11378. * @param radius The radius of the hemisphere to emit from
  11379. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11380. * @returns the emitter
  11381. */
  11382. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11383. /**
  11384. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11385. * @param radius The radius of the sphere to emit from
  11386. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11387. * @returns the emitter
  11388. */
  11389. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11390. /**
  11391. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11392. * @param radius The radius of the sphere to emit from
  11393. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11394. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11395. * @returns the emitter
  11396. */
  11397. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11398. /**
  11399. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11400. * @param radius The radius of the emission cylinder
  11401. * @param height The height of the emission cylinder
  11402. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11403. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11404. * @returns the emitter
  11405. */
  11406. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11407. /**
  11408. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11409. * @param radius The radius of the cylinder to emit from
  11410. * @param height The height of the emission cylinder
  11411. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11412. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11413. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11414. * @returns the emitter
  11415. */
  11416. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11417. /**
  11418. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11419. * @param radius The radius of the cone to emit from
  11420. * @param angle The base angle of the cone
  11421. * @returns the emitter
  11422. */
  11423. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11424. /**
  11425. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11428. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11429. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11430. * @returns the emitter
  11431. */
  11432. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11433. }
  11434. }
  11435. declare module BABYLON {
  11436. /**
  11437. * Type of sub emitter
  11438. */
  11439. export enum SubEmitterType {
  11440. /**
  11441. * Attached to the particle over it's lifetime
  11442. */
  11443. ATTACHED = 0,
  11444. /**
  11445. * Created when the particle dies
  11446. */
  11447. END = 1
  11448. }
  11449. /**
  11450. * Sub emitter class used to emit particles from an existing particle
  11451. */
  11452. export class SubEmitter {
  11453. /**
  11454. * the particle system to be used by the sub emitter
  11455. */
  11456. particleSystem: ParticleSystem;
  11457. /**
  11458. * Type of the submitter (Default: END)
  11459. */
  11460. type: SubEmitterType;
  11461. /**
  11462. * 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)
  11463. * Note: This only is supported when using an emitter of type Mesh
  11464. */
  11465. inheritDirection: boolean;
  11466. /**
  11467. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11468. */
  11469. inheritedVelocityAmount: number;
  11470. /**
  11471. * Creates a sub emitter
  11472. * @param particleSystem the particle system to be used by the sub emitter
  11473. */
  11474. constructor(
  11475. /**
  11476. * the particle system to be used by the sub emitter
  11477. */
  11478. particleSystem: ParticleSystem);
  11479. /**
  11480. * Clones the sub emitter
  11481. * @returns the cloned sub emitter
  11482. */
  11483. clone(): SubEmitter;
  11484. /**
  11485. * Serialize current object to a JSON object
  11486. * @returns the serialized object
  11487. */
  11488. serialize(): any;
  11489. /** @hidden */
  11490. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11491. /**
  11492. * Creates a new SubEmitter from a serialized JSON version
  11493. * @param serializationObject defines the JSON object to read from
  11494. * @param scene defines the hosting scene
  11495. * @param rootUrl defines the rootUrl for data loading
  11496. * @returns a new SubEmitter
  11497. */
  11498. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11499. /** Release associated resources */
  11500. dispose(): void;
  11501. }
  11502. }
  11503. declare module BABYLON {
  11504. /** @hidden */
  11505. export var imageProcessingDeclaration: {
  11506. name: string;
  11507. shader: string;
  11508. };
  11509. }
  11510. declare module BABYLON {
  11511. /** @hidden */
  11512. export var imageProcessingFunctions: {
  11513. name: string;
  11514. shader: string;
  11515. };
  11516. }
  11517. declare module BABYLON {
  11518. /** @hidden */
  11519. export var particlesPixelShader: {
  11520. name: string;
  11521. shader: string;
  11522. };
  11523. }
  11524. declare module BABYLON {
  11525. /** @hidden */
  11526. export var particlesVertexShader: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module BABYLON {
  11532. /**
  11533. * This represents a particle system in Babylon.
  11534. * 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.
  11535. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11536. * @example https://doc.babylonjs.com/babylon101/particles
  11537. */
  11538. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11539. /**
  11540. * Billboard mode will only apply to Y axis
  11541. */
  11542. static readonly BILLBOARDMODE_Y: number;
  11543. /**
  11544. * Billboard mode will apply to all axes
  11545. */
  11546. static readonly BILLBOARDMODE_ALL: number;
  11547. /**
  11548. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11549. */
  11550. static readonly BILLBOARDMODE_STRETCHED: number;
  11551. /**
  11552. * This function can be defined to provide custom update for active particles.
  11553. * This function will be called instead of regular update (age, position, color, etc.).
  11554. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11555. */
  11556. updateFunction: (particles: Particle[]) => void;
  11557. private _emitterWorldMatrix;
  11558. /**
  11559. * This function can be defined to specify initial direction for every new particle.
  11560. * It by default use the emitterType defined function
  11561. */
  11562. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11563. /**
  11564. * This function can be defined to specify initial position for every new particle.
  11565. * It by default use the emitterType defined function
  11566. */
  11567. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11568. /**
  11569. * @hidden
  11570. */
  11571. _inheritedVelocityOffset: Vector3;
  11572. /**
  11573. * An event triggered when the system is disposed
  11574. */
  11575. onDisposeObservable: Observable<ParticleSystem>;
  11576. private _onDisposeObserver;
  11577. /**
  11578. * Sets a callback that will be triggered when the system is disposed
  11579. */
  11580. set onDispose(callback: () => void);
  11581. private _particles;
  11582. private _epsilon;
  11583. private _capacity;
  11584. private _stockParticles;
  11585. private _newPartsExcess;
  11586. private _vertexData;
  11587. private _vertexBuffer;
  11588. private _vertexBuffers;
  11589. private _spriteBuffer;
  11590. private _indexBuffer;
  11591. private _effect;
  11592. private _customEffect;
  11593. private _cachedDefines;
  11594. private _scaledColorStep;
  11595. private _colorDiff;
  11596. private _scaledDirection;
  11597. private _scaledGravity;
  11598. private _currentRenderId;
  11599. private _alive;
  11600. private _useInstancing;
  11601. private _started;
  11602. private _stopped;
  11603. private _actualFrame;
  11604. private _scaledUpdateSpeed;
  11605. private _vertexBufferSize;
  11606. /** @hidden */
  11607. _currentEmitRateGradient: Nullable<FactorGradient>;
  11608. /** @hidden */
  11609. _currentEmitRate1: number;
  11610. /** @hidden */
  11611. _currentEmitRate2: number;
  11612. /** @hidden */
  11613. _currentStartSizeGradient: Nullable<FactorGradient>;
  11614. /** @hidden */
  11615. _currentStartSize1: number;
  11616. /** @hidden */
  11617. _currentStartSize2: number;
  11618. private readonly _rawTextureWidth;
  11619. private _rampGradientsTexture;
  11620. private _useRampGradients;
  11621. /** Gets or sets a boolean indicating that ramp gradients must be used
  11622. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11623. */
  11624. get useRampGradients(): boolean;
  11625. set useRampGradients(value: boolean);
  11626. /**
  11627. * 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.
  11628. * 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: [])
  11629. */
  11630. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11631. private _subEmitters;
  11632. /**
  11633. * @hidden
  11634. * If the particle systems emitter should be disposed when the particle system is disposed
  11635. */
  11636. _disposeEmitterOnDispose: boolean;
  11637. /**
  11638. * The current active Sub-systems, this property is used by the root particle system only.
  11639. */
  11640. activeSubSystems: Array<ParticleSystem>;
  11641. /**
  11642. * Specifies if the particles are updated in emitter local space or world space
  11643. */
  11644. isLocal: boolean;
  11645. private _rootParticleSystem;
  11646. /**
  11647. * Gets the current list of active particles
  11648. */
  11649. get particles(): Particle[];
  11650. /**
  11651. * Returns the string "ParticleSystem"
  11652. * @returns a string containing the class name
  11653. */
  11654. getClassName(): string;
  11655. /**
  11656. * Instantiates a particle system.
  11657. * 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.
  11658. * @param name The name of the particle system
  11659. * @param capacity The max number of particles alive at the same time
  11660. * @param scene The scene the particle system belongs to
  11661. * @param customEffect a custom effect used to change the way particles are rendered by default
  11662. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11663. * @param epsilon Offset used to render the particles
  11664. */
  11665. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11666. private _addFactorGradient;
  11667. private _removeFactorGradient;
  11668. /**
  11669. * Adds a new life time gradient
  11670. * @param gradient defines the gradient to use (between 0 and 1)
  11671. * @param factor defines the life time factor to affect to the specified gradient
  11672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11673. * @returns the current particle system
  11674. */
  11675. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11676. /**
  11677. * Remove a specific life time gradient
  11678. * @param gradient defines the gradient to remove
  11679. * @returns the current particle system
  11680. */
  11681. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11682. /**
  11683. * Adds a new size gradient
  11684. * @param gradient defines the gradient to use (between 0 and 1)
  11685. * @param factor defines the size factor to affect to the specified gradient
  11686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11687. * @returns the current particle system
  11688. */
  11689. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11690. /**
  11691. * Remove a specific size gradient
  11692. * @param gradient defines the gradient to remove
  11693. * @returns the current particle system
  11694. */
  11695. removeSizeGradient(gradient: number): IParticleSystem;
  11696. /**
  11697. * Adds a new color remap gradient
  11698. * @param gradient defines the gradient to use (between 0 and 1)
  11699. * @param min defines the color remap minimal range
  11700. * @param max defines the color remap maximal range
  11701. * @returns the current particle system
  11702. */
  11703. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11704. /**
  11705. * Remove a specific color remap gradient
  11706. * @param gradient defines the gradient to remove
  11707. * @returns the current particle system
  11708. */
  11709. removeColorRemapGradient(gradient: number): IParticleSystem;
  11710. /**
  11711. * Adds a new alpha remap gradient
  11712. * @param gradient defines the gradient to use (between 0 and 1)
  11713. * @param min defines the alpha remap minimal range
  11714. * @param max defines the alpha remap maximal range
  11715. * @returns the current particle system
  11716. */
  11717. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11718. /**
  11719. * Remove a specific alpha remap gradient
  11720. * @param gradient defines the gradient to remove
  11721. * @returns the current particle system
  11722. */
  11723. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11724. /**
  11725. * Adds a new angular speed gradient
  11726. * @param gradient defines the gradient to use (between 0 and 1)
  11727. * @param factor defines the angular speed to affect to the specified gradient
  11728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11729. * @returns the current particle system
  11730. */
  11731. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11732. /**
  11733. * Remove a specific angular speed gradient
  11734. * @param gradient defines the gradient to remove
  11735. * @returns the current particle system
  11736. */
  11737. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11738. /**
  11739. * Adds a new velocity gradient
  11740. * @param gradient defines the gradient to use (between 0 and 1)
  11741. * @param factor defines the velocity to affect to the specified gradient
  11742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11743. * @returns the current particle system
  11744. */
  11745. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11746. /**
  11747. * Remove a specific velocity gradient
  11748. * @param gradient defines the gradient to remove
  11749. * @returns the current particle system
  11750. */
  11751. removeVelocityGradient(gradient: number): IParticleSystem;
  11752. /**
  11753. * Adds a new limit velocity gradient
  11754. * @param gradient defines the gradient to use (between 0 and 1)
  11755. * @param factor defines the limit velocity value to affect to the specified gradient
  11756. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11757. * @returns the current particle system
  11758. */
  11759. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11760. /**
  11761. * Remove a specific limit velocity gradient
  11762. * @param gradient defines the gradient to remove
  11763. * @returns the current particle system
  11764. */
  11765. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11766. /**
  11767. * Adds a new drag gradient
  11768. * @param gradient defines the gradient to use (between 0 and 1)
  11769. * @param factor defines the drag value to affect to the specified gradient
  11770. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11771. * @returns the current particle system
  11772. */
  11773. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11774. /**
  11775. * Remove a specific drag gradient
  11776. * @param gradient defines the gradient to remove
  11777. * @returns the current particle system
  11778. */
  11779. removeDragGradient(gradient: number): IParticleSystem;
  11780. /**
  11781. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11782. * @param gradient defines the gradient to use (between 0 and 1)
  11783. * @param factor defines the emit rate value to affect to the specified gradient
  11784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11785. * @returns the current particle system
  11786. */
  11787. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11788. /**
  11789. * Remove a specific emit rate gradient
  11790. * @param gradient defines the gradient to remove
  11791. * @returns the current particle system
  11792. */
  11793. removeEmitRateGradient(gradient: number): IParticleSystem;
  11794. /**
  11795. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11796. * @param gradient defines the gradient to use (between 0 and 1)
  11797. * @param factor defines the start size value to affect to the specified gradient
  11798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11799. * @returns the current particle system
  11800. */
  11801. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11802. /**
  11803. * Remove a specific start size gradient
  11804. * @param gradient defines the gradient to remove
  11805. * @returns the current particle system
  11806. */
  11807. removeStartSizeGradient(gradient: number): IParticleSystem;
  11808. private _createRampGradientTexture;
  11809. /**
  11810. * Gets the current list of ramp gradients.
  11811. * You must use addRampGradient and removeRampGradient to udpate this list
  11812. * @returns the list of ramp gradients
  11813. */
  11814. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11815. /**
  11816. * Adds a new ramp gradient used to remap particle colors
  11817. * @param gradient defines the gradient to use (between 0 and 1)
  11818. * @param color defines the color to affect to the specified gradient
  11819. * @returns the current particle system
  11820. */
  11821. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11822. /**
  11823. * Remove a specific ramp gradient
  11824. * @param gradient defines the gradient to remove
  11825. * @returns the current particle system
  11826. */
  11827. removeRampGradient(gradient: number): ParticleSystem;
  11828. /**
  11829. * Adds a new color gradient
  11830. * @param gradient defines the gradient to use (between 0 and 1)
  11831. * @param color1 defines the color to affect to the specified gradient
  11832. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11833. * @returns this particle system
  11834. */
  11835. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11836. /**
  11837. * Remove a specific color gradient
  11838. * @param gradient defines the gradient to remove
  11839. * @returns this particle system
  11840. */
  11841. removeColorGradient(gradient: number): IParticleSystem;
  11842. private _fetchR;
  11843. protected _reset(): void;
  11844. private _resetEffect;
  11845. private _createVertexBuffers;
  11846. private _createIndexBuffer;
  11847. /**
  11848. * Gets the maximum number of particles active at the same time.
  11849. * @returns The max number of active particles.
  11850. */
  11851. getCapacity(): number;
  11852. /**
  11853. * Gets whether there are still active particles in the system.
  11854. * @returns True if it is alive, otherwise false.
  11855. */
  11856. isAlive(): boolean;
  11857. /**
  11858. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11859. * @returns True if it has been started, otherwise false.
  11860. */
  11861. isStarted(): boolean;
  11862. private _prepareSubEmitterInternalArray;
  11863. /**
  11864. * Starts the particle system and begins to emit
  11865. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11866. */
  11867. start(delay?: number): void;
  11868. /**
  11869. * Stops the particle system.
  11870. * @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.
  11871. */
  11872. stop(stopSubEmitters?: boolean): void;
  11873. /**
  11874. * Remove all active particles
  11875. */
  11876. reset(): void;
  11877. /**
  11878. * @hidden (for internal use only)
  11879. */
  11880. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11881. /**
  11882. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11883. * Its lifetime will start back at 0.
  11884. */
  11885. recycleParticle: (particle: Particle) => void;
  11886. private _stopSubEmitters;
  11887. private _createParticle;
  11888. private _removeFromRoot;
  11889. private _emitFromParticle;
  11890. private _update;
  11891. /** @hidden */
  11892. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11893. /** @hidden */
  11894. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11895. /** @hidden */
  11896. private _getEffect;
  11897. /**
  11898. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11899. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11900. */
  11901. animate(preWarmOnly?: boolean): void;
  11902. private _appendParticleVertices;
  11903. /**
  11904. * Rebuilds the particle system.
  11905. */
  11906. rebuild(): void;
  11907. /**
  11908. * Is this system ready to be used/rendered
  11909. * @return true if the system is ready
  11910. */
  11911. isReady(): boolean;
  11912. private _render;
  11913. /**
  11914. * Renders the particle system in its current state.
  11915. * @returns the current number of particles
  11916. */
  11917. render(): number;
  11918. /**
  11919. * Disposes the particle system and free the associated resources
  11920. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11921. */
  11922. dispose(disposeTexture?: boolean): void;
  11923. /**
  11924. * Clones the particle system.
  11925. * @param name The name of the cloned object
  11926. * @param newEmitter The new emitter to use
  11927. * @returns the cloned particle system
  11928. */
  11929. clone(name: string, newEmitter: any): ParticleSystem;
  11930. /**
  11931. * Serializes the particle system to a JSON object.
  11932. * @returns the JSON object
  11933. */
  11934. serialize(): any;
  11935. /** @hidden */
  11936. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11937. /** @hidden */
  11938. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11939. /**
  11940. * Parses a JSON object to create a particle system.
  11941. * @param parsedParticleSystem The JSON object to parse
  11942. * @param scene The scene to create the particle system in
  11943. * @param rootUrl The root url to use to load external dependencies like texture
  11944. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11945. * @returns the Parsed particle system
  11946. */
  11947. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11948. }
  11949. }
  11950. declare module BABYLON {
  11951. /**
  11952. * A particle represents one of the element emitted by a particle system.
  11953. * This is mainly define by its coordinates, direction, velocity and age.
  11954. */
  11955. export class Particle {
  11956. /**
  11957. * The particle system the particle belongs to.
  11958. */
  11959. particleSystem: ParticleSystem;
  11960. private static _Count;
  11961. /**
  11962. * Unique ID of the particle
  11963. */
  11964. id: number;
  11965. /**
  11966. * The world position of the particle in the scene.
  11967. */
  11968. position: Vector3;
  11969. /**
  11970. * The world direction of the particle in the scene.
  11971. */
  11972. direction: Vector3;
  11973. /**
  11974. * The color of the particle.
  11975. */
  11976. color: Color4;
  11977. /**
  11978. * The color change of the particle per step.
  11979. */
  11980. colorStep: Color4;
  11981. /**
  11982. * Defines how long will the life of the particle be.
  11983. */
  11984. lifeTime: number;
  11985. /**
  11986. * The current age of the particle.
  11987. */
  11988. age: number;
  11989. /**
  11990. * The current size of the particle.
  11991. */
  11992. size: number;
  11993. /**
  11994. * The current scale of the particle.
  11995. */
  11996. scale: Vector2;
  11997. /**
  11998. * The current angle of the particle.
  11999. */
  12000. angle: number;
  12001. /**
  12002. * Defines how fast is the angle changing.
  12003. */
  12004. angularSpeed: number;
  12005. /**
  12006. * Defines the cell index used by the particle to be rendered from a sprite.
  12007. */
  12008. cellIndex: number;
  12009. /**
  12010. * The information required to support color remapping
  12011. */
  12012. remapData: Vector4;
  12013. /** @hidden */
  12014. _randomCellOffset?: number;
  12015. /** @hidden */
  12016. _initialDirection: Nullable<Vector3>;
  12017. /** @hidden */
  12018. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12019. /** @hidden */
  12020. _initialStartSpriteCellID: number;
  12021. /** @hidden */
  12022. _initialEndSpriteCellID: number;
  12023. /** @hidden */
  12024. _currentColorGradient: Nullable<ColorGradient>;
  12025. /** @hidden */
  12026. _currentColor1: Color4;
  12027. /** @hidden */
  12028. _currentColor2: Color4;
  12029. /** @hidden */
  12030. _currentSizeGradient: Nullable<FactorGradient>;
  12031. /** @hidden */
  12032. _currentSize1: number;
  12033. /** @hidden */
  12034. _currentSize2: number;
  12035. /** @hidden */
  12036. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12037. /** @hidden */
  12038. _currentAngularSpeed1: number;
  12039. /** @hidden */
  12040. _currentAngularSpeed2: number;
  12041. /** @hidden */
  12042. _currentVelocityGradient: Nullable<FactorGradient>;
  12043. /** @hidden */
  12044. _currentVelocity1: number;
  12045. /** @hidden */
  12046. _currentVelocity2: number;
  12047. /** @hidden */
  12048. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12049. /** @hidden */
  12050. _currentLimitVelocity1: number;
  12051. /** @hidden */
  12052. _currentLimitVelocity2: number;
  12053. /** @hidden */
  12054. _currentDragGradient: Nullable<FactorGradient>;
  12055. /** @hidden */
  12056. _currentDrag1: number;
  12057. /** @hidden */
  12058. _currentDrag2: number;
  12059. /** @hidden */
  12060. _randomNoiseCoordinates1: Vector3;
  12061. /** @hidden */
  12062. _randomNoiseCoordinates2: Vector3;
  12063. /** @hidden */
  12064. _localPosition?: Vector3;
  12065. /**
  12066. * Creates a new instance Particle
  12067. * @param particleSystem the particle system the particle belongs to
  12068. */
  12069. constructor(
  12070. /**
  12071. * The particle system the particle belongs to.
  12072. */
  12073. particleSystem: ParticleSystem);
  12074. private updateCellInfoFromSystem;
  12075. /**
  12076. * Defines how the sprite cell index is updated for the particle
  12077. */
  12078. updateCellIndex(): void;
  12079. /** @hidden */
  12080. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12081. /** @hidden */
  12082. _inheritParticleInfoToSubEmitters(): void;
  12083. /** @hidden */
  12084. _reset(): void;
  12085. /**
  12086. * Copy the properties of particle to another one.
  12087. * @param other the particle to copy the information to.
  12088. */
  12089. copyTo(other: Particle): void;
  12090. }
  12091. }
  12092. declare module BABYLON {
  12093. /**
  12094. * Particle emitter represents a volume emitting particles.
  12095. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12096. */
  12097. export interface IParticleEmitterType {
  12098. /**
  12099. * Called by the particle System when the direction is computed for the created particle.
  12100. * @param worldMatrix is the world matrix of the particle system
  12101. * @param directionToUpdate is the direction vector to update with the result
  12102. * @param particle is the particle we are computed the direction for
  12103. * @param isLocal defines if the direction should be set in local space
  12104. */
  12105. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12106. /**
  12107. * Called by the particle System when the position is computed for the created particle.
  12108. * @param worldMatrix is the world matrix of the particle system
  12109. * @param positionToUpdate is the position vector to update with the result
  12110. * @param particle is the particle we are computed the position for
  12111. * @param isLocal defines if the position should be set in local space
  12112. */
  12113. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12114. /**
  12115. * Clones the current emitter and returns a copy of it
  12116. * @returns the new emitter
  12117. */
  12118. clone(): IParticleEmitterType;
  12119. /**
  12120. * Called by the GPUParticleSystem to setup the update shader
  12121. * @param effect defines the update shader
  12122. */
  12123. applyToShader(effect: Effect): void;
  12124. /**
  12125. * Returns a string to use to update the GPU particles update shader
  12126. * @returns the effect defines string
  12127. */
  12128. getEffectDefines(): string;
  12129. /**
  12130. * Returns a string representing the class name
  12131. * @returns a string containing the class name
  12132. */
  12133. getClassName(): string;
  12134. /**
  12135. * Serializes the particle system to a JSON object.
  12136. * @returns the JSON object
  12137. */
  12138. serialize(): any;
  12139. /**
  12140. * Parse properties from a JSON object
  12141. * @param serializationObject defines the JSON object
  12142. * @param scene defines the hosting scene
  12143. */
  12144. parse(serializationObject: any, scene: Scene): void;
  12145. }
  12146. }
  12147. declare module BABYLON {
  12148. /**
  12149. * Particle emitter emitting particles from the inside of a box.
  12150. * It emits the particles randomly between 2 given directions.
  12151. */
  12152. export class BoxParticleEmitter implements IParticleEmitterType {
  12153. /**
  12154. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12155. */
  12156. direction1: Vector3;
  12157. /**
  12158. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12159. */
  12160. direction2: Vector3;
  12161. /**
  12162. * 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.
  12163. */
  12164. minEmitBox: Vector3;
  12165. /**
  12166. * 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.
  12167. */
  12168. maxEmitBox: Vector3;
  12169. /**
  12170. * Creates a new instance BoxParticleEmitter
  12171. */
  12172. constructor();
  12173. /**
  12174. * Called by the particle System when the direction is computed for the created particle.
  12175. * @param worldMatrix is the world matrix of the particle system
  12176. * @param directionToUpdate is the direction vector to update with the result
  12177. * @param particle is the particle we are computed the direction for
  12178. * @param isLocal defines if the direction should be set in local space
  12179. */
  12180. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12181. /**
  12182. * Called by the particle System when the position is computed for the created particle.
  12183. * @param worldMatrix is the world matrix of the particle system
  12184. * @param positionToUpdate is the position vector to update with the result
  12185. * @param particle is the particle we are computed the position for
  12186. * @param isLocal defines if the position should be set in local space
  12187. */
  12188. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12189. /**
  12190. * Clones the current emitter and returns a copy of it
  12191. * @returns the new emitter
  12192. */
  12193. clone(): BoxParticleEmitter;
  12194. /**
  12195. * Called by the GPUParticleSystem to setup the update shader
  12196. * @param effect defines the update shader
  12197. */
  12198. applyToShader(effect: Effect): void;
  12199. /**
  12200. * Returns a string to use to update the GPU particles update shader
  12201. * @returns a string containng the defines string
  12202. */
  12203. getEffectDefines(): string;
  12204. /**
  12205. * Returns the string "BoxParticleEmitter"
  12206. * @returns a string containing the class name
  12207. */
  12208. getClassName(): string;
  12209. /**
  12210. * Serializes the particle system to a JSON object.
  12211. * @returns the JSON object
  12212. */
  12213. serialize(): any;
  12214. /**
  12215. * Parse properties from a JSON object
  12216. * @param serializationObject defines the JSON object
  12217. */
  12218. parse(serializationObject: any): void;
  12219. }
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * Particle emitter emitting particles from the inside of a cone.
  12224. * It emits the particles alongside the cone volume from the base to the particle.
  12225. * The emission direction might be randomized.
  12226. */
  12227. export class ConeParticleEmitter implements IParticleEmitterType {
  12228. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12229. directionRandomizer: number;
  12230. private _radius;
  12231. private _angle;
  12232. private _height;
  12233. /**
  12234. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12235. */
  12236. radiusRange: number;
  12237. /**
  12238. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12239. */
  12240. heightRange: number;
  12241. /**
  12242. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12243. */
  12244. emitFromSpawnPointOnly: boolean;
  12245. /**
  12246. * Gets or sets the radius of the emission cone
  12247. */
  12248. get radius(): number;
  12249. set radius(value: number);
  12250. /**
  12251. * Gets or sets the angle of the emission cone
  12252. */
  12253. get angle(): number;
  12254. set angle(value: number);
  12255. private _buildHeight;
  12256. /**
  12257. * Creates a new instance ConeParticleEmitter
  12258. * @param radius the radius of the emission cone (1 by default)
  12259. * @param angle the cone base angle (PI by default)
  12260. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12261. */
  12262. constructor(radius?: number, angle?: number,
  12263. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12264. directionRandomizer?: number);
  12265. /**
  12266. * Called by the particle System when the direction is computed for the created particle.
  12267. * @param worldMatrix is the world matrix of the particle system
  12268. * @param directionToUpdate is the direction vector to update with the result
  12269. * @param particle is the particle we are computed the direction for
  12270. * @param isLocal defines if the direction should be set in local space
  12271. */
  12272. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12273. /**
  12274. * Called by the particle System when the position is computed for the created particle.
  12275. * @param worldMatrix is the world matrix of the particle system
  12276. * @param positionToUpdate is the position vector to update with the result
  12277. * @param particle is the particle we are computed the position for
  12278. * @param isLocal defines if the position should be set in local space
  12279. */
  12280. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12281. /**
  12282. * Clones the current emitter and returns a copy of it
  12283. * @returns the new emitter
  12284. */
  12285. clone(): ConeParticleEmitter;
  12286. /**
  12287. * Called by the GPUParticleSystem to setup the update shader
  12288. * @param effect defines the update shader
  12289. */
  12290. applyToShader(effect: Effect): void;
  12291. /**
  12292. * Returns a string to use to update the GPU particles update shader
  12293. * @returns a string containng the defines string
  12294. */
  12295. getEffectDefines(): string;
  12296. /**
  12297. * Returns the string "ConeParticleEmitter"
  12298. * @returns a string containing the class name
  12299. */
  12300. getClassName(): string;
  12301. /**
  12302. * Serializes the particle system to a JSON object.
  12303. * @returns the JSON object
  12304. */
  12305. serialize(): any;
  12306. /**
  12307. * Parse properties from a JSON object
  12308. * @param serializationObject defines the JSON object
  12309. */
  12310. parse(serializationObject: any): void;
  12311. }
  12312. }
  12313. declare module BABYLON {
  12314. /**
  12315. * Particle emitter emitting particles from the inside of a cylinder.
  12316. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12317. */
  12318. export class CylinderParticleEmitter implements IParticleEmitterType {
  12319. /**
  12320. * The radius of the emission cylinder.
  12321. */
  12322. radius: number;
  12323. /**
  12324. * The height of the emission cylinder.
  12325. */
  12326. height: number;
  12327. /**
  12328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12329. */
  12330. radiusRange: number;
  12331. /**
  12332. * How much to randomize the particle direction [0-1].
  12333. */
  12334. directionRandomizer: number;
  12335. /**
  12336. * Creates a new instance CylinderParticleEmitter
  12337. * @param radius the radius of the emission cylinder (1 by default)
  12338. * @param height the height of the emission cylinder (1 by default)
  12339. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12340. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12341. */
  12342. constructor(
  12343. /**
  12344. * The radius of the emission cylinder.
  12345. */
  12346. radius?: number,
  12347. /**
  12348. * The height of the emission cylinder.
  12349. */
  12350. height?: number,
  12351. /**
  12352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12353. */
  12354. radiusRange?: number,
  12355. /**
  12356. * How much to randomize the particle direction [0-1].
  12357. */
  12358. directionRandomizer?: number);
  12359. /**
  12360. * Called by the particle System when the direction is computed for the created particle.
  12361. * @param worldMatrix is the world matrix of the particle system
  12362. * @param directionToUpdate is the direction vector to update with the result
  12363. * @param particle is the particle we are computed the direction for
  12364. * @param isLocal defines if the direction should be set in local space
  12365. */
  12366. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12367. /**
  12368. * Called by the particle System when the position is computed for the created particle.
  12369. * @param worldMatrix is the world matrix of the particle system
  12370. * @param positionToUpdate is the position vector to update with the result
  12371. * @param particle is the particle we are computed the position for
  12372. * @param isLocal defines if the position should be set in local space
  12373. */
  12374. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12375. /**
  12376. * Clones the current emitter and returns a copy of it
  12377. * @returns the new emitter
  12378. */
  12379. clone(): CylinderParticleEmitter;
  12380. /**
  12381. * Called by the GPUParticleSystem to setup the update shader
  12382. * @param effect defines the update shader
  12383. */
  12384. applyToShader(effect: Effect): void;
  12385. /**
  12386. * Returns a string to use to update the GPU particles update shader
  12387. * @returns a string containng the defines string
  12388. */
  12389. getEffectDefines(): string;
  12390. /**
  12391. * Returns the string "CylinderParticleEmitter"
  12392. * @returns a string containing the class name
  12393. */
  12394. getClassName(): string;
  12395. /**
  12396. * Serializes the particle system to a JSON object.
  12397. * @returns the JSON object
  12398. */
  12399. serialize(): any;
  12400. /**
  12401. * Parse properties from a JSON object
  12402. * @param serializationObject defines the JSON object
  12403. */
  12404. parse(serializationObject: any): void;
  12405. }
  12406. /**
  12407. * Particle emitter emitting particles from the inside of a cylinder.
  12408. * It emits the particles randomly between two vectors.
  12409. */
  12410. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12411. /**
  12412. * The min limit of the emission direction.
  12413. */
  12414. direction1: Vector3;
  12415. /**
  12416. * The max limit of the emission direction.
  12417. */
  12418. direction2: Vector3;
  12419. /**
  12420. * Creates a new instance CylinderDirectedParticleEmitter
  12421. * @param radius the radius of the emission cylinder (1 by default)
  12422. * @param height the height of the emission cylinder (1 by default)
  12423. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12424. * @param direction1 the min limit of the emission direction (up vector by default)
  12425. * @param direction2 the max limit of the emission direction (up vector by default)
  12426. */
  12427. constructor(radius?: number, height?: number, radiusRange?: number,
  12428. /**
  12429. * The min limit of the emission direction.
  12430. */
  12431. direction1?: Vector3,
  12432. /**
  12433. * The max limit of the emission direction.
  12434. */
  12435. direction2?: Vector3);
  12436. /**
  12437. * Called by the particle System when the direction is computed for the created particle.
  12438. * @param worldMatrix is the world matrix of the particle system
  12439. * @param directionToUpdate is the direction vector to update with the result
  12440. * @param particle is the particle we are computed the direction for
  12441. */
  12442. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12443. /**
  12444. * Clones the current emitter and returns a copy of it
  12445. * @returns the new emitter
  12446. */
  12447. clone(): CylinderDirectedParticleEmitter;
  12448. /**
  12449. * Called by the GPUParticleSystem to setup the update shader
  12450. * @param effect defines the update shader
  12451. */
  12452. applyToShader(effect: Effect): void;
  12453. /**
  12454. * Returns a string to use to update the GPU particles update shader
  12455. * @returns a string containng the defines string
  12456. */
  12457. getEffectDefines(): string;
  12458. /**
  12459. * Returns the string "CylinderDirectedParticleEmitter"
  12460. * @returns a string containing the class name
  12461. */
  12462. getClassName(): string;
  12463. /**
  12464. * Serializes the particle system to a JSON object.
  12465. * @returns the JSON object
  12466. */
  12467. serialize(): any;
  12468. /**
  12469. * Parse properties from a JSON object
  12470. * @param serializationObject defines the JSON object
  12471. */
  12472. parse(serializationObject: any): void;
  12473. }
  12474. }
  12475. declare module BABYLON {
  12476. /**
  12477. * Particle emitter emitting particles from the inside of a hemisphere.
  12478. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12479. */
  12480. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12481. /**
  12482. * The radius of the emission hemisphere.
  12483. */
  12484. radius: number;
  12485. /**
  12486. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12487. */
  12488. radiusRange: number;
  12489. /**
  12490. * How much to randomize the particle direction [0-1].
  12491. */
  12492. directionRandomizer: number;
  12493. /**
  12494. * Creates a new instance HemisphericParticleEmitter
  12495. * @param radius the radius of the emission hemisphere (1 by default)
  12496. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12498. */
  12499. constructor(
  12500. /**
  12501. * The radius of the emission hemisphere.
  12502. */
  12503. radius?: number,
  12504. /**
  12505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12506. */
  12507. radiusRange?: number,
  12508. /**
  12509. * How much to randomize the particle direction [0-1].
  12510. */
  12511. directionRandomizer?: number);
  12512. /**
  12513. * Called by the particle System when the direction is computed for the created particle.
  12514. * @param worldMatrix is the world matrix of the particle system
  12515. * @param directionToUpdate is the direction vector to update with the result
  12516. * @param particle is the particle we are computed the direction for
  12517. * @param isLocal defines if the direction should be set in local space
  12518. */
  12519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12520. /**
  12521. * Called by the particle System when the position is computed for the created particle.
  12522. * @param worldMatrix is the world matrix of the particle system
  12523. * @param positionToUpdate is the position vector to update with the result
  12524. * @param particle is the particle we are computed the position for
  12525. * @param isLocal defines if the position should be set in local space
  12526. */
  12527. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12528. /**
  12529. * Clones the current emitter and returns a copy of it
  12530. * @returns the new emitter
  12531. */
  12532. clone(): HemisphericParticleEmitter;
  12533. /**
  12534. * Called by the GPUParticleSystem to setup the update shader
  12535. * @param effect defines the update shader
  12536. */
  12537. applyToShader(effect: Effect): void;
  12538. /**
  12539. * Returns a string to use to update the GPU particles update shader
  12540. * @returns a string containng the defines string
  12541. */
  12542. getEffectDefines(): string;
  12543. /**
  12544. * Returns the string "HemisphericParticleEmitter"
  12545. * @returns a string containing the class name
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Serializes the particle system to a JSON object.
  12550. * @returns the JSON object
  12551. */
  12552. serialize(): any;
  12553. /**
  12554. * Parse properties from a JSON object
  12555. * @param serializationObject defines the JSON object
  12556. */
  12557. parse(serializationObject: any): void;
  12558. }
  12559. }
  12560. declare module BABYLON {
  12561. /**
  12562. * Particle emitter emitting particles from a point.
  12563. * It emits the particles randomly between 2 given directions.
  12564. */
  12565. export class PointParticleEmitter implements IParticleEmitterType {
  12566. /**
  12567. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12568. */
  12569. direction1: Vector3;
  12570. /**
  12571. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12572. */
  12573. direction2: Vector3;
  12574. /**
  12575. * Creates a new instance PointParticleEmitter
  12576. */
  12577. constructor();
  12578. /**
  12579. * Called by the particle System when the direction is computed for the created particle.
  12580. * @param worldMatrix is the world matrix of the particle system
  12581. * @param directionToUpdate is the direction vector to update with the result
  12582. * @param particle is the particle we are computed the direction for
  12583. * @param isLocal defines if the direction should be set in local space
  12584. */
  12585. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12586. /**
  12587. * Called by the particle System when the position is computed for the created particle.
  12588. * @param worldMatrix is the world matrix of the particle system
  12589. * @param positionToUpdate is the position vector to update with the result
  12590. * @param particle is the particle we are computed the position for
  12591. * @param isLocal defines if the position should be set in local space
  12592. */
  12593. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12594. /**
  12595. * Clones the current emitter and returns a copy of it
  12596. * @returns the new emitter
  12597. */
  12598. clone(): PointParticleEmitter;
  12599. /**
  12600. * Called by the GPUParticleSystem to setup the update shader
  12601. * @param effect defines the update shader
  12602. */
  12603. applyToShader(effect: Effect): void;
  12604. /**
  12605. * Returns a string to use to update the GPU particles update shader
  12606. * @returns a string containng the defines string
  12607. */
  12608. getEffectDefines(): string;
  12609. /**
  12610. * Returns the string "PointParticleEmitter"
  12611. * @returns a string containing the class name
  12612. */
  12613. getClassName(): string;
  12614. /**
  12615. * Serializes the particle system to a JSON object.
  12616. * @returns the JSON object
  12617. */
  12618. serialize(): any;
  12619. /**
  12620. * Parse properties from a JSON object
  12621. * @param serializationObject defines the JSON object
  12622. */
  12623. parse(serializationObject: any): void;
  12624. }
  12625. }
  12626. declare module BABYLON {
  12627. /**
  12628. * Particle emitter emitting particles from the inside of a sphere.
  12629. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12630. */
  12631. export class SphereParticleEmitter implements IParticleEmitterType {
  12632. /**
  12633. * The radius of the emission sphere.
  12634. */
  12635. radius: number;
  12636. /**
  12637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12638. */
  12639. radiusRange: number;
  12640. /**
  12641. * How much to randomize the particle direction [0-1].
  12642. */
  12643. directionRandomizer: number;
  12644. /**
  12645. * Creates a new instance SphereParticleEmitter
  12646. * @param radius the radius of the emission sphere (1 by default)
  12647. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12648. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12649. */
  12650. constructor(
  12651. /**
  12652. * The radius of the emission sphere.
  12653. */
  12654. radius?: number,
  12655. /**
  12656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12657. */
  12658. radiusRange?: number,
  12659. /**
  12660. * How much to randomize the particle direction [0-1].
  12661. */
  12662. directionRandomizer?: number);
  12663. /**
  12664. * Called by the particle System when the direction is computed for the created particle.
  12665. * @param worldMatrix is the world matrix of the particle system
  12666. * @param directionToUpdate is the direction vector to update with the result
  12667. * @param particle is the particle we are computed the direction for
  12668. * @param isLocal defines if the direction should be set in local space
  12669. */
  12670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12671. /**
  12672. * Called by the particle System when the position is computed for the created particle.
  12673. * @param worldMatrix is the world matrix of the particle system
  12674. * @param positionToUpdate is the position vector to update with the result
  12675. * @param particle is the particle we are computed the position for
  12676. * @param isLocal defines if the position should be set in local space
  12677. */
  12678. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12679. /**
  12680. * Clones the current emitter and returns a copy of it
  12681. * @returns the new emitter
  12682. */
  12683. clone(): SphereParticleEmitter;
  12684. /**
  12685. * Called by the GPUParticleSystem to setup the update shader
  12686. * @param effect defines the update shader
  12687. */
  12688. applyToShader(effect: Effect): void;
  12689. /**
  12690. * Returns a string to use to update the GPU particles update shader
  12691. * @returns a string containng the defines string
  12692. */
  12693. getEffectDefines(): string;
  12694. /**
  12695. * Returns the string "SphereParticleEmitter"
  12696. * @returns a string containing the class name
  12697. */
  12698. getClassName(): string;
  12699. /**
  12700. * Serializes the particle system to a JSON object.
  12701. * @returns the JSON object
  12702. */
  12703. serialize(): any;
  12704. /**
  12705. * Parse properties from a JSON object
  12706. * @param serializationObject defines the JSON object
  12707. */
  12708. parse(serializationObject: any): void;
  12709. }
  12710. /**
  12711. * Particle emitter emitting particles from the inside of a sphere.
  12712. * It emits the particles randomly between two vectors.
  12713. */
  12714. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12715. /**
  12716. * The min limit of the emission direction.
  12717. */
  12718. direction1: Vector3;
  12719. /**
  12720. * The max limit of the emission direction.
  12721. */
  12722. direction2: Vector3;
  12723. /**
  12724. * Creates a new instance SphereDirectedParticleEmitter
  12725. * @param radius the radius of the emission sphere (1 by default)
  12726. * @param direction1 the min limit of the emission direction (up vector by default)
  12727. * @param direction2 the max limit of the emission direction (up vector by default)
  12728. */
  12729. constructor(radius?: number,
  12730. /**
  12731. * The min limit of the emission direction.
  12732. */
  12733. direction1?: Vector3,
  12734. /**
  12735. * The max limit of the emission direction.
  12736. */
  12737. direction2?: Vector3);
  12738. /**
  12739. * Called by the particle System when the direction is computed for the created particle.
  12740. * @param worldMatrix is the world matrix of the particle system
  12741. * @param directionToUpdate is the direction vector to update with the result
  12742. * @param particle is the particle we are computed the direction for
  12743. */
  12744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12745. /**
  12746. * Clones the current emitter and returns a copy of it
  12747. * @returns the new emitter
  12748. */
  12749. clone(): SphereDirectedParticleEmitter;
  12750. /**
  12751. * Called by the GPUParticleSystem to setup the update shader
  12752. * @param effect defines the update shader
  12753. */
  12754. applyToShader(effect: Effect): void;
  12755. /**
  12756. * Returns a string to use to update the GPU particles update shader
  12757. * @returns a string containng the defines string
  12758. */
  12759. getEffectDefines(): string;
  12760. /**
  12761. * Returns the string "SphereDirectedParticleEmitter"
  12762. * @returns a string containing the class name
  12763. */
  12764. getClassName(): string;
  12765. /**
  12766. * Serializes the particle system to a JSON object.
  12767. * @returns the JSON object
  12768. */
  12769. serialize(): any;
  12770. /**
  12771. * Parse properties from a JSON object
  12772. * @param serializationObject defines the JSON object
  12773. */
  12774. parse(serializationObject: any): void;
  12775. }
  12776. }
  12777. declare module BABYLON {
  12778. /**
  12779. * Particle emitter emitting particles from a custom list of positions.
  12780. */
  12781. export class CustomParticleEmitter implements IParticleEmitterType {
  12782. /**
  12783. * Gets or sets the position generator that will create the inital position of each particle.
  12784. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12785. */
  12786. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12787. /**
  12788. * Gets or sets the destination generator that will create the final destination of each particle.
  12789. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12790. */
  12791. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12792. /**
  12793. * Creates a new instance CustomParticleEmitter
  12794. */
  12795. constructor();
  12796. /**
  12797. * Called by the particle System when the direction is computed for the created particle.
  12798. * @param worldMatrix is the world matrix of the particle system
  12799. * @param directionToUpdate is the direction vector to update with the result
  12800. * @param particle is the particle we are computed the direction for
  12801. * @param isLocal defines if the direction should be set in local space
  12802. */
  12803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12804. /**
  12805. * Called by the particle System when the position is computed for the created particle.
  12806. * @param worldMatrix is the world matrix of the particle system
  12807. * @param positionToUpdate is the position vector to update with the result
  12808. * @param particle is the particle we are computed the position for
  12809. * @param isLocal defines if the position should be set in local space
  12810. */
  12811. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12812. /**
  12813. * Clones the current emitter and returns a copy of it
  12814. * @returns the new emitter
  12815. */
  12816. clone(): CustomParticleEmitter;
  12817. /**
  12818. * Called by the GPUParticleSystem to setup the update shader
  12819. * @param effect defines the update shader
  12820. */
  12821. applyToShader(effect: Effect): void;
  12822. /**
  12823. * Returns a string to use to update the GPU particles update shader
  12824. * @returns a string containng the defines string
  12825. */
  12826. getEffectDefines(): string;
  12827. /**
  12828. * Returns the string "PointParticleEmitter"
  12829. * @returns a string containing the class name
  12830. */
  12831. getClassName(): string;
  12832. /**
  12833. * Serializes the particle system to a JSON object.
  12834. * @returns the JSON object
  12835. */
  12836. serialize(): any;
  12837. /**
  12838. * Parse properties from a JSON object
  12839. * @param serializationObject defines the JSON object
  12840. */
  12841. parse(serializationObject: any): void;
  12842. }
  12843. }
  12844. declare module BABYLON {
  12845. /**
  12846. * Particle emitter emitting particles from the inside of a box.
  12847. * It emits the particles randomly between 2 given directions.
  12848. */
  12849. export class MeshParticleEmitter implements IParticleEmitterType {
  12850. private _indices;
  12851. private _positions;
  12852. private _normals;
  12853. private _storedNormal;
  12854. private _mesh;
  12855. /**
  12856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12857. */
  12858. direction1: Vector3;
  12859. /**
  12860. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12861. */
  12862. direction2: Vector3;
  12863. /**
  12864. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12865. */
  12866. useMeshNormalsForDirection: boolean;
  12867. /** Defines the mesh to use as source */
  12868. get mesh(): Nullable<AbstractMesh>;
  12869. set mesh(value: Nullable<AbstractMesh>);
  12870. /**
  12871. * Creates a new instance MeshParticleEmitter
  12872. * @param mesh defines the mesh to use as source
  12873. */
  12874. constructor(mesh?: Nullable<AbstractMesh>);
  12875. /**
  12876. * Called by the particle System when the direction is computed for the created particle.
  12877. * @param worldMatrix is the world matrix of the particle system
  12878. * @param directionToUpdate is the direction vector to update with the result
  12879. * @param particle is the particle we are computed the direction for
  12880. * @param isLocal defines if the direction should be set in local space
  12881. */
  12882. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12883. /**
  12884. * Called by the particle System when the position is computed for the created particle.
  12885. * @param worldMatrix is the world matrix of the particle system
  12886. * @param positionToUpdate is the position vector to update with the result
  12887. * @param particle is the particle we are computed the position for
  12888. * @param isLocal defines if the position should be set in local space
  12889. */
  12890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12891. /**
  12892. * Clones the current emitter and returns a copy of it
  12893. * @returns the new emitter
  12894. */
  12895. clone(): MeshParticleEmitter;
  12896. /**
  12897. * Called by the GPUParticleSystem to setup the update shader
  12898. * @param effect defines the update shader
  12899. */
  12900. applyToShader(effect: Effect): void;
  12901. /**
  12902. * Returns a string to use to update the GPU particles update shader
  12903. * @returns a string containng the defines string
  12904. */
  12905. getEffectDefines(): string;
  12906. /**
  12907. * Returns the string "BoxParticleEmitter"
  12908. * @returns a string containing the class name
  12909. */
  12910. getClassName(): string;
  12911. /**
  12912. * Serializes the particle system to a JSON object.
  12913. * @returns the JSON object
  12914. */
  12915. serialize(): any;
  12916. /**
  12917. * Parse properties from a JSON object
  12918. * @param serializationObject defines the JSON object
  12919. * @param scene defines the hosting scene
  12920. */
  12921. parse(serializationObject: any, scene: Scene): void;
  12922. }
  12923. }
  12924. declare module BABYLON {
  12925. /**
  12926. * Interface representing a particle system in Babylon.js.
  12927. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12928. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12929. */
  12930. export interface IParticleSystem {
  12931. /**
  12932. * List of animations used by the particle system.
  12933. */
  12934. animations: Animation[];
  12935. /**
  12936. * The id of the Particle system.
  12937. */
  12938. id: string;
  12939. /**
  12940. * The name of the Particle system.
  12941. */
  12942. name: string;
  12943. /**
  12944. * The emitter represents the Mesh or position we are attaching the particle system to.
  12945. */
  12946. emitter: Nullable<AbstractMesh | Vector3>;
  12947. /**
  12948. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12949. */
  12950. isBillboardBased: boolean;
  12951. /**
  12952. * The rendering group used by the Particle system to chose when to render.
  12953. */
  12954. renderingGroupId: number;
  12955. /**
  12956. * The layer mask we are rendering the particles through.
  12957. */
  12958. layerMask: number;
  12959. /**
  12960. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12961. */
  12962. updateSpeed: number;
  12963. /**
  12964. * The amount of time the particle system is running (depends of the overall update speed).
  12965. */
  12966. targetStopDuration: number;
  12967. /**
  12968. * The texture used to render each particle. (this can be a spritesheet)
  12969. */
  12970. particleTexture: Nullable<Texture>;
  12971. /**
  12972. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12973. */
  12974. blendMode: number;
  12975. /**
  12976. * Minimum life time of emitting particles.
  12977. */
  12978. minLifeTime: number;
  12979. /**
  12980. * Maximum life time of emitting particles.
  12981. */
  12982. maxLifeTime: number;
  12983. /**
  12984. * Minimum Size of emitting particles.
  12985. */
  12986. minSize: number;
  12987. /**
  12988. * Maximum Size of emitting particles.
  12989. */
  12990. maxSize: number;
  12991. /**
  12992. * Minimum scale of emitting particles on X axis.
  12993. */
  12994. minScaleX: number;
  12995. /**
  12996. * Maximum scale of emitting particles on X axis.
  12997. */
  12998. maxScaleX: number;
  12999. /**
  13000. * Minimum scale of emitting particles on Y axis.
  13001. */
  13002. minScaleY: number;
  13003. /**
  13004. * Maximum scale of emitting particles on Y axis.
  13005. */
  13006. maxScaleY: number;
  13007. /**
  13008. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13009. */
  13010. color1: Color4;
  13011. /**
  13012. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13013. */
  13014. color2: Color4;
  13015. /**
  13016. * Color the particle will have at the end of its lifetime.
  13017. */
  13018. colorDead: Color4;
  13019. /**
  13020. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13021. */
  13022. emitRate: number;
  13023. /**
  13024. * You can use gravity if you want to give an orientation to your particles.
  13025. */
  13026. gravity: Vector3;
  13027. /**
  13028. * Minimum power of emitting particles.
  13029. */
  13030. minEmitPower: number;
  13031. /**
  13032. * Maximum power of emitting particles.
  13033. */
  13034. maxEmitPower: number;
  13035. /**
  13036. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13037. */
  13038. minAngularSpeed: number;
  13039. /**
  13040. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13041. */
  13042. maxAngularSpeed: number;
  13043. /**
  13044. * Gets or sets the minimal initial rotation in radians.
  13045. */
  13046. minInitialRotation: number;
  13047. /**
  13048. * Gets or sets the maximal initial rotation in radians.
  13049. */
  13050. maxInitialRotation: number;
  13051. /**
  13052. * The particle emitter type defines the emitter used by the particle system.
  13053. * It can be for example box, sphere, or cone...
  13054. */
  13055. particleEmitterType: Nullable<IParticleEmitterType>;
  13056. /**
  13057. * Defines the delay in milliseconds before starting the system (0 by default)
  13058. */
  13059. startDelay: number;
  13060. /**
  13061. * 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
  13062. */
  13063. preWarmCycles: number;
  13064. /**
  13065. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13066. */
  13067. preWarmStepOffset: number;
  13068. /**
  13069. * 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)
  13070. */
  13071. spriteCellChangeSpeed: number;
  13072. /**
  13073. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13074. */
  13075. startSpriteCellID: number;
  13076. /**
  13077. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13078. */
  13079. endSpriteCellID: number;
  13080. /**
  13081. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13082. */
  13083. spriteCellWidth: number;
  13084. /**
  13085. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13086. */
  13087. spriteCellHeight: number;
  13088. /**
  13089. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13090. */
  13091. spriteRandomStartCell: boolean;
  13092. /**
  13093. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13094. */
  13095. isAnimationSheetEnabled: boolean;
  13096. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13097. translationPivot: Vector2;
  13098. /**
  13099. * Gets or sets a texture used to add random noise to particle positions
  13100. */
  13101. noiseTexture: Nullable<BaseTexture>;
  13102. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13103. noiseStrength: Vector3;
  13104. /**
  13105. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13106. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13107. */
  13108. billboardMode: number;
  13109. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13110. limitVelocityDamping: number;
  13111. /**
  13112. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13113. */
  13114. beginAnimationOnStart: boolean;
  13115. /**
  13116. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13117. */
  13118. beginAnimationFrom: number;
  13119. /**
  13120. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13121. */
  13122. beginAnimationTo: number;
  13123. /**
  13124. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13125. */
  13126. beginAnimationLoop: boolean;
  13127. /**
  13128. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13129. */
  13130. disposeOnStop: boolean;
  13131. /**
  13132. * Specifies if the particles are updated in emitter local space or world space
  13133. */
  13134. isLocal: boolean;
  13135. /**
  13136. * Gets the maximum number of particles active at the same time.
  13137. * @returns The max number of active particles.
  13138. */
  13139. getCapacity(): number;
  13140. /**
  13141. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13142. * @returns True if it has been started, otherwise false.
  13143. */
  13144. isStarted(): boolean;
  13145. /**
  13146. * Animates the particle system for this frame.
  13147. */
  13148. animate(): void;
  13149. /**
  13150. * Renders the particle system in its current state.
  13151. * @returns the current number of particles
  13152. */
  13153. render(): number;
  13154. /**
  13155. * Dispose the particle system and frees its associated resources.
  13156. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13157. */
  13158. dispose(disposeTexture?: boolean): void;
  13159. /**
  13160. * Clones the particle system.
  13161. * @param name The name of the cloned object
  13162. * @param newEmitter The new emitter to use
  13163. * @returns the cloned particle system
  13164. */
  13165. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13166. /**
  13167. * Serializes the particle system to a JSON object.
  13168. * @returns the JSON object
  13169. */
  13170. serialize(): any;
  13171. /**
  13172. * Rebuild the particle system
  13173. */
  13174. rebuild(): void;
  13175. /**
  13176. * Starts the particle system and begins to emit
  13177. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13178. */
  13179. start(delay?: number): void;
  13180. /**
  13181. * Stops the particle system.
  13182. */
  13183. stop(): void;
  13184. /**
  13185. * Remove all active particles
  13186. */
  13187. reset(): void;
  13188. /**
  13189. * Is this system ready to be used/rendered
  13190. * @return true if the system is ready
  13191. */
  13192. isReady(): boolean;
  13193. /**
  13194. * Returns the string "ParticleSystem"
  13195. * @returns a string containing the class name
  13196. */
  13197. getClassName(): string;
  13198. /**
  13199. * Adds a new color gradient
  13200. * @param gradient defines the gradient to use (between 0 and 1)
  13201. * @param color1 defines the color to affect to the specified gradient
  13202. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13203. * @returns the current particle system
  13204. */
  13205. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13206. /**
  13207. * Remove a specific color gradient
  13208. * @param gradient defines the gradient to remove
  13209. * @returns the current particle system
  13210. */
  13211. removeColorGradient(gradient: number): IParticleSystem;
  13212. /**
  13213. * Adds a new size gradient
  13214. * @param gradient defines the gradient to use (between 0 and 1)
  13215. * @param factor defines the size factor to affect to the specified gradient
  13216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13217. * @returns the current particle system
  13218. */
  13219. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13220. /**
  13221. * Remove a specific size gradient
  13222. * @param gradient defines the gradient to remove
  13223. * @returns the current particle system
  13224. */
  13225. removeSizeGradient(gradient: number): IParticleSystem;
  13226. /**
  13227. * Gets the current list of color gradients.
  13228. * You must use addColorGradient and removeColorGradient to udpate this list
  13229. * @returns the list of color gradients
  13230. */
  13231. getColorGradients(): Nullable<Array<ColorGradient>>;
  13232. /**
  13233. * Gets the current list of size gradients.
  13234. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13235. * @returns the list of size gradients
  13236. */
  13237. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13238. /**
  13239. * Gets the current list of angular speed gradients.
  13240. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13241. * @returns the list of angular speed gradients
  13242. */
  13243. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13244. /**
  13245. * Adds a new angular speed gradient
  13246. * @param gradient defines the gradient to use (between 0 and 1)
  13247. * @param factor defines the angular speed to affect to the specified gradient
  13248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13249. * @returns the current particle system
  13250. */
  13251. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13252. /**
  13253. * Remove a specific angular speed gradient
  13254. * @param gradient defines the gradient to remove
  13255. * @returns the current particle system
  13256. */
  13257. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13258. /**
  13259. * Gets the current list of velocity gradients.
  13260. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13261. * @returns the list of velocity gradients
  13262. */
  13263. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13264. /**
  13265. * Adds a new velocity gradient
  13266. * @param gradient defines the gradient to use (between 0 and 1)
  13267. * @param factor defines the velocity to affect to the specified gradient
  13268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13269. * @returns the current particle system
  13270. */
  13271. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13272. /**
  13273. * Remove a specific velocity gradient
  13274. * @param gradient defines the gradient to remove
  13275. * @returns the current particle system
  13276. */
  13277. removeVelocityGradient(gradient: number): IParticleSystem;
  13278. /**
  13279. * Gets the current list of limit velocity gradients.
  13280. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13281. * @returns the list of limit velocity gradients
  13282. */
  13283. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13284. /**
  13285. * Adds a new limit velocity gradient
  13286. * @param gradient defines the gradient to use (between 0 and 1)
  13287. * @param factor defines the limit velocity to affect to the specified gradient
  13288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13289. * @returns the current particle system
  13290. */
  13291. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13292. /**
  13293. * Remove a specific limit velocity gradient
  13294. * @param gradient defines the gradient to remove
  13295. * @returns the current particle system
  13296. */
  13297. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13298. /**
  13299. * Adds a new drag gradient
  13300. * @param gradient defines the gradient to use (between 0 and 1)
  13301. * @param factor defines the drag to affect to the specified gradient
  13302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13303. * @returns the current particle system
  13304. */
  13305. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13306. /**
  13307. * Remove a specific drag gradient
  13308. * @param gradient defines the gradient to remove
  13309. * @returns the current particle system
  13310. */
  13311. removeDragGradient(gradient: number): IParticleSystem;
  13312. /**
  13313. * Gets the current list of drag gradients.
  13314. * You must use addDragGradient and removeDragGradient to udpate this list
  13315. * @returns the list of drag gradients
  13316. */
  13317. getDragGradients(): Nullable<Array<FactorGradient>>;
  13318. /**
  13319. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13320. * @param gradient defines the gradient to use (between 0 and 1)
  13321. * @param factor defines the emit rate to affect to the specified gradient
  13322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13323. * @returns the current particle system
  13324. */
  13325. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13326. /**
  13327. * Remove a specific emit rate gradient
  13328. * @param gradient defines the gradient to remove
  13329. * @returns the current particle system
  13330. */
  13331. removeEmitRateGradient(gradient: number): IParticleSystem;
  13332. /**
  13333. * Gets the current list of emit rate gradients.
  13334. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13335. * @returns the list of emit rate gradients
  13336. */
  13337. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13338. /**
  13339. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13340. * @param gradient defines the gradient to use (between 0 and 1)
  13341. * @param factor defines the start size to affect to the specified gradient
  13342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13343. * @returns the current particle system
  13344. */
  13345. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13346. /**
  13347. * Remove a specific start size gradient
  13348. * @param gradient defines the gradient to remove
  13349. * @returns the current particle system
  13350. */
  13351. removeStartSizeGradient(gradient: number): IParticleSystem;
  13352. /**
  13353. * Gets the current list of start size gradients.
  13354. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13355. * @returns the list of start size gradients
  13356. */
  13357. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13358. /**
  13359. * Adds a new life time gradient
  13360. * @param gradient defines the gradient to use (between 0 and 1)
  13361. * @param factor defines the life time factor to affect to the specified gradient
  13362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13363. * @returns the current particle system
  13364. */
  13365. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13366. /**
  13367. * Remove a specific life time gradient
  13368. * @param gradient defines the gradient to remove
  13369. * @returns the current particle system
  13370. */
  13371. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13372. /**
  13373. * Gets the current list of life time gradients.
  13374. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13375. * @returns the list of life time gradients
  13376. */
  13377. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13378. /**
  13379. * Gets the current list of color gradients.
  13380. * You must use addColorGradient and removeColorGradient to udpate this list
  13381. * @returns the list of color gradients
  13382. */
  13383. getColorGradients(): Nullable<Array<ColorGradient>>;
  13384. /**
  13385. * Adds a new ramp gradient used to remap particle colors
  13386. * @param gradient defines the gradient to use (between 0 and 1)
  13387. * @param color defines the color to affect to the specified gradient
  13388. * @returns the current particle system
  13389. */
  13390. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13391. /**
  13392. * Gets the current list of ramp gradients.
  13393. * You must use addRampGradient and removeRampGradient to udpate this list
  13394. * @returns the list of ramp gradients
  13395. */
  13396. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13397. /** Gets or sets a boolean indicating that ramp gradients must be used
  13398. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13399. */
  13400. useRampGradients: boolean;
  13401. /**
  13402. * Adds a new color remap gradient
  13403. * @param gradient defines the gradient to use (between 0 and 1)
  13404. * @param min defines the color remap minimal range
  13405. * @param max defines the color remap maximal range
  13406. * @returns the current particle system
  13407. */
  13408. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13409. /**
  13410. * Gets the current list of color remap gradients.
  13411. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13412. * @returns the list of color remap gradients
  13413. */
  13414. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13415. /**
  13416. * Adds a new alpha remap gradient
  13417. * @param gradient defines the gradient to use (between 0 and 1)
  13418. * @param min defines the alpha remap minimal range
  13419. * @param max defines the alpha remap maximal range
  13420. * @returns the current particle system
  13421. */
  13422. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13423. /**
  13424. * Gets the current list of alpha remap gradients.
  13425. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13426. * @returns the list of alpha remap gradients
  13427. */
  13428. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13429. /**
  13430. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13431. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13432. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13433. * @returns the emitter
  13434. */
  13435. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13436. /**
  13437. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13438. * @param radius The radius of the hemisphere to emit from
  13439. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13440. * @returns the emitter
  13441. */
  13442. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13443. /**
  13444. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13445. * @param radius The radius of the sphere to emit from
  13446. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13447. * @returns the emitter
  13448. */
  13449. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13450. /**
  13451. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13452. * @param radius The radius of the sphere to emit from
  13453. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13454. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13455. * @returns the emitter
  13456. */
  13457. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13458. /**
  13459. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13460. * @param radius The radius of the emission cylinder
  13461. * @param height The height of the emission cylinder
  13462. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13463. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13464. * @returns the emitter
  13465. */
  13466. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13467. /**
  13468. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13469. * @param radius The radius of the cylinder to emit from
  13470. * @param height The height of the emission cylinder
  13471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13472. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13473. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13474. * @returns the emitter
  13475. */
  13476. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13477. /**
  13478. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13479. * @param radius The radius of the cone to emit from
  13480. * @param angle The base angle of the cone
  13481. * @returns the emitter
  13482. */
  13483. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13484. /**
  13485. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13488. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13489. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13490. * @returns the emitter
  13491. */
  13492. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13493. /**
  13494. * Get hosting scene
  13495. * @returns the scene
  13496. */
  13497. getScene(): Scene;
  13498. }
  13499. }
  13500. declare module BABYLON {
  13501. /**
  13502. * 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.
  13503. * @see https://doc.babylonjs.com/how_to/transformnode
  13504. */
  13505. export class TransformNode extends Node {
  13506. /**
  13507. * Object will not rotate to face the camera
  13508. */
  13509. static BILLBOARDMODE_NONE: number;
  13510. /**
  13511. * Object will rotate to face the camera but only on the x axis
  13512. */
  13513. static BILLBOARDMODE_X: number;
  13514. /**
  13515. * Object will rotate to face the camera but only on the y axis
  13516. */
  13517. static BILLBOARDMODE_Y: number;
  13518. /**
  13519. * Object will rotate to face the camera but only on the z axis
  13520. */
  13521. static BILLBOARDMODE_Z: number;
  13522. /**
  13523. * Object will rotate to face the camera
  13524. */
  13525. static BILLBOARDMODE_ALL: number;
  13526. /**
  13527. * Object will rotate to face the camera's position instead of orientation
  13528. */
  13529. static BILLBOARDMODE_USE_POSITION: number;
  13530. private _forward;
  13531. private _forwardInverted;
  13532. private _up;
  13533. private _right;
  13534. private _rightInverted;
  13535. private _position;
  13536. private _rotation;
  13537. private _rotationQuaternion;
  13538. protected _scaling: Vector3;
  13539. protected _isDirty: boolean;
  13540. private _transformToBoneReferal;
  13541. private _isAbsoluteSynced;
  13542. private _billboardMode;
  13543. /**
  13544. * Gets or sets the billboard mode. Default is 0.
  13545. *
  13546. * | Value | Type | Description |
  13547. * | --- | --- | --- |
  13548. * | 0 | BILLBOARDMODE_NONE | |
  13549. * | 1 | BILLBOARDMODE_X | |
  13550. * | 2 | BILLBOARDMODE_Y | |
  13551. * | 4 | BILLBOARDMODE_Z | |
  13552. * | 7 | BILLBOARDMODE_ALL | |
  13553. *
  13554. */
  13555. get billboardMode(): number;
  13556. set billboardMode(value: number);
  13557. private _preserveParentRotationForBillboard;
  13558. /**
  13559. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13560. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13561. */
  13562. get preserveParentRotationForBillboard(): boolean;
  13563. set preserveParentRotationForBillboard(value: boolean);
  13564. /**
  13565. * 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
  13566. */
  13567. scalingDeterminant: number;
  13568. private _infiniteDistance;
  13569. /**
  13570. * Gets or sets the distance of the object to max, often used by skybox
  13571. */
  13572. get infiniteDistance(): boolean;
  13573. set infiniteDistance(value: boolean);
  13574. /**
  13575. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13576. * By default the system will update normals to compensate
  13577. */
  13578. ignoreNonUniformScaling: boolean;
  13579. /**
  13580. * 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
  13581. */
  13582. reIntegrateRotationIntoRotationQuaternion: boolean;
  13583. /** @hidden */
  13584. _poseMatrix: Nullable<Matrix>;
  13585. /** @hidden */
  13586. _localMatrix: Matrix;
  13587. private _usePivotMatrix;
  13588. private _absolutePosition;
  13589. private _absoluteScaling;
  13590. private _absoluteRotationQuaternion;
  13591. private _pivotMatrix;
  13592. private _pivotMatrixInverse;
  13593. protected _postMultiplyPivotMatrix: boolean;
  13594. protected _isWorldMatrixFrozen: boolean;
  13595. /** @hidden */
  13596. _indexInSceneTransformNodesArray: number;
  13597. /**
  13598. * An event triggered after the world matrix is updated
  13599. */
  13600. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13601. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13602. /**
  13603. * Gets a string identifying the name of the class
  13604. * @returns "TransformNode" string
  13605. */
  13606. getClassName(): string;
  13607. /**
  13608. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13609. */
  13610. get position(): Vector3;
  13611. set position(newPosition: Vector3);
  13612. /**
  13613. * 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)).
  13614. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13615. */
  13616. get rotation(): Vector3;
  13617. set rotation(newRotation: Vector3);
  13618. /**
  13619. * 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)).
  13620. */
  13621. get scaling(): Vector3;
  13622. set scaling(newScaling: Vector3);
  13623. /**
  13624. * 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).
  13625. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13626. */
  13627. get rotationQuaternion(): Nullable<Quaternion>;
  13628. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13629. /**
  13630. * The forward direction of that transform in world space.
  13631. */
  13632. get forward(): Vector3;
  13633. /**
  13634. * The up direction of that transform in world space.
  13635. */
  13636. get up(): Vector3;
  13637. /**
  13638. * The right direction of that transform in world space.
  13639. */
  13640. get right(): Vector3;
  13641. /**
  13642. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13643. * @param matrix the matrix to copy the pose from
  13644. * @returns this TransformNode.
  13645. */
  13646. updatePoseMatrix(matrix: Matrix): TransformNode;
  13647. /**
  13648. * Returns the mesh Pose matrix.
  13649. * @returns the pose matrix
  13650. */
  13651. getPoseMatrix(): Matrix;
  13652. /** @hidden */
  13653. _isSynchronized(): boolean;
  13654. /** @hidden */
  13655. _initCache(): void;
  13656. /**
  13657. * Flag the transform node as dirty (Forcing it to update everything)
  13658. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13659. * @returns this transform node
  13660. */
  13661. markAsDirty(property: string): TransformNode;
  13662. /**
  13663. * Returns the current mesh absolute position.
  13664. * Returns a Vector3.
  13665. */
  13666. get absolutePosition(): Vector3;
  13667. /**
  13668. * Returns the current mesh absolute scaling.
  13669. * Returns a Vector3.
  13670. */
  13671. get absoluteScaling(): Vector3;
  13672. /**
  13673. * Returns the current mesh absolute rotation.
  13674. * Returns a Quaternion.
  13675. */
  13676. get absoluteRotationQuaternion(): Quaternion;
  13677. /**
  13678. * Sets a new matrix to apply before all other transformation
  13679. * @param matrix defines the transform matrix
  13680. * @returns the current TransformNode
  13681. */
  13682. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13683. /**
  13684. * Sets a new pivot matrix to the current node
  13685. * @param matrix defines the new pivot matrix to use
  13686. * @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
  13687. * @returns the current TransformNode
  13688. */
  13689. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13690. /**
  13691. * Returns the mesh pivot matrix.
  13692. * Default : Identity.
  13693. * @returns the matrix
  13694. */
  13695. getPivotMatrix(): Matrix;
  13696. /**
  13697. * Instantiate (when possible) or clone that node with its hierarchy
  13698. * @param newParent defines the new parent to use for the instance (or clone)
  13699. * @param options defines options to configure how copy is done
  13700. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13701. * @returns an instance (or a clone) of the current node with its hiearchy
  13702. */
  13703. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13704. doNotInstantiate: boolean;
  13705. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13706. /**
  13707. * Prevents the World matrix to be computed any longer
  13708. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13709. * @returns the TransformNode.
  13710. */
  13711. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13712. /**
  13713. * Allows back the World matrix computation.
  13714. * @returns the TransformNode.
  13715. */
  13716. unfreezeWorldMatrix(): this;
  13717. /**
  13718. * True if the World matrix has been frozen.
  13719. */
  13720. get isWorldMatrixFrozen(): boolean;
  13721. /**
  13722. * Retuns the mesh absolute position in the World.
  13723. * @returns a Vector3.
  13724. */
  13725. getAbsolutePosition(): Vector3;
  13726. /**
  13727. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13728. * @param absolutePosition the absolute position to set
  13729. * @returns the TransformNode.
  13730. */
  13731. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13732. /**
  13733. * Sets the mesh position in its local space.
  13734. * @param vector3 the position to set in localspace
  13735. * @returns the TransformNode.
  13736. */
  13737. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13738. /**
  13739. * Returns the mesh position in the local space from the current World matrix values.
  13740. * @returns a new Vector3.
  13741. */
  13742. getPositionExpressedInLocalSpace(): Vector3;
  13743. /**
  13744. * Translates the mesh along the passed Vector3 in its local space.
  13745. * @param vector3 the distance to translate in localspace
  13746. * @returns the TransformNode.
  13747. */
  13748. locallyTranslate(vector3: Vector3): TransformNode;
  13749. private static _lookAtVectorCache;
  13750. /**
  13751. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13752. * @param targetPoint the position (must be in same space as current mesh) to look at
  13753. * @param yawCor optional yaw (y-axis) correction in radians
  13754. * @param pitchCor optional pitch (x-axis) correction in radians
  13755. * @param rollCor optional roll (z-axis) correction in radians
  13756. * @param space the choosen space of the target
  13757. * @returns the TransformNode.
  13758. */
  13759. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13760. /**
  13761. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13762. * This Vector3 is expressed in the World space.
  13763. * @param localAxis axis to rotate
  13764. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13765. */
  13766. getDirection(localAxis: Vector3): Vector3;
  13767. /**
  13768. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13769. * localAxis is expressed in the mesh local space.
  13770. * result is computed in the Wordl space from the mesh World matrix.
  13771. * @param localAxis axis to rotate
  13772. * @param result the resulting transformnode
  13773. * @returns this TransformNode.
  13774. */
  13775. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13776. /**
  13777. * Sets this transform node rotation to the given local axis.
  13778. * @param localAxis the axis in local space
  13779. * @param yawCor optional yaw (y-axis) correction in radians
  13780. * @param pitchCor optional pitch (x-axis) correction in radians
  13781. * @param rollCor optional roll (z-axis) correction in radians
  13782. * @returns this TransformNode
  13783. */
  13784. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13785. /**
  13786. * Sets a new pivot point to the current node
  13787. * @param point defines the new pivot point to use
  13788. * @param space defines if the point is in world or local space (local by default)
  13789. * @returns the current TransformNode
  13790. */
  13791. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13792. /**
  13793. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13794. * @returns the pivot point
  13795. */
  13796. getPivotPoint(): Vector3;
  13797. /**
  13798. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13799. * @param result the vector3 to store the result
  13800. * @returns this TransformNode.
  13801. */
  13802. getPivotPointToRef(result: Vector3): TransformNode;
  13803. /**
  13804. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13805. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13806. */
  13807. getAbsolutePivotPoint(): Vector3;
  13808. /**
  13809. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13810. * @param result vector3 to store the result
  13811. * @returns this TransformNode.
  13812. */
  13813. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13814. /**
  13815. * Defines the passed node as the parent of the current node.
  13816. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13817. * @see https://doc.babylonjs.com/how_to/parenting
  13818. * @param node the node ot set as the parent
  13819. * @returns this TransformNode.
  13820. */
  13821. setParent(node: Nullable<Node>): TransformNode;
  13822. private _nonUniformScaling;
  13823. /**
  13824. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13825. */
  13826. get nonUniformScaling(): boolean;
  13827. /** @hidden */
  13828. _updateNonUniformScalingState(value: boolean): boolean;
  13829. /**
  13830. * Attach the current TransformNode to another TransformNode associated with a bone
  13831. * @param bone Bone affecting the TransformNode
  13832. * @param affectedTransformNode TransformNode associated with the bone
  13833. * @returns this object
  13834. */
  13835. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13836. /**
  13837. * Detach the transform node if its associated with a bone
  13838. * @returns this object
  13839. */
  13840. detachFromBone(): TransformNode;
  13841. private static _rotationAxisCache;
  13842. /**
  13843. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13844. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13845. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13846. * The passed axis is also normalized.
  13847. * @param axis the axis to rotate around
  13848. * @param amount the amount to rotate in radians
  13849. * @param space Space to rotate in (Default: local)
  13850. * @returns the TransformNode.
  13851. */
  13852. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13853. /**
  13854. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13855. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13856. * The passed axis is also normalized. .
  13857. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13858. * @param point the point to rotate around
  13859. * @param axis the axis to rotate around
  13860. * @param amount the amount to rotate in radians
  13861. * @returns the TransformNode
  13862. */
  13863. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13864. /**
  13865. * Translates the mesh along the axis vector for the passed distance in the given space.
  13866. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13867. * @param axis the axis to translate in
  13868. * @param distance the distance to translate
  13869. * @param space Space to rotate in (Default: local)
  13870. * @returns the TransformNode.
  13871. */
  13872. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13873. /**
  13874. * Adds a rotation step to the mesh current rotation.
  13875. * x, y, z are Euler angles expressed in radians.
  13876. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13877. * This means this rotation is made in the mesh local space only.
  13878. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13879. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13880. * ```javascript
  13881. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13882. * ```
  13883. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13884. * 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.
  13885. * @param x Rotation to add
  13886. * @param y Rotation to add
  13887. * @param z Rotation to add
  13888. * @returns the TransformNode.
  13889. */
  13890. addRotation(x: number, y: number, z: number): TransformNode;
  13891. /**
  13892. * @hidden
  13893. */
  13894. protected _getEffectiveParent(): Nullable<Node>;
  13895. /**
  13896. * Computes the world matrix of the node
  13897. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13898. * @returns the world matrix
  13899. */
  13900. computeWorldMatrix(force?: boolean): Matrix;
  13901. /**
  13902. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13903. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13904. */
  13905. resetLocalMatrix(independentOfChildren?: boolean): void;
  13906. protected _afterComputeWorldMatrix(): void;
  13907. /**
  13908. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13909. * @param func callback function to add
  13910. *
  13911. * @returns the TransformNode.
  13912. */
  13913. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13914. /**
  13915. * Removes a registered callback function.
  13916. * @param func callback function to remove
  13917. * @returns the TransformNode.
  13918. */
  13919. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13920. /**
  13921. * Gets the position of the current mesh in camera space
  13922. * @param camera defines the camera to use
  13923. * @returns a position
  13924. */
  13925. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13926. /**
  13927. * Returns the distance from the mesh to the active camera
  13928. * @param camera defines the camera to use
  13929. * @returns the distance
  13930. */
  13931. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13932. /**
  13933. * Clone the current transform node
  13934. * @param name Name of the new clone
  13935. * @param newParent New parent for the clone
  13936. * @param doNotCloneChildren Do not clone children hierarchy
  13937. * @returns the new transform node
  13938. */
  13939. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13940. /**
  13941. * Serializes the objects information.
  13942. * @param currentSerializationObject defines the object to serialize in
  13943. * @returns the serialized object
  13944. */
  13945. serialize(currentSerializationObject?: any): any;
  13946. /**
  13947. * Returns a new TransformNode object parsed from the source provided.
  13948. * @param parsedTransformNode is the source.
  13949. * @param scene the scne the object belongs to
  13950. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13951. * @returns a new TransformNode object parsed from the source provided.
  13952. */
  13953. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13954. /**
  13955. * Get all child-transformNodes of this node
  13956. * @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
  13957. * @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
  13958. * @returns an array of TransformNode
  13959. */
  13960. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13961. /**
  13962. * Releases resources associated with this transform node.
  13963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13965. */
  13966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13967. /**
  13968. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13969. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13970. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13971. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13972. * @returns the current mesh
  13973. */
  13974. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13975. private _syncAbsoluteScalingAndRotation;
  13976. }
  13977. }
  13978. declare module BABYLON {
  13979. /**
  13980. * Class used to override all child animations of a given target
  13981. */
  13982. export class AnimationPropertiesOverride {
  13983. /**
  13984. * Gets or sets a value indicating if animation blending must be used
  13985. */
  13986. enableBlending: boolean;
  13987. /**
  13988. * Gets or sets the blending speed to use when enableBlending is true
  13989. */
  13990. blendingSpeed: number;
  13991. /**
  13992. * Gets or sets the default loop mode to use
  13993. */
  13994. loopMode: number;
  13995. }
  13996. }
  13997. declare module BABYLON {
  13998. /**
  13999. * Class used to store bone information
  14000. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14001. */
  14002. export class Bone extends Node {
  14003. /**
  14004. * defines the bone name
  14005. */
  14006. name: string;
  14007. private static _tmpVecs;
  14008. private static _tmpQuat;
  14009. private static _tmpMats;
  14010. /**
  14011. * Gets the list of child bones
  14012. */
  14013. children: Bone[];
  14014. /** Gets the animations associated with this bone */
  14015. animations: Animation[];
  14016. /**
  14017. * Gets or sets bone length
  14018. */
  14019. length: number;
  14020. /**
  14021. * @hidden Internal only
  14022. * Set this value to map this bone to a different index in the transform matrices
  14023. * Set this value to -1 to exclude the bone from the transform matrices
  14024. */
  14025. _index: Nullable<number>;
  14026. private _skeleton;
  14027. private _localMatrix;
  14028. private _restPose;
  14029. private _baseMatrix;
  14030. private _absoluteTransform;
  14031. private _invertedAbsoluteTransform;
  14032. private _parent;
  14033. private _scalingDeterminant;
  14034. private _worldTransform;
  14035. private _localScaling;
  14036. private _localRotation;
  14037. private _localPosition;
  14038. private _needToDecompose;
  14039. private _needToCompose;
  14040. /** @hidden */
  14041. _linkedTransformNode: Nullable<TransformNode>;
  14042. /** @hidden */
  14043. _waitingTransformNodeId: Nullable<string>;
  14044. /** @hidden */
  14045. get _matrix(): Matrix;
  14046. /** @hidden */
  14047. set _matrix(value: Matrix);
  14048. /**
  14049. * Create a new bone
  14050. * @param name defines the bone name
  14051. * @param skeleton defines the parent skeleton
  14052. * @param parentBone defines the parent (can be null if the bone is the root)
  14053. * @param localMatrix defines the local matrix
  14054. * @param restPose defines the rest pose matrix
  14055. * @param baseMatrix defines the base matrix
  14056. * @param index defines index of the bone in the hiearchy
  14057. */
  14058. constructor(
  14059. /**
  14060. * defines the bone name
  14061. */
  14062. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14063. /**
  14064. * Gets the current object class name.
  14065. * @return the class name
  14066. */
  14067. getClassName(): string;
  14068. /**
  14069. * Gets the parent skeleton
  14070. * @returns a skeleton
  14071. */
  14072. getSkeleton(): Skeleton;
  14073. /**
  14074. * Gets parent bone
  14075. * @returns a bone or null if the bone is the root of the bone hierarchy
  14076. */
  14077. getParent(): Nullable<Bone>;
  14078. /**
  14079. * Returns an array containing the root bones
  14080. * @returns an array containing the root bones
  14081. */
  14082. getChildren(): Array<Bone>;
  14083. /**
  14084. * Gets the node index in matrix array generated for rendering
  14085. * @returns the node index
  14086. */
  14087. getIndex(): number;
  14088. /**
  14089. * Sets the parent bone
  14090. * @param parent defines the parent (can be null if the bone is the root)
  14091. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14092. */
  14093. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14094. /**
  14095. * Gets the local matrix
  14096. * @returns a matrix
  14097. */
  14098. getLocalMatrix(): Matrix;
  14099. /**
  14100. * Gets the base matrix (initial matrix which remains unchanged)
  14101. * @returns a matrix
  14102. */
  14103. getBaseMatrix(): Matrix;
  14104. /**
  14105. * Gets the rest pose matrix
  14106. * @returns a matrix
  14107. */
  14108. getRestPose(): Matrix;
  14109. /**
  14110. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14111. */
  14112. getWorldMatrix(): Matrix;
  14113. /**
  14114. * Sets the local matrix to rest pose matrix
  14115. */
  14116. returnToRest(): void;
  14117. /**
  14118. * Gets the inverse of the absolute transform matrix.
  14119. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14120. * @returns a matrix
  14121. */
  14122. getInvertedAbsoluteTransform(): Matrix;
  14123. /**
  14124. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14125. * @returns a matrix
  14126. */
  14127. getAbsoluteTransform(): Matrix;
  14128. /**
  14129. * Links with the given transform node.
  14130. * The local matrix of this bone is copied from the transform node every frame.
  14131. * @param transformNode defines the transform node to link to
  14132. */
  14133. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14134. /**
  14135. * Gets the node used to drive the bone's transformation
  14136. * @returns a transform node or null
  14137. */
  14138. getTransformNode(): Nullable<TransformNode>;
  14139. /** Gets or sets current position (in local space) */
  14140. get position(): Vector3;
  14141. set position(newPosition: Vector3);
  14142. /** Gets or sets current rotation (in local space) */
  14143. get rotation(): Vector3;
  14144. set rotation(newRotation: Vector3);
  14145. /** Gets or sets current rotation quaternion (in local space) */
  14146. get rotationQuaternion(): Quaternion;
  14147. set rotationQuaternion(newRotation: Quaternion);
  14148. /** Gets or sets current scaling (in local space) */
  14149. get scaling(): Vector3;
  14150. set scaling(newScaling: Vector3);
  14151. /**
  14152. * Gets the animation properties override
  14153. */
  14154. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14155. private _decompose;
  14156. private _compose;
  14157. /**
  14158. * Update the base and local matrices
  14159. * @param matrix defines the new base or local matrix
  14160. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14161. * @param updateLocalMatrix defines if the local matrix should be updated
  14162. */
  14163. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14164. /** @hidden */
  14165. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14166. /**
  14167. * Flag the bone as dirty (Forcing it to update everything)
  14168. */
  14169. markAsDirty(): void;
  14170. /** @hidden */
  14171. _markAsDirtyAndCompose(): void;
  14172. private _markAsDirtyAndDecompose;
  14173. /**
  14174. * Translate the bone in local or world space
  14175. * @param vec The amount to translate the bone
  14176. * @param space The space that the translation is in
  14177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14178. */
  14179. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14180. /**
  14181. * Set the postion of the bone in local or world space
  14182. * @param position The position to set the bone
  14183. * @param space The space that the position is in
  14184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14185. */
  14186. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14187. /**
  14188. * Set the absolute position of the bone (world space)
  14189. * @param position The position to set the bone
  14190. * @param mesh The mesh that this bone is attached to
  14191. */
  14192. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14193. /**
  14194. * Scale the bone on the x, y and z axes (in local space)
  14195. * @param x The amount to scale the bone on the x axis
  14196. * @param y The amount to scale the bone on the y axis
  14197. * @param z The amount to scale the bone on the z axis
  14198. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14199. */
  14200. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14201. /**
  14202. * Set the bone scaling in local space
  14203. * @param scale defines the scaling vector
  14204. */
  14205. setScale(scale: Vector3): void;
  14206. /**
  14207. * Gets the current scaling in local space
  14208. * @returns the current scaling vector
  14209. */
  14210. getScale(): Vector3;
  14211. /**
  14212. * Gets the current scaling in local space and stores it in a target vector
  14213. * @param result defines the target vector
  14214. */
  14215. getScaleToRef(result: Vector3): void;
  14216. /**
  14217. * Set the yaw, pitch, and roll of the bone in local or world space
  14218. * @param yaw The rotation of the bone on the y axis
  14219. * @param pitch The rotation of the bone on the x axis
  14220. * @param roll The rotation of the bone on the z axis
  14221. * @param space The space that the axes of rotation are in
  14222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14223. */
  14224. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14225. /**
  14226. * Add a rotation to the bone on an axis in local or world space
  14227. * @param axis The axis to rotate the bone on
  14228. * @param amount The amount to rotate the bone
  14229. * @param space The space that the axis is in
  14230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14231. */
  14232. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14233. /**
  14234. * Set the rotation of the bone to a particular axis angle in local or world space
  14235. * @param axis The axis to rotate the bone on
  14236. * @param angle The angle that the bone should be rotated to
  14237. * @param space The space that the axis is in
  14238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14239. */
  14240. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14241. /**
  14242. * Set the euler rotation of the bone in local of world space
  14243. * @param rotation The euler rotation that the bone should be set to
  14244. * @param space The space that the rotation is in
  14245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14246. */
  14247. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14248. /**
  14249. * Set the quaternion rotation of the bone in local of world space
  14250. * @param quat The quaternion rotation that the bone should be set to
  14251. * @param space The space that the rotation is in
  14252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14253. */
  14254. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14255. /**
  14256. * Set the rotation matrix of the bone in local of world space
  14257. * @param rotMat The rotation matrix that the bone should be set to
  14258. * @param space The space that the rotation is in
  14259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14260. */
  14261. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14262. private _rotateWithMatrix;
  14263. private _getNegativeRotationToRef;
  14264. /**
  14265. * Get the position of the bone in local or world space
  14266. * @param space The space that the returned position is in
  14267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14268. * @returns The position of the bone
  14269. */
  14270. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14271. /**
  14272. * Copy the position of the bone to a vector3 in local or world space
  14273. * @param space The space that the returned position is in
  14274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14275. * @param result The vector3 to copy the position to
  14276. */
  14277. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14278. /**
  14279. * Get the absolute position of the bone (world space)
  14280. * @param mesh The mesh that this bone is attached to
  14281. * @returns The absolute position of the bone
  14282. */
  14283. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14284. /**
  14285. * Copy the absolute position of the bone (world space) to the result param
  14286. * @param mesh The mesh that this bone is attached to
  14287. * @param result The vector3 to copy the absolute position to
  14288. */
  14289. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14290. /**
  14291. * Compute the absolute transforms of this bone and its children
  14292. */
  14293. computeAbsoluteTransforms(): void;
  14294. /**
  14295. * Get the world direction from an axis that is in the local space of the bone
  14296. * @param localAxis The local direction that is used to compute the world direction
  14297. * @param mesh The mesh that this bone is attached to
  14298. * @returns The world direction
  14299. */
  14300. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14301. /**
  14302. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14303. * @param localAxis The local direction that is used to compute the world direction
  14304. * @param mesh The mesh that this bone is attached to
  14305. * @param result The vector3 that the world direction will be copied to
  14306. */
  14307. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14308. /**
  14309. * Get the euler rotation of the bone in local or world space
  14310. * @param space The space that the rotation should be in
  14311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14312. * @returns The euler rotation
  14313. */
  14314. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14315. /**
  14316. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14317. * @param space The space that the rotation should be in
  14318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14319. * @param result The vector3 that the rotation should be copied to
  14320. */
  14321. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14322. /**
  14323. * Get the quaternion rotation of the bone in either local or world space
  14324. * @param space The space that the rotation should be in
  14325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14326. * @returns The quaternion rotation
  14327. */
  14328. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14329. /**
  14330. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14331. * @param space The space that the rotation should be in
  14332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14333. * @param result The quaternion that the rotation should be copied to
  14334. */
  14335. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14336. /**
  14337. * Get the rotation matrix of the bone in local or world space
  14338. * @param space The space that the rotation should be in
  14339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14340. * @returns The rotation matrix
  14341. */
  14342. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14343. /**
  14344. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14345. * @param space The space that the rotation should be in
  14346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14347. * @param result The quaternion that the rotation should be copied to
  14348. */
  14349. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14350. /**
  14351. * Get the world position of a point that is in the local space of the bone
  14352. * @param position The local position
  14353. * @param mesh The mesh that this bone is attached to
  14354. * @returns The world position
  14355. */
  14356. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14357. /**
  14358. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14359. * @param position The local position
  14360. * @param mesh The mesh that this bone is attached to
  14361. * @param result The vector3 that the world position should be copied to
  14362. */
  14363. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14364. /**
  14365. * Get the local position of a point that is in world space
  14366. * @param position The world position
  14367. * @param mesh The mesh that this bone is attached to
  14368. * @returns The local position
  14369. */
  14370. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14371. /**
  14372. * Get the local position of a point that is in world space and copy it to the result param
  14373. * @param position The world position
  14374. * @param mesh The mesh that this bone is attached to
  14375. * @param result The vector3 that the local position should be copied to
  14376. */
  14377. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14378. }
  14379. }
  14380. declare module BABYLON {
  14381. /**
  14382. * Defines a runtime animation
  14383. */
  14384. export class RuntimeAnimation {
  14385. private _events;
  14386. /**
  14387. * The current frame of the runtime animation
  14388. */
  14389. private _currentFrame;
  14390. /**
  14391. * The animation used by the runtime animation
  14392. */
  14393. private _animation;
  14394. /**
  14395. * The target of the runtime animation
  14396. */
  14397. private _target;
  14398. /**
  14399. * The initiating animatable
  14400. */
  14401. private _host;
  14402. /**
  14403. * The original value of the runtime animation
  14404. */
  14405. private _originalValue;
  14406. /**
  14407. * The original blend value of the runtime animation
  14408. */
  14409. private _originalBlendValue;
  14410. /**
  14411. * The offsets cache of the runtime animation
  14412. */
  14413. private _offsetsCache;
  14414. /**
  14415. * The high limits cache of the runtime animation
  14416. */
  14417. private _highLimitsCache;
  14418. /**
  14419. * Specifies if the runtime animation has been stopped
  14420. */
  14421. private _stopped;
  14422. /**
  14423. * The blending factor of the runtime animation
  14424. */
  14425. private _blendingFactor;
  14426. /**
  14427. * The BabylonJS scene
  14428. */
  14429. private _scene;
  14430. /**
  14431. * The current value of the runtime animation
  14432. */
  14433. private _currentValue;
  14434. /** @hidden */
  14435. _animationState: _IAnimationState;
  14436. /**
  14437. * The active target of the runtime animation
  14438. */
  14439. private _activeTargets;
  14440. private _currentActiveTarget;
  14441. private _directTarget;
  14442. /**
  14443. * The target path of the runtime animation
  14444. */
  14445. private _targetPath;
  14446. /**
  14447. * The weight of the runtime animation
  14448. */
  14449. private _weight;
  14450. /**
  14451. * The ratio offset of the runtime animation
  14452. */
  14453. private _ratioOffset;
  14454. /**
  14455. * The previous delay of the runtime animation
  14456. */
  14457. private _previousDelay;
  14458. /**
  14459. * The previous ratio of the runtime animation
  14460. */
  14461. private _previousRatio;
  14462. private _enableBlending;
  14463. private _keys;
  14464. private _minFrame;
  14465. private _maxFrame;
  14466. private _minValue;
  14467. private _maxValue;
  14468. private _targetIsArray;
  14469. /**
  14470. * Gets the current frame of the runtime animation
  14471. */
  14472. get currentFrame(): number;
  14473. /**
  14474. * Gets the weight of the runtime animation
  14475. */
  14476. get weight(): number;
  14477. /**
  14478. * Gets the current value of the runtime animation
  14479. */
  14480. get currentValue(): any;
  14481. /**
  14482. * Gets the target path of the runtime animation
  14483. */
  14484. get targetPath(): string;
  14485. /**
  14486. * Gets the actual target of the runtime animation
  14487. */
  14488. get target(): any;
  14489. /**
  14490. * Gets the additive state of the runtime animation
  14491. */
  14492. get isAdditive(): boolean;
  14493. /** @hidden */
  14494. _onLoop: () => void;
  14495. /**
  14496. * Create a new RuntimeAnimation object
  14497. * @param target defines the target of the animation
  14498. * @param animation defines the source animation object
  14499. * @param scene defines the hosting scene
  14500. * @param host defines the initiating Animatable
  14501. */
  14502. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14503. private _preparePath;
  14504. /**
  14505. * Gets the animation from the runtime animation
  14506. */
  14507. get animation(): Animation;
  14508. /**
  14509. * Resets the runtime animation to the beginning
  14510. * @param restoreOriginal defines whether to restore the target property to the original value
  14511. */
  14512. reset(restoreOriginal?: boolean): void;
  14513. /**
  14514. * Specifies if the runtime animation is stopped
  14515. * @returns Boolean specifying if the runtime animation is stopped
  14516. */
  14517. isStopped(): boolean;
  14518. /**
  14519. * Disposes of the runtime animation
  14520. */
  14521. dispose(): void;
  14522. /**
  14523. * Apply the interpolated value to the target
  14524. * @param currentValue defines the value computed by the animation
  14525. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14526. */
  14527. setValue(currentValue: any, weight: number): void;
  14528. private _getOriginalValues;
  14529. private _setValue;
  14530. /**
  14531. * Gets the loop pmode of the runtime animation
  14532. * @returns Loop Mode
  14533. */
  14534. private _getCorrectLoopMode;
  14535. /**
  14536. * Move the current animation to a given frame
  14537. * @param frame defines the frame to move to
  14538. */
  14539. goToFrame(frame: number): void;
  14540. /**
  14541. * @hidden Internal use only
  14542. */
  14543. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14544. /**
  14545. * Execute the current animation
  14546. * @param delay defines the delay to add to the current frame
  14547. * @param from defines the lower bound of the animation range
  14548. * @param to defines the upper bound of the animation range
  14549. * @param loop defines if the current animation must loop
  14550. * @param speedRatio defines the current speed ratio
  14551. * @param weight defines the weight of the animation (default is -1 so no weight)
  14552. * @param onLoop optional callback called when animation loops
  14553. * @returns a boolean indicating if the animation is running
  14554. */
  14555. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14556. }
  14557. }
  14558. declare module BABYLON {
  14559. /**
  14560. * Class used to store an actual running animation
  14561. */
  14562. export class Animatable {
  14563. /** defines the target object */
  14564. target: any;
  14565. /** defines the starting frame number (default is 0) */
  14566. fromFrame: number;
  14567. /** defines the ending frame number (default is 100) */
  14568. toFrame: number;
  14569. /** defines if the animation must loop (default is false) */
  14570. loopAnimation: boolean;
  14571. /** defines a callback to call when animation ends if it is not looping */
  14572. onAnimationEnd?: (() => void) | null | undefined;
  14573. /** defines a callback to call when animation loops */
  14574. onAnimationLoop?: (() => void) | null | undefined;
  14575. /** defines whether the animation should be evaluated additively */
  14576. isAdditive: boolean;
  14577. private _localDelayOffset;
  14578. private _pausedDelay;
  14579. private _runtimeAnimations;
  14580. private _paused;
  14581. private _scene;
  14582. private _speedRatio;
  14583. private _weight;
  14584. private _syncRoot;
  14585. /**
  14586. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14587. * This will only apply for non looping animation (default is true)
  14588. */
  14589. disposeOnEnd: boolean;
  14590. /**
  14591. * Gets a boolean indicating if the animation has started
  14592. */
  14593. animationStarted: boolean;
  14594. /**
  14595. * Observer raised when the animation ends
  14596. */
  14597. onAnimationEndObservable: Observable<Animatable>;
  14598. /**
  14599. * Observer raised when the animation loops
  14600. */
  14601. onAnimationLoopObservable: Observable<Animatable>;
  14602. /**
  14603. * Gets the root Animatable used to synchronize and normalize animations
  14604. */
  14605. get syncRoot(): Nullable<Animatable>;
  14606. /**
  14607. * Gets the current frame of the first RuntimeAnimation
  14608. * Used to synchronize Animatables
  14609. */
  14610. get masterFrame(): number;
  14611. /**
  14612. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14613. */
  14614. get weight(): number;
  14615. set weight(value: number);
  14616. /**
  14617. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14618. */
  14619. get speedRatio(): number;
  14620. set speedRatio(value: number);
  14621. /**
  14622. * Creates a new Animatable
  14623. * @param scene defines the hosting scene
  14624. * @param target defines the target object
  14625. * @param fromFrame defines the starting frame number (default is 0)
  14626. * @param toFrame defines the ending frame number (default is 100)
  14627. * @param loopAnimation defines if the animation must loop (default is false)
  14628. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14629. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14630. * @param animations defines a group of animation to add to the new Animatable
  14631. * @param onAnimationLoop defines a callback to call when animation loops
  14632. * @param isAdditive defines whether the animation should be evaluated additively
  14633. */
  14634. constructor(scene: Scene,
  14635. /** defines the target object */
  14636. target: any,
  14637. /** defines the starting frame number (default is 0) */
  14638. fromFrame?: number,
  14639. /** defines the ending frame number (default is 100) */
  14640. toFrame?: number,
  14641. /** defines if the animation must loop (default is false) */
  14642. loopAnimation?: boolean, speedRatio?: number,
  14643. /** defines a callback to call when animation ends if it is not looping */
  14644. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14645. /** defines a callback to call when animation loops */
  14646. onAnimationLoop?: (() => void) | null | undefined,
  14647. /** defines whether the animation should be evaluated additively */
  14648. isAdditive?: boolean);
  14649. /**
  14650. * Synchronize and normalize current Animatable with a source Animatable
  14651. * This is useful when using animation weights and when animations are not of the same length
  14652. * @param root defines the root Animatable to synchronize with
  14653. * @returns the current Animatable
  14654. */
  14655. syncWith(root: Animatable): Animatable;
  14656. /**
  14657. * Gets the list of runtime animations
  14658. * @returns an array of RuntimeAnimation
  14659. */
  14660. getAnimations(): RuntimeAnimation[];
  14661. /**
  14662. * Adds more animations to the current animatable
  14663. * @param target defines the target of the animations
  14664. * @param animations defines the new animations to add
  14665. */
  14666. appendAnimations(target: any, animations: Animation[]): void;
  14667. /**
  14668. * Gets the source animation for a specific property
  14669. * @param property defines the propertyu to look for
  14670. * @returns null or the source animation for the given property
  14671. */
  14672. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14673. /**
  14674. * Gets the runtime animation for a specific property
  14675. * @param property defines the propertyu to look for
  14676. * @returns null or the runtime animation for the given property
  14677. */
  14678. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14679. /**
  14680. * Resets the animatable to its original state
  14681. */
  14682. reset(): void;
  14683. /**
  14684. * Allows the animatable to blend with current running animations
  14685. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14686. * @param blendingSpeed defines the blending speed to use
  14687. */
  14688. enableBlending(blendingSpeed: number): void;
  14689. /**
  14690. * Disable animation blending
  14691. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14692. */
  14693. disableBlending(): void;
  14694. /**
  14695. * Jump directly to a given frame
  14696. * @param frame defines the frame to jump to
  14697. */
  14698. goToFrame(frame: number): void;
  14699. /**
  14700. * Pause the animation
  14701. */
  14702. pause(): void;
  14703. /**
  14704. * Restart the animation
  14705. */
  14706. restart(): void;
  14707. private _raiseOnAnimationEnd;
  14708. /**
  14709. * Stop and delete the current animation
  14710. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14711. * @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)
  14712. */
  14713. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14714. /**
  14715. * Wait asynchronously for the animation to end
  14716. * @returns a promise which will be fullfilled when the animation ends
  14717. */
  14718. waitAsync(): Promise<Animatable>;
  14719. /** @hidden */
  14720. _animate(delay: number): boolean;
  14721. }
  14722. interface Scene {
  14723. /** @hidden */
  14724. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14725. /** @hidden */
  14726. _processLateAnimationBindingsForMatrices(holder: {
  14727. totalWeight: number;
  14728. totalAdditiveWeight: number;
  14729. animations: RuntimeAnimation[];
  14730. additiveAnimations: RuntimeAnimation[];
  14731. originalValue: Matrix;
  14732. }): any;
  14733. /** @hidden */
  14734. _processLateAnimationBindingsForQuaternions(holder: {
  14735. totalWeight: number;
  14736. totalAdditiveWeight: number;
  14737. animations: RuntimeAnimation[];
  14738. additiveAnimations: RuntimeAnimation[];
  14739. originalValue: Quaternion;
  14740. }, refQuaternion: Quaternion): Quaternion;
  14741. /** @hidden */
  14742. _processLateAnimationBindings(): void;
  14743. /**
  14744. * Will start the animation sequence of a given target
  14745. * @param target defines the target
  14746. * @param from defines from which frame should animation start
  14747. * @param to defines until which frame should animation run.
  14748. * @param weight defines the weight to apply to the animation (1.0 by default)
  14749. * @param loop defines if the animation loops
  14750. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14751. * @param onAnimationEnd defines the function to be executed when the animation ends
  14752. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14753. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14754. * @param onAnimationLoop defines the callback to call when an animation loops
  14755. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14756. * @returns the animatable object created for this animation
  14757. */
  14758. 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;
  14759. /**
  14760. * Will start the animation sequence of a given target
  14761. * @param target defines the target
  14762. * @param from defines from which frame should animation start
  14763. * @param to defines until which frame should animation run.
  14764. * @param loop defines if the animation loops
  14765. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14766. * @param onAnimationEnd defines the function to be executed when the animation ends
  14767. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14768. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14769. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14770. * @param onAnimationLoop defines the callback to call when an animation loops
  14771. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14772. * @returns the animatable object created for this animation
  14773. */
  14774. 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;
  14775. /**
  14776. * Will start the animation sequence of a given target and its hierarchy
  14777. * @param target defines the target
  14778. * @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.
  14779. * @param from defines from which frame should animation start
  14780. * @param to defines until which frame should animation run.
  14781. * @param loop defines if the animation loops
  14782. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14783. * @param onAnimationEnd defines the function to be executed when the animation ends
  14784. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14785. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14786. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14787. * @param onAnimationLoop defines the callback to call when an animation loops
  14788. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14789. * @returns the list of created animatables
  14790. */
  14791. 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[];
  14792. /**
  14793. * Begin a new animation on a given node
  14794. * @param target defines the target where the animation will take place
  14795. * @param animations defines the list of animations to start
  14796. * @param from defines the initial value
  14797. * @param to defines the final value
  14798. * @param loop defines if you want animation to loop (off by default)
  14799. * @param speedRatio defines the speed ratio to apply to all animations
  14800. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14801. * @param onAnimationLoop defines the callback to call when an animation loops
  14802. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14803. * @returns the list of created animatables
  14804. */
  14805. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14806. /**
  14807. * Begin a new animation on a given node and its hierarchy
  14808. * @param target defines the root node where the animation will take place
  14809. * @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.
  14810. * @param animations defines the list of animations to start
  14811. * @param from defines the initial value
  14812. * @param to defines the final value
  14813. * @param loop defines if you want animation to loop (off by default)
  14814. * @param speedRatio defines the speed ratio to apply to all animations
  14815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14816. * @param onAnimationLoop defines the callback to call when an animation loops
  14817. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14818. * @returns the list of animatables created for all nodes
  14819. */
  14820. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14821. /**
  14822. * Gets the animatable associated with a specific target
  14823. * @param target defines the target of the animatable
  14824. * @returns the required animatable if found
  14825. */
  14826. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14827. /**
  14828. * Gets all animatables associated with a given target
  14829. * @param target defines the target to look animatables for
  14830. * @returns an array of Animatables
  14831. */
  14832. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14833. /**
  14834. * Stops and removes all animations that have been applied to the scene
  14835. */
  14836. stopAllAnimations(): void;
  14837. /**
  14838. * Gets the current delta time used by animation engine
  14839. */
  14840. deltaTime: number;
  14841. }
  14842. interface Bone {
  14843. /**
  14844. * Copy an animation range from another bone
  14845. * @param source defines the source bone
  14846. * @param rangeName defines the range name to copy
  14847. * @param frameOffset defines the frame offset
  14848. * @param rescaleAsRequired defines if rescaling must be applied if required
  14849. * @param skelDimensionsRatio defines the scaling ratio
  14850. * @returns true if operation was successful
  14851. */
  14852. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14853. }
  14854. }
  14855. declare module BABYLON {
  14856. /**
  14857. * Class used to handle skinning animations
  14858. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14859. */
  14860. export class Skeleton implements IAnimatable {
  14861. /** defines the skeleton name */
  14862. name: string;
  14863. /** defines the skeleton Id */
  14864. id: string;
  14865. /**
  14866. * Defines the list of child bones
  14867. */
  14868. bones: Bone[];
  14869. /**
  14870. * Defines an estimate of the dimension of the skeleton at rest
  14871. */
  14872. dimensionsAtRest: Vector3;
  14873. /**
  14874. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14875. */
  14876. needInitialSkinMatrix: boolean;
  14877. /**
  14878. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14879. */
  14880. overrideMesh: Nullable<AbstractMesh>;
  14881. /**
  14882. * Gets the list of animations attached to this skeleton
  14883. */
  14884. animations: Array<Animation>;
  14885. private _scene;
  14886. private _isDirty;
  14887. private _transformMatrices;
  14888. private _transformMatrixTexture;
  14889. private _meshesWithPoseMatrix;
  14890. private _animatables;
  14891. private _identity;
  14892. private _synchronizedWithMesh;
  14893. private _ranges;
  14894. private _lastAbsoluteTransformsUpdateId;
  14895. private _canUseTextureForBones;
  14896. private _uniqueId;
  14897. /** @hidden */
  14898. _numBonesWithLinkedTransformNode: number;
  14899. /** @hidden */
  14900. _hasWaitingData: Nullable<boolean>;
  14901. /**
  14902. * Specifies if the skeleton should be serialized
  14903. */
  14904. doNotSerialize: boolean;
  14905. private _useTextureToStoreBoneMatrices;
  14906. /**
  14907. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14908. * Please note that this option is not available if the hardware does not support it
  14909. */
  14910. get useTextureToStoreBoneMatrices(): boolean;
  14911. set useTextureToStoreBoneMatrices(value: boolean);
  14912. private _animationPropertiesOverride;
  14913. /**
  14914. * Gets or sets the animation properties override
  14915. */
  14916. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14917. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14918. /**
  14919. * List of inspectable custom properties (used by the Inspector)
  14920. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14921. */
  14922. inspectableCustomProperties: IInspectable[];
  14923. /**
  14924. * An observable triggered before computing the skeleton's matrices
  14925. */
  14926. onBeforeComputeObservable: Observable<Skeleton>;
  14927. /**
  14928. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14929. */
  14930. get isUsingTextureForMatrices(): boolean;
  14931. /**
  14932. * Gets the unique ID of this skeleton
  14933. */
  14934. get uniqueId(): number;
  14935. /**
  14936. * Creates a new skeleton
  14937. * @param name defines the skeleton name
  14938. * @param id defines the skeleton Id
  14939. * @param scene defines the hosting scene
  14940. */
  14941. constructor(
  14942. /** defines the skeleton name */
  14943. name: string,
  14944. /** defines the skeleton Id */
  14945. id: string, scene: Scene);
  14946. /**
  14947. * Gets the current object class name.
  14948. * @return the class name
  14949. */
  14950. getClassName(): string;
  14951. /**
  14952. * Returns an array containing the root bones
  14953. * @returns an array containing the root bones
  14954. */
  14955. getChildren(): Array<Bone>;
  14956. /**
  14957. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14958. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14959. * @returns a Float32Array containing matrices data
  14960. */
  14961. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14962. /**
  14963. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14964. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14965. * @returns a raw texture containing the data
  14966. */
  14967. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14968. /**
  14969. * Gets the current hosting scene
  14970. * @returns a scene object
  14971. */
  14972. getScene(): Scene;
  14973. /**
  14974. * Gets a string representing the current skeleton data
  14975. * @param fullDetails defines a boolean indicating if we want a verbose version
  14976. * @returns a string representing the current skeleton data
  14977. */
  14978. toString(fullDetails?: boolean): string;
  14979. /**
  14980. * Get bone's index searching by name
  14981. * @param name defines bone's name to search for
  14982. * @return the indice of the bone. Returns -1 if not found
  14983. */
  14984. getBoneIndexByName(name: string): number;
  14985. /**
  14986. * Creater a new animation range
  14987. * @param name defines the name of the range
  14988. * @param from defines the start key
  14989. * @param to defines the end key
  14990. */
  14991. createAnimationRange(name: string, from: number, to: number): void;
  14992. /**
  14993. * Delete a specific animation range
  14994. * @param name defines the name of the range
  14995. * @param deleteFrames defines if frames must be removed as well
  14996. */
  14997. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14998. /**
  14999. * Gets a specific animation range
  15000. * @param name defines the name of the range to look for
  15001. * @returns the requested animation range or null if not found
  15002. */
  15003. getAnimationRange(name: string): Nullable<AnimationRange>;
  15004. /**
  15005. * Gets the list of all animation ranges defined on this skeleton
  15006. * @returns an array
  15007. */
  15008. getAnimationRanges(): Nullable<AnimationRange>[];
  15009. /**
  15010. * Copy animation range from a source skeleton.
  15011. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15012. * @param source defines the source skeleton
  15013. * @param name defines the name of the range to copy
  15014. * @param rescaleAsRequired defines if rescaling must be applied if required
  15015. * @returns true if operation was successful
  15016. */
  15017. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15018. /**
  15019. * Forces the skeleton to go to rest pose
  15020. */
  15021. returnToRest(): void;
  15022. private _getHighestAnimationFrame;
  15023. /**
  15024. * Begin a specific animation range
  15025. * @param name defines the name of the range to start
  15026. * @param loop defines if looping must be turned on (false by default)
  15027. * @param speedRatio defines the speed ratio to apply (1 by default)
  15028. * @param onAnimationEnd defines a callback which will be called when animation will end
  15029. * @returns a new animatable
  15030. */
  15031. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15032. /**
  15033. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15034. * @param skeleton defines the Skeleton containing the animation range to convert
  15035. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15036. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15037. * @returns the original skeleton
  15038. */
  15039. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15040. /** @hidden */
  15041. _markAsDirty(): void;
  15042. /** @hidden */
  15043. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15044. /** @hidden */
  15045. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15046. private _computeTransformMatrices;
  15047. /**
  15048. * Build all resources required to render a skeleton
  15049. */
  15050. prepare(): void;
  15051. /**
  15052. * Gets the list of animatables currently running for this skeleton
  15053. * @returns an array of animatables
  15054. */
  15055. getAnimatables(): IAnimatable[];
  15056. /**
  15057. * Clone the current skeleton
  15058. * @param name defines the name of the new skeleton
  15059. * @param id defines the id of the new skeleton
  15060. * @returns the new skeleton
  15061. */
  15062. clone(name: string, id?: string): Skeleton;
  15063. /**
  15064. * Enable animation blending for this skeleton
  15065. * @param blendingSpeed defines the blending speed to apply
  15066. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15067. */
  15068. enableBlending(blendingSpeed?: number): void;
  15069. /**
  15070. * Releases all resources associated with the current skeleton
  15071. */
  15072. dispose(): void;
  15073. /**
  15074. * Serialize the skeleton in a JSON object
  15075. * @returns a JSON object
  15076. */
  15077. serialize(): any;
  15078. /**
  15079. * Creates a new skeleton from serialized data
  15080. * @param parsedSkeleton defines the serialized data
  15081. * @param scene defines the hosting scene
  15082. * @returns a new skeleton
  15083. */
  15084. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15085. /**
  15086. * Compute all node absolute transforms
  15087. * @param forceUpdate defines if computation must be done even if cache is up to date
  15088. */
  15089. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15090. /**
  15091. * Gets the root pose matrix
  15092. * @returns a matrix
  15093. */
  15094. getPoseMatrix(): Nullable<Matrix>;
  15095. /**
  15096. * Sorts bones per internal index
  15097. */
  15098. sortBones(): void;
  15099. private _sortBones;
  15100. }
  15101. }
  15102. declare module BABYLON {
  15103. /**
  15104. * Creates an instance based on a source mesh.
  15105. */
  15106. export class InstancedMesh extends AbstractMesh {
  15107. private _sourceMesh;
  15108. private _currentLOD;
  15109. /** @hidden */
  15110. _indexInSourceMeshInstanceArray: number;
  15111. constructor(name: string, source: Mesh);
  15112. /**
  15113. * Returns the string "InstancedMesh".
  15114. */
  15115. getClassName(): string;
  15116. /** Gets the list of lights affecting that mesh */
  15117. get lightSources(): Light[];
  15118. _resyncLightSources(): void;
  15119. _resyncLightSource(light: Light): void;
  15120. _removeLightSource(light: Light, dispose: boolean): void;
  15121. /**
  15122. * If the source mesh receives shadows
  15123. */
  15124. get receiveShadows(): boolean;
  15125. /**
  15126. * The material of the source mesh
  15127. */
  15128. get material(): Nullable<Material>;
  15129. /**
  15130. * Visibility of the source mesh
  15131. */
  15132. get visibility(): number;
  15133. /**
  15134. * Skeleton of the source mesh
  15135. */
  15136. get skeleton(): Nullable<Skeleton>;
  15137. /**
  15138. * Rendering ground id of the source mesh
  15139. */
  15140. get renderingGroupId(): number;
  15141. set renderingGroupId(value: number);
  15142. /**
  15143. * Returns the total number of vertices (integer).
  15144. */
  15145. getTotalVertices(): number;
  15146. /**
  15147. * Returns a positive integer : the total number of indices in this mesh geometry.
  15148. * @returns the numner of indices or zero if the mesh has no geometry.
  15149. */
  15150. getTotalIndices(): number;
  15151. /**
  15152. * The source mesh of the instance
  15153. */
  15154. get sourceMesh(): Mesh;
  15155. /**
  15156. * Is this node ready to be used/rendered
  15157. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15158. * @return {boolean} is it ready
  15159. */
  15160. isReady(completeCheck?: boolean): boolean;
  15161. /**
  15162. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15163. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15164. * @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.
  15165. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15166. */
  15167. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15168. /**
  15169. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15170. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15171. * The `data` are either a numeric array either a Float32Array.
  15172. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15173. * 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).
  15174. * Note that a new underlying VertexBuffer object is created each call.
  15175. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15176. *
  15177. * Possible `kind` values :
  15178. * - VertexBuffer.PositionKind
  15179. * - VertexBuffer.UVKind
  15180. * - VertexBuffer.UV2Kind
  15181. * - VertexBuffer.UV3Kind
  15182. * - VertexBuffer.UV4Kind
  15183. * - VertexBuffer.UV5Kind
  15184. * - VertexBuffer.UV6Kind
  15185. * - VertexBuffer.ColorKind
  15186. * - VertexBuffer.MatricesIndicesKind
  15187. * - VertexBuffer.MatricesIndicesExtraKind
  15188. * - VertexBuffer.MatricesWeightsKind
  15189. * - VertexBuffer.MatricesWeightsExtraKind
  15190. *
  15191. * Returns the Mesh.
  15192. */
  15193. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15194. /**
  15195. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15196. * If the mesh has no geometry, it is simply returned as it is.
  15197. * The `data` are either a numeric array either a Float32Array.
  15198. * No new underlying VertexBuffer object is created.
  15199. * 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.
  15200. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15201. *
  15202. * Possible `kind` values :
  15203. * - VertexBuffer.PositionKind
  15204. * - VertexBuffer.UVKind
  15205. * - VertexBuffer.UV2Kind
  15206. * - VertexBuffer.UV3Kind
  15207. * - VertexBuffer.UV4Kind
  15208. * - VertexBuffer.UV5Kind
  15209. * - VertexBuffer.UV6Kind
  15210. * - VertexBuffer.ColorKind
  15211. * - VertexBuffer.MatricesIndicesKind
  15212. * - VertexBuffer.MatricesIndicesExtraKind
  15213. * - VertexBuffer.MatricesWeightsKind
  15214. * - VertexBuffer.MatricesWeightsExtraKind
  15215. *
  15216. * Returns the Mesh.
  15217. */
  15218. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15219. /**
  15220. * Sets the mesh indices.
  15221. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15222. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15223. * This method creates a new index buffer each call.
  15224. * Returns the Mesh.
  15225. */
  15226. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15227. /**
  15228. * Boolean : True if the mesh owns the requested kind of data.
  15229. */
  15230. isVerticesDataPresent(kind: string): boolean;
  15231. /**
  15232. * Returns an array of indices (IndicesArray).
  15233. */
  15234. getIndices(): Nullable<IndicesArray>;
  15235. get _positions(): Nullable<Vector3[]>;
  15236. /**
  15237. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15238. * This means the mesh underlying bounding box and sphere are recomputed.
  15239. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15240. * @returns the current mesh
  15241. */
  15242. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15243. /** @hidden */
  15244. _preActivate(): InstancedMesh;
  15245. /** @hidden */
  15246. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15247. /** @hidden */
  15248. _postActivate(): void;
  15249. getWorldMatrix(): Matrix;
  15250. get isAnInstance(): boolean;
  15251. /**
  15252. * Returns the current associated LOD AbstractMesh.
  15253. */
  15254. getLOD(camera: Camera): AbstractMesh;
  15255. /** @hidden */
  15256. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15257. /** @hidden */
  15258. _syncSubMeshes(): InstancedMesh;
  15259. /** @hidden */
  15260. _generatePointsArray(): boolean;
  15261. /**
  15262. * Creates a new InstancedMesh from the current mesh.
  15263. * - name (string) : the cloned mesh name
  15264. * - newParent (optional Node) : the optional Node to parent the clone to.
  15265. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15266. *
  15267. * Returns the clone.
  15268. */
  15269. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15270. /**
  15271. * Disposes the InstancedMesh.
  15272. * Returns nothing.
  15273. */
  15274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15275. }
  15276. interface Mesh {
  15277. /**
  15278. * Register a custom buffer that will be instanced
  15279. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15280. * @param kind defines the buffer kind
  15281. * @param stride defines the stride in floats
  15282. */
  15283. registerInstancedBuffer(kind: string, stride: number): void;
  15284. /** @hidden */
  15285. _userInstancedBuffersStorage: {
  15286. data: {
  15287. [key: string]: Float32Array;
  15288. };
  15289. sizes: {
  15290. [key: string]: number;
  15291. };
  15292. vertexBuffers: {
  15293. [key: string]: Nullable<VertexBuffer>;
  15294. };
  15295. strides: {
  15296. [key: string]: number;
  15297. };
  15298. };
  15299. }
  15300. interface AbstractMesh {
  15301. /**
  15302. * Object used to store instanced buffers defined by user
  15303. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15304. */
  15305. instancedBuffers: {
  15306. [key: string]: any;
  15307. };
  15308. }
  15309. }
  15310. declare module BABYLON {
  15311. /**
  15312. * Defines the options associated with the creation of a shader material.
  15313. */
  15314. export interface IShaderMaterialOptions {
  15315. /**
  15316. * Does the material work in alpha blend mode
  15317. */
  15318. needAlphaBlending: boolean;
  15319. /**
  15320. * Does the material work in alpha test mode
  15321. */
  15322. needAlphaTesting: boolean;
  15323. /**
  15324. * The list of attribute names used in the shader
  15325. */
  15326. attributes: string[];
  15327. /**
  15328. * The list of unifrom names used in the shader
  15329. */
  15330. uniforms: string[];
  15331. /**
  15332. * The list of UBO names used in the shader
  15333. */
  15334. uniformBuffers: string[];
  15335. /**
  15336. * The list of sampler names used in the shader
  15337. */
  15338. samplers: string[];
  15339. /**
  15340. * The list of defines used in the shader
  15341. */
  15342. defines: string[];
  15343. }
  15344. /**
  15345. * 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.
  15346. *
  15347. * This returned material effects how the mesh will look based on the code in the shaders.
  15348. *
  15349. * @see http://doc.babylonjs.com/how_to/shader_material
  15350. */
  15351. export class ShaderMaterial extends Material {
  15352. private _shaderPath;
  15353. private _options;
  15354. private _textures;
  15355. private _textureArrays;
  15356. private _floats;
  15357. private _ints;
  15358. private _floatsArrays;
  15359. private _colors3;
  15360. private _colors3Arrays;
  15361. private _colors4;
  15362. private _colors4Arrays;
  15363. private _vectors2;
  15364. private _vectors3;
  15365. private _vectors4;
  15366. private _matrices;
  15367. private _matrixArrays;
  15368. private _matrices3x3;
  15369. private _matrices2x2;
  15370. private _vectors2Arrays;
  15371. private _vectors3Arrays;
  15372. private _vectors4Arrays;
  15373. private _cachedWorldViewMatrix;
  15374. private _cachedWorldViewProjectionMatrix;
  15375. private _renderId;
  15376. private _multiview;
  15377. /**
  15378. * Instantiate a new shader material.
  15379. * 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.
  15380. * This returned material effects how the mesh will look based on the code in the shaders.
  15381. * @see http://doc.babylonjs.com/how_to/shader_material
  15382. * @param name Define the name of the material in the scene
  15383. * @param scene Define the scene the material belongs to
  15384. * @param shaderPath Defines the route to the shader code in one of three ways:
  15385. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15386. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15387. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15388. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15389. * @param options Define the options used to create the shader
  15390. */
  15391. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15392. /**
  15393. * Gets the shader path used to define the shader code
  15394. * It can be modified to trigger a new compilation
  15395. */
  15396. get shaderPath(): any;
  15397. /**
  15398. * Sets the shader path used to define the shader code
  15399. * It can be modified to trigger a new compilation
  15400. */
  15401. set shaderPath(shaderPath: any);
  15402. /**
  15403. * Gets the options used to compile the shader.
  15404. * They can be modified to trigger a new compilation
  15405. */
  15406. get options(): IShaderMaterialOptions;
  15407. /**
  15408. * Gets the current class name of the material e.g. "ShaderMaterial"
  15409. * Mainly use in serialization.
  15410. * @returns the class name
  15411. */
  15412. getClassName(): string;
  15413. /**
  15414. * Specifies if the material will require alpha blending
  15415. * @returns a boolean specifying if alpha blending is needed
  15416. */
  15417. needAlphaBlending(): boolean;
  15418. /**
  15419. * Specifies if this material should be rendered in alpha test mode
  15420. * @returns a boolean specifying if an alpha test is needed.
  15421. */
  15422. needAlphaTesting(): boolean;
  15423. private _checkUniform;
  15424. /**
  15425. * Set a texture in the shader.
  15426. * @param name Define the name of the uniform samplers as defined in the shader
  15427. * @param texture Define the texture to bind to this sampler
  15428. * @return the material itself allowing "fluent" like uniform updates
  15429. */
  15430. setTexture(name: string, texture: Texture): ShaderMaterial;
  15431. /**
  15432. * Set a texture array in the shader.
  15433. * @param name Define the name of the uniform sampler array as defined in the shader
  15434. * @param textures Define the list of textures to bind to this sampler
  15435. * @return the material itself allowing "fluent" like uniform updates
  15436. */
  15437. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15438. /**
  15439. * Set a float in the shader.
  15440. * @param name Define the name of the uniform as defined in the shader
  15441. * @param value Define the value to give to the uniform
  15442. * @return the material itself allowing "fluent" like uniform updates
  15443. */
  15444. setFloat(name: string, value: number): ShaderMaterial;
  15445. /**
  15446. * Set a int in the shader.
  15447. * @param name Define the name of the uniform as defined in the shader
  15448. * @param value Define the value to give to the uniform
  15449. * @return the material itself allowing "fluent" like uniform updates
  15450. */
  15451. setInt(name: string, value: number): ShaderMaterial;
  15452. /**
  15453. * Set an array of floats in the shader.
  15454. * @param name Define the name of the uniform as defined in the shader
  15455. * @param value Define the value to give to the uniform
  15456. * @return the material itself allowing "fluent" like uniform updates
  15457. */
  15458. setFloats(name: string, value: number[]): ShaderMaterial;
  15459. /**
  15460. * Set a vec3 in the shader from a Color3.
  15461. * @param name Define the name of the uniform as defined in the shader
  15462. * @param value Define the value to give to the uniform
  15463. * @return the material itself allowing "fluent" like uniform updates
  15464. */
  15465. setColor3(name: string, value: Color3): ShaderMaterial;
  15466. /**
  15467. * Set a vec3 array in the shader from a Color3 array.
  15468. * @param name Define the name of the uniform as defined in the shader
  15469. * @param value Define the value to give to the uniform
  15470. * @return the material itself allowing "fluent" like uniform updates
  15471. */
  15472. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15473. /**
  15474. * Set a vec4 in the shader from a Color4.
  15475. * @param name Define the name of the uniform as defined in the shader
  15476. * @param value Define the value to give to the uniform
  15477. * @return the material itself allowing "fluent" like uniform updates
  15478. */
  15479. setColor4(name: string, value: Color4): ShaderMaterial;
  15480. /**
  15481. * Set a vec4 array in the shader from a Color4 array.
  15482. * @param name Define the name of the uniform as defined in the shader
  15483. * @param value Define the value to give to the uniform
  15484. * @return the material itself allowing "fluent" like uniform updates
  15485. */
  15486. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15487. /**
  15488. * Set a vec2 in the shader from a Vector2.
  15489. * @param name Define the name of the uniform as defined in the shader
  15490. * @param value Define the value to give to the uniform
  15491. * @return the material itself allowing "fluent" like uniform updates
  15492. */
  15493. setVector2(name: string, value: Vector2): ShaderMaterial;
  15494. /**
  15495. * Set a vec3 in the shader from a Vector3.
  15496. * @param name Define the name of the uniform as defined in the shader
  15497. * @param value Define the value to give to the uniform
  15498. * @return the material itself allowing "fluent" like uniform updates
  15499. */
  15500. setVector3(name: string, value: Vector3): ShaderMaterial;
  15501. /**
  15502. * Set a vec4 in the shader from a Vector4.
  15503. * @param name Define the name of the uniform as defined in the shader
  15504. * @param value Define the value to give to the uniform
  15505. * @return the material itself allowing "fluent" like uniform updates
  15506. */
  15507. setVector4(name: string, value: Vector4): ShaderMaterial;
  15508. /**
  15509. * Set a mat4 in the shader from a Matrix.
  15510. * @param name Define the name of the uniform as defined in the shader
  15511. * @param value Define the value to give to the uniform
  15512. * @return the material itself allowing "fluent" like uniform updates
  15513. */
  15514. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15515. /**
  15516. * Set a float32Array in the shader from a matrix array.
  15517. * @param name Define the name of the uniform as defined in the shader
  15518. * @param value Define the value to give to the uniform
  15519. * @return the material itself allowing "fluent" like uniform updates
  15520. */
  15521. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15522. /**
  15523. * Set a mat3 in the shader from a Float32Array.
  15524. * @param name Define the name of the uniform as defined in the shader
  15525. * @param value Define the value to give to the uniform
  15526. * @return the material itself allowing "fluent" like uniform updates
  15527. */
  15528. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15529. /**
  15530. * Set a mat2 in the shader from a Float32Array.
  15531. * @param name Define the name of the uniform as defined in the shader
  15532. * @param value Define the value to give to the uniform
  15533. * @return the material itself allowing "fluent" like uniform updates
  15534. */
  15535. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15536. /**
  15537. * Set a vec2 array in the shader from a number array.
  15538. * @param name Define the name of the uniform as defined in the shader
  15539. * @param value Define the value to give to the uniform
  15540. * @return the material itself allowing "fluent" like uniform updates
  15541. */
  15542. setArray2(name: string, value: number[]): ShaderMaterial;
  15543. /**
  15544. * Set a vec3 array in the shader from a number array.
  15545. * @param name Define the name of the uniform as defined in the shader
  15546. * @param value Define the value to give to the uniform
  15547. * @return the material itself allowing "fluent" like uniform updates
  15548. */
  15549. setArray3(name: string, value: number[]): ShaderMaterial;
  15550. /**
  15551. * Set a vec4 array in the shader from a number array.
  15552. * @param name Define the name of the uniform as defined in the shader
  15553. * @param value Define the value to give to the uniform
  15554. * @return the material itself allowing "fluent" like uniform updates
  15555. */
  15556. setArray4(name: string, value: number[]): ShaderMaterial;
  15557. private _checkCache;
  15558. /**
  15559. * Specifies that the submesh is ready to be used
  15560. * @param mesh defines the mesh to check
  15561. * @param subMesh defines which submesh to check
  15562. * @param useInstances specifies that instances should be used
  15563. * @returns a boolean indicating that the submesh is ready or not
  15564. */
  15565. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15566. /**
  15567. * Checks if the material is ready to render the requested mesh
  15568. * @param mesh Define the mesh to render
  15569. * @param useInstances Define whether or not the material is used with instances
  15570. * @returns true if ready, otherwise false
  15571. */
  15572. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15573. /**
  15574. * Binds the world matrix to the material
  15575. * @param world defines the world transformation matrix
  15576. */
  15577. bindOnlyWorldMatrix(world: Matrix): void;
  15578. /**
  15579. * Binds the material to the mesh
  15580. * @param world defines the world transformation matrix
  15581. * @param mesh defines the mesh to bind the material to
  15582. */
  15583. bind(world: Matrix, mesh?: Mesh): void;
  15584. /**
  15585. * Gets the active textures from the material
  15586. * @returns an array of textures
  15587. */
  15588. getActiveTextures(): BaseTexture[];
  15589. /**
  15590. * Specifies if the material uses a texture
  15591. * @param texture defines the texture to check against the material
  15592. * @returns a boolean specifying if the material uses the texture
  15593. */
  15594. hasTexture(texture: BaseTexture): boolean;
  15595. /**
  15596. * Makes a duplicate of the material, and gives it a new name
  15597. * @param name defines the new name for the duplicated material
  15598. * @returns the cloned material
  15599. */
  15600. clone(name: string): ShaderMaterial;
  15601. /**
  15602. * Disposes the material
  15603. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15604. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15605. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15606. */
  15607. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15608. /**
  15609. * Serializes this material in a JSON representation
  15610. * @returns the serialized material object
  15611. */
  15612. serialize(): any;
  15613. /**
  15614. * Creates a shader material from parsed shader material data
  15615. * @param source defines the JSON represnetation of the material
  15616. * @param scene defines the hosting scene
  15617. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15618. * @returns a new material
  15619. */
  15620. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15621. }
  15622. }
  15623. declare module BABYLON {
  15624. /** @hidden */
  15625. export var colorPixelShader: {
  15626. name: string;
  15627. shader: string;
  15628. };
  15629. }
  15630. declare module BABYLON {
  15631. /** @hidden */
  15632. export var colorVertexShader: {
  15633. name: string;
  15634. shader: string;
  15635. };
  15636. }
  15637. declare module BABYLON {
  15638. /**
  15639. * Line mesh
  15640. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15641. */
  15642. export class LinesMesh extends Mesh {
  15643. /**
  15644. * If vertex color should be applied to the mesh
  15645. */
  15646. readonly useVertexColor?: boolean | undefined;
  15647. /**
  15648. * If vertex alpha should be applied to the mesh
  15649. */
  15650. readonly useVertexAlpha?: boolean | undefined;
  15651. /**
  15652. * Color of the line (Default: White)
  15653. */
  15654. color: Color3;
  15655. /**
  15656. * Alpha of the line (Default: 1)
  15657. */
  15658. alpha: number;
  15659. /**
  15660. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15661. * This margin is expressed in world space coordinates, so its value may vary.
  15662. * Default value is 0.1
  15663. */
  15664. intersectionThreshold: number;
  15665. private _colorShader;
  15666. private color4;
  15667. /**
  15668. * Creates a new LinesMesh
  15669. * @param name defines the name
  15670. * @param scene defines the hosting scene
  15671. * @param parent defines the parent mesh if any
  15672. * @param source defines the optional source LinesMesh used to clone data from
  15673. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15674. * When false, achieved by calling a clone(), also passing False.
  15675. * This will make creation of children, recursive.
  15676. * @param useVertexColor defines if this LinesMesh supports vertex color
  15677. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15678. */
  15679. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15680. /**
  15681. * If vertex color should be applied to the mesh
  15682. */
  15683. useVertexColor?: boolean | undefined,
  15684. /**
  15685. * If vertex alpha should be applied to the mesh
  15686. */
  15687. useVertexAlpha?: boolean | undefined);
  15688. private _addClipPlaneDefine;
  15689. private _removeClipPlaneDefine;
  15690. isReady(): boolean;
  15691. /**
  15692. * Returns the string "LineMesh"
  15693. */
  15694. getClassName(): string;
  15695. /**
  15696. * @hidden
  15697. */
  15698. get material(): Material;
  15699. /**
  15700. * @hidden
  15701. */
  15702. set material(value: Material);
  15703. /**
  15704. * @hidden
  15705. */
  15706. get checkCollisions(): boolean;
  15707. /** @hidden */
  15708. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15709. /** @hidden */
  15710. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15711. /**
  15712. * Disposes of the line mesh
  15713. * @param doNotRecurse If children should be disposed
  15714. */
  15715. dispose(doNotRecurse?: boolean): void;
  15716. /**
  15717. * Returns a new LineMesh object cloned from the current one.
  15718. */
  15719. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15720. /**
  15721. * Creates a new InstancedLinesMesh object from the mesh model.
  15722. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15723. * @param name defines the name of the new instance
  15724. * @returns a new InstancedLinesMesh
  15725. */
  15726. createInstance(name: string): InstancedLinesMesh;
  15727. }
  15728. /**
  15729. * Creates an instance based on a source LinesMesh
  15730. */
  15731. export class InstancedLinesMesh extends InstancedMesh {
  15732. /**
  15733. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15734. * This margin is expressed in world space coordinates, so its value may vary.
  15735. * Initilized with the intersectionThreshold value of the source LinesMesh
  15736. */
  15737. intersectionThreshold: number;
  15738. constructor(name: string, source: LinesMesh);
  15739. /**
  15740. * Returns the string "InstancedLinesMesh".
  15741. */
  15742. getClassName(): string;
  15743. }
  15744. }
  15745. declare module BABYLON {
  15746. /** @hidden */
  15747. export var linePixelShader: {
  15748. name: string;
  15749. shader: string;
  15750. };
  15751. }
  15752. declare module BABYLON {
  15753. /** @hidden */
  15754. export var lineVertexShader: {
  15755. name: string;
  15756. shader: string;
  15757. };
  15758. }
  15759. declare module BABYLON {
  15760. interface AbstractMesh {
  15761. /**
  15762. * Gets the edgesRenderer associated with the mesh
  15763. */
  15764. edgesRenderer: Nullable<EdgesRenderer>;
  15765. }
  15766. interface LinesMesh {
  15767. /**
  15768. * Enables the edge rendering mode on the mesh.
  15769. * This mode makes the mesh edges visible
  15770. * @param epsilon defines the maximal distance between two angles to detect a face
  15771. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15772. * @returns the currentAbstractMesh
  15773. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15774. */
  15775. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15776. }
  15777. interface InstancedLinesMesh {
  15778. /**
  15779. * Enables the edge rendering mode on the mesh.
  15780. * This mode makes the mesh edges visible
  15781. * @param epsilon defines the maximal distance between two angles to detect a face
  15782. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15783. * @returns the current InstancedLinesMesh
  15784. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15785. */
  15786. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15787. }
  15788. /**
  15789. * Defines the minimum contract an Edges renderer should follow.
  15790. */
  15791. export interface IEdgesRenderer extends IDisposable {
  15792. /**
  15793. * Gets or sets a boolean indicating if the edgesRenderer is active
  15794. */
  15795. isEnabled: boolean;
  15796. /**
  15797. * Renders the edges of the attached mesh,
  15798. */
  15799. render(): void;
  15800. /**
  15801. * Checks wether or not the edges renderer is ready to render.
  15802. * @return true if ready, otherwise false.
  15803. */
  15804. isReady(): boolean;
  15805. }
  15806. /**
  15807. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15808. */
  15809. export class EdgesRenderer implements IEdgesRenderer {
  15810. /**
  15811. * Define the size of the edges with an orthographic camera
  15812. */
  15813. edgesWidthScalerForOrthographic: number;
  15814. /**
  15815. * Define the size of the edges with a perspective camera
  15816. */
  15817. edgesWidthScalerForPerspective: number;
  15818. protected _source: AbstractMesh;
  15819. protected _linesPositions: number[];
  15820. protected _linesNormals: number[];
  15821. protected _linesIndices: number[];
  15822. protected _epsilon: number;
  15823. protected _indicesCount: number;
  15824. protected _lineShader: ShaderMaterial;
  15825. protected _ib: DataBuffer;
  15826. protected _buffers: {
  15827. [key: string]: Nullable<VertexBuffer>;
  15828. };
  15829. protected _checkVerticesInsteadOfIndices: boolean;
  15830. private _meshRebuildObserver;
  15831. private _meshDisposeObserver;
  15832. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15833. isEnabled: boolean;
  15834. /**
  15835. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15836. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15837. * @param source Mesh used to create edges
  15838. * @param epsilon sum of angles in adjacency to check for edge
  15839. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15840. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15841. */
  15842. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15843. protected _prepareRessources(): void;
  15844. /** @hidden */
  15845. _rebuild(): void;
  15846. /**
  15847. * Releases the required resources for the edges renderer
  15848. */
  15849. dispose(): void;
  15850. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15851. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15852. /**
  15853. * Checks if the pair of p0 and p1 is en edge
  15854. * @param faceIndex
  15855. * @param edge
  15856. * @param faceNormals
  15857. * @param p0
  15858. * @param p1
  15859. * @private
  15860. */
  15861. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15862. /**
  15863. * push line into the position, normal and index buffer
  15864. * @protected
  15865. */
  15866. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15867. /**
  15868. * Generates lines edges from adjacencjes
  15869. * @private
  15870. */
  15871. _generateEdgesLines(): void;
  15872. /**
  15873. * Checks wether or not the edges renderer is ready to render.
  15874. * @return true if ready, otherwise false.
  15875. */
  15876. isReady(): boolean;
  15877. /**
  15878. * Renders the edges of the attached mesh,
  15879. */
  15880. render(): void;
  15881. }
  15882. /**
  15883. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15884. */
  15885. export class LineEdgesRenderer extends EdgesRenderer {
  15886. /**
  15887. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15888. * @param source LineMesh used to generate edges
  15889. * @param epsilon not important (specified angle for edge detection)
  15890. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15891. */
  15892. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15893. /**
  15894. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15895. */
  15896. _generateEdgesLines(): void;
  15897. }
  15898. }
  15899. declare module BABYLON {
  15900. /**
  15901. * This represents the object necessary to create a rendering group.
  15902. * This is exclusively used and created by the rendering manager.
  15903. * To modify the behavior, you use the available helpers in your scene or meshes.
  15904. * @hidden
  15905. */
  15906. export class RenderingGroup {
  15907. index: number;
  15908. private static _zeroVector;
  15909. private _scene;
  15910. private _opaqueSubMeshes;
  15911. private _transparentSubMeshes;
  15912. private _alphaTestSubMeshes;
  15913. private _depthOnlySubMeshes;
  15914. private _particleSystems;
  15915. private _spriteManagers;
  15916. private _opaqueSortCompareFn;
  15917. private _alphaTestSortCompareFn;
  15918. private _transparentSortCompareFn;
  15919. private _renderOpaque;
  15920. private _renderAlphaTest;
  15921. private _renderTransparent;
  15922. /** @hidden */
  15923. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15924. onBeforeTransparentRendering: () => void;
  15925. /**
  15926. * Set the opaque sort comparison function.
  15927. * If null the sub meshes will be render in the order they were created
  15928. */
  15929. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15930. /**
  15931. * Set the alpha test sort comparison function.
  15932. * If null the sub meshes will be render in the order they were created
  15933. */
  15934. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15935. /**
  15936. * Set the transparent sort comparison function.
  15937. * If null the sub meshes will be render in the order they were created
  15938. */
  15939. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15940. /**
  15941. * Creates a new rendering group.
  15942. * @param index The rendering group index
  15943. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15944. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15945. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15946. */
  15947. 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>);
  15948. /**
  15949. * Render all the sub meshes contained in the group.
  15950. * @param customRenderFunction Used to override the default render behaviour of the group.
  15951. * @returns true if rendered some submeshes.
  15952. */
  15953. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15954. /**
  15955. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15956. * @param subMeshes The submeshes to render
  15957. */
  15958. private renderOpaqueSorted;
  15959. /**
  15960. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15961. * @param subMeshes The submeshes to render
  15962. */
  15963. private renderAlphaTestSorted;
  15964. /**
  15965. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15966. * @param subMeshes The submeshes to render
  15967. */
  15968. private renderTransparentSorted;
  15969. /**
  15970. * Renders the submeshes in a specified order.
  15971. * @param subMeshes The submeshes to sort before render
  15972. * @param sortCompareFn The comparison function use to sort
  15973. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15974. * @param transparent Specifies to activate blending if true
  15975. */
  15976. private static renderSorted;
  15977. /**
  15978. * Renders the submeshes in the order they were dispatched (no sort applied).
  15979. * @param subMeshes The submeshes to render
  15980. */
  15981. private static renderUnsorted;
  15982. /**
  15983. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15984. * are rendered back to front if in the same alpha index.
  15985. *
  15986. * @param a The first submesh
  15987. * @param b The second submesh
  15988. * @returns The result of the comparison
  15989. */
  15990. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15991. /**
  15992. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15993. * are rendered back to front.
  15994. *
  15995. * @param a The first submesh
  15996. * @param b The second submesh
  15997. * @returns The result of the comparison
  15998. */
  15999. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16000. /**
  16001. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16002. * are rendered front to back (prevent overdraw).
  16003. *
  16004. * @param a The first submesh
  16005. * @param b The second submesh
  16006. * @returns The result of the comparison
  16007. */
  16008. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16009. /**
  16010. * Resets the different lists of submeshes to prepare a new frame.
  16011. */
  16012. prepare(): void;
  16013. dispose(): void;
  16014. /**
  16015. * Inserts the submesh in its correct queue depending on its material.
  16016. * @param subMesh The submesh to dispatch
  16017. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16018. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16019. */
  16020. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16021. dispatchSprites(spriteManager: ISpriteManager): void;
  16022. dispatchParticles(particleSystem: IParticleSystem): void;
  16023. private _renderParticles;
  16024. private _renderSprites;
  16025. }
  16026. }
  16027. declare module BABYLON {
  16028. /**
  16029. * Interface describing the different options available in the rendering manager
  16030. * regarding Auto Clear between groups.
  16031. */
  16032. export interface IRenderingManagerAutoClearSetup {
  16033. /**
  16034. * Defines whether or not autoclear is enable.
  16035. */
  16036. autoClear: boolean;
  16037. /**
  16038. * Defines whether or not to autoclear the depth buffer.
  16039. */
  16040. depth: boolean;
  16041. /**
  16042. * Defines whether or not to autoclear the stencil buffer.
  16043. */
  16044. stencil: boolean;
  16045. }
  16046. /**
  16047. * This class is used by the onRenderingGroupObservable
  16048. */
  16049. export class RenderingGroupInfo {
  16050. /**
  16051. * The Scene that being rendered
  16052. */
  16053. scene: Scene;
  16054. /**
  16055. * The camera currently used for the rendering pass
  16056. */
  16057. camera: Nullable<Camera>;
  16058. /**
  16059. * The ID of the renderingGroup being processed
  16060. */
  16061. renderingGroupId: number;
  16062. }
  16063. /**
  16064. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16065. * It is enable to manage the different groups as well as the different necessary sort functions.
  16066. * This should not be used directly aside of the few static configurations
  16067. */
  16068. export class RenderingManager {
  16069. /**
  16070. * The max id used for rendering groups (not included)
  16071. */
  16072. static MAX_RENDERINGGROUPS: number;
  16073. /**
  16074. * The min id used for rendering groups (included)
  16075. */
  16076. static MIN_RENDERINGGROUPS: number;
  16077. /**
  16078. * Used to globally prevent autoclearing scenes.
  16079. */
  16080. static AUTOCLEAR: boolean;
  16081. /**
  16082. * @hidden
  16083. */
  16084. _useSceneAutoClearSetup: boolean;
  16085. private _scene;
  16086. private _renderingGroups;
  16087. private _depthStencilBufferAlreadyCleaned;
  16088. private _autoClearDepthStencil;
  16089. private _customOpaqueSortCompareFn;
  16090. private _customAlphaTestSortCompareFn;
  16091. private _customTransparentSortCompareFn;
  16092. private _renderingGroupInfo;
  16093. /**
  16094. * Instantiates a new rendering group for a particular scene
  16095. * @param scene Defines the scene the groups belongs to
  16096. */
  16097. constructor(scene: Scene);
  16098. private _clearDepthStencilBuffer;
  16099. /**
  16100. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16101. * @hidden
  16102. */
  16103. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16104. /**
  16105. * Resets the different information of the group to prepare a new frame
  16106. * @hidden
  16107. */
  16108. reset(): void;
  16109. /**
  16110. * Dispose and release the group and its associated resources.
  16111. * @hidden
  16112. */
  16113. dispose(): void;
  16114. /**
  16115. * Clear the info related to rendering groups preventing retention points during dispose.
  16116. */
  16117. freeRenderingGroups(): void;
  16118. private _prepareRenderingGroup;
  16119. /**
  16120. * Add a sprite manager to the rendering manager in order to render it this frame.
  16121. * @param spriteManager Define the sprite manager to render
  16122. */
  16123. dispatchSprites(spriteManager: ISpriteManager): void;
  16124. /**
  16125. * Add a particle system to the rendering manager in order to render it this frame.
  16126. * @param particleSystem Define the particle system to render
  16127. */
  16128. dispatchParticles(particleSystem: IParticleSystem): void;
  16129. /**
  16130. * Add a submesh to the manager in order to render it this frame
  16131. * @param subMesh The submesh to dispatch
  16132. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16133. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16134. */
  16135. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16136. /**
  16137. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16138. * This allowed control for front to back rendering or reversly depending of the special needs.
  16139. *
  16140. * @param renderingGroupId The rendering group id corresponding to its index
  16141. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16142. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16143. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16144. */
  16145. 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;
  16146. /**
  16147. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16148. *
  16149. * @param renderingGroupId The rendering group id corresponding to its index
  16150. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16151. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16152. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16153. */
  16154. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16155. /**
  16156. * Gets the current auto clear configuration for one rendering group of the rendering
  16157. * manager.
  16158. * @param index the rendering group index to get the information for
  16159. * @returns The auto clear setup for the requested rendering group
  16160. */
  16161. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16162. }
  16163. }
  16164. declare module BABYLON {
  16165. /**
  16166. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16167. */
  16168. export interface ICustomShaderOptions {
  16169. /**
  16170. * Gets or sets the custom shader name to use
  16171. */
  16172. shaderName: string;
  16173. /**
  16174. * The list of attribute names used in the shader
  16175. */
  16176. attributes?: string[];
  16177. /**
  16178. * The list of unifrom names used in the shader
  16179. */
  16180. uniforms?: string[];
  16181. /**
  16182. * The list of sampler names used in the shader
  16183. */
  16184. samplers?: string[];
  16185. /**
  16186. * The list of defines used in the shader
  16187. */
  16188. defines?: string[];
  16189. }
  16190. /**
  16191. * Interface to implement to create a shadow generator compatible with BJS.
  16192. */
  16193. export interface IShadowGenerator {
  16194. /**
  16195. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16196. * @returns The render target texture if present otherwise, null
  16197. */
  16198. getShadowMap(): Nullable<RenderTargetTexture>;
  16199. /**
  16200. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16201. * @param subMesh The submesh we want to render in the shadow map
  16202. * @param useInstances Defines wether will draw in the map using instances
  16203. * @returns true if ready otherwise, false
  16204. */
  16205. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16206. /**
  16207. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16208. * @param defines Defines of the material we want to update
  16209. * @param lightIndex Index of the light in the enabled light list of the material
  16210. */
  16211. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16212. /**
  16213. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16214. * defined in the generator but impacting the effect).
  16215. * It implies the unifroms available on the materials are the standard BJS ones.
  16216. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16217. * @param effect The effect we are binfing the information for
  16218. */
  16219. bindShadowLight(lightIndex: string, effect: Effect): void;
  16220. /**
  16221. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16222. * (eq to shadow prjection matrix * light transform matrix)
  16223. * @returns The transform matrix used to create the shadow map
  16224. */
  16225. getTransformMatrix(): Matrix;
  16226. /**
  16227. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16228. * Cube and 2D textures for instance.
  16229. */
  16230. recreateShadowMap(): void;
  16231. /**
  16232. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16233. * @param onCompiled Callback triggered at the and of the effects compilation
  16234. * @param options Sets of optional options forcing the compilation with different modes
  16235. */
  16236. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16237. useInstances: boolean;
  16238. }>): void;
  16239. /**
  16240. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16241. * @param options Sets of optional options forcing the compilation with different modes
  16242. * @returns A promise that resolves when the compilation completes
  16243. */
  16244. forceCompilationAsync(options?: Partial<{
  16245. useInstances: boolean;
  16246. }>): Promise<void>;
  16247. /**
  16248. * Serializes the shadow generator setup to a json object.
  16249. * @returns The serialized JSON object
  16250. */
  16251. serialize(): any;
  16252. /**
  16253. * Disposes the Shadow map and related Textures and effects.
  16254. */
  16255. dispose(): void;
  16256. }
  16257. /**
  16258. * Default implementation IShadowGenerator.
  16259. * This is the main object responsible of generating shadows in the framework.
  16260. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16261. */
  16262. export class ShadowGenerator implements IShadowGenerator {
  16263. /**
  16264. * Name of the shadow generator class
  16265. */
  16266. static CLASSNAME: string;
  16267. /**
  16268. * Shadow generator mode None: no filtering applied.
  16269. */
  16270. static readonly FILTER_NONE: number;
  16271. /**
  16272. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16273. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16274. */
  16275. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16276. /**
  16277. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16278. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16279. */
  16280. static readonly FILTER_POISSONSAMPLING: number;
  16281. /**
  16282. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16283. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16284. */
  16285. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16286. /**
  16287. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16288. * edge artifacts on steep falloff.
  16289. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16290. */
  16291. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16292. /**
  16293. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16294. * edge artifacts on steep falloff.
  16295. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16296. */
  16297. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16298. /**
  16299. * Shadow generator mode PCF: Percentage Closer Filtering
  16300. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16301. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16302. */
  16303. static readonly FILTER_PCF: number;
  16304. /**
  16305. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16306. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16307. * Contact Hardening
  16308. */
  16309. static readonly FILTER_PCSS: number;
  16310. /**
  16311. * Reserved for PCF and PCSS
  16312. * Highest Quality.
  16313. *
  16314. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16315. *
  16316. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16317. */
  16318. static readonly QUALITY_HIGH: number;
  16319. /**
  16320. * Reserved for PCF and PCSS
  16321. * Good tradeoff for quality/perf cross devices
  16322. *
  16323. * Execute PCF on a 3*3 kernel.
  16324. *
  16325. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16326. */
  16327. static readonly QUALITY_MEDIUM: number;
  16328. /**
  16329. * Reserved for PCF and PCSS
  16330. * The lowest quality but the fastest.
  16331. *
  16332. * Execute PCF on a 1*1 kernel.
  16333. *
  16334. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16335. */
  16336. static readonly QUALITY_LOW: number;
  16337. /** Gets or sets the custom shader name to use */
  16338. customShaderOptions: ICustomShaderOptions;
  16339. /**
  16340. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16341. */
  16342. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16343. /**
  16344. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16345. */
  16346. onAfterShadowMapRenderObservable: Observable<Effect>;
  16347. /**
  16348. * Observable triggered before a mesh is rendered in the shadow map.
  16349. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16350. */
  16351. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16352. /**
  16353. * Observable triggered after a mesh is rendered in the shadow map.
  16354. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16355. */
  16356. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16357. protected _bias: number;
  16358. /**
  16359. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16360. */
  16361. get bias(): number;
  16362. /**
  16363. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16364. */
  16365. set bias(bias: number);
  16366. protected _normalBias: number;
  16367. /**
  16368. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16369. */
  16370. get normalBias(): number;
  16371. /**
  16372. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16373. */
  16374. set normalBias(normalBias: number);
  16375. protected _blurBoxOffset: number;
  16376. /**
  16377. * Gets the blur box offset: offset applied during the blur pass.
  16378. * Only useful if useKernelBlur = false
  16379. */
  16380. get blurBoxOffset(): number;
  16381. /**
  16382. * Sets the blur box offset: offset applied during the blur pass.
  16383. * Only useful if useKernelBlur = false
  16384. */
  16385. set blurBoxOffset(value: number);
  16386. protected _blurScale: number;
  16387. /**
  16388. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16389. * 2 means half of the size.
  16390. */
  16391. get blurScale(): number;
  16392. /**
  16393. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16394. * 2 means half of the size.
  16395. */
  16396. set blurScale(value: number);
  16397. protected _blurKernel: number;
  16398. /**
  16399. * Gets the blur kernel: kernel size of the blur pass.
  16400. * Only useful if useKernelBlur = true
  16401. */
  16402. get blurKernel(): number;
  16403. /**
  16404. * Sets the blur kernel: kernel size of the blur pass.
  16405. * Only useful if useKernelBlur = true
  16406. */
  16407. set blurKernel(value: number);
  16408. protected _useKernelBlur: boolean;
  16409. /**
  16410. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16411. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16412. */
  16413. get useKernelBlur(): boolean;
  16414. /**
  16415. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16416. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16417. */
  16418. set useKernelBlur(value: boolean);
  16419. protected _depthScale: number;
  16420. /**
  16421. * Gets the depth scale used in ESM mode.
  16422. */
  16423. get depthScale(): number;
  16424. /**
  16425. * Sets the depth scale used in ESM mode.
  16426. * This can override the scale stored on the light.
  16427. */
  16428. set depthScale(value: number);
  16429. protected _validateFilter(filter: number): number;
  16430. protected _filter: number;
  16431. /**
  16432. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16433. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16434. */
  16435. get filter(): number;
  16436. /**
  16437. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16438. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16439. */
  16440. set filter(value: number);
  16441. /**
  16442. * Gets if the current filter is set to Poisson Sampling.
  16443. */
  16444. get usePoissonSampling(): boolean;
  16445. /**
  16446. * Sets the current filter to Poisson Sampling.
  16447. */
  16448. set usePoissonSampling(value: boolean);
  16449. /**
  16450. * Gets if the current filter is set to ESM.
  16451. */
  16452. get useExponentialShadowMap(): boolean;
  16453. /**
  16454. * Sets the current filter is to ESM.
  16455. */
  16456. set useExponentialShadowMap(value: boolean);
  16457. /**
  16458. * Gets if the current filter is set to filtered ESM.
  16459. */
  16460. get useBlurExponentialShadowMap(): boolean;
  16461. /**
  16462. * Gets if the current filter is set to filtered ESM.
  16463. */
  16464. set useBlurExponentialShadowMap(value: boolean);
  16465. /**
  16466. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16467. * exponential to prevent steep falloff artifacts).
  16468. */
  16469. get useCloseExponentialShadowMap(): boolean;
  16470. /**
  16471. * Sets the current filter to "close ESM" (using the inverse of the
  16472. * exponential to prevent steep falloff artifacts).
  16473. */
  16474. set useCloseExponentialShadowMap(value: boolean);
  16475. /**
  16476. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16477. * exponential to prevent steep falloff artifacts).
  16478. */
  16479. get useBlurCloseExponentialShadowMap(): boolean;
  16480. /**
  16481. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16482. * exponential to prevent steep falloff artifacts).
  16483. */
  16484. set useBlurCloseExponentialShadowMap(value: boolean);
  16485. /**
  16486. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16487. */
  16488. get usePercentageCloserFiltering(): boolean;
  16489. /**
  16490. * Sets the current filter to "PCF" (percentage closer filtering).
  16491. */
  16492. set usePercentageCloserFiltering(value: boolean);
  16493. protected _filteringQuality: number;
  16494. /**
  16495. * Gets the PCF or PCSS Quality.
  16496. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16497. */
  16498. get filteringQuality(): number;
  16499. /**
  16500. * Sets the PCF or PCSS Quality.
  16501. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16502. */
  16503. set filteringQuality(filteringQuality: number);
  16504. /**
  16505. * Gets if the current filter is set to "PCSS" (contact hardening).
  16506. */
  16507. get useContactHardeningShadow(): boolean;
  16508. /**
  16509. * Sets the current filter to "PCSS" (contact hardening).
  16510. */
  16511. set useContactHardeningShadow(value: boolean);
  16512. protected _contactHardeningLightSizeUVRatio: number;
  16513. /**
  16514. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16515. * Using a ratio helps keeping shape stability independently of the map size.
  16516. *
  16517. * It does not account for the light projection as it was having too much
  16518. * instability during the light setup or during light position changes.
  16519. *
  16520. * Only valid if useContactHardeningShadow is true.
  16521. */
  16522. get contactHardeningLightSizeUVRatio(): number;
  16523. /**
  16524. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16525. * Using a ratio helps keeping shape stability independently of the map size.
  16526. *
  16527. * It does not account for the light projection as it was having too much
  16528. * instability during the light setup or during light position changes.
  16529. *
  16530. * Only valid if useContactHardeningShadow is true.
  16531. */
  16532. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16533. protected _darkness: number;
  16534. /** Gets or sets the actual darkness of a shadow */
  16535. get darkness(): number;
  16536. set darkness(value: number);
  16537. /**
  16538. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16539. * 0 means strongest and 1 would means no shadow.
  16540. * @returns the darkness.
  16541. */
  16542. getDarkness(): number;
  16543. /**
  16544. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16545. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16546. * @returns the shadow generator allowing fluent coding.
  16547. */
  16548. setDarkness(darkness: number): ShadowGenerator;
  16549. protected _transparencyShadow: boolean;
  16550. /** Gets or sets the ability to have transparent shadow */
  16551. get transparencyShadow(): boolean;
  16552. set transparencyShadow(value: boolean);
  16553. /**
  16554. * Sets the ability to have transparent shadow (boolean).
  16555. * @param transparent True if transparent else False
  16556. * @returns the shadow generator allowing fluent coding
  16557. */
  16558. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16559. protected _shadowMap: Nullable<RenderTargetTexture>;
  16560. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16561. /**
  16562. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16563. * @returns The render target texture if present otherwise, null
  16564. */
  16565. getShadowMap(): Nullable<RenderTargetTexture>;
  16566. /**
  16567. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16568. * @returns The render target texture if the shadow map is present otherwise, null
  16569. */
  16570. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16571. /**
  16572. * Gets the class name of that object
  16573. * @returns "ShadowGenerator"
  16574. */
  16575. getClassName(): string;
  16576. /**
  16577. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16578. * @param mesh Mesh to add
  16579. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16580. * @returns the Shadow Generator itself
  16581. */
  16582. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16583. /**
  16584. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16585. * @param mesh Mesh to remove
  16586. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16587. * @returns the Shadow Generator itself
  16588. */
  16589. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16590. /**
  16591. * Controls the extent to which the shadows fade out at the edge of the frustum
  16592. */
  16593. frustumEdgeFalloff: number;
  16594. protected _light: IShadowLight;
  16595. /**
  16596. * Returns the associated light object.
  16597. * @returns the light generating the shadow
  16598. */
  16599. getLight(): IShadowLight;
  16600. /**
  16601. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16602. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16603. * It might on the other hand introduce peter panning.
  16604. */
  16605. forceBackFacesOnly: boolean;
  16606. protected _scene: Scene;
  16607. protected _lightDirection: Vector3;
  16608. protected _effect: Effect;
  16609. protected _viewMatrix: Matrix;
  16610. protected _projectionMatrix: Matrix;
  16611. protected _transformMatrix: Matrix;
  16612. protected _cachedPosition: Vector3;
  16613. protected _cachedDirection: Vector3;
  16614. protected _cachedDefines: string;
  16615. protected _currentRenderID: number;
  16616. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16617. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16618. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16619. protected _blurPostProcesses: PostProcess[];
  16620. protected _mapSize: number;
  16621. protected _currentFaceIndex: number;
  16622. protected _currentFaceIndexCache: number;
  16623. protected _textureType: number;
  16624. protected _defaultTextureMatrix: Matrix;
  16625. protected _storedUniqueId: Nullable<number>;
  16626. /** @hidden */
  16627. static _SceneComponentInitialization: (scene: Scene) => void;
  16628. /**
  16629. * Creates a ShadowGenerator object.
  16630. * A ShadowGenerator is the required tool to use the shadows.
  16631. * Each light casting shadows needs to use its own ShadowGenerator.
  16632. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16633. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16634. * @param light The light object generating the shadows.
  16635. * @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.
  16636. */
  16637. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16638. protected _initializeGenerator(): void;
  16639. protected _createTargetRenderTexture(): void;
  16640. protected _initializeShadowMap(): void;
  16641. protected _initializeBlurRTTAndPostProcesses(): void;
  16642. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16643. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16644. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16645. protected _applyFilterValues(): void;
  16646. /**
  16647. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16648. * @param onCompiled Callback triggered at the and of the effects compilation
  16649. * @param options Sets of optional options forcing the compilation with different modes
  16650. */
  16651. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16652. useInstances: boolean;
  16653. }>): void;
  16654. /**
  16655. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16656. * @param options Sets of optional options forcing the compilation with different modes
  16657. * @returns A promise that resolves when the compilation completes
  16658. */
  16659. forceCompilationAsync(options?: Partial<{
  16660. useInstances: boolean;
  16661. }>): Promise<void>;
  16662. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16663. /**
  16664. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16665. * @param subMesh The submesh we want to render in the shadow map
  16666. * @param useInstances Defines wether will draw in the map using instances
  16667. * @returns true if ready otherwise, false
  16668. */
  16669. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16670. /**
  16671. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16672. * @param defines Defines of the material we want to update
  16673. * @param lightIndex Index of the light in the enabled light list of the material
  16674. */
  16675. prepareDefines(defines: any, lightIndex: number): void;
  16676. /**
  16677. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16678. * defined in the generator but impacting the effect).
  16679. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16680. * @param effect The effect we are binfing the information for
  16681. */
  16682. bindShadowLight(lightIndex: string, effect: Effect): void;
  16683. /**
  16684. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16685. * (eq to shadow prjection matrix * light transform matrix)
  16686. * @returns The transform matrix used to create the shadow map
  16687. */
  16688. getTransformMatrix(): Matrix;
  16689. /**
  16690. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16691. * Cube and 2D textures for instance.
  16692. */
  16693. recreateShadowMap(): void;
  16694. protected _disposeBlurPostProcesses(): void;
  16695. protected _disposeRTTandPostProcesses(): void;
  16696. /**
  16697. * Disposes the ShadowGenerator.
  16698. * Returns nothing.
  16699. */
  16700. dispose(): void;
  16701. /**
  16702. * Serializes the shadow generator setup to a json object.
  16703. * @returns The serialized JSON object
  16704. */
  16705. serialize(): any;
  16706. /**
  16707. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16708. * @param parsedShadowGenerator The JSON object to parse
  16709. * @param scene The scene to create the shadow map for
  16710. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16711. * @returns The parsed shadow generator
  16712. */
  16713. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16714. }
  16715. }
  16716. declare module BABYLON {
  16717. /**
  16718. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16719. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16720. * 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.
  16721. */
  16722. export abstract class Light extends Node {
  16723. /**
  16724. * Falloff Default: light is falling off following the material specification:
  16725. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16726. */
  16727. static readonly FALLOFF_DEFAULT: number;
  16728. /**
  16729. * Falloff Physical: light is falling off following the inverse squared distance law.
  16730. */
  16731. static readonly FALLOFF_PHYSICAL: number;
  16732. /**
  16733. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16734. * to enhance interoperability with other engines.
  16735. */
  16736. static readonly FALLOFF_GLTF: number;
  16737. /**
  16738. * Falloff Standard: light is falling off like in the standard material
  16739. * to enhance interoperability with other materials.
  16740. */
  16741. static readonly FALLOFF_STANDARD: number;
  16742. /**
  16743. * If every light affecting the material is in this lightmapMode,
  16744. * material.lightmapTexture adds or multiplies
  16745. * (depends on material.useLightmapAsShadowmap)
  16746. * after every other light calculations.
  16747. */
  16748. static readonly LIGHTMAP_DEFAULT: number;
  16749. /**
  16750. * material.lightmapTexture as only diffuse lighting from this light
  16751. * adds only specular lighting from this light
  16752. * adds dynamic shadows
  16753. */
  16754. static readonly LIGHTMAP_SPECULAR: number;
  16755. /**
  16756. * material.lightmapTexture as only lighting
  16757. * no light calculation from this light
  16758. * only adds dynamic shadows from this light
  16759. */
  16760. static readonly LIGHTMAP_SHADOWSONLY: number;
  16761. /**
  16762. * Each light type uses the default quantity according to its type:
  16763. * point/spot lights use luminous intensity
  16764. * directional lights use illuminance
  16765. */
  16766. static readonly INTENSITYMODE_AUTOMATIC: number;
  16767. /**
  16768. * lumen (lm)
  16769. */
  16770. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16771. /**
  16772. * candela (lm/sr)
  16773. */
  16774. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16775. /**
  16776. * lux (lm/m^2)
  16777. */
  16778. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16779. /**
  16780. * nit (cd/m^2)
  16781. */
  16782. static readonly INTENSITYMODE_LUMINANCE: number;
  16783. /**
  16784. * Light type const id of the point light.
  16785. */
  16786. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16787. /**
  16788. * Light type const id of the directional light.
  16789. */
  16790. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16791. /**
  16792. * Light type const id of the spot light.
  16793. */
  16794. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16795. /**
  16796. * Light type const id of the hemispheric light.
  16797. */
  16798. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16799. /**
  16800. * Diffuse gives the basic color to an object.
  16801. */
  16802. diffuse: Color3;
  16803. /**
  16804. * Specular produces a highlight color on an object.
  16805. * Note: This is note affecting PBR materials.
  16806. */
  16807. specular: Color3;
  16808. /**
  16809. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16810. * falling off base on range or angle.
  16811. * This can be set to any values in Light.FALLOFF_x.
  16812. *
  16813. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16814. * other types of materials.
  16815. */
  16816. falloffType: number;
  16817. /**
  16818. * Strength of the light.
  16819. * Note: By default it is define in the framework own unit.
  16820. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16821. */
  16822. intensity: number;
  16823. private _range;
  16824. protected _inverseSquaredRange: number;
  16825. /**
  16826. * Defines how far from the source the light is impacting in scene units.
  16827. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16828. */
  16829. get range(): number;
  16830. /**
  16831. * Defines how far from the source the light is impacting in scene units.
  16832. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16833. */
  16834. set range(value: number);
  16835. /**
  16836. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16837. * of light.
  16838. */
  16839. private _photometricScale;
  16840. private _intensityMode;
  16841. /**
  16842. * Gets the photometric scale used to interpret the intensity.
  16843. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16844. */
  16845. get intensityMode(): number;
  16846. /**
  16847. * Sets the photometric scale used to interpret the intensity.
  16848. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16849. */
  16850. set intensityMode(value: number);
  16851. private _radius;
  16852. /**
  16853. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16854. */
  16855. get radius(): number;
  16856. /**
  16857. * sets the light radius used by PBR Materials to simulate soft area lights.
  16858. */
  16859. set radius(value: number);
  16860. private _renderPriority;
  16861. /**
  16862. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16863. * exceeding the number allowed of the materials.
  16864. */
  16865. renderPriority: number;
  16866. private _shadowEnabled;
  16867. /**
  16868. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16869. * the current shadow generator.
  16870. */
  16871. get shadowEnabled(): boolean;
  16872. /**
  16873. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16874. * the current shadow generator.
  16875. */
  16876. set shadowEnabled(value: boolean);
  16877. private _includedOnlyMeshes;
  16878. /**
  16879. * Gets the only meshes impacted by this light.
  16880. */
  16881. get includedOnlyMeshes(): AbstractMesh[];
  16882. /**
  16883. * Sets the only meshes impacted by this light.
  16884. */
  16885. set includedOnlyMeshes(value: AbstractMesh[]);
  16886. private _excludedMeshes;
  16887. /**
  16888. * Gets the meshes not impacted by this light.
  16889. */
  16890. get excludedMeshes(): AbstractMesh[];
  16891. /**
  16892. * Sets the meshes not impacted by this light.
  16893. */
  16894. set excludedMeshes(value: AbstractMesh[]);
  16895. private _excludeWithLayerMask;
  16896. /**
  16897. * Gets the layer id use to find what meshes are not impacted by the light.
  16898. * Inactive if 0
  16899. */
  16900. get excludeWithLayerMask(): number;
  16901. /**
  16902. * Sets the layer id use to find what meshes are not impacted by the light.
  16903. * Inactive if 0
  16904. */
  16905. set excludeWithLayerMask(value: number);
  16906. private _includeOnlyWithLayerMask;
  16907. /**
  16908. * Gets the layer id use to find what meshes are impacted by the light.
  16909. * Inactive if 0
  16910. */
  16911. get includeOnlyWithLayerMask(): number;
  16912. /**
  16913. * Sets the layer id use to find what meshes are impacted by the light.
  16914. * Inactive if 0
  16915. */
  16916. set includeOnlyWithLayerMask(value: number);
  16917. private _lightmapMode;
  16918. /**
  16919. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16920. */
  16921. get lightmapMode(): number;
  16922. /**
  16923. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16924. */
  16925. set lightmapMode(value: number);
  16926. /**
  16927. * Shadow generator associted to the light.
  16928. * @hidden Internal use only.
  16929. */
  16930. _shadowGenerator: Nullable<IShadowGenerator>;
  16931. /**
  16932. * @hidden Internal use only.
  16933. */
  16934. _excludedMeshesIds: string[];
  16935. /**
  16936. * @hidden Internal use only.
  16937. */
  16938. _includedOnlyMeshesIds: string[];
  16939. /**
  16940. * The current light unifom buffer.
  16941. * @hidden Internal use only.
  16942. */
  16943. _uniformBuffer: UniformBuffer;
  16944. /** @hidden */
  16945. _renderId: number;
  16946. /**
  16947. * Creates a Light object in the scene.
  16948. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16949. * @param name The firendly name of the light
  16950. * @param scene The scene the light belongs too
  16951. */
  16952. constructor(name: string, scene: Scene);
  16953. protected abstract _buildUniformLayout(): void;
  16954. /**
  16955. * Sets the passed Effect "effect" with the Light information.
  16956. * @param effect The effect to update
  16957. * @param lightIndex The index of the light in the effect to update
  16958. * @returns The light
  16959. */
  16960. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16961. /**
  16962. * Sets the passed Effect "effect" with the Light textures.
  16963. * @param effect The effect to update
  16964. * @param lightIndex The index of the light in the effect to update
  16965. * @returns The light
  16966. */
  16967. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16968. /**
  16969. * Binds the lights information from the scene to the effect for the given mesh.
  16970. * @param lightIndex Light index
  16971. * @param scene The scene where the light belongs to
  16972. * @param effect The effect we are binding the data to
  16973. * @param useSpecular Defines if specular is supported
  16974. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16975. */
  16976. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16977. /**
  16978. * Sets the passed Effect "effect" with the Light information.
  16979. * @param effect The effect to update
  16980. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16981. * @returns The light
  16982. */
  16983. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16984. /**
  16985. * Returns the string "Light".
  16986. * @returns the class name
  16987. */
  16988. getClassName(): string;
  16989. /** @hidden */
  16990. readonly _isLight: boolean;
  16991. /**
  16992. * Converts the light information to a readable string for debug purpose.
  16993. * @param fullDetails Supports for multiple levels of logging within scene loading
  16994. * @returns the human readable light info
  16995. */
  16996. toString(fullDetails?: boolean): string;
  16997. /** @hidden */
  16998. protected _syncParentEnabledState(): void;
  16999. /**
  17000. * Set the enabled state of this node.
  17001. * @param value - the new enabled state
  17002. */
  17003. setEnabled(value: boolean): void;
  17004. /**
  17005. * Returns the Light associated shadow generator if any.
  17006. * @return the associated shadow generator.
  17007. */
  17008. getShadowGenerator(): Nullable<IShadowGenerator>;
  17009. /**
  17010. * Returns a Vector3, the absolute light position in the World.
  17011. * @returns the world space position of the light
  17012. */
  17013. getAbsolutePosition(): Vector3;
  17014. /**
  17015. * Specifies if the light will affect the passed mesh.
  17016. * @param mesh The mesh to test against the light
  17017. * @return true the mesh is affected otherwise, false.
  17018. */
  17019. canAffectMesh(mesh: AbstractMesh): boolean;
  17020. /**
  17021. * Sort function to order lights for rendering.
  17022. * @param a First Light object to compare to second.
  17023. * @param b Second Light object to compare first.
  17024. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17025. */
  17026. static CompareLightsPriority(a: Light, b: Light): number;
  17027. /**
  17028. * Releases resources associated with this node.
  17029. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17030. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17031. */
  17032. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17033. /**
  17034. * Returns the light type ID (integer).
  17035. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17036. */
  17037. getTypeID(): number;
  17038. /**
  17039. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17040. * @returns the scaled intensity in intensity mode unit
  17041. */
  17042. getScaledIntensity(): number;
  17043. /**
  17044. * Returns a new Light object, named "name", from the current one.
  17045. * @param name The name of the cloned light
  17046. * @returns the new created light
  17047. */
  17048. clone(name: string): Nullable<Light>;
  17049. /**
  17050. * Serializes the current light into a Serialization object.
  17051. * @returns the serialized object.
  17052. */
  17053. serialize(): any;
  17054. /**
  17055. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17056. * This new light is named "name" and added to the passed scene.
  17057. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17058. * @param name The friendly name of the light
  17059. * @param scene The scene the new light will belong to
  17060. * @returns the constructor function
  17061. */
  17062. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17063. /**
  17064. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17065. * @param parsedLight The JSON representation of the light
  17066. * @param scene The scene to create the parsed light in
  17067. * @returns the created light after parsing
  17068. */
  17069. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17070. private _hookArrayForExcluded;
  17071. private _hookArrayForIncludedOnly;
  17072. private _resyncMeshes;
  17073. /**
  17074. * Forces the meshes to update their light related information in their rendering used effects
  17075. * @hidden Internal Use Only
  17076. */
  17077. _markMeshesAsLightDirty(): void;
  17078. /**
  17079. * Recomputes the cached photometric scale if needed.
  17080. */
  17081. private _computePhotometricScale;
  17082. /**
  17083. * Returns the Photometric Scale according to the light type and intensity mode.
  17084. */
  17085. private _getPhotometricScale;
  17086. /**
  17087. * Reorder the light in the scene according to their defined priority.
  17088. * @hidden Internal Use Only
  17089. */
  17090. _reorderLightsInScene(): void;
  17091. /**
  17092. * Prepares the list of defines specific to the light type.
  17093. * @param defines the list of defines
  17094. * @param lightIndex defines the index of the light for the effect
  17095. */
  17096. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17097. }
  17098. }
  17099. declare module BABYLON {
  17100. /**
  17101. * Interface used to define Action
  17102. */
  17103. export interface IAction {
  17104. /**
  17105. * Trigger for the action
  17106. */
  17107. trigger: number;
  17108. /** Options of the trigger */
  17109. triggerOptions: any;
  17110. /**
  17111. * Gets the trigger parameters
  17112. * @returns the trigger parameters
  17113. */
  17114. getTriggerParameter(): any;
  17115. /**
  17116. * Internal only - executes current action event
  17117. * @hidden
  17118. */
  17119. _executeCurrent(evt?: ActionEvent): void;
  17120. /**
  17121. * Serialize placeholder for child classes
  17122. * @param parent of child
  17123. * @returns the serialized object
  17124. */
  17125. serialize(parent: any): any;
  17126. /**
  17127. * Internal only
  17128. * @hidden
  17129. */
  17130. _prepare(): void;
  17131. /**
  17132. * Internal only - manager for action
  17133. * @hidden
  17134. */
  17135. _actionManager: AbstractActionManager;
  17136. /**
  17137. * Adds action to chain of actions, may be a DoNothingAction
  17138. * @param action defines the next action to execute
  17139. * @returns The action passed in
  17140. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17141. */
  17142. then(action: IAction): IAction;
  17143. }
  17144. /**
  17145. * The action to be carried out following a trigger
  17146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17147. */
  17148. export class Action implements IAction {
  17149. /** the trigger, with or without parameters, for the action */
  17150. triggerOptions: any;
  17151. /**
  17152. * Trigger for the action
  17153. */
  17154. trigger: number;
  17155. /**
  17156. * Internal only - manager for action
  17157. * @hidden
  17158. */
  17159. _actionManager: ActionManager;
  17160. private _nextActiveAction;
  17161. private _child;
  17162. private _condition?;
  17163. private _triggerParameter;
  17164. /**
  17165. * An event triggered prior to action being executed.
  17166. */
  17167. onBeforeExecuteObservable: Observable<Action>;
  17168. /**
  17169. * Creates a new Action
  17170. * @param triggerOptions the trigger, with or without parameters, for the action
  17171. * @param condition an optional determinant of action
  17172. */
  17173. constructor(
  17174. /** the trigger, with or without parameters, for the action */
  17175. triggerOptions: any, condition?: Condition);
  17176. /**
  17177. * Internal only
  17178. * @hidden
  17179. */
  17180. _prepare(): void;
  17181. /**
  17182. * Gets the trigger parameters
  17183. * @returns the trigger parameters
  17184. */
  17185. getTriggerParameter(): any;
  17186. /**
  17187. * Internal only - executes current action event
  17188. * @hidden
  17189. */
  17190. _executeCurrent(evt?: ActionEvent): void;
  17191. /**
  17192. * Execute placeholder for child classes
  17193. * @param evt optional action event
  17194. */
  17195. execute(evt?: ActionEvent): void;
  17196. /**
  17197. * Skips to next active action
  17198. */
  17199. skipToNextActiveAction(): void;
  17200. /**
  17201. * Adds action to chain of actions, may be a DoNothingAction
  17202. * @param action defines the next action to execute
  17203. * @returns The action passed in
  17204. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17205. */
  17206. then(action: Action): Action;
  17207. /**
  17208. * Internal only
  17209. * @hidden
  17210. */
  17211. _getProperty(propertyPath: string): string;
  17212. /**
  17213. * Internal only
  17214. * @hidden
  17215. */
  17216. _getEffectiveTarget(target: any, propertyPath: string): any;
  17217. /**
  17218. * Serialize placeholder for child classes
  17219. * @param parent of child
  17220. * @returns the serialized object
  17221. */
  17222. serialize(parent: any): any;
  17223. /**
  17224. * Internal only called by serialize
  17225. * @hidden
  17226. */
  17227. protected _serialize(serializedAction: any, parent?: any): any;
  17228. /**
  17229. * Internal only
  17230. * @hidden
  17231. */
  17232. static _SerializeValueAsString: (value: any) => string;
  17233. /**
  17234. * Internal only
  17235. * @hidden
  17236. */
  17237. static _GetTargetProperty: (target: Node | Scene) => {
  17238. name: string;
  17239. targetType: string;
  17240. value: string;
  17241. };
  17242. }
  17243. }
  17244. declare module BABYLON {
  17245. /**
  17246. * A Condition applied to an Action
  17247. */
  17248. export class Condition {
  17249. /**
  17250. * Internal only - manager for action
  17251. * @hidden
  17252. */
  17253. _actionManager: ActionManager;
  17254. /**
  17255. * Internal only
  17256. * @hidden
  17257. */
  17258. _evaluationId: number;
  17259. /**
  17260. * Internal only
  17261. * @hidden
  17262. */
  17263. _currentResult: boolean;
  17264. /**
  17265. * Creates a new Condition
  17266. * @param actionManager the manager of the action the condition is applied to
  17267. */
  17268. constructor(actionManager: ActionManager);
  17269. /**
  17270. * Check if the current condition is valid
  17271. * @returns a boolean
  17272. */
  17273. isValid(): boolean;
  17274. /**
  17275. * Internal only
  17276. * @hidden
  17277. */
  17278. _getProperty(propertyPath: string): string;
  17279. /**
  17280. * Internal only
  17281. * @hidden
  17282. */
  17283. _getEffectiveTarget(target: any, propertyPath: string): any;
  17284. /**
  17285. * Serialize placeholder for child classes
  17286. * @returns the serialized object
  17287. */
  17288. serialize(): any;
  17289. /**
  17290. * Internal only
  17291. * @hidden
  17292. */
  17293. protected _serialize(serializedCondition: any): any;
  17294. }
  17295. /**
  17296. * Defines specific conditional operators as extensions of Condition
  17297. */
  17298. export class ValueCondition extends Condition {
  17299. /** path to specify the property of the target the conditional operator uses */
  17300. propertyPath: string;
  17301. /** the value compared by the conditional operator against the current value of the property */
  17302. value: any;
  17303. /** the conditional operator, default ValueCondition.IsEqual */
  17304. operator: number;
  17305. /**
  17306. * Internal only
  17307. * @hidden
  17308. */
  17309. private static _IsEqual;
  17310. /**
  17311. * Internal only
  17312. * @hidden
  17313. */
  17314. private static _IsDifferent;
  17315. /**
  17316. * Internal only
  17317. * @hidden
  17318. */
  17319. private static _IsGreater;
  17320. /**
  17321. * Internal only
  17322. * @hidden
  17323. */
  17324. private static _IsLesser;
  17325. /**
  17326. * returns the number for IsEqual
  17327. */
  17328. static get IsEqual(): number;
  17329. /**
  17330. * Returns the number for IsDifferent
  17331. */
  17332. static get IsDifferent(): number;
  17333. /**
  17334. * Returns the number for IsGreater
  17335. */
  17336. static get IsGreater(): number;
  17337. /**
  17338. * Returns the number for IsLesser
  17339. */
  17340. static get IsLesser(): number;
  17341. /**
  17342. * Internal only The action manager for the condition
  17343. * @hidden
  17344. */
  17345. _actionManager: ActionManager;
  17346. /**
  17347. * Internal only
  17348. * @hidden
  17349. */
  17350. private _target;
  17351. /**
  17352. * Internal only
  17353. * @hidden
  17354. */
  17355. private _effectiveTarget;
  17356. /**
  17357. * Internal only
  17358. * @hidden
  17359. */
  17360. private _property;
  17361. /**
  17362. * Creates a new ValueCondition
  17363. * @param actionManager manager for the action the condition applies to
  17364. * @param target for the action
  17365. * @param propertyPath path to specify the property of the target the conditional operator uses
  17366. * @param value the value compared by the conditional operator against the current value of the property
  17367. * @param operator the conditional operator, default ValueCondition.IsEqual
  17368. */
  17369. constructor(actionManager: ActionManager, target: any,
  17370. /** path to specify the property of the target the conditional operator uses */
  17371. propertyPath: string,
  17372. /** the value compared by the conditional operator against the current value of the property */
  17373. value: any,
  17374. /** the conditional operator, default ValueCondition.IsEqual */
  17375. operator?: number);
  17376. /**
  17377. * Compares the given value with the property value for the specified conditional operator
  17378. * @returns the result of the comparison
  17379. */
  17380. isValid(): boolean;
  17381. /**
  17382. * Serialize the ValueCondition into a JSON compatible object
  17383. * @returns serialization object
  17384. */
  17385. serialize(): any;
  17386. /**
  17387. * Gets the name of the conditional operator for the ValueCondition
  17388. * @param operator the conditional operator
  17389. * @returns the name
  17390. */
  17391. static GetOperatorName(operator: number): string;
  17392. }
  17393. /**
  17394. * Defines a predicate condition as an extension of Condition
  17395. */
  17396. export class PredicateCondition extends Condition {
  17397. /** defines the predicate function used to validate the condition */
  17398. predicate: () => boolean;
  17399. /**
  17400. * Internal only - manager for action
  17401. * @hidden
  17402. */
  17403. _actionManager: ActionManager;
  17404. /**
  17405. * Creates a new PredicateCondition
  17406. * @param actionManager manager for the action the condition applies to
  17407. * @param predicate defines the predicate function used to validate the condition
  17408. */
  17409. constructor(actionManager: ActionManager,
  17410. /** defines the predicate function used to validate the condition */
  17411. predicate: () => boolean);
  17412. /**
  17413. * @returns the validity of the predicate condition
  17414. */
  17415. isValid(): boolean;
  17416. }
  17417. /**
  17418. * Defines a state condition as an extension of Condition
  17419. */
  17420. export class StateCondition extends Condition {
  17421. /** Value to compare with target state */
  17422. value: string;
  17423. /**
  17424. * Internal only - manager for action
  17425. * @hidden
  17426. */
  17427. _actionManager: ActionManager;
  17428. /**
  17429. * Internal only
  17430. * @hidden
  17431. */
  17432. private _target;
  17433. /**
  17434. * Creates a new StateCondition
  17435. * @param actionManager manager for the action the condition applies to
  17436. * @param target of the condition
  17437. * @param value to compare with target state
  17438. */
  17439. constructor(actionManager: ActionManager, target: any,
  17440. /** Value to compare with target state */
  17441. value: string);
  17442. /**
  17443. * Gets a boolean indicating if the current condition is met
  17444. * @returns the validity of the state
  17445. */
  17446. isValid(): boolean;
  17447. /**
  17448. * Serialize the StateCondition into a JSON compatible object
  17449. * @returns serialization object
  17450. */
  17451. serialize(): any;
  17452. }
  17453. }
  17454. declare module BABYLON {
  17455. /**
  17456. * This defines an action responsible to toggle a boolean once triggered.
  17457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17458. */
  17459. export class SwitchBooleanAction extends Action {
  17460. /**
  17461. * The path to the boolean property in the target object
  17462. */
  17463. propertyPath: string;
  17464. private _target;
  17465. private _effectiveTarget;
  17466. private _property;
  17467. /**
  17468. * Instantiate the action
  17469. * @param triggerOptions defines the trigger options
  17470. * @param target defines the object containing the boolean
  17471. * @param propertyPath defines the path to the boolean property in the target object
  17472. * @param condition defines the trigger related conditions
  17473. */
  17474. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17475. /** @hidden */
  17476. _prepare(): void;
  17477. /**
  17478. * Execute the action toggle the boolean value.
  17479. */
  17480. execute(): void;
  17481. /**
  17482. * Serializes the actions and its related information.
  17483. * @param parent defines the object to serialize in
  17484. * @returns the serialized object
  17485. */
  17486. serialize(parent: any): any;
  17487. }
  17488. /**
  17489. * This defines an action responsible to set a the state field of the target
  17490. * to a desired value once triggered.
  17491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17492. */
  17493. export class SetStateAction extends Action {
  17494. /**
  17495. * The value to store in the state field.
  17496. */
  17497. value: string;
  17498. private _target;
  17499. /**
  17500. * Instantiate the action
  17501. * @param triggerOptions defines the trigger options
  17502. * @param target defines the object containing the state property
  17503. * @param value defines the value to store in the state field
  17504. * @param condition defines the trigger related conditions
  17505. */
  17506. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17507. /**
  17508. * Execute the action and store the value on the target state property.
  17509. */
  17510. execute(): void;
  17511. /**
  17512. * Serializes the actions and its related information.
  17513. * @param parent defines the object to serialize in
  17514. * @returns the serialized object
  17515. */
  17516. serialize(parent: any): any;
  17517. }
  17518. /**
  17519. * This defines an action responsible to set a property of the target
  17520. * to a desired value once triggered.
  17521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17522. */
  17523. export class SetValueAction extends Action {
  17524. /**
  17525. * The path of the property to set in the target.
  17526. */
  17527. propertyPath: string;
  17528. /**
  17529. * The value to set in the property
  17530. */
  17531. value: any;
  17532. private _target;
  17533. private _effectiveTarget;
  17534. private _property;
  17535. /**
  17536. * Instantiate the action
  17537. * @param triggerOptions defines the trigger options
  17538. * @param target defines the object containing the property
  17539. * @param propertyPath defines the path of the property to set in the target
  17540. * @param value defines the value to set in the property
  17541. * @param condition defines the trigger related conditions
  17542. */
  17543. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17544. /** @hidden */
  17545. _prepare(): void;
  17546. /**
  17547. * Execute the action and set the targetted property to the desired value.
  17548. */
  17549. execute(): void;
  17550. /**
  17551. * Serializes the actions and its related information.
  17552. * @param parent defines the object to serialize in
  17553. * @returns the serialized object
  17554. */
  17555. serialize(parent: any): any;
  17556. }
  17557. /**
  17558. * This defines an action responsible to increment the target value
  17559. * to a desired value once triggered.
  17560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17561. */
  17562. export class IncrementValueAction extends Action {
  17563. /**
  17564. * The path of the property to increment in the target.
  17565. */
  17566. propertyPath: string;
  17567. /**
  17568. * The value we should increment the property by.
  17569. */
  17570. value: any;
  17571. private _target;
  17572. private _effectiveTarget;
  17573. private _property;
  17574. /**
  17575. * Instantiate the action
  17576. * @param triggerOptions defines the trigger options
  17577. * @param target defines the object containing the property
  17578. * @param propertyPath defines the path of the property to increment in the target
  17579. * @param value defines the value value we should increment the property by
  17580. * @param condition defines the trigger related conditions
  17581. */
  17582. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17583. /** @hidden */
  17584. _prepare(): void;
  17585. /**
  17586. * Execute the action and increment the target of the value amount.
  17587. */
  17588. execute(): void;
  17589. /**
  17590. * Serializes the actions and its related information.
  17591. * @param parent defines the object to serialize in
  17592. * @returns the serialized object
  17593. */
  17594. serialize(parent: any): any;
  17595. }
  17596. /**
  17597. * This defines an action responsible to start an animation once triggered.
  17598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17599. */
  17600. export class PlayAnimationAction extends Action {
  17601. /**
  17602. * Where the animation should start (animation frame)
  17603. */
  17604. from: number;
  17605. /**
  17606. * Where the animation should stop (animation frame)
  17607. */
  17608. to: number;
  17609. /**
  17610. * Define if the animation should loop or stop after the first play.
  17611. */
  17612. loop?: boolean;
  17613. private _target;
  17614. /**
  17615. * Instantiate the action
  17616. * @param triggerOptions defines the trigger options
  17617. * @param target defines the target animation or animation name
  17618. * @param from defines from where the animation should start (animation frame)
  17619. * @param end defines where the animation should stop (animation frame)
  17620. * @param loop defines if the animation should loop or stop after the first play
  17621. * @param condition defines the trigger related conditions
  17622. */
  17623. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17624. /** @hidden */
  17625. _prepare(): void;
  17626. /**
  17627. * Execute the action and play the animation.
  17628. */
  17629. execute(): void;
  17630. /**
  17631. * Serializes the actions and its related information.
  17632. * @param parent defines the object to serialize in
  17633. * @returns the serialized object
  17634. */
  17635. serialize(parent: any): any;
  17636. }
  17637. /**
  17638. * This defines an action responsible to stop an animation once triggered.
  17639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17640. */
  17641. export class StopAnimationAction extends Action {
  17642. private _target;
  17643. /**
  17644. * Instantiate the action
  17645. * @param triggerOptions defines the trigger options
  17646. * @param target defines the target animation or animation name
  17647. * @param condition defines the trigger related conditions
  17648. */
  17649. constructor(triggerOptions: any, target: any, condition?: Condition);
  17650. /** @hidden */
  17651. _prepare(): void;
  17652. /**
  17653. * Execute the action and stop the animation.
  17654. */
  17655. execute(): void;
  17656. /**
  17657. * Serializes the actions and its related information.
  17658. * @param parent defines the object to serialize in
  17659. * @returns the serialized object
  17660. */
  17661. serialize(parent: any): any;
  17662. }
  17663. /**
  17664. * This defines an action responsible that does nothing once triggered.
  17665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17666. */
  17667. export class DoNothingAction extends Action {
  17668. /**
  17669. * Instantiate the action
  17670. * @param triggerOptions defines the trigger options
  17671. * @param condition defines the trigger related conditions
  17672. */
  17673. constructor(triggerOptions?: any, condition?: Condition);
  17674. /**
  17675. * Execute the action and do nothing.
  17676. */
  17677. execute(): void;
  17678. /**
  17679. * Serializes the actions and its related information.
  17680. * @param parent defines the object to serialize in
  17681. * @returns the serialized object
  17682. */
  17683. serialize(parent: any): any;
  17684. }
  17685. /**
  17686. * This defines an action responsible to trigger several actions once triggered.
  17687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17688. */
  17689. export class CombineAction extends Action {
  17690. /**
  17691. * The list of aggregated animations to run.
  17692. */
  17693. children: Action[];
  17694. /**
  17695. * Instantiate the action
  17696. * @param triggerOptions defines the trigger options
  17697. * @param children defines the list of aggregated animations to run
  17698. * @param condition defines the trigger related conditions
  17699. */
  17700. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17701. /** @hidden */
  17702. _prepare(): void;
  17703. /**
  17704. * Execute the action and executes all the aggregated actions.
  17705. */
  17706. execute(evt: ActionEvent): void;
  17707. /**
  17708. * Serializes the actions and its related information.
  17709. * @param parent defines the object to serialize in
  17710. * @returns the serialized object
  17711. */
  17712. serialize(parent: any): any;
  17713. }
  17714. /**
  17715. * This defines an action responsible to run code (external event) once triggered.
  17716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17717. */
  17718. export class ExecuteCodeAction extends Action {
  17719. /**
  17720. * The callback function to run.
  17721. */
  17722. func: (evt: ActionEvent) => void;
  17723. /**
  17724. * Instantiate the action
  17725. * @param triggerOptions defines the trigger options
  17726. * @param func defines the callback function to run
  17727. * @param condition defines the trigger related conditions
  17728. */
  17729. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17730. /**
  17731. * Execute the action and run the attached code.
  17732. */
  17733. execute(evt: ActionEvent): void;
  17734. }
  17735. /**
  17736. * This defines an action responsible to set the parent property of the target once triggered.
  17737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17738. */
  17739. export class SetParentAction extends Action {
  17740. private _parent;
  17741. private _target;
  17742. /**
  17743. * Instantiate the action
  17744. * @param triggerOptions defines the trigger options
  17745. * @param target defines the target containing the parent property
  17746. * @param parent defines from where the animation should start (animation frame)
  17747. * @param condition defines the trigger related conditions
  17748. */
  17749. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17750. /** @hidden */
  17751. _prepare(): void;
  17752. /**
  17753. * Execute the action and set the parent property.
  17754. */
  17755. execute(): void;
  17756. /**
  17757. * Serializes the actions and its related information.
  17758. * @param parent defines the object to serialize in
  17759. * @returns the serialized object
  17760. */
  17761. serialize(parent: any): any;
  17762. }
  17763. }
  17764. declare module BABYLON {
  17765. /**
  17766. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17767. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17769. */
  17770. export class ActionManager extends AbstractActionManager {
  17771. /**
  17772. * Nothing
  17773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17774. */
  17775. static readonly NothingTrigger: number;
  17776. /**
  17777. * On pick
  17778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17779. */
  17780. static readonly OnPickTrigger: number;
  17781. /**
  17782. * On left pick
  17783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17784. */
  17785. static readonly OnLeftPickTrigger: number;
  17786. /**
  17787. * On right pick
  17788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17789. */
  17790. static readonly OnRightPickTrigger: number;
  17791. /**
  17792. * On center pick
  17793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17794. */
  17795. static readonly OnCenterPickTrigger: number;
  17796. /**
  17797. * On pick down
  17798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17799. */
  17800. static readonly OnPickDownTrigger: number;
  17801. /**
  17802. * On double pick
  17803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17804. */
  17805. static readonly OnDoublePickTrigger: number;
  17806. /**
  17807. * On pick up
  17808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17809. */
  17810. static readonly OnPickUpTrigger: number;
  17811. /**
  17812. * On pick out.
  17813. * This trigger will only be raised if you also declared a OnPickDown
  17814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17815. */
  17816. static readonly OnPickOutTrigger: number;
  17817. /**
  17818. * On long press
  17819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17820. */
  17821. static readonly OnLongPressTrigger: number;
  17822. /**
  17823. * On pointer over
  17824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17825. */
  17826. static readonly OnPointerOverTrigger: number;
  17827. /**
  17828. * On pointer out
  17829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17830. */
  17831. static readonly OnPointerOutTrigger: number;
  17832. /**
  17833. * On every frame
  17834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17835. */
  17836. static readonly OnEveryFrameTrigger: number;
  17837. /**
  17838. * On intersection enter
  17839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17840. */
  17841. static readonly OnIntersectionEnterTrigger: number;
  17842. /**
  17843. * On intersection exit
  17844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17845. */
  17846. static readonly OnIntersectionExitTrigger: number;
  17847. /**
  17848. * On key down
  17849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17850. */
  17851. static readonly OnKeyDownTrigger: number;
  17852. /**
  17853. * On key up
  17854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17855. */
  17856. static readonly OnKeyUpTrigger: number;
  17857. private _scene;
  17858. /**
  17859. * Creates a new action manager
  17860. * @param scene defines the hosting scene
  17861. */
  17862. constructor(scene: Scene);
  17863. /**
  17864. * Releases all associated resources
  17865. */
  17866. dispose(): void;
  17867. /**
  17868. * Gets hosting scene
  17869. * @returns the hosting scene
  17870. */
  17871. getScene(): Scene;
  17872. /**
  17873. * Does this action manager handles actions of any of the given triggers
  17874. * @param triggers defines the triggers to be tested
  17875. * @return a boolean indicating whether one (or more) of the triggers is handled
  17876. */
  17877. hasSpecificTriggers(triggers: number[]): boolean;
  17878. /**
  17879. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17880. * speed.
  17881. * @param triggerA defines the trigger to be tested
  17882. * @param triggerB defines the trigger to be tested
  17883. * @return a boolean indicating whether one (or more) of the triggers is handled
  17884. */
  17885. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17886. /**
  17887. * Does this action manager handles actions of a given trigger
  17888. * @param trigger defines the trigger to be tested
  17889. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17890. * @return whether the trigger is handled
  17891. */
  17892. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17893. /**
  17894. * Does this action manager has pointer triggers
  17895. */
  17896. get hasPointerTriggers(): boolean;
  17897. /**
  17898. * Does this action manager has pick triggers
  17899. */
  17900. get hasPickTriggers(): boolean;
  17901. /**
  17902. * Registers an action to this action manager
  17903. * @param action defines the action to be registered
  17904. * @return the action amended (prepared) after registration
  17905. */
  17906. registerAction(action: IAction): Nullable<IAction>;
  17907. /**
  17908. * Unregisters an action to this action manager
  17909. * @param action defines the action to be unregistered
  17910. * @return a boolean indicating whether the action has been unregistered
  17911. */
  17912. unregisterAction(action: IAction): Boolean;
  17913. /**
  17914. * Process a specific trigger
  17915. * @param trigger defines the trigger to process
  17916. * @param evt defines the event details to be processed
  17917. */
  17918. processTrigger(trigger: number, evt?: IActionEvent): void;
  17919. /** @hidden */
  17920. _getEffectiveTarget(target: any, propertyPath: string): any;
  17921. /** @hidden */
  17922. _getProperty(propertyPath: string): string;
  17923. /**
  17924. * Serialize this manager to a JSON object
  17925. * @param name defines the property name to store this manager
  17926. * @returns a JSON representation of this manager
  17927. */
  17928. serialize(name: string): any;
  17929. /**
  17930. * Creates a new ActionManager from a JSON data
  17931. * @param parsedActions defines the JSON data to read from
  17932. * @param object defines the hosting mesh
  17933. * @param scene defines the hosting scene
  17934. */
  17935. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17936. /**
  17937. * Get a trigger name by index
  17938. * @param trigger defines the trigger index
  17939. * @returns a trigger name
  17940. */
  17941. static GetTriggerName(trigger: number): string;
  17942. }
  17943. }
  17944. declare module BABYLON {
  17945. /**
  17946. * Class used to represent a sprite
  17947. * @see http://doc.babylonjs.com/babylon101/sprites
  17948. */
  17949. export class Sprite {
  17950. /** defines the name */
  17951. name: string;
  17952. /** Gets or sets the current world position */
  17953. position: Vector3;
  17954. /** Gets or sets the main color */
  17955. color: Color4;
  17956. /** Gets or sets the width */
  17957. width: number;
  17958. /** Gets or sets the height */
  17959. height: number;
  17960. /** Gets or sets rotation angle */
  17961. angle: number;
  17962. /** Gets or sets the cell index in the sprite sheet */
  17963. cellIndex: number;
  17964. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17965. cellRef: string;
  17966. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17967. invertU: number;
  17968. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17969. invertV: number;
  17970. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17971. disposeWhenFinishedAnimating: boolean;
  17972. /** Gets the list of attached animations */
  17973. animations: Animation[];
  17974. /** Gets or sets a boolean indicating if the sprite can be picked */
  17975. isPickable: boolean;
  17976. /**
  17977. * Gets or sets the associated action manager
  17978. */
  17979. actionManager: Nullable<ActionManager>;
  17980. private _animationStarted;
  17981. private _loopAnimation;
  17982. private _fromIndex;
  17983. private _toIndex;
  17984. private _delay;
  17985. private _direction;
  17986. private _manager;
  17987. private _time;
  17988. private _onAnimationEnd;
  17989. /**
  17990. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17991. */
  17992. isVisible: boolean;
  17993. /**
  17994. * Gets or sets the sprite size
  17995. */
  17996. get size(): number;
  17997. set size(value: number);
  17998. /**
  17999. * Creates a new Sprite
  18000. * @param name defines the name
  18001. * @param manager defines the manager
  18002. */
  18003. constructor(
  18004. /** defines the name */
  18005. name: string, manager: ISpriteManager);
  18006. /**
  18007. * Starts an animation
  18008. * @param from defines the initial key
  18009. * @param to defines the end key
  18010. * @param loop defines if the animation must loop
  18011. * @param delay defines the start delay (in ms)
  18012. * @param onAnimationEnd defines a callback to call when animation ends
  18013. */
  18014. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18015. /** Stops current animation (if any) */
  18016. stopAnimation(): void;
  18017. /** @hidden */
  18018. _animate(deltaTime: number): void;
  18019. /** Release associated resources */
  18020. dispose(): void;
  18021. }
  18022. }
  18023. declare module BABYLON {
  18024. /**
  18025. * Information about the result of picking within a scene
  18026. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18027. */
  18028. export class PickingInfo {
  18029. /** @hidden */
  18030. _pickingUnavailable: boolean;
  18031. /**
  18032. * If the pick collided with an object
  18033. */
  18034. hit: boolean;
  18035. /**
  18036. * Distance away where the pick collided
  18037. */
  18038. distance: number;
  18039. /**
  18040. * The location of pick collision
  18041. */
  18042. pickedPoint: Nullable<Vector3>;
  18043. /**
  18044. * The mesh corresponding the the pick collision
  18045. */
  18046. pickedMesh: Nullable<AbstractMesh>;
  18047. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18048. bu: number;
  18049. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18050. bv: number;
  18051. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18052. faceId: number;
  18053. /** Id of the the submesh that was picked */
  18054. subMeshId: number;
  18055. /** If a sprite was picked, this will be the sprite the pick collided with */
  18056. pickedSprite: Nullable<Sprite>;
  18057. /**
  18058. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18059. */
  18060. originMesh: Nullable<AbstractMesh>;
  18061. /**
  18062. * The ray that was used to perform the picking.
  18063. */
  18064. ray: Nullable<Ray>;
  18065. /**
  18066. * Gets the normal correspodning to the face the pick collided with
  18067. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18068. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18069. * @returns The normal correspodning to the face the pick collided with
  18070. */
  18071. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18072. /**
  18073. * Gets the texture coordinates of where the pick occured
  18074. * @returns the vector containing the coordnates of the texture
  18075. */
  18076. getTextureCoordinates(): Nullable<Vector2>;
  18077. }
  18078. }
  18079. declare module BABYLON {
  18080. /**
  18081. * Gather the list of pointer event types as constants.
  18082. */
  18083. export class PointerEventTypes {
  18084. /**
  18085. * 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.
  18086. */
  18087. static readonly POINTERDOWN: number;
  18088. /**
  18089. * The pointerup event is fired when a pointer is no longer active.
  18090. */
  18091. static readonly POINTERUP: number;
  18092. /**
  18093. * The pointermove event is fired when a pointer changes coordinates.
  18094. */
  18095. static readonly POINTERMOVE: number;
  18096. /**
  18097. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18098. */
  18099. static readonly POINTERWHEEL: number;
  18100. /**
  18101. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18102. */
  18103. static readonly POINTERPICK: number;
  18104. /**
  18105. * The pointertap event is fired when a the object has been touched and released without drag.
  18106. */
  18107. static readonly POINTERTAP: number;
  18108. /**
  18109. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18110. */
  18111. static readonly POINTERDOUBLETAP: number;
  18112. }
  18113. /**
  18114. * Base class of pointer info types.
  18115. */
  18116. export class PointerInfoBase {
  18117. /**
  18118. * Defines the type of event (PointerEventTypes)
  18119. */
  18120. type: number;
  18121. /**
  18122. * Defines the related dom event
  18123. */
  18124. event: PointerEvent | MouseWheelEvent;
  18125. /**
  18126. * Instantiates the base class of pointers info.
  18127. * @param type Defines the type of event (PointerEventTypes)
  18128. * @param event Defines the related dom event
  18129. */
  18130. constructor(
  18131. /**
  18132. * Defines the type of event (PointerEventTypes)
  18133. */
  18134. type: number,
  18135. /**
  18136. * Defines the related dom event
  18137. */
  18138. event: PointerEvent | MouseWheelEvent);
  18139. }
  18140. /**
  18141. * This class is used to store pointer related info for the onPrePointerObservable event.
  18142. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18143. */
  18144. export class PointerInfoPre extends PointerInfoBase {
  18145. /**
  18146. * Ray from a pointer if availible (eg. 6dof controller)
  18147. */
  18148. ray: Nullable<Ray>;
  18149. /**
  18150. * Defines the local position of the pointer on the canvas.
  18151. */
  18152. localPosition: Vector2;
  18153. /**
  18154. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18155. */
  18156. skipOnPointerObservable: boolean;
  18157. /**
  18158. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18159. * @param type Defines the type of event (PointerEventTypes)
  18160. * @param event Defines the related dom event
  18161. * @param localX Defines the local x coordinates of the pointer when the event occured
  18162. * @param localY Defines the local y coordinates of the pointer when the event occured
  18163. */
  18164. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18165. }
  18166. /**
  18167. * This type contains all the data related to a pointer event in Babylon.js.
  18168. * 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.
  18169. */
  18170. export class PointerInfo extends PointerInfoBase {
  18171. /**
  18172. * Defines the picking info associated to the info (if any)\
  18173. */
  18174. pickInfo: Nullable<PickingInfo>;
  18175. /**
  18176. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18177. * @param type Defines the type of event (PointerEventTypes)
  18178. * @param event Defines the related dom event
  18179. * @param pickInfo Defines the picking info associated to the info (if any)\
  18180. */
  18181. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18182. /**
  18183. * Defines the picking info associated to the info (if any)\
  18184. */
  18185. pickInfo: Nullable<PickingInfo>);
  18186. }
  18187. /**
  18188. * Data relating to a touch event on the screen.
  18189. */
  18190. export interface PointerTouch {
  18191. /**
  18192. * X coordinate of touch.
  18193. */
  18194. x: number;
  18195. /**
  18196. * Y coordinate of touch.
  18197. */
  18198. y: number;
  18199. /**
  18200. * Id of touch. Unique for each finger.
  18201. */
  18202. pointerId: number;
  18203. /**
  18204. * Event type passed from DOM.
  18205. */
  18206. type: any;
  18207. }
  18208. }
  18209. declare module BABYLON {
  18210. /**
  18211. * Manage the mouse inputs to control the movement of a free camera.
  18212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18213. */
  18214. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18215. /**
  18216. * Define if touch is enabled in the mouse input
  18217. */
  18218. touchEnabled: boolean;
  18219. /**
  18220. * Defines the camera the input is attached to.
  18221. */
  18222. camera: FreeCamera;
  18223. /**
  18224. * Defines the buttons associated with the input to handle camera move.
  18225. */
  18226. buttons: number[];
  18227. /**
  18228. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18229. */
  18230. angularSensibility: number;
  18231. private _pointerInput;
  18232. private _onMouseMove;
  18233. private _observer;
  18234. private previousPosition;
  18235. /**
  18236. * Observable for when a pointer move event occurs containing the move offset
  18237. */
  18238. onPointerMovedObservable: Observable<{
  18239. offsetX: number;
  18240. offsetY: number;
  18241. }>;
  18242. /**
  18243. * @hidden
  18244. * If the camera should be rotated automatically based on pointer movement
  18245. */
  18246. _allowCameraRotation: boolean;
  18247. /**
  18248. * Manage the mouse inputs to control the movement of a free camera.
  18249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18250. * @param touchEnabled Defines if touch is enabled or not
  18251. */
  18252. constructor(
  18253. /**
  18254. * Define if touch is enabled in the mouse input
  18255. */
  18256. touchEnabled?: boolean);
  18257. /**
  18258. * Attach the input controls to a specific dom element to get the input from.
  18259. * @param element Defines the element the controls should be listened from
  18260. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18261. */
  18262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18263. /**
  18264. * Called on JS contextmenu event.
  18265. * Override this method to provide functionality.
  18266. */
  18267. protected onContextMenu(evt: PointerEvent): void;
  18268. /**
  18269. * Detach the current controls from the specified dom element.
  18270. * @param element Defines the element to stop listening the inputs from
  18271. */
  18272. detachControl(element: Nullable<HTMLElement>): void;
  18273. /**
  18274. * Gets the class name of the current intput.
  18275. * @returns the class name
  18276. */
  18277. getClassName(): string;
  18278. /**
  18279. * Get the friendly name associated with the input class.
  18280. * @returns the input friendly name
  18281. */
  18282. getSimpleName(): string;
  18283. }
  18284. }
  18285. declare module BABYLON {
  18286. /**
  18287. * Manage the touch inputs to control the movement of a free camera.
  18288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18289. */
  18290. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18291. /**
  18292. * Defines the camera the input is attached to.
  18293. */
  18294. camera: FreeCamera;
  18295. /**
  18296. * Defines the touch sensibility for rotation.
  18297. * The higher the faster.
  18298. */
  18299. touchAngularSensibility: number;
  18300. /**
  18301. * Defines the touch sensibility for move.
  18302. * The higher the faster.
  18303. */
  18304. touchMoveSensibility: number;
  18305. private _offsetX;
  18306. private _offsetY;
  18307. private _pointerPressed;
  18308. private _pointerInput;
  18309. private _observer;
  18310. private _onLostFocus;
  18311. /**
  18312. * Attach the input controls to a specific dom element to get the input from.
  18313. * @param element Defines the element the controls should be listened from
  18314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18315. */
  18316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18317. /**
  18318. * Detach the current controls from the specified dom element.
  18319. * @param element Defines the element to stop listening the inputs from
  18320. */
  18321. detachControl(element: Nullable<HTMLElement>): void;
  18322. /**
  18323. * Update the current camera state depending on the inputs that have been used this frame.
  18324. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18325. */
  18326. checkInputs(): void;
  18327. /**
  18328. * Gets the class name of the current intput.
  18329. * @returns the class name
  18330. */
  18331. getClassName(): string;
  18332. /**
  18333. * Get the friendly name associated with the input class.
  18334. * @returns the input friendly name
  18335. */
  18336. getSimpleName(): string;
  18337. }
  18338. }
  18339. declare module BABYLON {
  18340. /**
  18341. * Default Inputs manager for the FreeCamera.
  18342. * It groups all the default supported inputs for ease of use.
  18343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18344. */
  18345. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18346. /**
  18347. * @hidden
  18348. */
  18349. _mouseInput: Nullable<FreeCameraMouseInput>;
  18350. /**
  18351. * Instantiates a new FreeCameraInputsManager.
  18352. * @param camera Defines the camera the inputs belong to
  18353. */
  18354. constructor(camera: FreeCamera);
  18355. /**
  18356. * Add keyboard input support to the input manager.
  18357. * @returns the current input manager
  18358. */
  18359. addKeyboard(): FreeCameraInputsManager;
  18360. /**
  18361. * Add mouse input support to the input manager.
  18362. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18363. * @returns the current input manager
  18364. */
  18365. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18366. /**
  18367. * Removes the mouse input support from the manager
  18368. * @returns the current input manager
  18369. */
  18370. removeMouse(): FreeCameraInputsManager;
  18371. /**
  18372. * Add touch input support to the input manager.
  18373. * @returns the current input manager
  18374. */
  18375. addTouch(): FreeCameraInputsManager;
  18376. /**
  18377. * Remove all attached input methods from a camera
  18378. */
  18379. clear(): void;
  18380. }
  18381. }
  18382. declare module BABYLON {
  18383. /**
  18384. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18385. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18386. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18387. */
  18388. export class FreeCamera extends TargetCamera {
  18389. /**
  18390. * Define the collision ellipsoid of the camera.
  18391. * This is helpful to simulate a camera body like the player body around the camera
  18392. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18393. */
  18394. ellipsoid: Vector3;
  18395. /**
  18396. * Define an offset for the position of the ellipsoid around the camera.
  18397. * This can be helpful to determine the center of the body near the gravity center of the body
  18398. * instead of its head.
  18399. */
  18400. ellipsoidOffset: Vector3;
  18401. /**
  18402. * Enable or disable collisions of the camera with the rest of the scene objects.
  18403. */
  18404. checkCollisions: boolean;
  18405. /**
  18406. * Enable or disable gravity on the camera.
  18407. */
  18408. applyGravity: boolean;
  18409. /**
  18410. * Define the input manager associated to the camera.
  18411. */
  18412. inputs: FreeCameraInputsManager;
  18413. /**
  18414. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18415. * Higher values reduce sensitivity.
  18416. */
  18417. get angularSensibility(): number;
  18418. /**
  18419. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18420. * Higher values reduce sensitivity.
  18421. */
  18422. set angularSensibility(value: number);
  18423. /**
  18424. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18425. */
  18426. get keysUp(): number[];
  18427. set keysUp(value: number[]);
  18428. /**
  18429. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18430. */
  18431. get keysUpward(): number[];
  18432. set keysUpward(value: number[]);
  18433. /**
  18434. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18435. */
  18436. get keysDown(): number[];
  18437. set keysDown(value: number[]);
  18438. /**
  18439. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18440. */
  18441. get keysDownward(): number[];
  18442. set keysDownward(value: number[]);
  18443. /**
  18444. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18445. */
  18446. get keysLeft(): number[];
  18447. set keysLeft(value: number[]);
  18448. /**
  18449. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18450. */
  18451. get keysRight(): number[];
  18452. set keysRight(value: number[]);
  18453. /**
  18454. * Event raised when the camera collide with a mesh in the scene.
  18455. */
  18456. onCollide: (collidedMesh: AbstractMesh) => void;
  18457. private _collider;
  18458. private _needMoveForGravity;
  18459. private _oldPosition;
  18460. private _diffPosition;
  18461. private _newPosition;
  18462. /** @hidden */
  18463. _localDirection: Vector3;
  18464. /** @hidden */
  18465. _transformedDirection: Vector3;
  18466. /**
  18467. * Instantiates a Free Camera.
  18468. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18469. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18470. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18471. * @param name Define the name of the camera in the scene
  18472. * @param position Define the start position of the camera in the scene
  18473. * @param scene Define the scene the camera belongs to
  18474. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18475. */
  18476. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18477. /**
  18478. * Attached controls to the current camera.
  18479. * @param element Defines the element the controls should be listened from
  18480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18481. */
  18482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18483. /**
  18484. * Detach the current controls from the camera.
  18485. * The camera will stop reacting to inputs.
  18486. * @param element Defines the element to stop listening the inputs from
  18487. */
  18488. detachControl(element: HTMLElement): void;
  18489. private _collisionMask;
  18490. /**
  18491. * Define a collision mask to limit the list of object the camera can collide with
  18492. */
  18493. get collisionMask(): number;
  18494. set collisionMask(mask: number);
  18495. /** @hidden */
  18496. _collideWithWorld(displacement: Vector3): void;
  18497. private _onCollisionPositionChange;
  18498. /** @hidden */
  18499. _checkInputs(): void;
  18500. /** @hidden */
  18501. _decideIfNeedsToMove(): boolean;
  18502. /** @hidden */
  18503. _updatePosition(): void;
  18504. /**
  18505. * Destroy the camera and release the current resources hold by it.
  18506. */
  18507. dispose(): void;
  18508. /**
  18509. * Gets the current object class name.
  18510. * @return the class name
  18511. */
  18512. getClassName(): string;
  18513. }
  18514. }
  18515. declare module BABYLON {
  18516. /**
  18517. * Represents a gamepad control stick position
  18518. */
  18519. export class StickValues {
  18520. /**
  18521. * The x component of the control stick
  18522. */
  18523. x: number;
  18524. /**
  18525. * The y component of the control stick
  18526. */
  18527. y: number;
  18528. /**
  18529. * Initializes the gamepad x and y control stick values
  18530. * @param x The x component of the gamepad control stick value
  18531. * @param y The y component of the gamepad control stick value
  18532. */
  18533. constructor(
  18534. /**
  18535. * The x component of the control stick
  18536. */
  18537. x: number,
  18538. /**
  18539. * The y component of the control stick
  18540. */
  18541. y: number);
  18542. }
  18543. /**
  18544. * An interface which manages callbacks for gamepad button changes
  18545. */
  18546. export interface GamepadButtonChanges {
  18547. /**
  18548. * Called when a gamepad has been changed
  18549. */
  18550. changed: boolean;
  18551. /**
  18552. * Called when a gamepad press event has been triggered
  18553. */
  18554. pressChanged: boolean;
  18555. /**
  18556. * Called when a touch event has been triggered
  18557. */
  18558. touchChanged: boolean;
  18559. /**
  18560. * Called when a value has changed
  18561. */
  18562. valueChanged: boolean;
  18563. }
  18564. /**
  18565. * Represents a gamepad
  18566. */
  18567. export class Gamepad {
  18568. /**
  18569. * The id of the gamepad
  18570. */
  18571. id: string;
  18572. /**
  18573. * The index of the gamepad
  18574. */
  18575. index: number;
  18576. /**
  18577. * The browser gamepad
  18578. */
  18579. browserGamepad: any;
  18580. /**
  18581. * Specifies what type of gamepad this represents
  18582. */
  18583. type: number;
  18584. private _leftStick;
  18585. private _rightStick;
  18586. /** @hidden */
  18587. _isConnected: boolean;
  18588. private _leftStickAxisX;
  18589. private _leftStickAxisY;
  18590. private _rightStickAxisX;
  18591. private _rightStickAxisY;
  18592. /**
  18593. * Triggered when the left control stick has been changed
  18594. */
  18595. private _onleftstickchanged;
  18596. /**
  18597. * Triggered when the right control stick has been changed
  18598. */
  18599. private _onrightstickchanged;
  18600. /**
  18601. * Represents a gamepad controller
  18602. */
  18603. static GAMEPAD: number;
  18604. /**
  18605. * Represents a generic controller
  18606. */
  18607. static GENERIC: number;
  18608. /**
  18609. * Represents an XBox controller
  18610. */
  18611. static XBOX: number;
  18612. /**
  18613. * Represents a pose-enabled controller
  18614. */
  18615. static POSE_ENABLED: number;
  18616. /**
  18617. * Represents an Dual Shock controller
  18618. */
  18619. static DUALSHOCK: number;
  18620. /**
  18621. * Specifies whether the left control stick should be Y-inverted
  18622. */
  18623. protected _invertLeftStickY: boolean;
  18624. /**
  18625. * Specifies if the gamepad has been connected
  18626. */
  18627. get isConnected(): boolean;
  18628. /**
  18629. * Initializes the gamepad
  18630. * @param id The id of the gamepad
  18631. * @param index The index of the gamepad
  18632. * @param browserGamepad The browser gamepad
  18633. * @param leftStickX The x component of the left joystick
  18634. * @param leftStickY The y component of the left joystick
  18635. * @param rightStickX The x component of the right joystick
  18636. * @param rightStickY The y component of the right joystick
  18637. */
  18638. constructor(
  18639. /**
  18640. * The id of the gamepad
  18641. */
  18642. id: string,
  18643. /**
  18644. * The index of the gamepad
  18645. */
  18646. index: number,
  18647. /**
  18648. * The browser gamepad
  18649. */
  18650. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18651. /**
  18652. * Callback triggered when the left joystick has changed
  18653. * @param callback
  18654. */
  18655. onleftstickchanged(callback: (values: StickValues) => void): void;
  18656. /**
  18657. * Callback triggered when the right joystick has changed
  18658. * @param callback
  18659. */
  18660. onrightstickchanged(callback: (values: StickValues) => void): void;
  18661. /**
  18662. * Gets the left joystick
  18663. */
  18664. get leftStick(): StickValues;
  18665. /**
  18666. * Sets the left joystick values
  18667. */
  18668. set leftStick(newValues: StickValues);
  18669. /**
  18670. * Gets the right joystick
  18671. */
  18672. get rightStick(): StickValues;
  18673. /**
  18674. * Sets the right joystick value
  18675. */
  18676. set rightStick(newValues: StickValues);
  18677. /**
  18678. * Updates the gamepad joystick positions
  18679. */
  18680. update(): void;
  18681. /**
  18682. * Disposes the gamepad
  18683. */
  18684. dispose(): void;
  18685. }
  18686. /**
  18687. * Represents a generic gamepad
  18688. */
  18689. export class GenericPad extends Gamepad {
  18690. private _buttons;
  18691. private _onbuttondown;
  18692. private _onbuttonup;
  18693. /**
  18694. * Observable triggered when a button has been pressed
  18695. */
  18696. onButtonDownObservable: Observable<number>;
  18697. /**
  18698. * Observable triggered when a button has been released
  18699. */
  18700. onButtonUpObservable: Observable<number>;
  18701. /**
  18702. * Callback triggered when a button has been pressed
  18703. * @param callback Called when a button has been pressed
  18704. */
  18705. onbuttondown(callback: (buttonPressed: number) => void): void;
  18706. /**
  18707. * Callback triggered when a button has been released
  18708. * @param callback Called when a button has been released
  18709. */
  18710. onbuttonup(callback: (buttonReleased: number) => void): void;
  18711. /**
  18712. * Initializes the generic gamepad
  18713. * @param id The id of the generic gamepad
  18714. * @param index The index of the generic gamepad
  18715. * @param browserGamepad The browser gamepad
  18716. */
  18717. constructor(id: string, index: number, browserGamepad: any);
  18718. private _setButtonValue;
  18719. /**
  18720. * Updates the generic gamepad
  18721. */
  18722. update(): void;
  18723. /**
  18724. * Disposes the generic gamepad
  18725. */
  18726. dispose(): void;
  18727. }
  18728. }
  18729. declare module BABYLON {
  18730. /**
  18731. * Defines the types of pose enabled controllers that are supported
  18732. */
  18733. export enum PoseEnabledControllerType {
  18734. /**
  18735. * HTC Vive
  18736. */
  18737. VIVE = 0,
  18738. /**
  18739. * Oculus Rift
  18740. */
  18741. OCULUS = 1,
  18742. /**
  18743. * Windows mixed reality
  18744. */
  18745. WINDOWS = 2,
  18746. /**
  18747. * Samsung gear VR
  18748. */
  18749. GEAR_VR = 3,
  18750. /**
  18751. * Google Daydream
  18752. */
  18753. DAYDREAM = 4,
  18754. /**
  18755. * Generic
  18756. */
  18757. GENERIC = 5
  18758. }
  18759. /**
  18760. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18761. */
  18762. export interface MutableGamepadButton {
  18763. /**
  18764. * Value of the button/trigger
  18765. */
  18766. value: number;
  18767. /**
  18768. * If the button/trigger is currently touched
  18769. */
  18770. touched: boolean;
  18771. /**
  18772. * If the button/trigger is currently pressed
  18773. */
  18774. pressed: boolean;
  18775. }
  18776. /**
  18777. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18778. * @hidden
  18779. */
  18780. export interface ExtendedGamepadButton extends GamepadButton {
  18781. /**
  18782. * If the button/trigger is currently pressed
  18783. */
  18784. readonly pressed: boolean;
  18785. /**
  18786. * If the button/trigger is currently touched
  18787. */
  18788. readonly touched: boolean;
  18789. /**
  18790. * Value of the button/trigger
  18791. */
  18792. readonly value: number;
  18793. }
  18794. /** @hidden */
  18795. export interface _GamePadFactory {
  18796. /**
  18797. * Returns whether or not the current gamepad can be created for this type of controller.
  18798. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18799. * @returns true if it can be created, otherwise false
  18800. */
  18801. canCreate(gamepadInfo: any): boolean;
  18802. /**
  18803. * Creates a new instance of the Gamepad.
  18804. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18805. * @returns the new gamepad instance
  18806. */
  18807. create(gamepadInfo: any): Gamepad;
  18808. }
  18809. /**
  18810. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18811. */
  18812. export class PoseEnabledControllerHelper {
  18813. /** @hidden */
  18814. static _ControllerFactories: _GamePadFactory[];
  18815. /** @hidden */
  18816. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18817. /**
  18818. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18819. * @param vrGamepad the gamepad to initialized
  18820. * @returns a vr controller of the type the gamepad identified as
  18821. */
  18822. static InitiateController(vrGamepad: any): Gamepad;
  18823. }
  18824. /**
  18825. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18826. */
  18827. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18828. /**
  18829. * If the controller is used in a webXR session
  18830. */
  18831. isXR: boolean;
  18832. private _deviceRoomPosition;
  18833. private _deviceRoomRotationQuaternion;
  18834. /**
  18835. * The device position in babylon space
  18836. */
  18837. devicePosition: Vector3;
  18838. /**
  18839. * The device rotation in babylon space
  18840. */
  18841. deviceRotationQuaternion: Quaternion;
  18842. /**
  18843. * The scale factor of the device in babylon space
  18844. */
  18845. deviceScaleFactor: number;
  18846. /**
  18847. * (Likely devicePosition should be used instead) The device position in its room space
  18848. */
  18849. position: Vector3;
  18850. /**
  18851. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18852. */
  18853. rotationQuaternion: Quaternion;
  18854. /**
  18855. * The type of controller (Eg. Windows mixed reality)
  18856. */
  18857. controllerType: PoseEnabledControllerType;
  18858. protected _calculatedPosition: Vector3;
  18859. private _calculatedRotation;
  18860. /**
  18861. * The raw pose from the device
  18862. */
  18863. rawPose: DevicePose;
  18864. private _trackPosition;
  18865. private _maxRotationDistFromHeadset;
  18866. private _draggedRoomRotation;
  18867. /**
  18868. * @hidden
  18869. */
  18870. _disableTrackPosition(fixedPosition: Vector3): void;
  18871. /**
  18872. * Internal, the mesh attached to the controller
  18873. * @hidden
  18874. */
  18875. _mesh: Nullable<AbstractMesh>;
  18876. private _poseControlledCamera;
  18877. private _leftHandSystemQuaternion;
  18878. /**
  18879. * Internal, matrix used to convert room space to babylon space
  18880. * @hidden
  18881. */
  18882. _deviceToWorld: Matrix;
  18883. /**
  18884. * Node to be used when casting a ray from the controller
  18885. * @hidden
  18886. */
  18887. _pointingPoseNode: Nullable<TransformNode>;
  18888. /**
  18889. * Name of the child mesh that can be used to cast a ray from the controller
  18890. */
  18891. static readonly POINTING_POSE: string;
  18892. /**
  18893. * Creates a new PoseEnabledController from a gamepad
  18894. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18895. */
  18896. constructor(browserGamepad: any);
  18897. private _workingMatrix;
  18898. /**
  18899. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18900. */
  18901. update(): void;
  18902. /**
  18903. * Updates only the pose device and mesh without doing any button event checking
  18904. */
  18905. protected _updatePoseAndMesh(): void;
  18906. /**
  18907. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18908. * @param poseData raw pose fromthe device
  18909. */
  18910. updateFromDevice(poseData: DevicePose): void;
  18911. /**
  18912. * @hidden
  18913. */
  18914. _meshAttachedObservable: Observable<AbstractMesh>;
  18915. /**
  18916. * Attaches a mesh to the controller
  18917. * @param mesh the mesh to be attached
  18918. */
  18919. attachToMesh(mesh: AbstractMesh): void;
  18920. /**
  18921. * Attaches the controllers mesh to a camera
  18922. * @param camera the camera the mesh should be attached to
  18923. */
  18924. attachToPoseControlledCamera(camera: TargetCamera): void;
  18925. /**
  18926. * Disposes of the controller
  18927. */
  18928. dispose(): void;
  18929. /**
  18930. * The mesh that is attached to the controller
  18931. */
  18932. get mesh(): Nullable<AbstractMesh>;
  18933. /**
  18934. * Gets the ray of the controller in the direction the controller is pointing
  18935. * @param length the length the resulting ray should be
  18936. * @returns a ray in the direction the controller is pointing
  18937. */
  18938. getForwardRay(length?: number): Ray;
  18939. }
  18940. }
  18941. declare module BABYLON {
  18942. /**
  18943. * Defines the WebVRController object that represents controllers tracked in 3D space
  18944. */
  18945. export abstract class WebVRController extends PoseEnabledController {
  18946. /**
  18947. * Internal, the default controller model for the controller
  18948. */
  18949. protected _defaultModel: Nullable<AbstractMesh>;
  18950. /**
  18951. * Fired when the trigger state has changed
  18952. */
  18953. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18954. /**
  18955. * Fired when the main button state has changed
  18956. */
  18957. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18958. /**
  18959. * Fired when the secondary button state has changed
  18960. */
  18961. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18962. /**
  18963. * Fired when the pad state has changed
  18964. */
  18965. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18966. /**
  18967. * Fired when controllers stick values have changed
  18968. */
  18969. onPadValuesChangedObservable: Observable<StickValues>;
  18970. /**
  18971. * Array of button availible on the controller
  18972. */
  18973. protected _buttons: Array<MutableGamepadButton>;
  18974. private _onButtonStateChange;
  18975. /**
  18976. * Fired when a controller button's state has changed
  18977. * @param callback the callback containing the button that was modified
  18978. */
  18979. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18980. /**
  18981. * X and Y axis corresponding to the controllers joystick
  18982. */
  18983. pad: StickValues;
  18984. /**
  18985. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18986. */
  18987. hand: string;
  18988. /**
  18989. * The default controller model for the controller
  18990. */
  18991. get defaultModel(): Nullable<AbstractMesh>;
  18992. /**
  18993. * Creates a new WebVRController from a gamepad
  18994. * @param vrGamepad the gamepad that the WebVRController should be created from
  18995. */
  18996. constructor(vrGamepad: any);
  18997. /**
  18998. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18999. */
  19000. update(): void;
  19001. /**
  19002. * Function to be called when a button is modified
  19003. */
  19004. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19005. /**
  19006. * Loads a mesh and attaches it to the controller
  19007. * @param scene the scene the mesh should be added to
  19008. * @param meshLoaded callback for when the mesh has been loaded
  19009. */
  19010. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19011. private _setButtonValue;
  19012. private _changes;
  19013. private _checkChanges;
  19014. /**
  19015. * Disposes of th webVRCOntroller
  19016. */
  19017. dispose(): void;
  19018. }
  19019. }
  19020. declare module BABYLON {
  19021. /**
  19022. * The HemisphericLight simulates the ambient environment light,
  19023. * so the passed direction is the light reflection direction, not the incoming direction.
  19024. */
  19025. export class HemisphericLight extends Light {
  19026. /**
  19027. * The groundColor is the light in the opposite direction to the one specified during creation.
  19028. * 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.
  19029. */
  19030. groundColor: Color3;
  19031. /**
  19032. * The light reflection direction, not the incoming direction.
  19033. */
  19034. direction: Vector3;
  19035. /**
  19036. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19037. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19038. * The HemisphericLight can't cast shadows.
  19039. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19040. * @param name The friendly name of the light
  19041. * @param direction The direction of the light reflection
  19042. * @param scene The scene the light belongs to
  19043. */
  19044. constructor(name: string, direction: Vector3, scene: Scene);
  19045. protected _buildUniformLayout(): void;
  19046. /**
  19047. * Returns the string "HemisphericLight".
  19048. * @return The class name
  19049. */
  19050. getClassName(): string;
  19051. /**
  19052. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19053. * Returns the updated direction.
  19054. * @param target The target the direction should point to
  19055. * @return The computed direction
  19056. */
  19057. setDirectionToTarget(target: Vector3): Vector3;
  19058. /**
  19059. * Returns the shadow generator associated to the light.
  19060. * @returns Always null for hemispheric lights because it does not support shadows.
  19061. */
  19062. getShadowGenerator(): Nullable<IShadowGenerator>;
  19063. /**
  19064. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19065. * @param effect The effect to update
  19066. * @param lightIndex The index of the light in the effect to update
  19067. * @returns The hemispheric light
  19068. */
  19069. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19070. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19071. /**
  19072. * Computes the world matrix of the node
  19073. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19074. * @param useWasUpdatedFlag defines a reserved property
  19075. * @returns the world matrix
  19076. */
  19077. computeWorldMatrix(): Matrix;
  19078. /**
  19079. * Returns the integer 3.
  19080. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19081. */
  19082. getTypeID(): number;
  19083. /**
  19084. * Prepares the list of defines specific to the light type.
  19085. * @param defines the list of defines
  19086. * @param lightIndex defines the index of the light for the effect
  19087. */
  19088. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19089. }
  19090. }
  19091. declare module BABYLON {
  19092. /** @hidden */
  19093. export var vrMultiviewToSingleviewPixelShader: {
  19094. name: string;
  19095. shader: string;
  19096. };
  19097. }
  19098. declare module BABYLON {
  19099. /**
  19100. * Renders to multiple views with a single draw call
  19101. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19102. */
  19103. export class MultiviewRenderTarget extends RenderTargetTexture {
  19104. /**
  19105. * Creates a multiview render target
  19106. * @param scene scene used with the render target
  19107. * @param size the size of the render target (used for each view)
  19108. */
  19109. constructor(scene: Scene, size?: number | {
  19110. width: number;
  19111. height: number;
  19112. } | {
  19113. ratio: number;
  19114. });
  19115. /**
  19116. * @hidden
  19117. * @param faceIndex the face index, if its a cube texture
  19118. */
  19119. _bindFrameBuffer(faceIndex?: number): void;
  19120. /**
  19121. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19122. * @returns the view count
  19123. */
  19124. getViewCount(): number;
  19125. }
  19126. }
  19127. declare module BABYLON {
  19128. /**
  19129. * Represents a camera frustum
  19130. */
  19131. export class Frustum {
  19132. /**
  19133. * Gets the planes representing the frustum
  19134. * @param transform matrix to be applied to the returned planes
  19135. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19136. */
  19137. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19138. /**
  19139. * Gets the near frustum plane transformed by the transform matrix
  19140. * @param transform transformation matrix to be applied to the resulting frustum plane
  19141. * @param frustumPlane the resuling frustum plane
  19142. */
  19143. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19144. /**
  19145. * Gets the far frustum plane transformed by the transform matrix
  19146. * @param transform transformation matrix to be applied to the resulting frustum plane
  19147. * @param frustumPlane the resuling frustum plane
  19148. */
  19149. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19150. /**
  19151. * Gets the left frustum plane transformed by the transform matrix
  19152. * @param transform transformation matrix to be applied to the resulting frustum plane
  19153. * @param frustumPlane the resuling frustum plane
  19154. */
  19155. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19156. /**
  19157. * Gets the right frustum plane transformed by the transform matrix
  19158. * @param transform transformation matrix to be applied to the resulting frustum plane
  19159. * @param frustumPlane the resuling frustum plane
  19160. */
  19161. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19162. /**
  19163. * Gets the top frustum plane transformed by the transform matrix
  19164. * @param transform transformation matrix to be applied to the resulting frustum plane
  19165. * @param frustumPlane the resuling frustum plane
  19166. */
  19167. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19168. /**
  19169. * Gets the bottom frustum plane transformed by the transform matrix
  19170. * @param transform transformation matrix to be applied to the resulting frustum plane
  19171. * @param frustumPlane the resuling frustum plane
  19172. */
  19173. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19174. /**
  19175. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19176. * @param transform transformation matrix to be applied to the resulting frustum planes
  19177. * @param frustumPlanes the resuling frustum planes
  19178. */
  19179. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19180. }
  19181. }
  19182. declare module BABYLON {
  19183. interface Engine {
  19184. /**
  19185. * Creates a new multiview render target
  19186. * @param width defines the width of the texture
  19187. * @param height defines the height of the texture
  19188. * @returns the created multiview texture
  19189. */
  19190. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19191. /**
  19192. * Binds a multiview framebuffer to be drawn to
  19193. * @param multiviewTexture texture to bind
  19194. */
  19195. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19196. }
  19197. interface Camera {
  19198. /**
  19199. * @hidden
  19200. * 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)
  19201. */
  19202. _useMultiviewToSingleView: boolean;
  19203. /**
  19204. * @hidden
  19205. * 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)
  19206. */
  19207. _multiviewTexture: Nullable<RenderTargetTexture>;
  19208. /**
  19209. * @hidden
  19210. * ensures the multiview texture of the camera exists and has the specified width/height
  19211. * @param width height to set on the multiview texture
  19212. * @param height width to set on the multiview texture
  19213. */
  19214. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19215. }
  19216. interface Scene {
  19217. /** @hidden */
  19218. _transformMatrixR: Matrix;
  19219. /** @hidden */
  19220. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19221. /** @hidden */
  19222. _createMultiviewUbo(): void;
  19223. /** @hidden */
  19224. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19225. /** @hidden */
  19226. _renderMultiviewToSingleView(camera: Camera): void;
  19227. }
  19228. }
  19229. declare module BABYLON {
  19230. /**
  19231. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19232. * This will not be used for webXR as it supports displaying texture arrays directly
  19233. */
  19234. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19235. /**
  19236. * Initializes a VRMultiviewToSingleview
  19237. * @param name name of the post process
  19238. * @param camera camera to be applied to
  19239. * @param scaleFactor scaling factor to the size of the output texture
  19240. */
  19241. constructor(name: string, camera: Camera, scaleFactor: number);
  19242. }
  19243. }
  19244. declare module BABYLON {
  19245. /**
  19246. * Interface used to define additional presentation attributes
  19247. */
  19248. export interface IVRPresentationAttributes {
  19249. /**
  19250. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19251. */
  19252. highRefreshRate: boolean;
  19253. /**
  19254. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19255. */
  19256. foveationLevel: number;
  19257. }
  19258. interface Engine {
  19259. /** @hidden */
  19260. _vrDisplay: any;
  19261. /** @hidden */
  19262. _vrSupported: boolean;
  19263. /** @hidden */
  19264. _oldSize: Size;
  19265. /** @hidden */
  19266. _oldHardwareScaleFactor: number;
  19267. /** @hidden */
  19268. _vrExclusivePointerMode: boolean;
  19269. /** @hidden */
  19270. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19271. /** @hidden */
  19272. _onVRDisplayPointerRestricted: () => void;
  19273. /** @hidden */
  19274. _onVRDisplayPointerUnrestricted: () => void;
  19275. /** @hidden */
  19276. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19277. /** @hidden */
  19278. _onVrDisplayDisconnect: Nullable<() => void>;
  19279. /** @hidden */
  19280. _onVrDisplayPresentChange: Nullable<() => void>;
  19281. /**
  19282. * Observable signaled when VR display mode changes
  19283. */
  19284. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19285. /**
  19286. * Observable signaled when VR request present is complete
  19287. */
  19288. onVRRequestPresentComplete: Observable<boolean>;
  19289. /**
  19290. * Observable signaled when VR request present starts
  19291. */
  19292. onVRRequestPresentStart: Observable<Engine>;
  19293. /**
  19294. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19295. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19296. */
  19297. isInVRExclusivePointerMode: boolean;
  19298. /**
  19299. * Gets a boolean indicating if a webVR device was detected
  19300. * @returns true if a webVR device was detected
  19301. */
  19302. isVRDevicePresent(): boolean;
  19303. /**
  19304. * Gets the current webVR device
  19305. * @returns the current webVR device (or null)
  19306. */
  19307. getVRDevice(): any;
  19308. /**
  19309. * Initializes a webVR display and starts listening to display change events
  19310. * The onVRDisplayChangedObservable will be notified upon these changes
  19311. * @returns A promise containing a VRDisplay and if vr is supported
  19312. */
  19313. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19314. /** @hidden */
  19315. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19316. /**
  19317. * Gets or sets the presentation attributes used to configure VR rendering
  19318. */
  19319. vrPresentationAttributes?: IVRPresentationAttributes;
  19320. /**
  19321. * Call this function to switch to webVR mode
  19322. * Will do nothing if webVR is not supported or if there is no webVR device
  19323. * @param options the webvr options provided to the camera. mainly used for multiview
  19324. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19325. */
  19326. enableVR(options: WebVROptions): void;
  19327. /** @hidden */
  19328. _onVRFullScreenTriggered(): void;
  19329. }
  19330. }
  19331. declare module BABYLON {
  19332. /**
  19333. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19334. * IMPORTANT!! The data is right-hand data.
  19335. * @export
  19336. * @interface DevicePose
  19337. */
  19338. export interface DevicePose {
  19339. /**
  19340. * The position of the device, values in array are [x,y,z].
  19341. */
  19342. readonly position: Nullable<Float32Array>;
  19343. /**
  19344. * The linearVelocity of the device, values in array are [x,y,z].
  19345. */
  19346. readonly linearVelocity: Nullable<Float32Array>;
  19347. /**
  19348. * The linearAcceleration of the device, values in array are [x,y,z].
  19349. */
  19350. readonly linearAcceleration: Nullable<Float32Array>;
  19351. /**
  19352. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19353. */
  19354. readonly orientation: Nullable<Float32Array>;
  19355. /**
  19356. * The angularVelocity of the device, values in array are [x,y,z].
  19357. */
  19358. readonly angularVelocity: Nullable<Float32Array>;
  19359. /**
  19360. * The angularAcceleration of the device, values in array are [x,y,z].
  19361. */
  19362. readonly angularAcceleration: Nullable<Float32Array>;
  19363. }
  19364. /**
  19365. * Interface representing a pose controlled object in Babylon.
  19366. * A pose controlled object has both regular pose values as well as pose values
  19367. * from an external device such as a VR head mounted display
  19368. */
  19369. export interface PoseControlled {
  19370. /**
  19371. * The position of the object in babylon space.
  19372. */
  19373. position: Vector3;
  19374. /**
  19375. * The rotation quaternion of the object in babylon space.
  19376. */
  19377. rotationQuaternion: Quaternion;
  19378. /**
  19379. * The position of the device in babylon space.
  19380. */
  19381. devicePosition?: Vector3;
  19382. /**
  19383. * The rotation quaternion of the device in babylon space.
  19384. */
  19385. deviceRotationQuaternion: Quaternion;
  19386. /**
  19387. * The raw pose coming from the device.
  19388. */
  19389. rawPose: Nullable<DevicePose>;
  19390. /**
  19391. * The scale of the device to be used when translating from device space to babylon space.
  19392. */
  19393. deviceScaleFactor: number;
  19394. /**
  19395. * Updates the poseControlled values based on the input device pose.
  19396. * @param poseData the pose data to update the object with
  19397. */
  19398. updateFromDevice(poseData: DevicePose): void;
  19399. }
  19400. /**
  19401. * Set of options to customize the webVRCamera
  19402. */
  19403. export interface WebVROptions {
  19404. /**
  19405. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19406. */
  19407. trackPosition?: boolean;
  19408. /**
  19409. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19410. */
  19411. positionScale?: number;
  19412. /**
  19413. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19414. */
  19415. displayName?: string;
  19416. /**
  19417. * Should the native controller meshes be initialized. (default: true)
  19418. */
  19419. controllerMeshes?: boolean;
  19420. /**
  19421. * Creating a default HemiLight only on controllers. (default: true)
  19422. */
  19423. defaultLightingOnControllers?: boolean;
  19424. /**
  19425. * If you don't want to use the default VR button of the helper. (default: false)
  19426. */
  19427. useCustomVRButton?: boolean;
  19428. /**
  19429. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19430. */
  19431. customVRButton?: HTMLButtonElement;
  19432. /**
  19433. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19434. */
  19435. rayLength?: number;
  19436. /**
  19437. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19438. */
  19439. defaultHeight?: number;
  19440. /**
  19441. * If multiview should be used if availible (default: false)
  19442. */
  19443. useMultiview?: boolean;
  19444. }
  19445. /**
  19446. * This represents a WebVR camera.
  19447. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19448. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19449. */
  19450. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19451. private webVROptions;
  19452. /**
  19453. * @hidden
  19454. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19455. */
  19456. _vrDevice: any;
  19457. /**
  19458. * The rawPose of the vrDevice.
  19459. */
  19460. rawPose: Nullable<DevicePose>;
  19461. private _onVREnabled;
  19462. private _specsVersion;
  19463. private _attached;
  19464. private _frameData;
  19465. protected _descendants: Array<Node>;
  19466. private _deviceRoomPosition;
  19467. /** @hidden */
  19468. _deviceRoomRotationQuaternion: Quaternion;
  19469. private _standingMatrix;
  19470. /**
  19471. * Represents device position in babylon space.
  19472. */
  19473. devicePosition: Vector3;
  19474. /**
  19475. * Represents device rotation in babylon space.
  19476. */
  19477. deviceRotationQuaternion: Quaternion;
  19478. /**
  19479. * The scale of the device to be used when translating from device space to babylon space.
  19480. */
  19481. deviceScaleFactor: number;
  19482. private _deviceToWorld;
  19483. private _worldToDevice;
  19484. /**
  19485. * References to the webVR controllers for the vrDevice.
  19486. */
  19487. controllers: Array<WebVRController>;
  19488. /**
  19489. * Emits an event when a controller is attached.
  19490. */
  19491. onControllersAttachedObservable: Observable<WebVRController[]>;
  19492. /**
  19493. * Emits an event when a controller's mesh has been loaded;
  19494. */
  19495. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19496. /**
  19497. * Emits an event when the HMD's pose has been updated.
  19498. */
  19499. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19500. private _poseSet;
  19501. /**
  19502. * If the rig cameras be used as parent instead of this camera.
  19503. */
  19504. rigParenting: boolean;
  19505. private _lightOnControllers;
  19506. private _defaultHeight?;
  19507. /**
  19508. * Instantiates a WebVRFreeCamera.
  19509. * @param name The name of the WebVRFreeCamera
  19510. * @param position The starting anchor position for the camera
  19511. * @param scene The scene the camera belongs to
  19512. * @param webVROptions a set of customizable options for the webVRCamera
  19513. */
  19514. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19515. /**
  19516. * Gets the device distance from the ground in meters.
  19517. * @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.
  19518. */
  19519. deviceDistanceToRoomGround(): number;
  19520. /**
  19521. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19522. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19523. */
  19524. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19525. /**
  19526. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19527. * @returns A promise with a boolean set to if the standing matrix is supported.
  19528. */
  19529. useStandingMatrixAsync(): Promise<boolean>;
  19530. /**
  19531. * Disposes the camera
  19532. */
  19533. dispose(): void;
  19534. /**
  19535. * Gets a vrController by name.
  19536. * @param name The name of the controller to retreive
  19537. * @returns the controller matching the name specified or null if not found
  19538. */
  19539. getControllerByName(name: string): Nullable<WebVRController>;
  19540. private _leftController;
  19541. /**
  19542. * The controller corresponding to the users left hand.
  19543. */
  19544. get leftController(): Nullable<WebVRController>;
  19545. private _rightController;
  19546. /**
  19547. * The controller corresponding to the users right hand.
  19548. */
  19549. get rightController(): Nullable<WebVRController>;
  19550. /**
  19551. * Casts a ray forward from the vrCamera's gaze.
  19552. * @param length Length of the ray (default: 100)
  19553. * @returns the ray corresponding to the gaze
  19554. */
  19555. getForwardRay(length?: number): Ray;
  19556. /**
  19557. * @hidden
  19558. * Updates the camera based on device's frame data
  19559. */
  19560. _checkInputs(): void;
  19561. /**
  19562. * Updates the poseControlled values based on the input device pose.
  19563. * @param poseData Pose coming from the device
  19564. */
  19565. updateFromDevice(poseData: DevicePose): void;
  19566. private _htmlElementAttached;
  19567. private _detachIfAttached;
  19568. /**
  19569. * WebVR's attach control will start broadcasting frames to the device.
  19570. * Note that in certain browsers (chrome for example) this function must be called
  19571. * within a user-interaction callback. Example:
  19572. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19573. *
  19574. * @param element html element to attach the vrDevice to
  19575. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19576. */
  19577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19578. /**
  19579. * Detaches the camera from the html element and disables VR
  19580. *
  19581. * @param element html element to detach from
  19582. */
  19583. detachControl(element: HTMLElement): void;
  19584. /**
  19585. * @returns the name of this class
  19586. */
  19587. getClassName(): string;
  19588. /**
  19589. * Calls resetPose on the vrDisplay
  19590. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19591. */
  19592. resetToCurrentRotation(): void;
  19593. /**
  19594. * @hidden
  19595. * Updates the rig cameras (left and right eye)
  19596. */
  19597. _updateRigCameras(): void;
  19598. private _workingVector;
  19599. private _oneVector;
  19600. private _workingMatrix;
  19601. private updateCacheCalled;
  19602. private _correctPositionIfNotTrackPosition;
  19603. /**
  19604. * @hidden
  19605. * Updates the cached values of the camera
  19606. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19607. */
  19608. _updateCache(ignoreParentClass?: boolean): void;
  19609. /**
  19610. * @hidden
  19611. * Get current device position in babylon world
  19612. */
  19613. _computeDevicePosition(): void;
  19614. /**
  19615. * Updates the current device position and rotation in the babylon world
  19616. */
  19617. update(): void;
  19618. /**
  19619. * @hidden
  19620. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19621. * @returns an identity matrix
  19622. */
  19623. _getViewMatrix(): Matrix;
  19624. private _tmpMatrix;
  19625. /**
  19626. * This function is called by the two RIG cameras.
  19627. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19628. * @hidden
  19629. */
  19630. _getWebVRViewMatrix(): Matrix;
  19631. /** @hidden */
  19632. _getWebVRProjectionMatrix(): Matrix;
  19633. private _onGamepadConnectedObserver;
  19634. private _onGamepadDisconnectedObserver;
  19635. private _updateCacheWhenTrackingDisabledObserver;
  19636. /**
  19637. * Initializes the controllers and their meshes
  19638. */
  19639. initControllers(): void;
  19640. }
  19641. }
  19642. declare module BABYLON {
  19643. /**
  19644. * Size options for a post process
  19645. */
  19646. export type PostProcessOptions = {
  19647. width: number;
  19648. height: number;
  19649. };
  19650. /**
  19651. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19652. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19653. */
  19654. export class PostProcess {
  19655. /** Name of the PostProcess. */
  19656. name: string;
  19657. /**
  19658. * Gets or sets the unique id of the post process
  19659. */
  19660. uniqueId: number;
  19661. /**
  19662. * Width of the texture to apply the post process on
  19663. */
  19664. width: number;
  19665. /**
  19666. * Height of the texture to apply the post process on
  19667. */
  19668. height: number;
  19669. /**
  19670. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19671. * @hidden
  19672. */
  19673. _outputTexture: Nullable<InternalTexture>;
  19674. /**
  19675. * Sampling mode used by the shader
  19676. * See https://doc.babylonjs.com/classes/3.1/texture
  19677. */
  19678. renderTargetSamplingMode: number;
  19679. /**
  19680. * Clear color to use when screen clearing
  19681. */
  19682. clearColor: Color4;
  19683. /**
  19684. * If the buffer needs to be cleared before applying the post process. (default: true)
  19685. * Should be set to false if shader will overwrite all previous pixels.
  19686. */
  19687. autoClear: boolean;
  19688. /**
  19689. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19690. */
  19691. alphaMode: number;
  19692. /**
  19693. * Sets the setAlphaBlendConstants of the babylon engine
  19694. */
  19695. alphaConstants: Color4;
  19696. /**
  19697. * Animations to be used for the post processing
  19698. */
  19699. animations: Animation[];
  19700. /**
  19701. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19702. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19703. */
  19704. enablePixelPerfectMode: boolean;
  19705. /**
  19706. * Force the postprocess to be applied without taking in account viewport
  19707. */
  19708. forceFullscreenViewport: boolean;
  19709. /**
  19710. * List of inspectable custom properties (used by the Inspector)
  19711. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19712. */
  19713. inspectableCustomProperties: IInspectable[];
  19714. /**
  19715. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19716. *
  19717. * | Value | Type | Description |
  19718. * | ----- | ----------------------------------- | ----------- |
  19719. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19720. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19721. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19722. *
  19723. */
  19724. scaleMode: number;
  19725. /**
  19726. * Force textures to be a power of two (default: false)
  19727. */
  19728. alwaysForcePOT: boolean;
  19729. private _samples;
  19730. /**
  19731. * Number of sample textures (default: 1)
  19732. */
  19733. get samples(): number;
  19734. set samples(n: number);
  19735. /**
  19736. * Modify the scale of the post process to be the same as the viewport (default: false)
  19737. */
  19738. adaptScaleToCurrentViewport: boolean;
  19739. private _camera;
  19740. private _scene;
  19741. private _engine;
  19742. private _options;
  19743. private _reusable;
  19744. private _textureType;
  19745. private _textureFormat;
  19746. /**
  19747. * Smart array of input and output textures for the post process.
  19748. * @hidden
  19749. */
  19750. _textures: SmartArray<InternalTexture>;
  19751. /**
  19752. * The index in _textures that corresponds to the output texture.
  19753. * @hidden
  19754. */
  19755. _currentRenderTextureInd: number;
  19756. private _effect;
  19757. private _samplers;
  19758. private _fragmentUrl;
  19759. private _vertexUrl;
  19760. private _parameters;
  19761. private _scaleRatio;
  19762. protected _indexParameters: any;
  19763. private _shareOutputWithPostProcess;
  19764. private _texelSize;
  19765. private _forcedOutputTexture;
  19766. /**
  19767. * Returns the fragment url or shader name used in the post process.
  19768. * @returns the fragment url or name in the shader store.
  19769. */
  19770. getEffectName(): string;
  19771. /**
  19772. * An event triggered when the postprocess is activated.
  19773. */
  19774. onActivateObservable: Observable<Camera>;
  19775. private _onActivateObserver;
  19776. /**
  19777. * A function that is added to the onActivateObservable
  19778. */
  19779. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19780. /**
  19781. * An event triggered when the postprocess changes its size.
  19782. */
  19783. onSizeChangedObservable: Observable<PostProcess>;
  19784. private _onSizeChangedObserver;
  19785. /**
  19786. * A function that is added to the onSizeChangedObservable
  19787. */
  19788. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19789. /**
  19790. * An event triggered when the postprocess applies its effect.
  19791. */
  19792. onApplyObservable: Observable<Effect>;
  19793. private _onApplyObserver;
  19794. /**
  19795. * A function that is added to the onApplyObservable
  19796. */
  19797. set onApply(callback: (effect: Effect) => void);
  19798. /**
  19799. * An event triggered before rendering the postprocess
  19800. */
  19801. onBeforeRenderObservable: Observable<Effect>;
  19802. private _onBeforeRenderObserver;
  19803. /**
  19804. * A function that is added to the onBeforeRenderObservable
  19805. */
  19806. set onBeforeRender(callback: (effect: Effect) => void);
  19807. /**
  19808. * An event triggered after rendering the postprocess
  19809. */
  19810. onAfterRenderObservable: Observable<Effect>;
  19811. private _onAfterRenderObserver;
  19812. /**
  19813. * A function that is added to the onAfterRenderObservable
  19814. */
  19815. set onAfterRender(callback: (efect: Effect) => void);
  19816. /**
  19817. * 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
  19818. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19819. */
  19820. get inputTexture(): InternalTexture;
  19821. set inputTexture(value: InternalTexture);
  19822. /**
  19823. * Gets the camera which post process is applied to.
  19824. * @returns The camera the post process is applied to.
  19825. */
  19826. getCamera(): Camera;
  19827. /**
  19828. * Gets the texel size of the postprocess.
  19829. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19830. */
  19831. get texelSize(): Vector2;
  19832. /**
  19833. * Creates a new instance PostProcess
  19834. * @param name The name of the PostProcess.
  19835. * @param fragmentUrl The url of the fragment shader to be used.
  19836. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19837. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19838. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19839. * @param camera The camera to apply the render pass to.
  19840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19841. * @param engine The engine which the post process will be applied. (default: current engine)
  19842. * @param reusable If the post process can be reused on the same frame. (default: false)
  19843. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19844. * @param textureType Type of textures used when performing the post process. (default: 0)
  19845. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19846. * @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
  19847. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19848. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19849. */
  19850. constructor(
  19851. /** Name of the PostProcess. */
  19852. 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);
  19853. /**
  19854. * Gets a string idenfifying the name of the class
  19855. * @returns "PostProcess" string
  19856. */
  19857. getClassName(): string;
  19858. /**
  19859. * Gets the engine which this post process belongs to.
  19860. * @returns The engine the post process was enabled with.
  19861. */
  19862. getEngine(): Engine;
  19863. /**
  19864. * The effect that is created when initializing the post process.
  19865. * @returns The created effect corresponding the the postprocess.
  19866. */
  19867. getEffect(): Effect;
  19868. /**
  19869. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19870. * @param postProcess The post process to share the output with.
  19871. * @returns This post process.
  19872. */
  19873. shareOutputWith(postProcess: PostProcess): PostProcess;
  19874. /**
  19875. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19876. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19877. */
  19878. useOwnOutput(): void;
  19879. /**
  19880. * Updates the effect with the current post process compile time values and recompiles the shader.
  19881. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19882. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19883. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19884. * @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
  19885. * @param onCompiled Called when the shader has been compiled.
  19886. * @param onError Called if there is an error when compiling a shader.
  19887. */
  19888. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19889. /**
  19890. * The post process is reusable if it can be used multiple times within one frame.
  19891. * @returns If the post process is reusable
  19892. */
  19893. isReusable(): boolean;
  19894. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19895. markTextureDirty(): void;
  19896. /**
  19897. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19898. * 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.
  19899. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19900. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19901. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19902. * @returns The target texture that was bound to be written to.
  19903. */
  19904. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19905. /**
  19906. * If the post process is supported.
  19907. */
  19908. get isSupported(): boolean;
  19909. /**
  19910. * The aspect ratio of the output texture.
  19911. */
  19912. get aspectRatio(): number;
  19913. /**
  19914. * Get a value indicating if the post-process is ready to be used
  19915. * @returns true if the post-process is ready (shader is compiled)
  19916. */
  19917. isReady(): boolean;
  19918. /**
  19919. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19920. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19921. */
  19922. apply(): Nullable<Effect>;
  19923. private _disposeTextures;
  19924. /**
  19925. * Disposes the post process.
  19926. * @param camera The camera to dispose the post process on.
  19927. */
  19928. dispose(camera?: Camera): void;
  19929. }
  19930. }
  19931. declare module BABYLON {
  19932. /** @hidden */
  19933. export var kernelBlurVaryingDeclaration: {
  19934. name: string;
  19935. shader: string;
  19936. };
  19937. }
  19938. declare module BABYLON {
  19939. /** @hidden */
  19940. export var kernelBlurFragment: {
  19941. name: string;
  19942. shader: string;
  19943. };
  19944. }
  19945. declare module BABYLON {
  19946. /** @hidden */
  19947. export var kernelBlurFragment2: {
  19948. name: string;
  19949. shader: string;
  19950. };
  19951. }
  19952. declare module BABYLON {
  19953. /** @hidden */
  19954. export var kernelBlurPixelShader: {
  19955. name: string;
  19956. shader: string;
  19957. };
  19958. }
  19959. declare module BABYLON {
  19960. /** @hidden */
  19961. export var kernelBlurVertex: {
  19962. name: string;
  19963. shader: string;
  19964. };
  19965. }
  19966. declare module BABYLON {
  19967. /** @hidden */
  19968. export var kernelBlurVertexShader: {
  19969. name: string;
  19970. shader: string;
  19971. };
  19972. }
  19973. declare module BABYLON {
  19974. /**
  19975. * The Blur Post Process which blurs an image based on a kernel and direction.
  19976. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19977. */
  19978. export class BlurPostProcess extends PostProcess {
  19979. /** The direction in which to blur the image. */
  19980. direction: Vector2;
  19981. private blockCompilation;
  19982. protected _kernel: number;
  19983. protected _idealKernel: number;
  19984. protected _packedFloat: boolean;
  19985. private _staticDefines;
  19986. /**
  19987. * Sets the length in pixels of the blur sample region
  19988. */
  19989. set kernel(v: number);
  19990. /**
  19991. * Gets the length in pixels of the blur sample region
  19992. */
  19993. get kernel(): number;
  19994. /**
  19995. * Sets wether or not the blur needs to unpack/repack floats
  19996. */
  19997. set packedFloat(v: boolean);
  19998. /**
  19999. * Gets wether or not the blur is unpacking/repacking floats
  20000. */
  20001. get packedFloat(): boolean;
  20002. /**
  20003. * Creates a new instance BlurPostProcess
  20004. * @param name The name of the effect.
  20005. * @param direction The direction in which to blur the image.
  20006. * @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.
  20007. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20008. * @param camera The camera to apply the render pass to.
  20009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20010. * @param engine The engine which the post process will be applied. (default: current engine)
  20011. * @param reusable If the post process can be reused on the same frame. (default: false)
  20012. * @param textureType Type of textures used when performing the post process. (default: 0)
  20013. * @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)
  20014. */
  20015. constructor(name: string,
  20016. /** The direction in which to blur the image. */
  20017. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20018. /**
  20019. * Updates the effect with the current post process compile time values and recompiles the shader.
  20020. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20021. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20022. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20023. * @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
  20024. * @param onCompiled Called when the shader has been compiled.
  20025. * @param onError Called if there is an error when compiling a shader.
  20026. */
  20027. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20028. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20029. /**
  20030. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20031. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20032. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20033. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20034. * The gaps between physical kernels are compensated for in the weighting of the samples
  20035. * @param idealKernel Ideal blur kernel.
  20036. * @return Nearest best kernel.
  20037. */
  20038. protected _nearestBestKernel(idealKernel: number): number;
  20039. /**
  20040. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20041. * @param x The point on the Gaussian distribution to sample.
  20042. * @return the value of the Gaussian function at x.
  20043. */
  20044. protected _gaussianWeight(x: number): number;
  20045. /**
  20046. * Generates a string that can be used as a floating point number in GLSL.
  20047. * @param x Value to print.
  20048. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20049. * @return GLSL float string.
  20050. */
  20051. protected _glslFloat(x: number, decimalFigures?: number): string;
  20052. }
  20053. }
  20054. declare module BABYLON {
  20055. /**
  20056. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20057. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20058. * You can then easily use it as a reflectionTexture on a flat surface.
  20059. * In case the surface is not a plane, please consider relying on reflection probes.
  20060. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20061. */
  20062. export class MirrorTexture extends RenderTargetTexture {
  20063. private scene;
  20064. /**
  20065. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20066. * 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.
  20067. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20068. */
  20069. mirrorPlane: Plane;
  20070. /**
  20071. * Define the blur ratio used to blur the reflection if needed.
  20072. */
  20073. set blurRatio(value: number);
  20074. get blurRatio(): number;
  20075. /**
  20076. * Define the adaptive blur kernel used to blur the reflection if needed.
  20077. * This will autocompute the closest best match for the `blurKernel`
  20078. */
  20079. set adaptiveBlurKernel(value: number);
  20080. /**
  20081. * Define the blur kernel used to blur the reflection if needed.
  20082. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20083. */
  20084. set blurKernel(value: number);
  20085. /**
  20086. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20087. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20088. */
  20089. set blurKernelX(value: number);
  20090. get blurKernelX(): number;
  20091. /**
  20092. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20093. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20094. */
  20095. set blurKernelY(value: number);
  20096. get blurKernelY(): number;
  20097. private _autoComputeBlurKernel;
  20098. protected _onRatioRescale(): void;
  20099. private _updateGammaSpace;
  20100. private _imageProcessingConfigChangeObserver;
  20101. private _transformMatrix;
  20102. private _mirrorMatrix;
  20103. private _savedViewMatrix;
  20104. private _blurX;
  20105. private _blurY;
  20106. private _adaptiveBlurKernel;
  20107. private _blurKernelX;
  20108. private _blurKernelY;
  20109. private _blurRatio;
  20110. /**
  20111. * Instantiates a Mirror Texture.
  20112. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20113. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20114. * You can then easily use it as a reflectionTexture on a flat surface.
  20115. * In case the surface is not a plane, please consider relying on reflection probes.
  20116. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20117. * @param name
  20118. * @param size
  20119. * @param scene
  20120. * @param generateMipMaps
  20121. * @param type
  20122. * @param samplingMode
  20123. * @param generateDepthBuffer
  20124. */
  20125. constructor(name: string, size: number | {
  20126. width: number;
  20127. height: number;
  20128. } | {
  20129. ratio: number;
  20130. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20131. private _preparePostProcesses;
  20132. /**
  20133. * Clone the mirror texture.
  20134. * @returns the cloned texture
  20135. */
  20136. clone(): MirrorTexture;
  20137. /**
  20138. * Serialize the texture to a JSON representation you could use in Parse later on
  20139. * @returns the serialized JSON representation
  20140. */
  20141. serialize(): any;
  20142. /**
  20143. * Dispose the texture and release its associated resources.
  20144. */
  20145. dispose(): void;
  20146. }
  20147. }
  20148. declare module BABYLON {
  20149. /**
  20150. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20151. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20152. */
  20153. export class Texture extends BaseTexture {
  20154. /**
  20155. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20156. */
  20157. static SerializeBuffers: boolean;
  20158. /** @hidden */
  20159. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20160. /** @hidden */
  20161. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20162. /** @hidden */
  20163. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20164. /** nearest is mag = nearest and min = nearest and mip = linear */
  20165. static readonly NEAREST_SAMPLINGMODE: number;
  20166. /** nearest is mag = nearest and min = nearest and mip = linear */
  20167. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20168. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20169. static readonly BILINEAR_SAMPLINGMODE: number;
  20170. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20171. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20172. /** Trilinear is mag = linear and min = linear and mip = linear */
  20173. static readonly TRILINEAR_SAMPLINGMODE: number;
  20174. /** Trilinear is mag = linear and min = linear and mip = linear */
  20175. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20176. /** mag = nearest and min = nearest and mip = nearest */
  20177. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20178. /** mag = nearest and min = linear and mip = nearest */
  20179. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20180. /** mag = nearest and min = linear and mip = linear */
  20181. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20182. /** mag = nearest and min = linear and mip = none */
  20183. static readonly NEAREST_LINEAR: number;
  20184. /** mag = nearest and min = nearest and mip = none */
  20185. static readonly NEAREST_NEAREST: number;
  20186. /** mag = linear and min = nearest and mip = nearest */
  20187. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20188. /** mag = linear and min = nearest and mip = linear */
  20189. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20190. /** mag = linear and min = linear and mip = none */
  20191. static readonly LINEAR_LINEAR: number;
  20192. /** mag = linear and min = nearest and mip = none */
  20193. static readonly LINEAR_NEAREST: number;
  20194. /** Explicit coordinates mode */
  20195. static readonly EXPLICIT_MODE: number;
  20196. /** Spherical coordinates mode */
  20197. static readonly SPHERICAL_MODE: number;
  20198. /** Planar coordinates mode */
  20199. static readonly PLANAR_MODE: number;
  20200. /** Cubic coordinates mode */
  20201. static readonly CUBIC_MODE: number;
  20202. /** Projection coordinates mode */
  20203. static readonly PROJECTION_MODE: number;
  20204. /** Inverse Cubic coordinates mode */
  20205. static readonly SKYBOX_MODE: number;
  20206. /** Inverse Cubic coordinates mode */
  20207. static readonly INVCUBIC_MODE: number;
  20208. /** Equirectangular coordinates mode */
  20209. static readonly EQUIRECTANGULAR_MODE: number;
  20210. /** Equirectangular Fixed coordinates mode */
  20211. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20212. /** Equirectangular Fixed Mirrored coordinates mode */
  20213. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20214. /** Texture is not repeating outside of 0..1 UVs */
  20215. static readonly CLAMP_ADDRESSMODE: number;
  20216. /** Texture is repeating outside of 0..1 UVs */
  20217. static readonly WRAP_ADDRESSMODE: number;
  20218. /** Texture is repeating and mirrored */
  20219. static readonly MIRROR_ADDRESSMODE: number;
  20220. /**
  20221. * 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
  20222. */
  20223. static UseSerializedUrlIfAny: boolean;
  20224. /**
  20225. * Define the url of the texture.
  20226. */
  20227. url: Nullable<string>;
  20228. /**
  20229. * Define an offset on the texture to offset the u coordinates of the UVs
  20230. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20231. */
  20232. uOffset: number;
  20233. /**
  20234. * Define an offset on the texture to offset the v coordinates of the UVs
  20235. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20236. */
  20237. vOffset: number;
  20238. /**
  20239. * Define an offset on the texture to scale the u coordinates of the UVs
  20240. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20241. */
  20242. uScale: number;
  20243. /**
  20244. * Define an offset on the texture to scale the v coordinates of the UVs
  20245. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20246. */
  20247. vScale: number;
  20248. /**
  20249. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20250. * @see http://doc.babylonjs.com/how_to/more_materials
  20251. */
  20252. uAng: number;
  20253. /**
  20254. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20255. * @see http://doc.babylonjs.com/how_to/more_materials
  20256. */
  20257. vAng: number;
  20258. /**
  20259. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20260. * @see http://doc.babylonjs.com/how_to/more_materials
  20261. */
  20262. wAng: number;
  20263. /**
  20264. * Defines the center of rotation (U)
  20265. */
  20266. uRotationCenter: number;
  20267. /**
  20268. * Defines the center of rotation (V)
  20269. */
  20270. vRotationCenter: number;
  20271. /**
  20272. * Defines the center of rotation (W)
  20273. */
  20274. wRotationCenter: number;
  20275. /**
  20276. * Are mip maps generated for this texture or not.
  20277. */
  20278. get noMipmap(): boolean;
  20279. /**
  20280. * List of inspectable custom properties (used by the Inspector)
  20281. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20282. */
  20283. inspectableCustomProperties: Nullable<IInspectable[]>;
  20284. private _noMipmap;
  20285. /** @hidden */
  20286. _invertY: boolean;
  20287. private _rowGenerationMatrix;
  20288. private _cachedTextureMatrix;
  20289. private _projectionModeMatrix;
  20290. private _t0;
  20291. private _t1;
  20292. private _t2;
  20293. private _cachedUOffset;
  20294. private _cachedVOffset;
  20295. private _cachedUScale;
  20296. private _cachedVScale;
  20297. private _cachedUAng;
  20298. private _cachedVAng;
  20299. private _cachedWAng;
  20300. private _cachedProjectionMatrixId;
  20301. private _cachedCoordinatesMode;
  20302. /** @hidden */
  20303. protected _initialSamplingMode: number;
  20304. /** @hidden */
  20305. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20306. private _deleteBuffer;
  20307. protected _format: Nullable<number>;
  20308. private _delayedOnLoad;
  20309. private _delayedOnError;
  20310. private _mimeType?;
  20311. /**
  20312. * Observable triggered once the texture has been loaded.
  20313. */
  20314. onLoadObservable: Observable<Texture>;
  20315. protected _isBlocking: boolean;
  20316. /**
  20317. * Is the texture preventing material to render while loading.
  20318. * If false, a default texture will be used instead of the loading one during the preparation step.
  20319. */
  20320. set isBlocking(value: boolean);
  20321. get isBlocking(): boolean;
  20322. /**
  20323. * Get the current sampling mode associated with the texture.
  20324. */
  20325. get samplingMode(): number;
  20326. /**
  20327. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20328. */
  20329. get invertY(): boolean;
  20330. /**
  20331. * Instantiates a new texture.
  20332. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20333. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20334. * @param url defines the url of the picture to load as a texture
  20335. * @param scene defines the scene or engine the texture will belong to
  20336. * @param noMipmap defines if the texture will require mip maps or not
  20337. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20338. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20339. * @param onLoad defines a callback triggered when the texture has been loaded
  20340. * @param onError defines a callback triggered when an error occurred during the loading session
  20341. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20342. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20343. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20344. * @param mimeType defines an optional mime type information
  20345. */
  20346. 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);
  20347. /**
  20348. * Update the url (and optional buffer) of this texture if url was null during construction.
  20349. * @param url the url of the texture
  20350. * @param buffer the buffer of the texture (defaults to null)
  20351. * @param onLoad callback called when the texture is loaded (defaults to null)
  20352. */
  20353. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20354. /**
  20355. * Finish the loading sequence of a texture flagged as delayed load.
  20356. * @hidden
  20357. */
  20358. delayLoad(): void;
  20359. private _prepareRowForTextureGeneration;
  20360. /**
  20361. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20362. * @returns the transform matrix of the texture.
  20363. */
  20364. getTextureMatrix(uBase?: number): Matrix;
  20365. /**
  20366. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20367. * @returns The reflection texture transform
  20368. */
  20369. getReflectionTextureMatrix(): Matrix;
  20370. /**
  20371. * Clones the texture.
  20372. * @returns the cloned texture
  20373. */
  20374. clone(): Texture;
  20375. /**
  20376. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20377. * @returns The JSON representation of the texture
  20378. */
  20379. serialize(): any;
  20380. /**
  20381. * Get the current class name of the texture useful for serialization or dynamic coding.
  20382. * @returns "Texture"
  20383. */
  20384. getClassName(): string;
  20385. /**
  20386. * Dispose the texture and release its associated resources.
  20387. */
  20388. dispose(): void;
  20389. /**
  20390. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20391. * @param parsedTexture Define the JSON representation of the texture
  20392. * @param scene Define the scene the parsed texture should be instantiated in
  20393. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20394. * @returns The parsed texture if successful
  20395. */
  20396. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20397. /**
  20398. * Creates a texture from its base 64 representation.
  20399. * @param data Define the base64 payload without the data: prefix
  20400. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20401. * @param scene Define the scene the texture should belong to
  20402. * @param noMipmap Forces the texture to not create mip map information if true
  20403. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20404. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20405. * @param onLoad define a callback triggered when the texture has been loaded
  20406. * @param onError define a callback triggered when an error occurred during the loading session
  20407. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20408. * @returns the created texture
  20409. */
  20410. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20411. /**
  20412. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20413. * @param data Define the base64 payload without the data: prefix
  20414. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20415. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20416. * @param scene Define the scene the texture should belong to
  20417. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20418. * @param noMipmap Forces the texture to not create mip map information if true
  20419. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20420. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20421. * @param onLoad define a callback triggered when the texture has been loaded
  20422. * @param onError define a callback triggered when an error occurred during the loading session
  20423. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20424. * @returns the created texture
  20425. */
  20426. 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;
  20427. }
  20428. }
  20429. declare module BABYLON {
  20430. /**
  20431. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20432. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20433. */
  20434. export class PostProcessManager {
  20435. private _scene;
  20436. private _indexBuffer;
  20437. private _vertexBuffers;
  20438. /**
  20439. * Creates a new instance PostProcess
  20440. * @param scene The scene that the post process is associated with.
  20441. */
  20442. constructor(scene: Scene);
  20443. private _prepareBuffers;
  20444. private _buildIndexBuffer;
  20445. /**
  20446. * Rebuilds the vertex buffers of the manager.
  20447. * @hidden
  20448. */
  20449. _rebuild(): void;
  20450. /**
  20451. * Prepares a frame to be run through a post process.
  20452. * @param sourceTexture The input texture to the post procesess. (default: null)
  20453. * @param postProcesses An array of post processes to be run. (default: null)
  20454. * @returns True if the post processes were able to be run.
  20455. * @hidden
  20456. */
  20457. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20458. /**
  20459. * Manually render a set of post processes to a texture.
  20460. * @param postProcesses An array of post processes to be run.
  20461. * @param targetTexture The target texture to render to.
  20462. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20463. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20464. * @param lodLevel defines which lod of the texture to render to
  20465. */
  20466. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20467. /**
  20468. * Finalize the result of the output of the postprocesses.
  20469. * @param doNotPresent If true the result will not be displayed to the screen.
  20470. * @param targetTexture The target texture to render to.
  20471. * @param faceIndex The index of the face to bind the target texture to.
  20472. * @param postProcesses The array of post processes to render.
  20473. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20474. * @hidden
  20475. */
  20476. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20477. /**
  20478. * Disposes of the post process manager.
  20479. */
  20480. dispose(): void;
  20481. }
  20482. }
  20483. declare module BABYLON {
  20484. /**
  20485. * This Helps creating a texture that will be created from a camera in your scene.
  20486. * It is basically a dynamic texture that could be used to create special effects for instance.
  20487. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20488. */
  20489. export class RenderTargetTexture extends Texture {
  20490. isCube: boolean;
  20491. /**
  20492. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20493. */
  20494. static readonly REFRESHRATE_RENDER_ONCE: number;
  20495. /**
  20496. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20497. */
  20498. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20499. /**
  20500. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20501. * the central point of your effect and can save a lot of performances.
  20502. */
  20503. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20504. /**
  20505. * Use this predicate to dynamically define the list of mesh you want to render.
  20506. * If set, the renderList property will be overwritten.
  20507. */
  20508. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20509. private _renderList;
  20510. /**
  20511. * Use this list to define the list of mesh you want to render.
  20512. */
  20513. get renderList(): Nullable<Array<AbstractMesh>>;
  20514. set renderList(value: Nullable<Array<AbstractMesh>>);
  20515. /**
  20516. * Use this function to overload the renderList array at rendering time.
  20517. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20518. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20519. * the cube (if the RTT is a cube, else layerOrFace=0).
  20520. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20521. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20522. * hold dummy elements!
  20523. */
  20524. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20525. private _hookArray;
  20526. /**
  20527. * Define if particles should be rendered in your texture.
  20528. */
  20529. renderParticles: boolean;
  20530. /**
  20531. * Define if sprites should be rendered in your texture.
  20532. */
  20533. renderSprites: boolean;
  20534. /**
  20535. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20536. */
  20537. coordinatesMode: number;
  20538. /**
  20539. * Define the camera used to render the texture.
  20540. */
  20541. activeCamera: Nullable<Camera>;
  20542. /**
  20543. * Override the mesh isReady function with your own one.
  20544. */
  20545. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20546. /**
  20547. * Override the render function of the texture with your own one.
  20548. */
  20549. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20550. /**
  20551. * Define if camera post processes should be use while rendering the texture.
  20552. */
  20553. useCameraPostProcesses: boolean;
  20554. /**
  20555. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20556. */
  20557. ignoreCameraViewport: boolean;
  20558. private _postProcessManager;
  20559. private _postProcesses;
  20560. private _resizeObserver;
  20561. /**
  20562. * An event triggered when the texture is unbind.
  20563. */
  20564. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20565. /**
  20566. * An event triggered when the texture is unbind.
  20567. */
  20568. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20569. private _onAfterUnbindObserver;
  20570. /**
  20571. * Set a after unbind callback in the texture.
  20572. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20573. */
  20574. set onAfterUnbind(callback: () => void);
  20575. /**
  20576. * An event triggered before rendering the texture
  20577. */
  20578. onBeforeRenderObservable: Observable<number>;
  20579. private _onBeforeRenderObserver;
  20580. /**
  20581. * Set a before render callback in the texture.
  20582. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20583. */
  20584. set onBeforeRender(callback: (faceIndex: number) => void);
  20585. /**
  20586. * An event triggered after rendering the texture
  20587. */
  20588. onAfterRenderObservable: Observable<number>;
  20589. private _onAfterRenderObserver;
  20590. /**
  20591. * Set a after render callback in the texture.
  20592. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20593. */
  20594. set onAfterRender(callback: (faceIndex: number) => void);
  20595. /**
  20596. * An event triggered after the texture clear
  20597. */
  20598. onClearObservable: Observable<Engine>;
  20599. private _onClearObserver;
  20600. /**
  20601. * Set a clear callback in the texture.
  20602. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20603. */
  20604. set onClear(callback: (Engine: Engine) => void);
  20605. /**
  20606. * An event triggered when the texture is resized.
  20607. */
  20608. onResizeObservable: Observable<RenderTargetTexture>;
  20609. /**
  20610. * Define the clear color of the Render Target if it should be different from the scene.
  20611. */
  20612. clearColor: Color4;
  20613. protected _size: number | {
  20614. width: number;
  20615. height: number;
  20616. layers?: number;
  20617. };
  20618. protected _initialSizeParameter: number | {
  20619. width: number;
  20620. height: number;
  20621. } | {
  20622. ratio: number;
  20623. };
  20624. protected _sizeRatio: Nullable<number>;
  20625. /** @hidden */
  20626. _generateMipMaps: boolean;
  20627. protected _renderingManager: RenderingManager;
  20628. /** @hidden */
  20629. _waitingRenderList: string[];
  20630. protected _doNotChangeAspectRatio: boolean;
  20631. protected _currentRefreshId: number;
  20632. protected _refreshRate: number;
  20633. protected _textureMatrix: Matrix;
  20634. protected _samples: number;
  20635. protected _renderTargetOptions: RenderTargetCreationOptions;
  20636. /**
  20637. * Gets render target creation options that were used.
  20638. */
  20639. get renderTargetOptions(): RenderTargetCreationOptions;
  20640. protected _engine: Engine;
  20641. protected _onRatioRescale(): void;
  20642. /**
  20643. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20644. * It must define where the camera used to render the texture is set
  20645. */
  20646. boundingBoxPosition: Vector3;
  20647. private _boundingBoxSize;
  20648. /**
  20649. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20650. * When defined, the cubemap will switch to local mode
  20651. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20652. * @example https://www.babylonjs-playground.com/#RNASML
  20653. */
  20654. set boundingBoxSize(value: Vector3);
  20655. get boundingBoxSize(): Vector3;
  20656. /**
  20657. * In case the RTT has been created with a depth texture, get the associated
  20658. * depth texture.
  20659. * Otherwise, return null.
  20660. */
  20661. get depthStencilTexture(): Nullable<InternalTexture>;
  20662. /**
  20663. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20664. * or used a shadow, depth texture...
  20665. * @param name The friendly name of the texture
  20666. * @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)
  20667. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20668. * @param generateMipMaps True if mip maps need to be generated after render.
  20669. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20670. * @param type The type of the buffer in the RTT (int, half float, float...)
  20671. * @param isCube True if a cube texture needs to be created
  20672. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20673. * @param generateDepthBuffer True to generate a depth buffer
  20674. * @param generateStencilBuffer True to generate a stencil buffer
  20675. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20676. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20677. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20678. */
  20679. constructor(name: string, size: number | {
  20680. width: number;
  20681. height: number;
  20682. layers?: number;
  20683. } | {
  20684. ratio: number;
  20685. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20686. /**
  20687. * Creates a depth stencil texture.
  20688. * This is only available in WebGL 2 or with the depth texture extension available.
  20689. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20690. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20691. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20692. */
  20693. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20694. private _processSizeParameter;
  20695. /**
  20696. * Define the number of samples to use in case of MSAA.
  20697. * It defaults to one meaning no MSAA has been enabled.
  20698. */
  20699. get samples(): number;
  20700. set samples(value: number);
  20701. /**
  20702. * Resets the refresh counter of the texture and start bak from scratch.
  20703. * Could be useful to regenerate the texture if it is setup to render only once.
  20704. */
  20705. resetRefreshCounter(): void;
  20706. /**
  20707. * Define the refresh rate of the texture or the rendering frequency.
  20708. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20709. */
  20710. get refreshRate(): number;
  20711. set refreshRate(value: number);
  20712. /**
  20713. * Adds a post process to the render target rendering passes.
  20714. * @param postProcess define the post process to add
  20715. */
  20716. addPostProcess(postProcess: PostProcess): void;
  20717. /**
  20718. * Clear all the post processes attached to the render target
  20719. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20720. */
  20721. clearPostProcesses(dispose?: boolean): void;
  20722. /**
  20723. * Remove one of the post process from the list of attached post processes to the texture
  20724. * @param postProcess define the post process to remove from the list
  20725. */
  20726. removePostProcess(postProcess: PostProcess): void;
  20727. /** @hidden */
  20728. _shouldRender(): boolean;
  20729. /**
  20730. * Gets the actual render size of the texture.
  20731. * @returns the width of the render size
  20732. */
  20733. getRenderSize(): number;
  20734. /**
  20735. * Gets the actual render width of the texture.
  20736. * @returns the width of the render size
  20737. */
  20738. getRenderWidth(): number;
  20739. /**
  20740. * Gets the actual render height of the texture.
  20741. * @returns the height of the render size
  20742. */
  20743. getRenderHeight(): number;
  20744. /**
  20745. * Gets the actual number of layers of the texture.
  20746. * @returns the number of layers
  20747. */
  20748. getRenderLayers(): number;
  20749. /**
  20750. * Get if the texture can be rescaled or not.
  20751. */
  20752. get canRescale(): boolean;
  20753. /**
  20754. * Resize the texture using a ratio.
  20755. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20756. */
  20757. scale(ratio: number): void;
  20758. /**
  20759. * Get the texture reflection matrix used to rotate/transform the reflection.
  20760. * @returns the reflection matrix
  20761. */
  20762. getReflectionTextureMatrix(): Matrix;
  20763. /**
  20764. * Resize the texture to a new desired size.
  20765. * Be carrefull as it will recreate all the data in the new texture.
  20766. * @param size Define the new size. It can be:
  20767. * - a number for squared texture,
  20768. * - an object containing { width: number, height: number }
  20769. * - or an object containing a ratio { ratio: number }
  20770. */
  20771. resize(size: number | {
  20772. width: number;
  20773. height: number;
  20774. } | {
  20775. ratio: number;
  20776. }): void;
  20777. private _defaultRenderListPrepared;
  20778. /**
  20779. * Renders all the objects from the render list into the texture.
  20780. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20781. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20782. */
  20783. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20784. private _bestReflectionRenderTargetDimension;
  20785. private _prepareRenderingManager;
  20786. /**
  20787. * @hidden
  20788. * @param faceIndex face index to bind to if this is a cubetexture
  20789. * @param layer defines the index of the texture to bind in the array
  20790. */
  20791. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20792. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20793. private renderToTarget;
  20794. /**
  20795. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20796. * This allowed control for front to back rendering or reversly depending of the special needs.
  20797. *
  20798. * @param renderingGroupId The rendering group id corresponding to its index
  20799. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20800. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20801. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20802. */
  20803. 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;
  20804. /**
  20805. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20806. *
  20807. * @param renderingGroupId The rendering group id corresponding to its index
  20808. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20809. */
  20810. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20811. /**
  20812. * Clones the texture.
  20813. * @returns the cloned texture
  20814. */
  20815. clone(): RenderTargetTexture;
  20816. /**
  20817. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20818. * @returns The JSON representation of the texture
  20819. */
  20820. serialize(): any;
  20821. /**
  20822. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20823. */
  20824. disposeFramebufferObjects(): void;
  20825. /**
  20826. * Dispose the texture and release its associated resources.
  20827. */
  20828. dispose(): void;
  20829. /** @hidden */
  20830. _rebuild(): void;
  20831. /**
  20832. * Clear the info related to rendering groups preventing retention point in material dispose.
  20833. */
  20834. freeRenderingGroups(): void;
  20835. /**
  20836. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20837. * @returns the view count
  20838. */
  20839. getViewCount(): number;
  20840. }
  20841. }
  20842. declare module BABYLON {
  20843. /**
  20844. * Options for compiling materials.
  20845. */
  20846. export interface IMaterialCompilationOptions {
  20847. /**
  20848. * Defines whether clip planes are enabled.
  20849. */
  20850. clipPlane: boolean;
  20851. /**
  20852. * Defines whether instances are enabled.
  20853. */
  20854. useInstances: boolean;
  20855. }
  20856. /**
  20857. * Base class for the main features of a material in Babylon.js
  20858. */
  20859. export class Material implements IAnimatable {
  20860. /**
  20861. * Returns the triangle fill mode
  20862. */
  20863. static readonly TriangleFillMode: number;
  20864. /**
  20865. * Returns the wireframe mode
  20866. */
  20867. static readonly WireFrameFillMode: number;
  20868. /**
  20869. * Returns the point fill mode
  20870. */
  20871. static readonly PointFillMode: number;
  20872. /**
  20873. * Returns the point list draw mode
  20874. */
  20875. static readonly PointListDrawMode: number;
  20876. /**
  20877. * Returns the line list draw mode
  20878. */
  20879. static readonly LineListDrawMode: number;
  20880. /**
  20881. * Returns the line loop draw mode
  20882. */
  20883. static readonly LineLoopDrawMode: number;
  20884. /**
  20885. * Returns the line strip draw mode
  20886. */
  20887. static readonly LineStripDrawMode: number;
  20888. /**
  20889. * Returns the triangle strip draw mode
  20890. */
  20891. static readonly TriangleStripDrawMode: number;
  20892. /**
  20893. * Returns the triangle fan draw mode
  20894. */
  20895. static readonly TriangleFanDrawMode: number;
  20896. /**
  20897. * Stores the clock-wise side orientation
  20898. */
  20899. static readonly ClockWiseSideOrientation: number;
  20900. /**
  20901. * Stores the counter clock-wise side orientation
  20902. */
  20903. static readonly CounterClockWiseSideOrientation: number;
  20904. /**
  20905. * The dirty texture flag value
  20906. */
  20907. static readonly TextureDirtyFlag: number;
  20908. /**
  20909. * The dirty light flag value
  20910. */
  20911. static readonly LightDirtyFlag: number;
  20912. /**
  20913. * The dirty fresnel flag value
  20914. */
  20915. static readonly FresnelDirtyFlag: number;
  20916. /**
  20917. * The dirty attribute flag value
  20918. */
  20919. static readonly AttributesDirtyFlag: number;
  20920. /**
  20921. * The dirty misc flag value
  20922. */
  20923. static readonly MiscDirtyFlag: number;
  20924. /**
  20925. * The all dirty flag value
  20926. */
  20927. static readonly AllDirtyFlag: number;
  20928. /**
  20929. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20930. */
  20931. static readonly MATERIAL_OPAQUE: number;
  20932. /**
  20933. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20934. */
  20935. static readonly MATERIAL_ALPHATEST: number;
  20936. /**
  20937. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20938. */
  20939. static readonly MATERIAL_ALPHABLEND: number;
  20940. /**
  20941. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20942. * They are also discarded below the alpha cutoff threshold to improve performances.
  20943. */
  20944. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  20945. /**
  20946. * The ID of the material
  20947. */
  20948. id: string;
  20949. /**
  20950. * Gets or sets the unique id of the material
  20951. */
  20952. uniqueId: number;
  20953. /**
  20954. * The name of the material
  20955. */
  20956. name: string;
  20957. /**
  20958. * Gets or sets user defined metadata
  20959. */
  20960. metadata: any;
  20961. /**
  20962. * For internal use only. Please do not use.
  20963. */
  20964. reservedDataStore: any;
  20965. /**
  20966. * Specifies if the ready state should be checked on each call
  20967. */
  20968. checkReadyOnEveryCall: boolean;
  20969. /**
  20970. * Specifies if the ready state should be checked once
  20971. */
  20972. checkReadyOnlyOnce: boolean;
  20973. /**
  20974. * The state of the material
  20975. */
  20976. state: string;
  20977. /**
  20978. * The alpha value of the material
  20979. */
  20980. protected _alpha: number;
  20981. /**
  20982. * List of inspectable custom properties (used by the Inspector)
  20983. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20984. */
  20985. inspectableCustomProperties: IInspectable[];
  20986. /**
  20987. * Sets the alpha value of the material
  20988. */
  20989. set alpha(value: number);
  20990. /**
  20991. * Gets the alpha value of the material
  20992. */
  20993. get alpha(): number;
  20994. /**
  20995. * Specifies if back face culling is enabled
  20996. */
  20997. protected _backFaceCulling: boolean;
  20998. /**
  20999. * Sets the back-face culling state
  21000. */
  21001. set backFaceCulling(value: boolean);
  21002. /**
  21003. * Gets the back-face culling state
  21004. */
  21005. get backFaceCulling(): boolean;
  21006. /**
  21007. * Stores the value for side orientation
  21008. */
  21009. sideOrientation: number;
  21010. /**
  21011. * Callback triggered when the material is compiled
  21012. */
  21013. onCompiled: Nullable<(effect: Effect) => void>;
  21014. /**
  21015. * Callback triggered when an error occurs
  21016. */
  21017. onError: Nullable<(effect: Effect, errors: string) => void>;
  21018. /**
  21019. * Callback triggered to get the render target textures
  21020. */
  21021. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21022. /**
  21023. * Gets a boolean indicating that current material needs to register RTT
  21024. */
  21025. get hasRenderTargetTextures(): boolean;
  21026. /**
  21027. * Specifies if the material should be serialized
  21028. */
  21029. doNotSerialize: boolean;
  21030. /**
  21031. * @hidden
  21032. */
  21033. _storeEffectOnSubMeshes: boolean;
  21034. /**
  21035. * Stores the animations for the material
  21036. */
  21037. animations: Nullable<Array<Animation>>;
  21038. /**
  21039. * An event triggered when the material is disposed
  21040. */
  21041. onDisposeObservable: Observable<Material>;
  21042. /**
  21043. * An observer which watches for dispose events
  21044. */
  21045. private _onDisposeObserver;
  21046. private _onUnBindObservable;
  21047. /**
  21048. * Called during a dispose event
  21049. */
  21050. set onDispose(callback: () => void);
  21051. private _onBindObservable;
  21052. /**
  21053. * An event triggered when the material is bound
  21054. */
  21055. get onBindObservable(): Observable<AbstractMesh>;
  21056. /**
  21057. * An observer which watches for bind events
  21058. */
  21059. private _onBindObserver;
  21060. /**
  21061. * Called during a bind event
  21062. */
  21063. set onBind(callback: (Mesh: AbstractMesh) => void);
  21064. /**
  21065. * An event triggered when the material is unbound
  21066. */
  21067. get onUnBindObservable(): Observable<Material>;
  21068. /**
  21069. * Stores the value of the alpha mode
  21070. */
  21071. private _alphaMode;
  21072. /**
  21073. * Sets the value of the alpha mode.
  21074. *
  21075. * | Value | Type | Description |
  21076. * | --- | --- | --- |
  21077. * | 0 | ALPHA_DISABLE | |
  21078. * | 1 | ALPHA_ADD | |
  21079. * | 2 | ALPHA_COMBINE | |
  21080. * | 3 | ALPHA_SUBTRACT | |
  21081. * | 4 | ALPHA_MULTIPLY | |
  21082. * | 5 | ALPHA_MAXIMIZED | |
  21083. * | 6 | ALPHA_ONEONE | |
  21084. * | 7 | ALPHA_PREMULTIPLIED | |
  21085. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21086. * | 9 | ALPHA_INTERPOLATE | |
  21087. * | 10 | ALPHA_SCREENMODE | |
  21088. *
  21089. */
  21090. set alphaMode(value: number);
  21091. /**
  21092. * Gets the value of the alpha mode
  21093. */
  21094. get alphaMode(): number;
  21095. /**
  21096. * Stores the state of the need depth pre-pass value
  21097. */
  21098. private _needDepthPrePass;
  21099. /**
  21100. * Sets the need depth pre-pass value
  21101. */
  21102. set needDepthPrePass(value: boolean);
  21103. /**
  21104. * Gets the depth pre-pass value
  21105. */
  21106. get needDepthPrePass(): boolean;
  21107. /**
  21108. * Specifies if depth writing should be disabled
  21109. */
  21110. disableDepthWrite: boolean;
  21111. /**
  21112. * Specifies if depth writing should be forced
  21113. */
  21114. forceDepthWrite: boolean;
  21115. /**
  21116. * Specifies the depth function that should be used. 0 means the default engine function
  21117. */
  21118. depthFunction: number;
  21119. /**
  21120. * Specifies if there should be a separate pass for culling
  21121. */
  21122. separateCullingPass: boolean;
  21123. /**
  21124. * Stores the state specifing if fog should be enabled
  21125. */
  21126. private _fogEnabled;
  21127. /**
  21128. * Sets the state for enabling fog
  21129. */
  21130. set fogEnabled(value: boolean);
  21131. /**
  21132. * Gets the value of the fog enabled state
  21133. */
  21134. get fogEnabled(): boolean;
  21135. /**
  21136. * Stores the size of points
  21137. */
  21138. pointSize: number;
  21139. /**
  21140. * Stores the z offset value
  21141. */
  21142. zOffset: number;
  21143. /**
  21144. * Gets a value specifying if wireframe mode is enabled
  21145. */
  21146. get wireframe(): boolean;
  21147. /**
  21148. * Sets the state of wireframe mode
  21149. */
  21150. set wireframe(value: boolean);
  21151. /**
  21152. * Gets the value specifying if point clouds are enabled
  21153. */
  21154. get pointsCloud(): boolean;
  21155. /**
  21156. * Sets the state of point cloud mode
  21157. */
  21158. set pointsCloud(value: boolean);
  21159. /**
  21160. * Gets the material fill mode
  21161. */
  21162. get fillMode(): number;
  21163. /**
  21164. * Sets the material fill mode
  21165. */
  21166. set fillMode(value: number);
  21167. /**
  21168. * @hidden
  21169. * Stores the effects for the material
  21170. */
  21171. _effect: Nullable<Effect>;
  21172. /**
  21173. * Specifies if uniform buffers should be used
  21174. */
  21175. private _useUBO;
  21176. /**
  21177. * Stores a reference to the scene
  21178. */
  21179. private _scene;
  21180. /**
  21181. * Stores the fill mode state
  21182. */
  21183. private _fillMode;
  21184. /**
  21185. * Specifies if the depth write state should be cached
  21186. */
  21187. private _cachedDepthWriteState;
  21188. /**
  21189. * Specifies if the depth function state should be cached
  21190. */
  21191. private _cachedDepthFunctionState;
  21192. /**
  21193. * Stores the uniform buffer
  21194. */
  21195. protected _uniformBuffer: UniformBuffer;
  21196. /** @hidden */
  21197. _indexInSceneMaterialArray: number;
  21198. /** @hidden */
  21199. meshMap: Nullable<{
  21200. [id: string]: AbstractMesh | undefined;
  21201. }>;
  21202. /**
  21203. * Creates a material instance
  21204. * @param name defines the name of the material
  21205. * @param scene defines the scene to reference
  21206. * @param doNotAdd specifies if the material should be added to the scene
  21207. */
  21208. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21209. /**
  21210. * Returns a string representation of the current material
  21211. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21212. * @returns a string with material information
  21213. */
  21214. toString(fullDetails?: boolean): string;
  21215. /**
  21216. * Gets the class name of the material
  21217. * @returns a string with the class name of the material
  21218. */
  21219. getClassName(): string;
  21220. /**
  21221. * Specifies if updates for the material been locked
  21222. */
  21223. get isFrozen(): boolean;
  21224. /**
  21225. * Locks updates for the material
  21226. */
  21227. freeze(): void;
  21228. /**
  21229. * Unlocks updates for the material
  21230. */
  21231. unfreeze(): void;
  21232. /**
  21233. * Specifies if the material is ready to be used
  21234. * @param mesh defines the mesh to check
  21235. * @param useInstances specifies if instances should be used
  21236. * @returns a boolean indicating if the material is ready to be used
  21237. */
  21238. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21239. /**
  21240. * Specifies that the submesh is ready to be used
  21241. * @param mesh defines the mesh to check
  21242. * @param subMesh defines which submesh to check
  21243. * @param useInstances specifies that instances should be used
  21244. * @returns a boolean indicating that the submesh is ready or not
  21245. */
  21246. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21247. /**
  21248. * Returns the material effect
  21249. * @returns the effect associated with the material
  21250. */
  21251. getEffect(): Nullable<Effect>;
  21252. /**
  21253. * Returns the current scene
  21254. * @returns a Scene
  21255. */
  21256. getScene(): Scene;
  21257. /**
  21258. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21259. */
  21260. protected _forceAlphaTest: boolean;
  21261. /**
  21262. * The transparency mode of the material.
  21263. */
  21264. protected _transparencyMode: Nullable<number>;
  21265. /**
  21266. * Gets the current transparency mode.
  21267. */
  21268. get transparencyMode(): Nullable<number>;
  21269. /**
  21270. * Sets the transparency mode of the material.
  21271. *
  21272. * | Value | Type | Description |
  21273. * | ----- | ----------------------------------- | ----------- |
  21274. * | 0 | OPAQUE | |
  21275. * | 1 | ALPHATEST | |
  21276. * | 2 | ALPHABLEND | |
  21277. * | 3 | ALPHATESTANDBLEND | |
  21278. *
  21279. */
  21280. set transparencyMode(value: Nullable<number>);
  21281. /**
  21282. * Returns true if alpha blending should be disabled.
  21283. */
  21284. protected get _disableAlphaBlending(): boolean;
  21285. /**
  21286. * Specifies whether or not this material should be rendered in alpha blend mode.
  21287. * @returns a boolean specifying if alpha blending is needed
  21288. */
  21289. needAlphaBlending(): boolean;
  21290. /**
  21291. * Specifies if the mesh will require alpha blending
  21292. * @param mesh defines the mesh to check
  21293. * @returns a boolean specifying if alpha blending is needed for the mesh
  21294. */
  21295. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21296. /**
  21297. * Specifies whether or not this material should be rendered in alpha test mode.
  21298. * @returns a boolean specifying if an alpha test is needed.
  21299. */
  21300. needAlphaTesting(): boolean;
  21301. /**
  21302. * Specifies if material alpha testing should be turned on for the mesh
  21303. * @param mesh defines the mesh to check
  21304. */
  21305. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21306. /**
  21307. * Gets the texture used for the alpha test
  21308. * @returns the texture to use for alpha testing
  21309. */
  21310. getAlphaTestTexture(): Nullable<BaseTexture>;
  21311. /**
  21312. * Marks the material to indicate that it needs to be re-calculated
  21313. */
  21314. markDirty(): void;
  21315. /** @hidden */
  21316. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21317. /**
  21318. * Binds the material to the mesh
  21319. * @param world defines the world transformation matrix
  21320. * @param mesh defines the mesh to bind the material to
  21321. */
  21322. bind(world: Matrix, mesh?: Mesh): void;
  21323. /**
  21324. * Binds the submesh to the material
  21325. * @param world defines the world transformation matrix
  21326. * @param mesh defines the mesh containing the submesh
  21327. * @param subMesh defines the submesh to bind the material to
  21328. */
  21329. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21330. /**
  21331. * Binds the world matrix to the material
  21332. * @param world defines the world transformation matrix
  21333. */
  21334. bindOnlyWorldMatrix(world: Matrix): void;
  21335. /**
  21336. * Binds the scene's uniform buffer to the effect.
  21337. * @param effect defines the effect to bind to the scene uniform buffer
  21338. * @param sceneUbo defines the uniform buffer storing scene data
  21339. */
  21340. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21341. /**
  21342. * Binds the view matrix to the effect
  21343. * @param effect defines the effect to bind the view matrix to
  21344. */
  21345. bindView(effect: Effect): void;
  21346. /**
  21347. * Binds the view projection matrix to the effect
  21348. * @param effect defines the effect to bind the view projection matrix to
  21349. */
  21350. bindViewProjection(effect: Effect): void;
  21351. /**
  21352. * Processes to execute after binding the material to a mesh
  21353. * @param mesh defines the rendered mesh
  21354. */
  21355. protected _afterBind(mesh?: Mesh): void;
  21356. /**
  21357. * Unbinds the material from the mesh
  21358. */
  21359. unbind(): void;
  21360. /**
  21361. * Gets the active textures from the material
  21362. * @returns an array of textures
  21363. */
  21364. getActiveTextures(): BaseTexture[];
  21365. /**
  21366. * Specifies if the material uses a texture
  21367. * @param texture defines the texture to check against the material
  21368. * @returns a boolean specifying if the material uses the texture
  21369. */
  21370. hasTexture(texture: BaseTexture): boolean;
  21371. /**
  21372. * Makes a duplicate of the material, and gives it a new name
  21373. * @param name defines the new name for the duplicated material
  21374. * @returns the cloned material
  21375. */
  21376. clone(name: string): Nullable<Material>;
  21377. /**
  21378. * Gets the meshes bound to the material
  21379. * @returns an array of meshes bound to the material
  21380. */
  21381. getBindedMeshes(): AbstractMesh[];
  21382. /**
  21383. * Force shader compilation
  21384. * @param mesh defines the mesh associated with this material
  21385. * @param onCompiled defines a function to execute once the material is compiled
  21386. * @param options defines the options to configure the compilation
  21387. * @param onError defines a function to execute if the material fails compiling
  21388. */
  21389. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21390. /**
  21391. * Force shader compilation
  21392. * @param mesh defines the mesh that will use this material
  21393. * @param options defines additional options for compiling the shaders
  21394. * @returns a promise that resolves when the compilation completes
  21395. */
  21396. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21397. private static readonly _AllDirtyCallBack;
  21398. private static readonly _ImageProcessingDirtyCallBack;
  21399. private static readonly _TextureDirtyCallBack;
  21400. private static readonly _FresnelDirtyCallBack;
  21401. private static readonly _MiscDirtyCallBack;
  21402. private static readonly _LightsDirtyCallBack;
  21403. private static readonly _AttributeDirtyCallBack;
  21404. private static _FresnelAndMiscDirtyCallBack;
  21405. private static _TextureAndMiscDirtyCallBack;
  21406. private static readonly _DirtyCallbackArray;
  21407. private static readonly _RunDirtyCallBacks;
  21408. /**
  21409. * Marks a define in the material to indicate that it needs to be re-computed
  21410. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21411. */
  21412. markAsDirty(flag: number): void;
  21413. /**
  21414. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21415. * @param func defines a function which checks material defines against the submeshes
  21416. */
  21417. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21418. /**
  21419. * Indicates that we need to re-calculated for all submeshes
  21420. */
  21421. protected _markAllSubMeshesAsAllDirty(): void;
  21422. /**
  21423. * Indicates that image processing needs to be re-calculated for all submeshes
  21424. */
  21425. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21426. /**
  21427. * Indicates that textures need to be re-calculated for all submeshes
  21428. */
  21429. protected _markAllSubMeshesAsTexturesDirty(): void;
  21430. /**
  21431. * Indicates that fresnel needs to be re-calculated for all submeshes
  21432. */
  21433. protected _markAllSubMeshesAsFresnelDirty(): void;
  21434. /**
  21435. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21436. */
  21437. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21438. /**
  21439. * Indicates that lights need to be re-calculated for all submeshes
  21440. */
  21441. protected _markAllSubMeshesAsLightsDirty(): void;
  21442. /**
  21443. * Indicates that attributes need to be re-calculated for all submeshes
  21444. */
  21445. protected _markAllSubMeshesAsAttributesDirty(): void;
  21446. /**
  21447. * Indicates that misc needs to be re-calculated for all submeshes
  21448. */
  21449. protected _markAllSubMeshesAsMiscDirty(): void;
  21450. /**
  21451. * Indicates that textures and misc need to be re-calculated for all submeshes
  21452. */
  21453. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21454. /**
  21455. * Disposes the material
  21456. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21457. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21458. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21459. */
  21460. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21461. /** @hidden */
  21462. private releaseVertexArrayObject;
  21463. /**
  21464. * Serializes this material
  21465. * @returns the serialized material object
  21466. */
  21467. serialize(): any;
  21468. /**
  21469. * Creates a material from parsed material data
  21470. * @param parsedMaterial defines parsed material data
  21471. * @param scene defines the hosting scene
  21472. * @param rootUrl defines the root URL to use to load textures
  21473. * @returns a new material
  21474. */
  21475. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21476. }
  21477. }
  21478. declare module BABYLON {
  21479. /**
  21480. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21481. * separate meshes. This can be use to improve performances.
  21482. * @see http://doc.babylonjs.com/how_to/multi_materials
  21483. */
  21484. export class MultiMaterial extends Material {
  21485. private _subMaterials;
  21486. /**
  21487. * Gets or Sets the list of Materials used within the multi material.
  21488. * They need to be ordered according to the submeshes order in the associated mesh
  21489. */
  21490. get subMaterials(): Nullable<Material>[];
  21491. set subMaterials(value: Nullable<Material>[]);
  21492. /**
  21493. * Function used to align with Node.getChildren()
  21494. * @returns the list of Materials used within the multi material
  21495. */
  21496. getChildren(): Nullable<Material>[];
  21497. /**
  21498. * Instantiates a new Multi Material
  21499. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21500. * separate meshes. This can be use to improve performances.
  21501. * @see http://doc.babylonjs.com/how_to/multi_materials
  21502. * @param name Define the name in the scene
  21503. * @param scene Define the scene the material belongs to
  21504. */
  21505. constructor(name: string, scene: Scene);
  21506. private _hookArray;
  21507. /**
  21508. * Get one of the submaterial by its index in the submaterials array
  21509. * @param index The index to look the sub material at
  21510. * @returns The Material if the index has been defined
  21511. */
  21512. getSubMaterial(index: number): Nullable<Material>;
  21513. /**
  21514. * Get the list of active textures for the whole sub materials list.
  21515. * @returns All the textures that will be used during the rendering
  21516. */
  21517. getActiveTextures(): BaseTexture[];
  21518. /**
  21519. * Gets the current class name of the material e.g. "MultiMaterial"
  21520. * Mainly use in serialization.
  21521. * @returns the class name
  21522. */
  21523. getClassName(): string;
  21524. /**
  21525. * Checks if the material is ready to render the requested sub mesh
  21526. * @param mesh Define the mesh the submesh belongs to
  21527. * @param subMesh Define the sub mesh to look readyness for
  21528. * @param useInstances Define whether or not the material is used with instances
  21529. * @returns true if ready, otherwise false
  21530. */
  21531. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21532. /**
  21533. * Clones the current material and its related sub materials
  21534. * @param name Define the name of the newly cloned material
  21535. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21536. * @returns the cloned material
  21537. */
  21538. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21539. /**
  21540. * Serializes the materials into a JSON representation.
  21541. * @returns the JSON representation
  21542. */
  21543. serialize(): any;
  21544. /**
  21545. * Dispose the material and release its associated resources
  21546. * @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)
  21547. * @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)
  21548. * @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)
  21549. */
  21550. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21551. /**
  21552. * Creates a MultiMaterial from parsed MultiMaterial data.
  21553. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21554. * @param scene defines the hosting scene
  21555. * @returns a new MultiMaterial
  21556. */
  21557. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21558. }
  21559. }
  21560. declare module BABYLON {
  21561. /**
  21562. * Base class for submeshes
  21563. */
  21564. export class BaseSubMesh {
  21565. /** @hidden */
  21566. _materialDefines: Nullable<MaterialDefines>;
  21567. /** @hidden */
  21568. _materialEffect: Nullable<Effect>;
  21569. /**
  21570. * Gets material defines used by the effect associated to the sub mesh
  21571. */
  21572. get materialDefines(): Nullable<MaterialDefines>;
  21573. /**
  21574. * Sets material defines used by the effect associated to the sub mesh
  21575. */
  21576. set materialDefines(defines: Nullable<MaterialDefines>);
  21577. /**
  21578. * Gets associated effect
  21579. */
  21580. get effect(): Nullable<Effect>;
  21581. /**
  21582. * Sets associated effect (effect used to render this submesh)
  21583. * @param effect defines the effect to associate with
  21584. * @param defines defines the set of defines used to compile this effect
  21585. */
  21586. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21587. }
  21588. /**
  21589. * Defines a subdivision inside a mesh
  21590. */
  21591. export class SubMesh extends BaseSubMesh implements ICullable {
  21592. /** the material index to use */
  21593. materialIndex: number;
  21594. /** vertex index start */
  21595. verticesStart: number;
  21596. /** vertices count */
  21597. verticesCount: number;
  21598. /** index start */
  21599. indexStart: number;
  21600. /** indices count */
  21601. indexCount: number;
  21602. /** @hidden */
  21603. _linesIndexCount: number;
  21604. private _mesh;
  21605. private _renderingMesh;
  21606. private _boundingInfo;
  21607. private _linesIndexBuffer;
  21608. /** @hidden */
  21609. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21610. /** @hidden */
  21611. _trianglePlanes: Plane[];
  21612. /** @hidden */
  21613. _lastColliderTransformMatrix: Nullable<Matrix>;
  21614. /** @hidden */
  21615. _renderId: number;
  21616. /** @hidden */
  21617. _alphaIndex: number;
  21618. /** @hidden */
  21619. _distanceToCamera: number;
  21620. /** @hidden */
  21621. _id: number;
  21622. private _currentMaterial;
  21623. /**
  21624. * Add a new submesh to a mesh
  21625. * @param materialIndex defines the material index to use
  21626. * @param verticesStart defines vertex index start
  21627. * @param verticesCount defines vertices count
  21628. * @param indexStart defines index start
  21629. * @param indexCount defines indices count
  21630. * @param mesh defines the parent mesh
  21631. * @param renderingMesh defines an optional rendering mesh
  21632. * @param createBoundingBox defines if bounding box should be created for this submesh
  21633. * @returns the new submesh
  21634. */
  21635. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21636. /**
  21637. * Creates a new submesh
  21638. * @param materialIndex defines the material index to use
  21639. * @param verticesStart defines vertex index start
  21640. * @param verticesCount defines vertices count
  21641. * @param indexStart defines index start
  21642. * @param indexCount defines indices count
  21643. * @param mesh defines the parent mesh
  21644. * @param renderingMesh defines an optional rendering mesh
  21645. * @param createBoundingBox defines if bounding box should be created for this submesh
  21646. */
  21647. constructor(
  21648. /** the material index to use */
  21649. materialIndex: number,
  21650. /** vertex index start */
  21651. verticesStart: number,
  21652. /** vertices count */
  21653. verticesCount: number,
  21654. /** index start */
  21655. indexStart: number,
  21656. /** indices count */
  21657. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21658. /**
  21659. * Returns true if this submesh covers the entire parent mesh
  21660. * @ignorenaming
  21661. */
  21662. get IsGlobal(): boolean;
  21663. /**
  21664. * Returns the submesh BoudingInfo object
  21665. * @returns current bounding info (or mesh's one if the submesh is global)
  21666. */
  21667. getBoundingInfo(): BoundingInfo;
  21668. /**
  21669. * Sets the submesh BoundingInfo
  21670. * @param boundingInfo defines the new bounding info to use
  21671. * @returns the SubMesh
  21672. */
  21673. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21674. /**
  21675. * Returns the mesh of the current submesh
  21676. * @return the parent mesh
  21677. */
  21678. getMesh(): AbstractMesh;
  21679. /**
  21680. * Returns the rendering mesh of the submesh
  21681. * @returns the rendering mesh (could be different from parent mesh)
  21682. */
  21683. getRenderingMesh(): Mesh;
  21684. /**
  21685. * Returns the submesh material
  21686. * @returns null or the current material
  21687. */
  21688. getMaterial(): Nullable<Material>;
  21689. /**
  21690. * Sets a new updated BoundingInfo object to the submesh
  21691. * @param data defines an optional position array to use to determine the bounding info
  21692. * @returns the SubMesh
  21693. */
  21694. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21695. /** @hidden */
  21696. _checkCollision(collider: Collider): boolean;
  21697. /**
  21698. * Updates the submesh BoundingInfo
  21699. * @param world defines the world matrix to use to update the bounding info
  21700. * @returns the submesh
  21701. */
  21702. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21703. /**
  21704. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21705. * @param frustumPlanes defines the frustum planes
  21706. * @returns true if the submesh is intersecting with the frustum
  21707. */
  21708. isInFrustum(frustumPlanes: Plane[]): boolean;
  21709. /**
  21710. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21711. * @param frustumPlanes defines the frustum planes
  21712. * @returns true if the submesh is inside the frustum
  21713. */
  21714. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21715. /**
  21716. * Renders the submesh
  21717. * @param enableAlphaMode defines if alpha needs to be used
  21718. * @returns the submesh
  21719. */
  21720. render(enableAlphaMode: boolean): SubMesh;
  21721. /**
  21722. * @hidden
  21723. */
  21724. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21725. /**
  21726. * Checks if the submesh intersects with a ray
  21727. * @param ray defines the ray to test
  21728. * @returns true is the passed ray intersects the submesh bounding box
  21729. */
  21730. canIntersects(ray: Ray): boolean;
  21731. /**
  21732. * Intersects current submesh with a ray
  21733. * @param ray defines the ray to test
  21734. * @param positions defines mesh's positions array
  21735. * @param indices defines mesh's indices array
  21736. * @param fastCheck defines if only bounding info should be used
  21737. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21738. * @returns intersection info or null if no intersection
  21739. */
  21740. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21741. /** @hidden */
  21742. private _intersectLines;
  21743. /** @hidden */
  21744. private _intersectUnIndexedLines;
  21745. /** @hidden */
  21746. private _intersectTriangles;
  21747. /** @hidden */
  21748. private _intersectUnIndexedTriangles;
  21749. /** @hidden */
  21750. _rebuild(): void;
  21751. /**
  21752. * Creates a new submesh from the passed mesh
  21753. * @param newMesh defines the new hosting mesh
  21754. * @param newRenderingMesh defines an optional rendering mesh
  21755. * @returns the new submesh
  21756. */
  21757. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21758. /**
  21759. * Release associated resources
  21760. */
  21761. dispose(): void;
  21762. /**
  21763. * Gets the class name
  21764. * @returns the string "SubMesh".
  21765. */
  21766. getClassName(): string;
  21767. /**
  21768. * Creates a new submesh from indices data
  21769. * @param materialIndex the index of the main mesh material
  21770. * @param startIndex the index where to start the copy in the mesh indices array
  21771. * @param indexCount the number of indices to copy then from the startIndex
  21772. * @param mesh the main mesh to create the submesh from
  21773. * @param renderingMesh the optional rendering mesh
  21774. * @returns a new submesh
  21775. */
  21776. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21777. }
  21778. }
  21779. declare module BABYLON {
  21780. /**
  21781. * Class used to represent data loading progression
  21782. */
  21783. export class SceneLoaderFlags {
  21784. private static _ForceFullSceneLoadingForIncremental;
  21785. private static _ShowLoadingScreen;
  21786. private static _CleanBoneMatrixWeights;
  21787. private static _loggingLevel;
  21788. /**
  21789. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21790. */
  21791. static get ForceFullSceneLoadingForIncremental(): boolean;
  21792. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21793. /**
  21794. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21795. */
  21796. static get ShowLoadingScreen(): boolean;
  21797. static set ShowLoadingScreen(value: boolean);
  21798. /**
  21799. * Defines the current logging level (while loading the scene)
  21800. * @ignorenaming
  21801. */
  21802. static get loggingLevel(): number;
  21803. static set loggingLevel(value: number);
  21804. /**
  21805. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21806. */
  21807. static get CleanBoneMatrixWeights(): boolean;
  21808. static set CleanBoneMatrixWeights(value: boolean);
  21809. }
  21810. }
  21811. declare module BABYLON {
  21812. /**
  21813. * Class used to store geometry data (vertex buffers + index buffer)
  21814. */
  21815. export class Geometry implements IGetSetVerticesData {
  21816. /**
  21817. * Gets or sets the ID of the geometry
  21818. */
  21819. id: string;
  21820. /**
  21821. * Gets or sets the unique ID of the geometry
  21822. */
  21823. uniqueId: number;
  21824. /**
  21825. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21826. */
  21827. delayLoadState: number;
  21828. /**
  21829. * Gets the file containing the data to load when running in delay load state
  21830. */
  21831. delayLoadingFile: Nullable<string>;
  21832. /**
  21833. * Callback called when the geometry is updated
  21834. */
  21835. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21836. private _scene;
  21837. private _engine;
  21838. private _meshes;
  21839. private _totalVertices;
  21840. /** @hidden */
  21841. _indices: IndicesArray;
  21842. /** @hidden */
  21843. _vertexBuffers: {
  21844. [key: string]: VertexBuffer;
  21845. };
  21846. private _isDisposed;
  21847. private _extend;
  21848. private _boundingBias;
  21849. /** @hidden */
  21850. _delayInfo: Array<string>;
  21851. private _indexBuffer;
  21852. private _indexBufferIsUpdatable;
  21853. /** @hidden */
  21854. _boundingInfo: Nullable<BoundingInfo>;
  21855. /** @hidden */
  21856. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21857. /** @hidden */
  21858. _softwareSkinningFrameId: number;
  21859. private _vertexArrayObjects;
  21860. private _updatable;
  21861. /** @hidden */
  21862. _positions: Nullable<Vector3[]>;
  21863. /**
  21864. * 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
  21865. */
  21866. get boundingBias(): Vector2;
  21867. /**
  21868. * 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
  21869. */
  21870. set boundingBias(value: Vector2);
  21871. /**
  21872. * Static function used to attach a new empty geometry to a mesh
  21873. * @param mesh defines the mesh to attach the geometry to
  21874. * @returns the new Geometry
  21875. */
  21876. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21877. /**
  21878. * Creates a new geometry
  21879. * @param id defines the unique ID
  21880. * @param scene defines the hosting scene
  21881. * @param vertexData defines the VertexData used to get geometry data
  21882. * @param updatable defines if geometry must be updatable (false by default)
  21883. * @param mesh defines the mesh that will be associated with the geometry
  21884. */
  21885. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21886. /**
  21887. * Gets the current extend of the geometry
  21888. */
  21889. get extend(): {
  21890. minimum: Vector3;
  21891. maximum: Vector3;
  21892. };
  21893. /**
  21894. * Gets the hosting scene
  21895. * @returns the hosting Scene
  21896. */
  21897. getScene(): Scene;
  21898. /**
  21899. * Gets the hosting engine
  21900. * @returns the hosting Engine
  21901. */
  21902. getEngine(): Engine;
  21903. /**
  21904. * Defines if the geometry is ready to use
  21905. * @returns true if the geometry is ready to be used
  21906. */
  21907. isReady(): boolean;
  21908. /**
  21909. * Gets a value indicating that the geometry should not be serialized
  21910. */
  21911. get doNotSerialize(): boolean;
  21912. /** @hidden */
  21913. _rebuild(): void;
  21914. /**
  21915. * Affects all geometry data in one call
  21916. * @param vertexData defines the geometry data
  21917. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21918. */
  21919. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21920. /**
  21921. * Set specific vertex data
  21922. * @param kind defines the data kind (Position, normal, etc...)
  21923. * @param data defines the vertex data to use
  21924. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21925. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21926. */
  21927. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21928. /**
  21929. * Removes a specific vertex data
  21930. * @param kind defines the data kind (Position, normal, etc...)
  21931. */
  21932. removeVerticesData(kind: string): void;
  21933. /**
  21934. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21935. * @param buffer defines the vertex buffer to use
  21936. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21937. */
  21938. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21939. /**
  21940. * Update a specific vertex buffer
  21941. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21942. * It will do nothing if the buffer is not updatable
  21943. * @param kind defines the data kind (Position, normal, etc...)
  21944. * @param data defines the data to use
  21945. * @param offset defines the offset in the target buffer where to store the data
  21946. * @param useBytes set to true if the offset is in bytes
  21947. */
  21948. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21949. /**
  21950. * Update a specific vertex buffer
  21951. * This function will create a new buffer if the current one is not updatable
  21952. * @param kind defines the data kind (Position, normal, etc...)
  21953. * @param data defines the data to use
  21954. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21955. */
  21956. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21957. private _updateBoundingInfo;
  21958. /** @hidden */
  21959. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21960. /**
  21961. * Gets total number of vertices
  21962. * @returns the total number of vertices
  21963. */
  21964. getTotalVertices(): number;
  21965. /**
  21966. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21967. * @param kind defines the data kind (Position, normal, etc...)
  21968. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21969. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21970. * @returns a float array containing vertex data
  21971. */
  21972. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21973. /**
  21974. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21975. * @param kind defines the data kind (Position, normal, etc...)
  21976. * @returns true if the vertex buffer with the specified kind is updatable
  21977. */
  21978. isVertexBufferUpdatable(kind: string): boolean;
  21979. /**
  21980. * Gets a specific vertex buffer
  21981. * @param kind defines the data kind (Position, normal, etc...)
  21982. * @returns a VertexBuffer
  21983. */
  21984. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21985. /**
  21986. * Returns all vertex buffers
  21987. * @return an object holding all vertex buffers indexed by kind
  21988. */
  21989. getVertexBuffers(): Nullable<{
  21990. [key: string]: VertexBuffer;
  21991. }>;
  21992. /**
  21993. * Gets a boolean indicating if specific vertex buffer is present
  21994. * @param kind defines the data kind (Position, normal, etc...)
  21995. * @returns true if data is present
  21996. */
  21997. isVerticesDataPresent(kind: string): boolean;
  21998. /**
  21999. * Gets a list of all attached data kinds (Position, normal, etc...)
  22000. * @returns a list of string containing all kinds
  22001. */
  22002. getVerticesDataKinds(): string[];
  22003. /**
  22004. * Update index buffer
  22005. * @param indices defines the indices to store in the index buffer
  22006. * @param offset defines the offset in the target buffer where to store the data
  22007. * @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)
  22008. */
  22009. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22010. /**
  22011. * Creates a new index buffer
  22012. * @param indices defines the indices to store in the index buffer
  22013. * @param totalVertices defines the total number of vertices (could be null)
  22014. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22015. */
  22016. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22017. /**
  22018. * Return the total number of indices
  22019. * @returns the total number of indices
  22020. */
  22021. getTotalIndices(): number;
  22022. /**
  22023. * Gets the index buffer array
  22024. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22025. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22026. * @returns the index buffer array
  22027. */
  22028. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22029. /**
  22030. * Gets the index buffer
  22031. * @return the index buffer
  22032. */
  22033. getIndexBuffer(): Nullable<DataBuffer>;
  22034. /** @hidden */
  22035. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22036. /**
  22037. * Release the associated resources for a specific mesh
  22038. * @param mesh defines the source mesh
  22039. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22040. */
  22041. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22042. /**
  22043. * Apply current geometry to a given mesh
  22044. * @param mesh defines the mesh to apply geometry to
  22045. */
  22046. applyToMesh(mesh: Mesh): void;
  22047. private _updateExtend;
  22048. private _applyToMesh;
  22049. private notifyUpdate;
  22050. /**
  22051. * Load the geometry if it was flagged as delay loaded
  22052. * @param scene defines the hosting scene
  22053. * @param onLoaded defines a callback called when the geometry is loaded
  22054. */
  22055. load(scene: Scene, onLoaded?: () => void): void;
  22056. private _queueLoad;
  22057. /**
  22058. * Invert the geometry to move from a right handed system to a left handed one.
  22059. */
  22060. toLeftHanded(): void;
  22061. /** @hidden */
  22062. _resetPointsArrayCache(): void;
  22063. /** @hidden */
  22064. _generatePointsArray(): boolean;
  22065. /**
  22066. * Gets a value indicating if the geometry is disposed
  22067. * @returns true if the geometry was disposed
  22068. */
  22069. isDisposed(): boolean;
  22070. private _disposeVertexArrayObjects;
  22071. /**
  22072. * Free all associated resources
  22073. */
  22074. dispose(): void;
  22075. /**
  22076. * Clone the current geometry into a new geometry
  22077. * @param id defines the unique ID of the new geometry
  22078. * @returns a new geometry object
  22079. */
  22080. copy(id: string): Geometry;
  22081. /**
  22082. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22083. * @return a JSON representation of the current geometry data (without the vertices data)
  22084. */
  22085. serialize(): any;
  22086. private toNumberArray;
  22087. /**
  22088. * Serialize all vertices data into a JSON oject
  22089. * @returns a JSON representation of the current geometry data
  22090. */
  22091. serializeVerticeData(): any;
  22092. /**
  22093. * Extracts a clone of a mesh geometry
  22094. * @param mesh defines the source mesh
  22095. * @param id defines the unique ID of the new geometry object
  22096. * @returns the new geometry object
  22097. */
  22098. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22099. /**
  22100. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22101. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22102. * Be aware Math.random() could cause collisions, but:
  22103. * "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"
  22104. * @returns a string containing a new GUID
  22105. */
  22106. static RandomId(): string;
  22107. /** @hidden */
  22108. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22109. private static _CleanMatricesWeights;
  22110. /**
  22111. * Create a new geometry from persisted data (Using .babylon file format)
  22112. * @param parsedVertexData defines the persisted data
  22113. * @param scene defines the hosting scene
  22114. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22115. * @returns the new geometry object
  22116. */
  22117. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22118. }
  22119. }
  22120. declare module BABYLON {
  22121. /**
  22122. * Define an interface for all classes that will get and set the data on vertices
  22123. */
  22124. export interface IGetSetVerticesData {
  22125. /**
  22126. * Gets a boolean indicating if specific vertex data is present
  22127. * @param kind defines the vertex data kind to use
  22128. * @returns true is data kind is present
  22129. */
  22130. isVerticesDataPresent(kind: string): boolean;
  22131. /**
  22132. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22133. * @param kind defines the data kind (Position, normal, etc...)
  22134. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22135. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22136. * @returns a float array containing vertex data
  22137. */
  22138. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22139. /**
  22140. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22141. * @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.
  22142. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22143. * @returns the indices array or an empty array if the mesh has no geometry
  22144. */
  22145. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22146. /**
  22147. * Set specific vertex data
  22148. * @param kind defines the data kind (Position, normal, etc...)
  22149. * @param data defines the vertex data to use
  22150. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22151. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22152. */
  22153. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22154. /**
  22155. * Update a specific associated vertex buffer
  22156. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22157. * - VertexBuffer.PositionKind
  22158. * - VertexBuffer.UVKind
  22159. * - VertexBuffer.UV2Kind
  22160. * - VertexBuffer.UV3Kind
  22161. * - VertexBuffer.UV4Kind
  22162. * - VertexBuffer.UV5Kind
  22163. * - VertexBuffer.UV6Kind
  22164. * - VertexBuffer.ColorKind
  22165. * - VertexBuffer.MatricesIndicesKind
  22166. * - VertexBuffer.MatricesIndicesExtraKind
  22167. * - VertexBuffer.MatricesWeightsKind
  22168. * - VertexBuffer.MatricesWeightsExtraKind
  22169. * @param data defines the data source
  22170. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22171. * @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)
  22172. */
  22173. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22174. /**
  22175. * Creates a new index buffer
  22176. * @param indices defines the indices to store in the index buffer
  22177. * @param totalVertices defines the total number of vertices (could be null)
  22178. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22179. */
  22180. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22181. }
  22182. /**
  22183. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22184. */
  22185. export class VertexData {
  22186. /**
  22187. * Mesh side orientation : usually the external or front surface
  22188. */
  22189. static readonly FRONTSIDE: number;
  22190. /**
  22191. * Mesh side orientation : usually the internal or back surface
  22192. */
  22193. static readonly BACKSIDE: number;
  22194. /**
  22195. * Mesh side orientation : both internal and external or front and back surfaces
  22196. */
  22197. static readonly DOUBLESIDE: number;
  22198. /**
  22199. * Mesh side orientation : by default, `FRONTSIDE`
  22200. */
  22201. static readonly DEFAULTSIDE: number;
  22202. /**
  22203. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22204. */
  22205. positions: Nullable<FloatArray>;
  22206. /**
  22207. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22208. */
  22209. normals: Nullable<FloatArray>;
  22210. /**
  22211. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22212. */
  22213. tangents: Nullable<FloatArray>;
  22214. /**
  22215. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22216. */
  22217. uvs: Nullable<FloatArray>;
  22218. /**
  22219. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22220. */
  22221. uvs2: Nullable<FloatArray>;
  22222. /**
  22223. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22224. */
  22225. uvs3: Nullable<FloatArray>;
  22226. /**
  22227. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22228. */
  22229. uvs4: Nullable<FloatArray>;
  22230. /**
  22231. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22232. */
  22233. uvs5: Nullable<FloatArray>;
  22234. /**
  22235. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22236. */
  22237. uvs6: Nullable<FloatArray>;
  22238. /**
  22239. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22240. */
  22241. colors: Nullable<FloatArray>;
  22242. /**
  22243. * 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).
  22244. */
  22245. matricesIndices: Nullable<FloatArray>;
  22246. /**
  22247. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22248. */
  22249. matricesWeights: Nullable<FloatArray>;
  22250. /**
  22251. * An array extending the number of possible indices
  22252. */
  22253. matricesIndicesExtra: Nullable<FloatArray>;
  22254. /**
  22255. * An array extending the number of possible weights when the number of indices is extended
  22256. */
  22257. matricesWeightsExtra: Nullable<FloatArray>;
  22258. /**
  22259. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22260. */
  22261. indices: Nullable<IndicesArray>;
  22262. /**
  22263. * Uses the passed data array to set the set the values for the specified kind of data
  22264. * @param data a linear array of floating numbers
  22265. * @param kind the type of data that is being set, eg positions, colors etc
  22266. */
  22267. set(data: FloatArray, kind: string): void;
  22268. /**
  22269. * Associates the vertexData to the passed Mesh.
  22270. * Sets it as updatable or not (default `false`)
  22271. * @param mesh the mesh the vertexData is applied to
  22272. * @param updatable when used and having the value true allows new data to update the vertexData
  22273. * @returns the VertexData
  22274. */
  22275. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22276. /**
  22277. * Associates the vertexData to the passed Geometry.
  22278. * Sets it as updatable or not (default `false`)
  22279. * @param geometry the geometry the vertexData is applied to
  22280. * @param updatable when used and having the value true allows new data to update the vertexData
  22281. * @returns VertexData
  22282. */
  22283. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22284. /**
  22285. * Updates the associated mesh
  22286. * @param mesh the mesh to be updated
  22287. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22288. * @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
  22289. * @returns VertexData
  22290. */
  22291. updateMesh(mesh: Mesh): VertexData;
  22292. /**
  22293. * Updates the associated geometry
  22294. * @param geometry the geometry to be updated
  22295. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22296. * @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
  22297. * @returns VertexData.
  22298. */
  22299. updateGeometry(geometry: Geometry): VertexData;
  22300. private _applyTo;
  22301. private _update;
  22302. /**
  22303. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22304. * @param matrix the transforming matrix
  22305. * @returns the VertexData
  22306. */
  22307. transform(matrix: Matrix): VertexData;
  22308. /**
  22309. * Merges the passed VertexData into the current one
  22310. * @param other the VertexData to be merged into the current one
  22311. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22312. * @returns the modified VertexData
  22313. */
  22314. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22315. private _mergeElement;
  22316. private _validate;
  22317. /**
  22318. * Serializes the VertexData
  22319. * @returns a serialized object
  22320. */
  22321. serialize(): any;
  22322. /**
  22323. * Extracts the vertexData from a mesh
  22324. * @param mesh the mesh from which to extract the VertexData
  22325. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22326. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22327. * @returns the object VertexData associated to the passed mesh
  22328. */
  22329. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22330. /**
  22331. * Extracts the vertexData from the geometry
  22332. * @param geometry the geometry from which to extract the VertexData
  22333. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22334. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22335. * @returns the object VertexData associated to the passed mesh
  22336. */
  22337. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22338. private static _ExtractFrom;
  22339. /**
  22340. * Creates the VertexData for a Ribbon
  22341. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22342. * * pathArray array of paths, each of which an array of successive Vector3
  22343. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22344. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22345. * * 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
  22346. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22347. * * 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)
  22348. * * 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)
  22349. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22350. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22351. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22352. * @returns the VertexData of the ribbon
  22353. */
  22354. static CreateRibbon(options: {
  22355. pathArray: Vector3[][];
  22356. closeArray?: boolean;
  22357. closePath?: boolean;
  22358. offset?: number;
  22359. sideOrientation?: number;
  22360. frontUVs?: Vector4;
  22361. backUVs?: Vector4;
  22362. invertUV?: boolean;
  22363. uvs?: Vector2[];
  22364. colors?: Color4[];
  22365. }): VertexData;
  22366. /**
  22367. * Creates the VertexData for a box
  22368. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22369. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22370. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22371. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22372. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22373. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22374. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22375. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22376. * * 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)
  22377. * * 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)
  22378. * @returns the VertexData of the box
  22379. */
  22380. static CreateBox(options: {
  22381. size?: number;
  22382. width?: number;
  22383. height?: number;
  22384. depth?: number;
  22385. faceUV?: Vector4[];
  22386. faceColors?: Color4[];
  22387. sideOrientation?: number;
  22388. frontUVs?: Vector4;
  22389. backUVs?: Vector4;
  22390. }): VertexData;
  22391. /**
  22392. * Creates the VertexData for a tiled box
  22393. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22394. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22395. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22396. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22397. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22398. * @returns the VertexData of the box
  22399. */
  22400. static CreateTiledBox(options: {
  22401. pattern?: number;
  22402. width?: number;
  22403. height?: number;
  22404. depth?: number;
  22405. tileSize?: number;
  22406. tileWidth?: number;
  22407. tileHeight?: number;
  22408. alignHorizontal?: number;
  22409. alignVertical?: number;
  22410. faceUV?: Vector4[];
  22411. faceColors?: Color4[];
  22412. sideOrientation?: number;
  22413. }): VertexData;
  22414. /**
  22415. * Creates the VertexData for a tiled plane
  22416. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22417. * * pattern a limited pattern arrangement depending on the number
  22418. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22419. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22420. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22421. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22422. * * 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)
  22423. * * 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)
  22424. * @returns the VertexData of the tiled plane
  22425. */
  22426. static CreateTiledPlane(options: {
  22427. pattern?: number;
  22428. tileSize?: number;
  22429. tileWidth?: number;
  22430. tileHeight?: number;
  22431. size?: number;
  22432. width?: number;
  22433. height?: number;
  22434. alignHorizontal?: number;
  22435. alignVertical?: number;
  22436. sideOrientation?: number;
  22437. frontUVs?: Vector4;
  22438. backUVs?: Vector4;
  22439. }): VertexData;
  22440. /**
  22441. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22442. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22443. * * segments sets the number of horizontal strips optional, default 32
  22444. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22445. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22446. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22447. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22448. * * 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
  22449. * * 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
  22450. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22451. * * 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)
  22452. * * 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)
  22453. * @returns the VertexData of the ellipsoid
  22454. */
  22455. static CreateSphere(options: {
  22456. segments?: number;
  22457. diameter?: number;
  22458. diameterX?: number;
  22459. diameterY?: number;
  22460. diameterZ?: number;
  22461. arc?: number;
  22462. slice?: number;
  22463. sideOrientation?: number;
  22464. frontUVs?: Vector4;
  22465. backUVs?: Vector4;
  22466. }): VertexData;
  22467. /**
  22468. * Creates the VertexData for a cylinder, cone or prism
  22469. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22470. * * height sets the height (y direction) of the cylinder, optional, default 2
  22471. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22472. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22473. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22474. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22475. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22476. * * 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
  22477. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22478. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22479. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22480. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22482. * * 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)
  22483. * * 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)
  22484. * @returns the VertexData of the cylinder, cone or prism
  22485. */
  22486. static CreateCylinder(options: {
  22487. height?: number;
  22488. diameterTop?: number;
  22489. diameterBottom?: number;
  22490. diameter?: number;
  22491. tessellation?: number;
  22492. subdivisions?: number;
  22493. arc?: number;
  22494. faceColors?: Color4[];
  22495. faceUV?: Vector4[];
  22496. hasRings?: boolean;
  22497. enclose?: boolean;
  22498. sideOrientation?: number;
  22499. frontUVs?: Vector4;
  22500. backUVs?: Vector4;
  22501. }): VertexData;
  22502. /**
  22503. * Creates the VertexData for a torus
  22504. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22505. * * diameter the diameter of the torus, optional default 1
  22506. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22507. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22508. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22509. * * 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)
  22510. * * 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)
  22511. * @returns the VertexData of the torus
  22512. */
  22513. static CreateTorus(options: {
  22514. diameter?: number;
  22515. thickness?: number;
  22516. tessellation?: number;
  22517. sideOrientation?: number;
  22518. frontUVs?: Vector4;
  22519. backUVs?: Vector4;
  22520. }): VertexData;
  22521. /**
  22522. * Creates the VertexData of the LineSystem
  22523. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22524. * - lines an array of lines, each line being an array of successive Vector3
  22525. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22526. * @returns the VertexData of the LineSystem
  22527. */
  22528. static CreateLineSystem(options: {
  22529. lines: Vector3[][];
  22530. colors?: Nullable<Color4[][]>;
  22531. }): VertexData;
  22532. /**
  22533. * Create the VertexData for a DashedLines
  22534. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22535. * - points an array successive Vector3
  22536. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22537. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22538. * - dashNb the intended total number of dashes, optional, default 200
  22539. * @returns the VertexData for the DashedLines
  22540. */
  22541. static CreateDashedLines(options: {
  22542. points: Vector3[];
  22543. dashSize?: number;
  22544. gapSize?: number;
  22545. dashNb?: number;
  22546. }): VertexData;
  22547. /**
  22548. * Creates the VertexData for a Ground
  22549. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22550. * - width the width (x direction) of the ground, optional, default 1
  22551. * - height the height (z direction) of the ground, optional, default 1
  22552. * - subdivisions the number of subdivisions per side, optional, default 1
  22553. * @returns the VertexData of the Ground
  22554. */
  22555. static CreateGround(options: {
  22556. width?: number;
  22557. height?: number;
  22558. subdivisions?: number;
  22559. subdivisionsX?: number;
  22560. subdivisionsY?: number;
  22561. }): VertexData;
  22562. /**
  22563. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22564. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22565. * * xmin the ground minimum X coordinate, optional, default -1
  22566. * * zmin the ground minimum Z coordinate, optional, default -1
  22567. * * xmax the ground maximum X coordinate, optional, default 1
  22568. * * zmax the ground maximum Z coordinate, optional, default 1
  22569. * * 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}
  22570. * * 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}
  22571. * @returns the VertexData of the TiledGround
  22572. */
  22573. static CreateTiledGround(options: {
  22574. xmin: number;
  22575. zmin: number;
  22576. xmax: number;
  22577. zmax: number;
  22578. subdivisions?: {
  22579. w: number;
  22580. h: number;
  22581. };
  22582. precision?: {
  22583. w: number;
  22584. h: number;
  22585. };
  22586. }): VertexData;
  22587. /**
  22588. * Creates the VertexData of the Ground designed from a heightmap
  22589. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22590. * * width the width (x direction) of the ground
  22591. * * height the height (z direction) of the ground
  22592. * * subdivisions the number of subdivisions per side
  22593. * * minHeight the minimum altitude on the ground, optional, default 0
  22594. * * maxHeight the maximum altitude on the ground, optional default 1
  22595. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22596. * * buffer the array holding the image color data
  22597. * * bufferWidth the width of image
  22598. * * bufferHeight the height of image
  22599. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22600. * @returns the VertexData of the Ground designed from a heightmap
  22601. */
  22602. static CreateGroundFromHeightMap(options: {
  22603. width: number;
  22604. height: number;
  22605. subdivisions: number;
  22606. minHeight: number;
  22607. maxHeight: number;
  22608. colorFilter: Color3;
  22609. buffer: Uint8Array;
  22610. bufferWidth: number;
  22611. bufferHeight: number;
  22612. alphaFilter: number;
  22613. }): VertexData;
  22614. /**
  22615. * Creates the VertexData for a Plane
  22616. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22617. * * size sets the width and height of the plane to the value of size, optional default 1
  22618. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22619. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22621. * * 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)
  22622. * * 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)
  22623. * @returns the VertexData of the box
  22624. */
  22625. static CreatePlane(options: {
  22626. size?: number;
  22627. width?: number;
  22628. height?: number;
  22629. sideOrientation?: number;
  22630. frontUVs?: Vector4;
  22631. backUVs?: Vector4;
  22632. }): VertexData;
  22633. /**
  22634. * Creates the VertexData of the Disc or regular Polygon
  22635. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22636. * * radius the radius of the disc, optional default 0.5
  22637. * * tessellation the number of polygon sides, optional, default 64
  22638. * * 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
  22639. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22640. * * 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)
  22641. * * 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)
  22642. * @returns the VertexData of the box
  22643. */
  22644. static CreateDisc(options: {
  22645. radius?: number;
  22646. tessellation?: number;
  22647. arc?: number;
  22648. sideOrientation?: number;
  22649. frontUVs?: Vector4;
  22650. backUVs?: Vector4;
  22651. }): VertexData;
  22652. /**
  22653. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22654. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22655. * @param polygon a mesh built from polygonTriangulation.build()
  22656. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22657. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22658. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22659. * @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)
  22660. * @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)
  22661. * @returns the VertexData of the Polygon
  22662. */
  22663. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22664. /**
  22665. * Creates the VertexData of the IcoSphere
  22666. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22667. * * radius the radius of the IcoSphere, optional default 1
  22668. * * radiusX allows stretching in the x direction, optional, default radius
  22669. * * radiusY allows stretching in the y direction, optional, default radius
  22670. * * radiusZ allows stretching in the z direction, optional, default radius
  22671. * * flat when true creates a flat shaded mesh, optional, default true
  22672. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22673. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22674. * * 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)
  22675. * * 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)
  22676. * @returns the VertexData of the IcoSphere
  22677. */
  22678. static CreateIcoSphere(options: {
  22679. radius?: number;
  22680. radiusX?: number;
  22681. radiusY?: number;
  22682. radiusZ?: number;
  22683. flat?: boolean;
  22684. subdivisions?: number;
  22685. sideOrientation?: number;
  22686. frontUVs?: Vector4;
  22687. backUVs?: Vector4;
  22688. }): VertexData;
  22689. /**
  22690. * Creates the VertexData for a Polyhedron
  22691. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22692. * * type provided types are:
  22693. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22694. * * 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)
  22695. * * size the size of the IcoSphere, optional default 1
  22696. * * sizeX allows stretching in the x direction, optional, default size
  22697. * * sizeY allows stretching in the y direction, optional, default size
  22698. * * sizeZ allows stretching in the z direction, optional, default size
  22699. * * 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
  22700. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22701. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22702. * * flat when true creates a flat shaded mesh, optional, default true
  22703. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22705. * * 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)
  22706. * * 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)
  22707. * @returns the VertexData of the Polyhedron
  22708. */
  22709. static CreatePolyhedron(options: {
  22710. type?: number;
  22711. size?: number;
  22712. sizeX?: number;
  22713. sizeY?: number;
  22714. sizeZ?: number;
  22715. custom?: any;
  22716. faceUV?: Vector4[];
  22717. faceColors?: Color4[];
  22718. flat?: boolean;
  22719. sideOrientation?: number;
  22720. frontUVs?: Vector4;
  22721. backUVs?: Vector4;
  22722. }): VertexData;
  22723. /**
  22724. * Creates the VertexData for a TorusKnot
  22725. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22726. * * radius the radius of the torus knot, optional, default 2
  22727. * * tube the thickness of the tube, optional, default 0.5
  22728. * * radialSegments the number of sides on each tube segments, optional, default 32
  22729. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22730. * * p the number of windings around the z axis, optional, default 2
  22731. * * q the number of windings around the x axis, optional, default 3
  22732. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22733. * * 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)
  22734. * * 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)
  22735. * @returns the VertexData of the Torus Knot
  22736. */
  22737. static CreateTorusKnot(options: {
  22738. radius?: number;
  22739. tube?: number;
  22740. radialSegments?: number;
  22741. tubularSegments?: number;
  22742. p?: number;
  22743. q?: number;
  22744. sideOrientation?: number;
  22745. frontUVs?: Vector4;
  22746. backUVs?: Vector4;
  22747. }): VertexData;
  22748. /**
  22749. * Compute normals for given positions and indices
  22750. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22751. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22752. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22753. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22754. * * facetNormals : optional array of facet normals (vector3)
  22755. * * facetPositions : optional array of facet positions (vector3)
  22756. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22757. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22758. * * bInfo : optional bounding info, required for facetPartitioning computation
  22759. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22760. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22761. * * useRightHandedSystem: optional boolean to for right handed system computation
  22762. * * depthSort : optional boolean to enable the facet depth sort computation
  22763. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22764. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22765. */
  22766. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22767. facetNormals?: any;
  22768. facetPositions?: any;
  22769. facetPartitioning?: any;
  22770. ratio?: number;
  22771. bInfo?: any;
  22772. bbSize?: Vector3;
  22773. subDiv?: any;
  22774. useRightHandedSystem?: boolean;
  22775. depthSort?: boolean;
  22776. distanceTo?: Vector3;
  22777. depthSortedFacets?: any;
  22778. }): void;
  22779. /** @hidden */
  22780. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22781. /**
  22782. * Applies VertexData created from the imported parameters to the geometry
  22783. * @param parsedVertexData the parsed data from an imported file
  22784. * @param geometry the geometry to apply the VertexData to
  22785. */
  22786. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22787. }
  22788. }
  22789. declare module BABYLON {
  22790. /**
  22791. * Defines a target to use with MorphTargetManager
  22792. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22793. */
  22794. export class MorphTarget implements IAnimatable {
  22795. /** defines the name of the target */
  22796. name: string;
  22797. /**
  22798. * Gets or sets the list of animations
  22799. */
  22800. animations: Animation[];
  22801. private _scene;
  22802. private _positions;
  22803. private _normals;
  22804. private _tangents;
  22805. private _uvs;
  22806. private _influence;
  22807. private _uniqueId;
  22808. /**
  22809. * Observable raised when the influence changes
  22810. */
  22811. onInfluenceChanged: Observable<boolean>;
  22812. /** @hidden */
  22813. _onDataLayoutChanged: Observable<void>;
  22814. /**
  22815. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22816. */
  22817. get influence(): number;
  22818. set influence(influence: number);
  22819. /**
  22820. * Gets or sets the id of the morph Target
  22821. */
  22822. id: string;
  22823. private _animationPropertiesOverride;
  22824. /**
  22825. * Gets or sets the animation properties override
  22826. */
  22827. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22828. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22829. /**
  22830. * Creates a new MorphTarget
  22831. * @param name defines the name of the target
  22832. * @param influence defines the influence to use
  22833. * @param scene defines the scene the morphtarget belongs to
  22834. */
  22835. constructor(
  22836. /** defines the name of the target */
  22837. name: string, influence?: number, scene?: Nullable<Scene>);
  22838. /**
  22839. * Gets the unique ID of this manager
  22840. */
  22841. get uniqueId(): number;
  22842. /**
  22843. * Gets a boolean defining if the target contains position data
  22844. */
  22845. get hasPositions(): boolean;
  22846. /**
  22847. * Gets a boolean defining if the target contains normal data
  22848. */
  22849. get hasNormals(): boolean;
  22850. /**
  22851. * Gets a boolean defining if the target contains tangent data
  22852. */
  22853. get hasTangents(): boolean;
  22854. /**
  22855. * Gets a boolean defining if the target contains texture coordinates data
  22856. */
  22857. get hasUVs(): boolean;
  22858. /**
  22859. * Affects position data to this target
  22860. * @param data defines the position data to use
  22861. */
  22862. setPositions(data: Nullable<FloatArray>): void;
  22863. /**
  22864. * Gets the position data stored in this target
  22865. * @returns a FloatArray containing the position data (or null if not present)
  22866. */
  22867. getPositions(): Nullable<FloatArray>;
  22868. /**
  22869. * Affects normal data to this target
  22870. * @param data defines the normal data to use
  22871. */
  22872. setNormals(data: Nullable<FloatArray>): void;
  22873. /**
  22874. * Gets the normal data stored in this target
  22875. * @returns a FloatArray containing the normal data (or null if not present)
  22876. */
  22877. getNormals(): Nullable<FloatArray>;
  22878. /**
  22879. * Affects tangent data to this target
  22880. * @param data defines the tangent data to use
  22881. */
  22882. setTangents(data: Nullable<FloatArray>): void;
  22883. /**
  22884. * Gets the tangent data stored in this target
  22885. * @returns a FloatArray containing the tangent data (or null if not present)
  22886. */
  22887. getTangents(): Nullable<FloatArray>;
  22888. /**
  22889. * Affects texture coordinates data to this target
  22890. * @param data defines the texture coordinates data to use
  22891. */
  22892. setUVs(data: Nullable<FloatArray>): void;
  22893. /**
  22894. * Gets the texture coordinates data stored in this target
  22895. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22896. */
  22897. getUVs(): Nullable<FloatArray>;
  22898. /**
  22899. * Clone the current target
  22900. * @returns a new MorphTarget
  22901. */
  22902. clone(): MorphTarget;
  22903. /**
  22904. * Serializes the current target into a Serialization object
  22905. * @returns the serialized object
  22906. */
  22907. serialize(): any;
  22908. /**
  22909. * Returns the string "MorphTarget"
  22910. * @returns "MorphTarget"
  22911. */
  22912. getClassName(): string;
  22913. /**
  22914. * Creates a new target from serialized data
  22915. * @param serializationObject defines the serialized data to use
  22916. * @returns a new MorphTarget
  22917. */
  22918. static Parse(serializationObject: any): MorphTarget;
  22919. /**
  22920. * Creates a MorphTarget from mesh data
  22921. * @param mesh defines the source mesh
  22922. * @param name defines the name to use for the new target
  22923. * @param influence defines the influence to attach to the target
  22924. * @returns a new MorphTarget
  22925. */
  22926. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22927. }
  22928. }
  22929. declare module BABYLON {
  22930. /**
  22931. * This class is used to deform meshes using morphing between different targets
  22932. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22933. */
  22934. export class MorphTargetManager {
  22935. private _targets;
  22936. private _targetInfluenceChangedObservers;
  22937. private _targetDataLayoutChangedObservers;
  22938. private _activeTargets;
  22939. private _scene;
  22940. private _influences;
  22941. private _supportsNormals;
  22942. private _supportsTangents;
  22943. private _supportsUVs;
  22944. private _vertexCount;
  22945. private _uniqueId;
  22946. private _tempInfluences;
  22947. /**
  22948. * Gets or sets a boolean indicating if normals must be morphed
  22949. */
  22950. enableNormalMorphing: boolean;
  22951. /**
  22952. * Gets or sets a boolean indicating if tangents must be morphed
  22953. */
  22954. enableTangentMorphing: boolean;
  22955. /**
  22956. * Gets or sets a boolean indicating if UV must be morphed
  22957. */
  22958. enableUVMorphing: boolean;
  22959. /**
  22960. * Creates a new MorphTargetManager
  22961. * @param scene defines the current scene
  22962. */
  22963. constructor(scene?: Nullable<Scene>);
  22964. /**
  22965. * Gets the unique ID of this manager
  22966. */
  22967. get uniqueId(): number;
  22968. /**
  22969. * Gets the number of vertices handled by this manager
  22970. */
  22971. get vertexCount(): number;
  22972. /**
  22973. * Gets a boolean indicating if this manager supports morphing of normals
  22974. */
  22975. get supportsNormals(): boolean;
  22976. /**
  22977. * Gets a boolean indicating if this manager supports morphing of tangents
  22978. */
  22979. get supportsTangents(): boolean;
  22980. /**
  22981. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22982. */
  22983. get supportsUVs(): boolean;
  22984. /**
  22985. * Gets the number of targets stored in this manager
  22986. */
  22987. get numTargets(): number;
  22988. /**
  22989. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22990. */
  22991. get numInfluencers(): number;
  22992. /**
  22993. * Gets the list of influences (one per target)
  22994. */
  22995. get influences(): Float32Array;
  22996. /**
  22997. * Gets the active target at specified index. An active target is a target with an influence > 0
  22998. * @param index defines the index to check
  22999. * @returns the requested target
  23000. */
  23001. getActiveTarget(index: number): MorphTarget;
  23002. /**
  23003. * Gets the target at specified index
  23004. * @param index defines the index to check
  23005. * @returns the requested target
  23006. */
  23007. getTarget(index: number): MorphTarget;
  23008. /**
  23009. * Add a new target to this manager
  23010. * @param target defines the target to add
  23011. */
  23012. addTarget(target: MorphTarget): void;
  23013. /**
  23014. * Removes a target from the manager
  23015. * @param target defines the target to remove
  23016. */
  23017. removeTarget(target: MorphTarget): void;
  23018. /**
  23019. * Clone the current manager
  23020. * @returns a new MorphTargetManager
  23021. */
  23022. clone(): MorphTargetManager;
  23023. /**
  23024. * Serializes the current manager into a Serialization object
  23025. * @returns the serialized object
  23026. */
  23027. serialize(): any;
  23028. private _syncActiveTargets;
  23029. /**
  23030. * Syncrhonize the targets with all the meshes using this morph target manager
  23031. */
  23032. synchronize(): void;
  23033. /**
  23034. * Creates a new MorphTargetManager from serialized data
  23035. * @param serializationObject defines the serialized data
  23036. * @param scene defines the hosting scene
  23037. * @returns the new MorphTargetManager
  23038. */
  23039. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23040. }
  23041. }
  23042. declare module BABYLON {
  23043. /**
  23044. * Class used to represent a specific level of detail of a mesh
  23045. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23046. */
  23047. export class MeshLODLevel {
  23048. /** Defines the distance where this level should start being displayed */
  23049. distance: number;
  23050. /** Defines the mesh to use to render this level */
  23051. mesh: Nullable<Mesh>;
  23052. /**
  23053. * Creates a new LOD level
  23054. * @param distance defines the distance where this level should star being displayed
  23055. * @param mesh defines the mesh to use to render this level
  23056. */
  23057. constructor(
  23058. /** Defines the distance where this level should start being displayed */
  23059. distance: number,
  23060. /** Defines the mesh to use to render this level */
  23061. mesh: Nullable<Mesh>);
  23062. }
  23063. }
  23064. declare module BABYLON {
  23065. /**
  23066. * Mesh representing the gorund
  23067. */
  23068. export class GroundMesh extends Mesh {
  23069. /** If octree should be generated */
  23070. generateOctree: boolean;
  23071. private _heightQuads;
  23072. /** @hidden */
  23073. _subdivisionsX: number;
  23074. /** @hidden */
  23075. _subdivisionsY: number;
  23076. /** @hidden */
  23077. _width: number;
  23078. /** @hidden */
  23079. _height: number;
  23080. /** @hidden */
  23081. _minX: number;
  23082. /** @hidden */
  23083. _maxX: number;
  23084. /** @hidden */
  23085. _minZ: number;
  23086. /** @hidden */
  23087. _maxZ: number;
  23088. constructor(name: string, scene: Scene);
  23089. /**
  23090. * "GroundMesh"
  23091. * @returns "GroundMesh"
  23092. */
  23093. getClassName(): string;
  23094. /**
  23095. * The minimum of x and y subdivisions
  23096. */
  23097. get subdivisions(): number;
  23098. /**
  23099. * X subdivisions
  23100. */
  23101. get subdivisionsX(): number;
  23102. /**
  23103. * Y subdivisions
  23104. */
  23105. get subdivisionsY(): number;
  23106. /**
  23107. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23108. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23109. * @param chunksCount the number of subdivisions for x and y
  23110. * @param octreeBlocksSize (Default: 32)
  23111. */
  23112. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23113. /**
  23114. * Returns a height (y) value in the Worl system :
  23115. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23116. * @param x x coordinate
  23117. * @param z z coordinate
  23118. * @returns the ground y position if (x, z) are outside the ground surface.
  23119. */
  23120. getHeightAtCoordinates(x: number, z: number): number;
  23121. /**
  23122. * Returns a normalized vector (Vector3) orthogonal to the ground
  23123. * at the ground coordinates (x, z) expressed in the World system.
  23124. * @param x x coordinate
  23125. * @param z z coordinate
  23126. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23127. */
  23128. getNormalAtCoordinates(x: number, z: number): Vector3;
  23129. /**
  23130. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23131. * at the ground coordinates (x, z) expressed in the World system.
  23132. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23133. * @param x x coordinate
  23134. * @param z z coordinate
  23135. * @param ref vector to store the result
  23136. * @returns the GroundMesh.
  23137. */
  23138. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23139. /**
  23140. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23141. * if the ground has been updated.
  23142. * This can be used in the render loop.
  23143. * @returns the GroundMesh.
  23144. */
  23145. updateCoordinateHeights(): GroundMesh;
  23146. private _getFacetAt;
  23147. private _initHeightQuads;
  23148. private _computeHeightQuads;
  23149. /**
  23150. * Serializes this ground mesh
  23151. * @param serializationObject object to write serialization to
  23152. */
  23153. serialize(serializationObject: any): void;
  23154. /**
  23155. * Parses a serialized ground mesh
  23156. * @param parsedMesh the serialized mesh
  23157. * @param scene the scene to create the ground mesh in
  23158. * @returns the created ground mesh
  23159. */
  23160. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23161. }
  23162. }
  23163. declare module BABYLON {
  23164. /**
  23165. * Interface for Physics-Joint data
  23166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23167. */
  23168. export interface PhysicsJointData {
  23169. /**
  23170. * The main pivot of the joint
  23171. */
  23172. mainPivot?: Vector3;
  23173. /**
  23174. * The connected pivot of the joint
  23175. */
  23176. connectedPivot?: Vector3;
  23177. /**
  23178. * The main axis of the joint
  23179. */
  23180. mainAxis?: Vector3;
  23181. /**
  23182. * The connected axis of the joint
  23183. */
  23184. connectedAxis?: Vector3;
  23185. /**
  23186. * The collision of the joint
  23187. */
  23188. collision?: boolean;
  23189. /**
  23190. * Native Oimo/Cannon/Energy data
  23191. */
  23192. nativeParams?: any;
  23193. }
  23194. /**
  23195. * This is a holder class for the physics joint created by the physics plugin
  23196. * It holds a set of functions to control the underlying joint
  23197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23198. */
  23199. export class PhysicsJoint {
  23200. /**
  23201. * The type of the physics joint
  23202. */
  23203. type: number;
  23204. /**
  23205. * The data for the physics joint
  23206. */
  23207. jointData: PhysicsJointData;
  23208. private _physicsJoint;
  23209. protected _physicsPlugin: IPhysicsEnginePlugin;
  23210. /**
  23211. * Initializes the physics joint
  23212. * @param type The type of the physics joint
  23213. * @param jointData The data for the physics joint
  23214. */
  23215. constructor(
  23216. /**
  23217. * The type of the physics joint
  23218. */
  23219. type: number,
  23220. /**
  23221. * The data for the physics joint
  23222. */
  23223. jointData: PhysicsJointData);
  23224. /**
  23225. * Gets the physics joint
  23226. */
  23227. get physicsJoint(): any;
  23228. /**
  23229. * Sets the physics joint
  23230. */
  23231. set physicsJoint(newJoint: any);
  23232. /**
  23233. * Sets the physics plugin
  23234. */
  23235. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23236. /**
  23237. * Execute a function that is physics-plugin specific.
  23238. * @param {Function} func the function that will be executed.
  23239. * It accepts two parameters: the physics world and the physics joint
  23240. */
  23241. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23242. /**
  23243. * Distance-Joint type
  23244. */
  23245. static DistanceJoint: number;
  23246. /**
  23247. * Hinge-Joint type
  23248. */
  23249. static HingeJoint: number;
  23250. /**
  23251. * Ball-and-Socket joint type
  23252. */
  23253. static BallAndSocketJoint: number;
  23254. /**
  23255. * Wheel-Joint type
  23256. */
  23257. static WheelJoint: number;
  23258. /**
  23259. * Slider-Joint type
  23260. */
  23261. static SliderJoint: number;
  23262. /**
  23263. * Prismatic-Joint type
  23264. */
  23265. static PrismaticJoint: number;
  23266. /**
  23267. * Universal-Joint type
  23268. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23269. */
  23270. static UniversalJoint: number;
  23271. /**
  23272. * Hinge-Joint 2 type
  23273. */
  23274. static Hinge2Joint: number;
  23275. /**
  23276. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23277. */
  23278. static PointToPointJoint: number;
  23279. /**
  23280. * Spring-Joint type
  23281. */
  23282. static SpringJoint: number;
  23283. /**
  23284. * Lock-Joint type
  23285. */
  23286. static LockJoint: number;
  23287. }
  23288. /**
  23289. * A class representing a physics distance joint
  23290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23291. */
  23292. export class DistanceJoint extends PhysicsJoint {
  23293. /**
  23294. *
  23295. * @param jointData The data for the Distance-Joint
  23296. */
  23297. constructor(jointData: DistanceJointData);
  23298. /**
  23299. * Update the predefined distance.
  23300. * @param maxDistance The maximum preferred distance
  23301. * @param minDistance The minimum preferred distance
  23302. */
  23303. updateDistance(maxDistance: number, minDistance?: number): void;
  23304. }
  23305. /**
  23306. * Represents a Motor-Enabled Joint
  23307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23308. */
  23309. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23310. /**
  23311. * Initializes the Motor-Enabled Joint
  23312. * @param type The type of the joint
  23313. * @param jointData The physica joint data for the joint
  23314. */
  23315. constructor(type: number, jointData: PhysicsJointData);
  23316. /**
  23317. * Set the motor values.
  23318. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23319. * @param force the force to apply
  23320. * @param maxForce max force for this motor.
  23321. */
  23322. setMotor(force?: number, maxForce?: number): void;
  23323. /**
  23324. * Set the motor's limits.
  23325. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23326. * @param upperLimit The upper limit of the motor
  23327. * @param lowerLimit The lower limit of the motor
  23328. */
  23329. setLimit(upperLimit: number, lowerLimit?: number): void;
  23330. }
  23331. /**
  23332. * This class represents a single physics Hinge-Joint
  23333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23334. */
  23335. export class HingeJoint extends MotorEnabledJoint {
  23336. /**
  23337. * Initializes the Hinge-Joint
  23338. * @param jointData The joint data for the Hinge-Joint
  23339. */
  23340. constructor(jointData: PhysicsJointData);
  23341. /**
  23342. * Set the motor values.
  23343. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23344. * @param {number} force the force to apply
  23345. * @param {number} maxForce max force for this motor.
  23346. */
  23347. setMotor(force?: number, maxForce?: number): void;
  23348. /**
  23349. * Set the motor's limits.
  23350. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23351. * @param upperLimit The upper limit of the motor
  23352. * @param lowerLimit The lower limit of the motor
  23353. */
  23354. setLimit(upperLimit: number, lowerLimit?: number): void;
  23355. }
  23356. /**
  23357. * This class represents a dual hinge physics joint (same as wheel joint)
  23358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23359. */
  23360. export class Hinge2Joint extends MotorEnabledJoint {
  23361. /**
  23362. * Initializes the Hinge2-Joint
  23363. * @param jointData The joint data for the Hinge2-Joint
  23364. */
  23365. constructor(jointData: PhysicsJointData);
  23366. /**
  23367. * Set the motor values.
  23368. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23369. * @param {number} targetSpeed the speed the motor is to reach
  23370. * @param {number} maxForce max force for this motor.
  23371. * @param {motorIndex} the motor's index, 0 or 1.
  23372. */
  23373. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23374. /**
  23375. * Set the motor limits.
  23376. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23377. * @param {number} upperLimit the upper limit
  23378. * @param {number} lowerLimit lower limit
  23379. * @param {motorIndex} the motor's index, 0 or 1.
  23380. */
  23381. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23382. }
  23383. /**
  23384. * Interface for a motor enabled joint
  23385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23386. */
  23387. export interface IMotorEnabledJoint {
  23388. /**
  23389. * Physics joint
  23390. */
  23391. physicsJoint: any;
  23392. /**
  23393. * Sets the motor of the motor-enabled joint
  23394. * @param force The force of the motor
  23395. * @param maxForce The maximum force of the motor
  23396. * @param motorIndex The index of the motor
  23397. */
  23398. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23399. /**
  23400. * Sets the limit of the motor
  23401. * @param upperLimit The upper limit of the motor
  23402. * @param lowerLimit The lower limit of the motor
  23403. * @param motorIndex The index of the motor
  23404. */
  23405. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23406. }
  23407. /**
  23408. * Joint data for a Distance-Joint
  23409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23410. */
  23411. export interface DistanceJointData extends PhysicsJointData {
  23412. /**
  23413. * Max distance the 2 joint objects can be apart
  23414. */
  23415. maxDistance: number;
  23416. }
  23417. /**
  23418. * Joint data from a spring joint
  23419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23420. */
  23421. export interface SpringJointData extends PhysicsJointData {
  23422. /**
  23423. * Length of the spring
  23424. */
  23425. length: number;
  23426. /**
  23427. * Stiffness of the spring
  23428. */
  23429. stiffness: number;
  23430. /**
  23431. * Damping of the spring
  23432. */
  23433. damping: number;
  23434. /** this callback will be called when applying the force to the impostors. */
  23435. forceApplicationCallback: () => void;
  23436. }
  23437. }
  23438. declare module BABYLON {
  23439. /**
  23440. * Holds the data for the raycast result
  23441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23442. */
  23443. export class PhysicsRaycastResult {
  23444. private _hasHit;
  23445. private _hitDistance;
  23446. private _hitNormalWorld;
  23447. private _hitPointWorld;
  23448. private _rayFromWorld;
  23449. private _rayToWorld;
  23450. /**
  23451. * Gets if there was a hit
  23452. */
  23453. get hasHit(): boolean;
  23454. /**
  23455. * Gets the distance from the hit
  23456. */
  23457. get hitDistance(): number;
  23458. /**
  23459. * Gets the hit normal/direction in the world
  23460. */
  23461. get hitNormalWorld(): Vector3;
  23462. /**
  23463. * Gets the hit point in the world
  23464. */
  23465. get hitPointWorld(): Vector3;
  23466. /**
  23467. * Gets the ray "start point" of the ray in the world
  23468. */
  23469. get rayFromWorld(): Vector3;
  23470. /**
  23471. * Gets the ray "end point" of the ray in the world
  23472. */
  23473. get rayToWorld(): Vector3;
  23474. /**
  23475. * Sets the hit data (normal & point in world space)
  23476. * @param hitNormalWorld defines the normal in world space
  23477. * @param hitPointWorld defines the point in world space
  23478. */
  23479. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23480. /**
  23481. * Sets the distance from the start point to the hit point
  23482. * @param distance
  23483. */
  23484. setHitDistance(distance: number): void;
  23485. /**
  23486. * Calculates the distance manually
  23487. */
  23488. calculateHitDistance(): void;
  23489. /**
  23490. * Resets all the values to default
  23491. * @param from The from point on world space
  23492. * @param to The to point on world space
  23493. */
  23494. reset(from?: Vector3, to?: Vector3): void;
  23495. }
  23496. /**
  23497. * Interface for the size containing width and height
  23498. */
  23499. interface IXYZ {
  23500. /**
  23501. * X
  23502. */
  23503. x: number;
  23504. /**
  23505. * Y
  23506. */
  23507. y: number;
  23508. /**
  23509. * Z
  23510. */
  23511. z: number;
  23512. }
  23513. }
  23514. declare module BABYLON {
  23515. /**
  23516. * Interface used to describe a physics joint
  23517. */
  23518. export interface PhysicsImpostorJoint {
  23519. /** Defines the main impostor to which the joint is linked */
  23520. mainImpostor: PhysicsImpostor;
  23521. /** Defines the impostor that is connected to the main impostor using this joint */
  23522. connectedImpostor: PhysicsImpostor;
  23523. /** Defines the joint itself */
  23524. joint: PhysicsJoint;
  23525. }
  23526. /** @hidden */
  23527. export interface IPhysicsEnginePlugin {
  23528. world: any;
  23529. name: string;
  23530. setGravity(gravity: Vector3): void;
  23531. setTimeStep(timeStep: number): void;
  23532. getTimeStep(): number;
  23533. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23534. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23535. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23536. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23537. removePhysicsBody(impostor: PhysicsImpostor): void;
  23538. generateJoint(joint: PhysicsImpostorJoint): void;
  23539. removeJoint(joint: PhysicsImpostorJoint): void;
  23540. isSupported(): boolean;
  23541. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23542. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23543. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23544. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23545. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23546. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23547. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23548. getBodyMass(impostor: PhysicsImpostor): number;
  23549. getBodyFriction(impostor: PhysicsImpostor): number;
  23550. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23551. getBodyRestitution(impostor: PhysicsImpostor): number;
  23552. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23553. getBodyPressure?(impostor: PhysicsImpostor): number;
  23554. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23555. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23556. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23557. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23558. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23559. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23560. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23561. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23562. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23563. sleepBody(impostor: PhysicsImpostor): void;
  23564. wakeUpBody(impostor: PhysicsImpostor): void;
  23565. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23566. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23567. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23568. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23569. getRadius(impostor: PhysicsImpostor): number;
  23570. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23571. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23572. dispose(): void;
  23573. }
  23574. /**
  23575. * Interface used to define a physics engine
  23576. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23577. */
  23578. export interface IPhysicsEngine {
  23579. /**
  23580. * Gets the gravity vector used by the simulation
  23581. */
  23582. gravity: Vector3;
  23583. /**
  23584. * Sets the gravity vector used by the simulation
  23585. * @param gravity defines the gravity vector to use
  23586. */
  23587. setGravity(gravity: Vector3): void;
  23588. /**
  23589. * Set the time step of the physics engine.
  23590. * Default is 1/60.
  23591. * To slow it down, enter 1/600 for example.
  23592. * To speed it up, 1/30
  23593. * @param newTimeStep the new timestep to apply to this world.
  23594. */
  23595. setTimeStep(newTimeStep: number): void;
  23596. /**
  23597. * Get the time step of the physics engine.
  23598. * @returns the current time step
  23599. */
  23600. getTimeStep(): number;
  23601. /**
  23602. * Set the sub time step of the physics engine.
  23603. * Default is 0 meaning there is no sub steps
  23604. * To increase physics resolution precision, set a small value (like 1 ms)
  23605. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23606. */
  23607. setSubTimeStep(subTimeStep: number): void;
  23608. /**
  23609. * Get the sub time step of the physics engine.
  23610. * @returns the current sub time step
  23611. */
  23612. getSubTimeStep(): number;
  23613. /**
  23614. * Release all resources
  23615. */
  23616. dispose(): void;
  23617. /**
  23618. * Gets the name of the current physics plugin
  23619. * @returns the name of the plugin
  23620. */
  23621. getPhysicsPluginName(): string;
  23622. /**
  23623. * Adding a new impostor for the impostor tracking.
  23624. * This will be done by the impostor itself.
  23625. * @param impostor the impostor to add
  23626. */
  23627. addImpostor(impostor: PhysicsImpostor): void;
  23628. /**
  23629. * Remove an impostor from the engine.
  23630. * This impostor and its mesh will not longer be updated by the physics engine.
  23631. * @param impostor the impostor to remove
  23632. */
  23633. removeImpostor(impostor: PhysicsImpostor): void;
  23634. /**
  23635. * Add a joint to the physics engine
  23636. * @param mainImpostor defines the main impostor to which the joint is added.
  23637. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23638. * @param joint defines the joint that will connect both impostors.
  23639. */
  23640. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23641. /**
  23642. * Removes a joint from the simulation
  23643. * @param mainImpostor defines the impostor used with the joint
  23644. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23645. * @param joint defines the joint to remove
  23646. */
  23647. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23648. /**
  23649. * Gets the current plugin used to run the simulation
  23650. * @returns current plugin
  23651. */
  23652. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23653. /**
  23654. * Gets the list of physic impostors
  23655. * @returns an array of PhysicsImpostor
  23656. */
  23657. getImpostors(): Array<PhysicsImpostor>;
  23658. /**
  23659. * Gets the impostor for a physics enabled object
  23660. * @param object defines the object impersonated by the impostor
  23661. * @returns the PhysicsImpostor or null if not found
  23662. */
  23663. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23664. /**
  23665. * Gets the impostor for a physics body object
  23666. * @param body defines physics body used by the impostor
  23667. * @returns the PhysicsImpostor or null if not found
  23668. */
  23669. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23670. /**
  23671. * Does a raycast in the physics world
  23672. * @param from when should the ray start?
  23673. * @param to when should the ray end?
  23674. * @returns PhysicsRaycastResult
  23675. */
  23676. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23677. /**
  23678. * Called by the scene. No need to call it.
  23679. * @param delta defines the timespam between frames
  23680. */
  23681. _step(delta: number): void;
  23682. }
  23683. }
  23684. declare module BABYLON {
  23685. /**
  23686. * The interface for the physics imposter parameters
  23687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23688. */
  23689. export interface PhysicsImpostorParameters {
  23690. /**
  23691. * The mass of the physics imposter
  23692. */
  23693. mass: number;
  23694. /**
  23695. * The friction of the physics imposter
  23696. */
  23697. friction?: number;
  23698. /**
  23699. * The coefficient of restitution of the physics imposter
  23700. */
  23701. restitution?: number;
  23702. /**
  23703. * The native options of the physics imposter
  23704. */
  23705. nativeOptions?: any;
  23706. /**
  23707. * Specifies if the parent should be ignored
  23708. */
  23709. ignoreParent?: boolean;
  23710. /**
  23711. * Specifies if bi-directional transformations should be disabled
  23712. */
  23713. disableBidirectionalTransformation?: boolean;
  23714. /**
  23715. * The pressure inside the physics imposter, soft object only
  23716. */
  23717. pressure?: number;
  23718. /**
  23719. * The stiffness the physics imposter, soft object only
  23720. */
  23721. stiffness?: number;
  23722. /**
  23723. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23724. */
  23725. velocityIterations?: number;
  23726. /**
  23727. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23728. */
  23729. positionIterations?: number;
  23730. /**
  23731. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23732. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23733. * Add to fix multiple points
  23734. */
  23735. fixedPoints?: number;
  23736. /**
  23737. * The collision margin around a soft object
  23738. */
  23739. margin?: number;
  23740. /**
  23741. * The collision margin around a soft object
  23742. */
  23743. damping?: number;
  23744. /**
  23745. * The path for a rope based on an extrusion
  23746. */
  23747. path?: any;
  23748. /**
  23749. * The shape of an extrusion used for a rope based on an extrusion
  23750. */
  23751. shape?: any;
  23752. }
  23753. /**
  23754. * Interface for a physics-enabled object
  23755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23756. */
  23757. export interface IPhysicsEnabledObject {
  23758. /**
  23759. * The position of the physics-enabled object
  23760. */
  23761. position: Vector3;
  23762. /**
  23763. * The rotation of the physics-enabled object
  23764. */
  23765. rotationQuaternion: Nullable<Quaternion>;
  23766. /**
  23767. * The scale of the physics-enabled object
  23768. */
  23769. scaling: Vector3;
  23770. /**
  23771. * The rotation of the physics-enabled object
  23772. */
  23773. rotation?: Vector3;
  23774. /**
  23775. * The parent of the physics-enabled object
  23776. */
  23777. parent?: any;
  23778. /**
  23779. * The bounding info of the physics-enabled object
  23780. * @returns The bounding info of the physics-enabled object
  23781. */
  23782. getBoundingInfo(): BoundingInfo;
  23783. /**
  23784. * Computes the world matrix
  23785. * @param force Specifies if the world matrix should be computed by force
  23786. * @returns A world matrix
  23787. */
  23788. computeWorldMatrix(force: boolean): Matrix;
  23789. /**
  23790. * Gets the world matrix
  23791. * @returns A world matrix
  23792. */
  23793. getWorldMatrix?(): Matrix;
  23794. /**
  23795. * Gets the child meshes
  23796. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23797. * @returns An array of abstract meshes
  23798. */
  23799. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23800. /**
  23801. * Gets the vertex data
  23802. * @param kind The type of vertex data
  23803. * @returns A nullable array of numbers, or a float32 array
  23804. */
  23805. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23806. /**
  23807. * Gets the indices from the mesh
  23808. * @returns A nullable array of index arrays
  23809. */
  23810. getIndices?(): Nullable<IndicesArray>;
  23811. /**
  23812. * Gets the scene from the mesh
  23813. * @returns the indices array or null
  23814. */
  23815. getScene?(): Scene;
  23816. /**
  23817. * Gets the absolute position from the mesh
  23818. * @returns the absolute position
  23819. */
  23820. getAbsolutePosition(): Vector3;
  23821. /**
  23822. * Gets the absolute pivot point from the mesh
  23823. * @returns the absolute pivot point
  23824. */
  23825. getAbsolutePivotPoint(): Vector3;
  23826. /**
  23827. * Rotates the mesh
  23828. * @param axis The axis of rotation
  23829. * @param amount The amount of rotation
  23830. * @param space The space of the rotation
  23831. * @returns The rotation transform node
  23832. */
  23833. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23834. /**
  23835. * Translates the mesh
  23836. * @param axis The axis of translation
  23837. * @param distance The distance of translation
  23838. * @param space The space of the translation
  23839. * @returns The transform node
  23840. */
  23841. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23842. /**
  23843. * Sets the absolute position of the mesh
  23844. * @param absolutePosition The absolute position of the mesh
  23845. * @returns The transform node
  23846. */
  23847. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23848. /**
  23849. * Gets the class name of the mesh
  23850. * @returns The class name
  23851. */
  23852. getClassName(): string;
  23853. }
  23854. /**
  23855. * Represents a physics imposter
  23856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23857. */
  23858. export class PhysicsImpostor {
  23859. /**
  23860. * The physics-enabled object used as the physics imposter
  23861. */
  23862. object: IPhysicsEnabledObject;
  23863. /**
  23864. * The type of the physics imposter
  23865. */
  23866. type: number;
  23867. private _options;
  23868. private _scene?;
  23869. /**
  23870. * The default object size of the imposter
  23871. */
  23872. static DEFAULT_OBJECT_SIZE: Vector3;
  23873. /**
  23874. * The identity quaternion of the imposter
  23875. */
  23876. static IDENTITY_QUATERNION: Quaternion;
  23877. /** @hidden */
  23878. _pluginData: any;
  23879. private _physicsEngine;
  23880. private _physicsBody;
  23881. private _bodyUpdateRequired;
  23882. private _onBeforePhysicsStepCallbacks;
  23883. private _onAfterPhysicsStepCallbacks;
  23884. /** @hidden */
  23885. _onPhysicsCollideCallbacks: Array<{
  23886. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23887. otherImpostors: Array<PhysicsImpostor>;
  23888. }>;
  23889. private _deltaPosition;
  23890. private _deltaRotation;
  23891. private _deltaRotationConjugated;
  23892. /** @hidden */
  23893. _isFromLine: boolean;
  23894. private _parent;
  23895. private _isDisposed;
  23896. private static _tmpVecs;
  23897. private static _tmpQuat;
  23898. /**
  23899. * Specifies if the physics imposter is disposed
  23900. */
  23901. get isDisposed(): boolean;
  23902. /**
  23903. * Gets the mass of the physics imposter
  23904. */
  23905. get mass(): number;
  23906. set mass(value: number);
  23907. /**
  23908. * Gets the coefficient of friction
  23909. */
  23910. get friction(): number;
  23911. /**
  23912. * Sets the coefficient of friction
  23913. */
  23914. set friction(value: number);
  23915. /**
  23916. * Gets the coefficient of restitution
  23917. */
  23918. get restitution(): number;
  23919. /**
  23920. * Sets the coefficient of restitution
  23921. */
  23922. set restitution(value: number);
  23923. /**
  23924. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23925. */
  23926. get pressure(): number;
  23927. /**
  23928. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23929. */
  23930. set pressure(value: number);
  23931. /**
  23932. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23933. */
  23934. get stiffness(): number;
  23935. /**
  23936. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23937. */
  23938. set stiffness(value: number);
  23939. /**
  23940. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23941. */
  23942. get velocityIterations(): number;
  23943. /**
  23944. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23945. */
  23946. set velocityIterations(value: number);
  23947. /**
  23948. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23949. */
  23950. get positionIterations(): number;
  23951. /**
  23952. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23953. */
  23954. set positionIterations(value: number);
  23955. /**
  23956. * The unique id of the physics imposter
  23957. * set by the physics engine when adding this impostor to the array
  23958. */
  23959. uniqueId: number;
  23960. /**
  23961. * @hidden
  23962. */
  23963. soft: boolean;
  23964. /**
  23965. * @hidden
  23966. */
  23967. segments: number;
  23968. private _joints;
  23969. /**
  23970. * Initializes the physics imposter
  23971. * @param object The physics-enabled object used as the physics imposter
  23972. * @param type The type of the physics imposter
  23973. * @param _options The options for the physics imposter
  23974. * @param _scene The Babylon scene
  23975. */
  23976. constructor(
  23977. /**
  23978. * The physics-enabled object used as the physics imposter
  23979. */
  23980. object: IPhysicsEnabledObject,
  23981. /**
  23982. * The type of the physics imposter
  23983. */
  23984. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23985. /**
  23986. * This function will completly initialize this impostor.
  23987. * It will create a new body - but only if this mesh has no parent.
  23988. * If it has, this impostor will not be used other than to define the impostor
  23989. * of the child mesh.
  23990. * @hidden
  23991. */
  23992. _init(): void;
  23993. private _getPhysicsParent;
  23994. /**
  23995. * Should a new body be generated.
  23996. * @returns boolean specifying if body initialization is required
  23997. */
  23998. isBodyInitRequired(): boolean;
  23999. /**
  24000. * Sets the updated scaling
  24001. * @param updated Specifies if the scaling is updated
  24002. */
  24003. setScalingUpdated(): void;
  24004. /**
  24005. * Force a regeneration of this or the parent's impostor's body.
  24006. * Use under cautious - This will remove all joints already implemented.
  24007. */
  24008. forceUpdate(): void;
  24009. /**
  24010. * Gets the body that holds this impostor. Either its own, or its parent.
  24011. */
  24012. get physicsBody(): any;
  24013. /**
  24014. * Get the parent of the physics imposter
  24015. * @returns Physics imposter or null
  24016. */
  24017. get parent(): Nullable<PhysicsImpostor>;
  24018. /**
  24019. * Sets the parent of the physics imposter
  24020. */
  24021. set parent(value: Nullable<PhysicsImpostor>);
  24022. /**
  24023. * Set the physics body. Used mainly by the physics engine/plugin
  24024. */
  24025. set physicsBody(physicsBody: any);
  24026. /**
  24027. * Resets the update flags
  24028. */
  24029. resetUpdateFlags(): void;
  24030. /**
  24031. * Gets the object extend size
  24032. * @returns the object extend size
  24033. */
  24034. getObjectExtendSize(): Vector3;
  24035. /**
  24036. * Gets the object center
  24037. * @returns The object center
  24038. */
  24039. getObjectCenter(): Vector3;
  24040. /**
  24041. * Get a specific parameter from the options parameters
  24042. * @param paramName The object parameter name
  24043. * @returns The object parameter
  24044. */
  24045. getParam(paramName: string): any;
  24046. /**
  24047. * Sets a specific parameter in the options given to the physics plugin
  24048. * @param paramName The parameter name
  24049. * @param value The value of the parameter
  24050. */
  24051. setParam(paramName: string, value: number): void;
  24052. /**
  24053. * Specifically change the body's mass option. Won't recreate the physics body object
  24054. * @param mass The mass of the physics imposter
  24055. */
  24056. setMass(mass: number): void;
  24057. /**
  24058. * Gets the linear velocity
  24059. * @returns linear velocity or null
  24060. */
  24061. getLinearVelocity(): Nullable<Vector3>;
  24062. /**
  24063. * Sets the linear velocity
  24064. * @param velocity linear velocity or null
  24065. */
  24066. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24067. /**
  24068. * Gets the angular velocity
  24069. * @returns angular velocity or null
  24070. */
  24071. getAngularVelocity(): Nullable<Vector3>;
  24072. /**
  24073. * Sets the angular velocity
  24074. * @param velocity The velocity or null
  24075. */
  24076. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24077. /**
  24078. * Execute a function with the physics plugin native code
  24079. * Provide a function the will have two variables - the world object and the physics body object
  24080. * @param func The function to execute with the physics plugin native code
  24081. */
  24082. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24083. /**
  24084. * Register a function that will be executed before the physics world is stepping forward
  24085. * @param func The function to execute before the physics world is stepped forward
  24086. */
  24087. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24088. /**
  24089. * Unregister a function that will be executed before the physics world is stepping forward
  24090. * @param func The function to execute before the physics world is stepped forward
  24091. */
  24092. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24093. /**
  24094. * Register a function that will be executed after the physics step
  24095. * @param func The function to execute after physics step
  24096. */
  24097. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24098. /**
  24099. * Unregisters a function that will be executed after the physics step
  24100. * @param func The function to execute after physics step
  24101. */
  24102. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24103. /**
  24104. * register a function that will be executed when this impostor collides against a different body
  24105. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24106. * @param func Callback that is executed on collision
  24107. */
  24108. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24109. /**
  24110. * Unregisters the physics imposter on contact
  24111. * @param collideAgainst The physics object to collide against
  24112. * @param func Callback to execute on collision
  24113. */
  24114. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24115. private _tmpQuat;
  24116. private _tmpQuat2;
  24117. /**
  24118. * Get the parent rotation
  24119. * @returns The parent rotation
  24120. */
  24121. getParentsRotation(): Quaternion;
  24122. /**
  24123. * this function is executed by the physics engine.
  24124. */
  24125. beforeStep: () => void;
  24126. /**
  24127. * this function is executed by the physics engine
  24128. */
  24129. afterStep: () => void;
  24130. /**
  24131. * Legacy collision detection event support
  24132. */
  24133. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24134. /**
  24135. * event and body object due to cannon's event-based architecture.
  24136. */
  24137. onCollide: (e: {
  24138. body: any;
  24139. }) => void;
  24140. /**
  24141. * Apply a force
  24142. * @param force The force to apply
  24143. * @param contactPoint The contact point for the force
  24144. * @returns The physics imposter
  24145. */
  24146. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24147. /**
  24148. * Apply an impulse
  24149. * @param force The impulse force
  24150. * @param contactPoint The contact point for the impulse force
  24151. * @returns The physics imposter
  24152. */
  24153. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24154. /**
  24155. * A help function to create a joint
  24156. * @param otherImpostor A physics imposter used to create a joint
  24157. * @param jointType The type of joint
  24158. * @param jointData The data for the joint
  24159. * @returns The physics imposter
  24160. */
  24161. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24162. /**
  24163. * Add a joint to this impostor with a different impostor
  24164. * @param otherImpostor A physics imposter used to add a joint
  24165. * @param joint The joint to add
  24166. * @returns The physics imposter
  24167. */
  24168. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24169. /**
  24170. * Add an anchor to a cloth impostor
  24171. * @param otherImpostor rigid impostor to anchor to
  24172. * @param width ratio across width from 0 to 1
  24173. * @param height ratio up height from 0 to 1
  24174. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24175. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24176. * @returns impostor the soft imposter
  24177. */
  24178. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24179. /**
  24180. * Add a hook to a rope impostor
  24181. * @param otherImpostor rigid impostor to anchor to
  24182. * @param length ratio across rope from 0 to 1
  24183. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24184. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24185. * @returns impostor the rope imposter
  24186. */
  24187. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24188. /**
  24189. * Will keep this body still, in a sleep mode.
  24190. * @returns the physics imposter
  24191. */
  24192. sleep(): PhysicsImpostor;
  24193. /**
  24194. * Wake the body up.
  24195. * @returns The physics imposter
  24196. */
  24197. wakeUp(): PhysicsImpostor;
  24198. /**
  24199. * Clones the physics imposter
  24200. * @param newObject The physics imposter clones to this physics-enabled object
  24201. * @returns A nullable physics imposter
  24202. */
  24203. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24204. /**
  24205. * Disposes the physics imposter
  24206. */
  24207. dispose(): void;
  24208. /**
  24209. * Sets the delta position
  24210. * @param position The delta position amount
  24211. */
  24212. setDeltaPosition(position: Vector3): void;
  24213. /**
  24214. * Sets the delta rotation
  24215. * @param rotation The delta rotation amount
  24216. */
  24217. setDeltaRotation(rotation: Quaternion): void;
  24218. /**
  24219. * Gets the box size of the physics imposter and stores the result in the input parameter
  24220. * @param result Stores the box size
  24221. * @returns The physics imposter
  24222. */
  24223. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24224. /**
  24225. * Gets the radius of the physics imposter
  24226. * @returns Radius of the physics imposter
  24227. */
  24228. getRadius(): number;
  24229. /**
  24230. * Sync a bone with this impostor
  24231. * @param bone The bone to sync to the impostor.
  24232. * @param boneMesh The mesh that the bone is influencing.
  24233. * @param jointPivot The pivot of the joint / bone in local space.
  24234. * @param distToJoint Optional distance from the impostor to the joint.
  24235. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24236. */
  24237. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24238. /**
  24239. * Sync impostor to a bone
  24240. * @param bone The bone that the impostor will be synced to.
  24241. * @param boneMesh The mesh that the bone is influencing.
  24242. * @param jointPivot The pivot of the joint / bone in local space.
  24243. * @param distToJoint Optional distance from the impostor to the joint.
  24244. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24245. * @param boneAxis Optional vector3 axis the bone is aligned with
  24246. */
  24247. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24248. /**
  24249. * No-Imposter type
  24250. */
  24251. static NoImpostor: number;
  24252. /**
  24253. * Sphere-Imposter type
  24254. */
  24255. static SphereImpostor: number;
  24256. /**
  24257. * Box-Imposter type
  24258. */
  24259. static BoxImpostor: number;
  24260. /**
  24261. * Plane-Imposter type
  24262. */
  24263. static PlaneImpostor: number;
  24264. /**
  24265. * Mesh-imposter type
  24266. */
  24267. static MeshImpostor: number;
  24268. /**
  24269. * Capsule-Impostor type (Ammo.js plugin only)
  24270. */
  24271. static CapsuleImpostor: number;
  24272. /**
  24273. * Cylinder-Imposter type
  24274. */
  24275. static CylinderImpostor: number;
  24276. /**
  24277. * Particle-Imposter type
  24278. */
  24279. static ParticleImpostor: number;
  24280. /**
  24281. * Heightmap-Imposter type
  24282. */
  24283. static HeightmapImpostor: number;
  24284. /**
  24285. * ConvexHull-Impostor type (Ammo.js plugin only)
  24286. */
  24287. static ConvexHullImpostor: number;
  24288. /**
  24289. * Custom-Imposter type (Ammo.js plugin only)
  24290. */
  24291. static CustomImpostor: number;
  24292. /**
  24293. * Rope-Imposter type
  24294. */
  24295. static RopeImpostor: number;
  24296. /**
  24297. * Cloth-Imposter type
  24298. */
  24299. static ClothImpostor: number;
  24300. /**
  24301. * Softbody-Imposter type
  24302. */
  24303. static SoftbodyImpostor: number;
  24304. }
  24305. }
  24306. declare module BABYLON {
  24307. /**
  24308. * @hidden
  24309. **/
  24310. export class _CreationDataStorage {
  24311. closePath?: boolean;
  24312. closeArray?: boolean;
  24313. idx: number[];
  24314. dashSize: number;
  24315. gapSize: number;
  24316. path3D: Path3D;
  24317. pathArray: Vector3[][];
  24318. arc: number;
  24319. radius: number;
  24320. cap: number;
  24321. tessellation: number;
  24322. }
  24323. /**
  24324. * @hidden
  24325. **/
  24326. class _InstanceDataStorage {
  24327. visibleInstances: any;
  24328. batchCache: _InstancesBatch;
  24329. instancesBufferSize: number;
  24330. instancesBuffer: Nullable<Buffer>;
  24331. instancesData: Float32Array;
  24332. overridenInstanceCount: number;
  24333. isFrozen: boolean;
  24334. previousBatch: Nullable<_InstancesBatch>;
  24335. hardwareInstancedRendering: boolean;
  24336. sideOrientation: number;
  24337. manualUpdate: boolean;
  24338. }
  24339. /**
  24340. * @hidden
  24341. **/
  24342. export class _InstancesBatch {
  24343. mustReturn: boolean;
  24344. visibleInstances: Nullable<InstancedMesh[]>[];
  24345. renderSelf: boolean[];
  24346. hardwareInstancedRendering: boolean[];
  24347. }
  24348. /**
  24349. * Class used to represent renderable models
  24350. */
  24351. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24352. /**
  24353. * Mesh side orientation : usually the external or front surface
  24354. */
  24355. static readonly FRONTSIDE: number;
  24356. /**
  24357. * Mesh side orientation : usually the internal or back surface
  24358. */
  24359. static readonly BACKSIDE: number;
  24360. /**
  24361. * Mesh side orientation : both internal and external or front and back surfaces
  24362. */
  24363. static readonly DOUBLESIDE: number;
  24364. /**
  24365. * Mesh side orientation : by default, `FRONTSIDE`
  24366. */
  24367. static readonly DEFAULTSIDE: number;
  24368. /**
  24369. * Mesh cap setting : no cap
  24370. */
  24371. static readonly NO_CAP: number;
  24372. /**
  24373. * Mesh cap setting : one cap at the beginning of the mesh
  24374. */
  24375. static readonly CAP_START: number;
  24376. /**
  24377. * Mesh cap setting : one cap at the end of the mesh
  24378. */
  24379. static readonly CAP_END: number;
  24380. /**
  24381. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24382. */
  24383. static readonly CAP_ALL: number;
  24384. /**
  24385. * Mesh pattern setting : no flip or rotate
  24386. */
  24387. static readonly NO_FLIP: number;
  24388. /**
  24389. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24390. */
  24391. static readonly FLIP_TILE: number;
  24392. /**
  24393. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24394. */
  24395. static readonly ROTATE_TILE: number;
  24396. /**
  24397. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24398. */
  24399. static readonly FLIP_ROW: number;
  24400. /**
  24401. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24402. */
  24403. static readonly ROTATE_ROW: number;
  24404. /**
  24405. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24406. */
  24407. static readonly FLIP_N_ROTATE_TILE: number;
  24408. /**
  24409. * Mesh pattern setting : rotate pattern and rotate
  24410. */
  24411. static readonly FLIP_N_ROTATE_ROW: number;
  24412. /**
  24413. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24414. */
  24415. static readonly CENTER: number;
  24416. /**
  24417. * Mesh tile positioning : part tiles on left
  24418. */
  24419. static readonly LEFT: number;
  24420. /**
  24421. * Mesh tile positioning : part tiles on right
  24422. */
  24423. static readonly RIGHT: number;
  24424. /**
  24425. * Mesh tile positioning : part tiles on top
  24426. */
  24427. static readonly TOP: number;
  24428. /**
  24429. * Mesh tile positioning : part tiles on bottom
  24430. */
  24431. static readonly BOTTOM: number;
  24432. /**
  24433. * Gets the default side orientation.
  24434. * @param orientation the orientation to value to attempt to get
  24435. * @returns the default orientation
  24436. * @hidden
  24437. */
  24438. static _GetDefaultSideOrientation(orientation?: number): number;
  24439. private _internalMeshDataInfo;
  24440. /**
  24441. * An event triggered before rendering the mesh
  24442. */
  24443. get onBeforeRenderObservable(): Observable<Mesh>;
  24444. /**
  24445. * An event triggered before binding the mesh
  24446. */
  24447. get onBeforeBindObservable(): Observable<Mesh>;
  24448. /**
  24449. * An event triggered after rendering the mesh
  24450. */
  24451. get onAfterRenderObservable(): Observable<Mesh>;
  24452. /**
  24453. * An event triggered before drawing the mesh
  24454. */
  24455. get onBeforeDrawObservable(): Observable<Mesh>;
  24456. private _onBeforeDrawObserver;
  24457. /**
  24458. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24459. */
  24460. set onBeforeDraw(callback: () => void);
  24461. get hasInstances(): boolean;
  24462. /**
  24463. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24464. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24465. */
  24466. delayLoadState: number;
  24467. /**
  24468. * Gets the list of instances created from this mesh
  24469. * it is not supposed to be modified manually.
  24470. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24471. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24472. */
  24473. instances: InstancedMesh[];
  24474. /**
  24475. * Gets the file containing delay loading data for this mesh
  24476. */
  24477. delayLoadingFile: string;
  24478. /** @hidden */
  24479. _binaryInfo: any;
  24480. /**
  24481. * User defined function used to change how LOD level selection is done
  24482. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24483. */
  24484. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24485. /**
  24486. * Gets or sets the morph target manager
  24487. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24488. */
  24489. get morphTargetManager(): Nullable<MorphTargetManager>;
  24490. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24491. /** @hidden */
  24492. _creationDataStorage: Nullable<_CreationDataStorage>;
  24493. /** @hidden */
  24494. _geometry: Nullable<Geometry>;
  24495. /** @hidden */
  24496. _delayInfo: Array<string>;
  24497. /** @hidden */
  24498. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24499. /** @hidden */
  24500. _instanceDataStorage: _InstanceDataStorage;
  24501. private _effectiveMaterial;
  24502. /** @hidden */
  24503. _shouldGenerateFlatShading: boolean;
  24504. /** @hidden */
  24505. _originalBuilderSideOrientation: number;
  24506. /**
  24507. * Use this property to change the original side orientation defined at construction time
  24508. */
  24509. overrideMaterialSideOrientation: Nullable<number>;
  24510. /**
  24511. * Gets the source mesh (the one used to clone this one from)
  24512. */
  24513. get source(): Nullable<Mesh>;
  24514. /**
  24515. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24516. */
  24517. get isUnIndexed(): boolean;
  24518. set isUnIndexed(value: boolean);
  24519. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24520. get worldMatrixInstancedBuffer(): Float32Array;
  24521. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24522. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24523. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24524. /**
  24525. * @constructor
  24526. * @param name The value used by scene.getMeshByName() to do a lookup.
  24527. * @param scene The scene to add this mesh to.
  24528. * @param parent The parent of this mesh, if it has one
  24529. * @param source An optional Mesh from which geometry is shared, cloned.
  24530. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24531. * When false, achieved by calling a clone(), also passing False.
  24532. * This will make creation of children, recursive.
  24533. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24534. */
  24535. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24536. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24537. doNotInstantiate: boolean;
  24538. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24539. /**
  24540. * Gets the class name
  24541. * @returns the string "Mesh".
  24542. */
  24543. getClassName(): string;
  24544. /** @hidden */
  24545. get _isMesh(): boolean;
  24546. /**
  24547. * Returns a description of this mesh
  24548. * @param fullDetails define if full details about this mesh must be used
  24549. * @returns a descriptive string representing this mesh
  24550. */
  24551. toString(fullDetails?: boolean): string;
  24552. /** @hidden */
  24553. _unBindEffect(): void;
  24554. /**
  24555. * Gets a boolean indicating if this mesh has LOD
  24556. */
  24557. get hasLODLevels(): boolean;
  24558. /**
  24559. * Gets the list of MeshLODLevel associated with the current mesh
  24560. * @returns an array of MeshLODLevel
  24561. */
  24562. getLODLevels(): MeshLODLevel[];
  24563. private _sortLODLevels;
  24564. /**
  24565. * Add a mesh as LOD level triggered at the given distance.
  24566. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24567. * @param distance The distance from the center of the object to show this level
  24568. * @param mesh The mesh to be added as LOD level (can be null)
  24569. * @return This mesh (for chaining)
  24570. */
  24571. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24572. /**
  24573. * Returns the LOD level mesh at the passed distance or null if not found.
  24574. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24575. * @param distance The distance from the center of the object to show this level
  24576. * @returns a Mesh or `null`
  24577. */
  24578. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24579. /**
  24580. * Remove a mesh from the LOD array
  24581. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24582. * @param mesh defines the mesh to be removed
  24583. * @return This mesh (for chaining)
  24584. */
  24585. removeLODLevel(mesh: Mesh): Mesh;
  24586. /**
  24587. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24588. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24589. * @param camera defines the camera to use to compute distance
  24590. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24591. * @return This mesh (for chaining)
  24592. */
  24593. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24594. /**
  24595. * Gets the mesh internal Geometry object
  24596. */
  24597. get geometry(): Nullable<Geometry>;
  24598. /**
  24599. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24600. * @returns the total number of vertices
  24601. */
  24602. getTotalVertices(): number;
  24603. /**
  24604. * Returns the content of an associated vertex buffer
  24605. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24606. * - VertexBuffer.PositionKind
  24607. * - VertexBuffer.UVKind
  24608. * - VertexBuffer.UV2Kind
  24609. * - VertexBuffer.UV3Kind
  24610. * - VertexBuffer.UV4Kind
  24611. * - VertexBuffer.UV5Kind
  24612. * - VertexBuffer.UV6Kind
  24613. * - VertexBuffer.ColorKind
  24614. * - VertexBuffer.MatricesIndicesKind
  24615. * - VertexBuffer.MatricesIndicesExtraKind
  24616. * - VertexBuffer.MatricesWeightsKind
  24617. * - VertexBuffer.MatricesWeightsExtraKind
  24618. * @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
  24619. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24620. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24621. */
  24622. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24623. /**
  24624. * Returns the mesh VertexBuffer object from the requested `kind`
  24625. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24626. * - VertexBuffer.PositionKind
  24627. * - VertexBuffer.NormalKind
  24628. * - VertexBuffer.UVKind
  24629. * - VertexBuffer.UV2Kind
  24630. * - VertexBuffer.UV3Kind
  24631. * - VertexBuffer.UV4Kind
  24632. * - VertexBuffer.UV5Kind
  24633. * - VertexBuffer.UV6Kind
  24634. * - VertexBuffer.ColorKind
  24635. * - VertexBuffer.MatricesIndicesKind
  24636. * - VertexBuffer.MatricesIndicesExtraKind
  24637. * - VertexBuffer.MatricesWeightsKind
  24638. * - VertexBuffer.MatricesWeightsExtraKind
  24639. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24640. */
  24641. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24642. /**
  24643. * Tests if a specific vertex buffer is associated with this mesh
  24644. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24645. * - VertexBuffer.PositionKind
  24646. * - VertexBuffer.NormalKind
  24647. * - VertexBuffer.UVKind
  24648. * - VertexBuffer.UV2Kind
  24649. * - VertexBuffer.UV3Kind
  24650. * - VertexBuffer.UV4Kind
  24651. * - VertexBuffer.UV5Kind
  24652. * - VertexBuffer.UV6Kind
  24653. * - VertexBuffer.ColorKind
  24654. * - VertexBuffer.MatricesIndicesKind
  24655. * - VertexBuffer.MatricesIndicesExtraKind
  24656. * - VertexBuffer.MatricesWeightsKind
  24657. * - VertexBuffer.MatricesWeightsExtraKind
  24658. * @returns a boolean
  24659. */
  24660. isVerticesDataPresent(kind: string): boolean;
  24661. /**
  24662. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24663. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24664. * - VertexBuffer.PositionKind
  24665. * - VertexBuffer.UVKind
  24666. * - VertexBuffer.UV2Kind
  24667. * - VertexBuffer.UV3Kind
  24668. * - VertexBuffer.UV4Kind
  24669. * - VertexBuffer.UV5Kind
  24670. * - VertexBuffer.UV6Kind
  24671. * - VertexBuffer.ColorKind
  24672. * - VertexBuffer.MatricesIndicesKind
  24673. * - VertexBuffer.MatricesIndicesExtraKind
  24674. * - VertexBuffer.MatricesWeightsKind
  24675. * - VertexBuffer.MatricesWeightsExtraKind
  24676. * @returns a boolean
  24677. */
  24678. isVertexBufferUpdatable(kind: string): boolean;
  24679. /**
  24680. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24681. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24682. * - VertexBuffer.PositionKind
  24683. * - VertexBuffer.NormalKind
  24684. * - VertexBuffer.UVKind
  24685. * - VertexBuffer.UV2Kind
  24686. * - VertexBuffer.UV3Kind
  24687. * - VertexBuffer.UV4Kind
  24688. * - VertexBuffer.UV5Kind
  24689. * - VertexBuffer.UV6Kind
  24690. * - VertexBuffer.ColorKind
  24691. * - VertexBuffer.MatricesIndicesKind
  24692. * - VertexBuffer.MatricesIndicesExtraKind
  24693. * - VertexBuffer.MatricesWeightsKind
  24694. * - VertexBuffer.MatricesWeightsExtraKind
  24695. * @returns an array of strings
  24696. */
  24697. getVerticesDataKinds(): string[];
  24698. /**
  24699. * Returns a positive integer : the total number of indices in this mesh geometry.
  24700. * @returns the numner of indices or zero if the mesh has no geometry.
  24701. */
  24702. getTotalIndices(): number;
  24703. /**
  24704. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24705. * @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.
  24706. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24707. * @returns the indices array or an empty array if the mesh has no geometry
  24708. */
  24709. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24710. get isBlocked(): boolean;
  24711. /**
  24712. * Determine if the current mesh is ready to be rendered
  24713. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24714. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24715. * @returns true if all associated assets are ready (material, textures, shaders)
  24716. */
  24717. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24718. /**
  24719. * 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.
  24720. */
  24721. get areNormalsFrozen(): boolean;
  24722. /**
  24723. * 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.
  24724. * @returns the current mesh
  24725. */
  24726. freezeNormals(): Mesh;
  24727. /**
  24728. * 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
  24729. * @returns the current mesh
  24730. */
  24731. unfreezeNormals(): Mesh;
  24732. /**
  24733. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24734. */
  24735. set overridenInstanceCount(count: number);
  24736. /** @hidden */
  24737. _preActivate(): Mesh;
  24738. /** @hidden */
  24739. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24740. /** @hidden */
  24741. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24742. /**
  24743. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24744. * This means the mesh underlying bounding box and sphere are recomputed.
  24745. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24746. * @returns the current mesh
  24747. */
  24748. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24749. /** @hidden */
  24750. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24751. /**
  24752. * This function will subdivide the mesh into multiple submeshes
  24753. * @param count defines the expected number of submeshes
  24754. */
  24755. subdivide(count: number): void;
  24756. /**
  24757. * Copy a FloatArray into a specific associated vertex buffer
  24758. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24759. * - VertexBuffer.PositionKind
  24760. * - VertexBuffer.UVKind
  24761. * - VertexBuffer.UV2Kind
  24762. * - VertexBuffer.UV3Kind
  24763. * - VertexBuffer.UV4Kind
  24764. * - VertexBuffer.UV5Kind
  24765. * - VertexBuffer.UV6Kind
  24766. * - VertexBuffer.ColorKind
  24767. * - VertexBuffer.MatricesIndicesKind
  24768. * - VertexBuffer.MatricesIndicesExtraKind
  24769. * - VertexBuffer.MatricesWeightsKind
  24770. * - VertexBuffer.MatricesWeightsExtraKind
  24771. * @param data defines the data source
  24772. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24773. * @param stride defines the data stride size (can be null)
  24774. * @returns the current mesh
  24775. */
  24776. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24777. /**
  24778. * Delete a vertex buffer associated with this mesh
  24779. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24780. * - VertexBuffer.PositionKind
  24781. * - VertexBuffer.UVKind
  24782. * - VertexBuffer.UV2Kind
  24783. * - VertexBuffer.UV3Kind
  24784. * - VertexBuffer.UV4Kind
  24785. * - VertexBuffer.UV5Kind
  24786. * - VertexBuffer.UV6Kind
  24787. * - VertexBuffer.ColorKind
  24788. * - VertexBuffer.MatricesIndicesKind
  24789. * - VertexBuffer.MatricesIndicesExtraKind
  24790. * - VertexBuffer.MatricesWeightsKind
  24791. * - VertexBuffer.MatricesWeightsExtraKind
  24792. */
  24793. removeVerticesData(kind: string): void;
  24794. /**
  24795. * Flags an associated vertex buffer as updatable
  24796. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24797. * - VertexBuffer.PositionKind
  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. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24810. */
  24811. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24812. /**
  24813. * Sets the mesh global Vertex Buffer
  24814. * @param buffer defines the buffer to use
  24815. * @returns the current mesh
  24816. */
  24817. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24818. /**
  24819. * Update a specific associated vertex buffer
  24820. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24821. * - VertexBuffer.PositionKind
  24822. * - VertexBuffer.UVKind
  24823. * - VertexBuffer.UV2Kind
  24824. * - VertexBuffer.UV3Kind
  24825. * - VertexBuffer.UV4Kind
  24826. * - VertexBuffer.UV5Kind
  24827. * - VertexBuffer.UV6Kind
  24828. * - VertexBuffer.ColorKind
  24829. * - VertexBuffer.MatricesIndicesKind
  24830. * - VertexBuffer.MatricesIndicesExtraKind
  24831. * - VertexBuffer.MatricesWeightsKind
  24832. * - VertexBuffer.MatricesWeightsExtraKind
  24833. * @param data defines the data source
  24834. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24835. * @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)
  24836. * @returns the current mesh
  24837. */
  24838. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24839. /**
  24840. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24841. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24842. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24843. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24844. * @returns the current mesh
  24845. */
  24846. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24847. /**
  24848. * Creates a un-shared specific occurence of the geometry for the mesh.
  24849. * @returns the current mesh
  24850. */
  24851. makeGeometryUnique(): Mesh;
  24852. /**
  24853. * Set the index buffer of this mesh
  24854. * @param indices defines the source data
  24855. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24856. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24857. * @returns the current mesh
  24858. */
  24859. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24860. /**
  24861. * Update the current index buffer
  24862. * @param indices defines the source data
  24863. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24864. * @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)
  24865. * @returns the current mesh
  24866. */
  24867. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24868. /**
  24869. * Invert the geometry to move from a right handed system to a left handed one.
  24870. * @returns the current mesh
  24871. */
  24872. toLeftHanded(): Mesh;
  24873. /** @hidden */
  24874. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24875. /** @hidden */
  24876. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24877. /**
  24878. * Registers for this mesh a javascript function called just before the rendering process
  24879. * @param func defines the function to call before rendering this mesh
  24880. * @returns the current mesh
  24881. */
  24882. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24883. /**
  24884. * Disposes a previously registered javascript function called before the rendering
  24885. * @param func defines the function to remove
  24886. * @returns the current mesh
  24887. */
  24888. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24889. /**
  24890. * Registers for this mesh a javascript function called just after the rendering is complete
  24891. * @param func defines the function to call after rendering this mesh
  24892. * @returns the current mesh
  24893. */
  24894. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24895. /**
  24896. * Disposes a previously registered javascript function called after the rendering.
  24897. * @param func defines the function to remove
  24898. * @returns the current mesh
  24899. */
  24900. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24901. /** @hidden */
  24902. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24903. /** @hidden */
  24904. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24905. /** @hidden */
  24906. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24907. /** @hidden */
  24908. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24909. /** @hidden */
  24910. _rebuild(): void;
  24911. /** @hidden */
  24912. _freeze(): void;
  24913. /** @hidden */
  24914. _unFreeze(): void;
  24915. /**
  24916. * 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
  24917. * @param subMesh defines the subMesh to render
  24918. * @param enableAlphaMode defines if alpha mode can be changed
  24919. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24920. * @returns the current mesh
  24921. */
  24922. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24923. private _onBeforeDraw;
  24924. /**
  24925. * Renormalize the mesh and patch it up if there are no weights
  24926. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24927. * However in the case of zero weights then we set just a single influence to 1.
  24928. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24929. */
  24930. cleanMatrixWeights(): void;
  24931. private normalizeSkinFourWeights;
  24932. private normalizeSkinWeightsAndExtra;
  24933. /**
  24934. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24935. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24936. * the user know there was an issue with importing the mesh
  24937. * @returns a validation object with skinned, valid and report string
  24938. */
  24939. validateSkinning(): {
  24940. skinned: boolean;
  24941. valid: boolean;
  24942. report: string;
  24943. };
  24944. /** @hidden */
  24945. _checkDelayState(): Mesh;
  24946. private _queueLoad;
  24947. /**
  24948. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24949. * A mesh is in the frustum if its bounding box intersects the frustum
  24950. * @param frustumPlanes defines the frustum to test
  24951. * @returns true if the mesh is in the frustum planes
  24952. */
  24953. isInFrustum(frustumPlanes: Plane[]): boolean;
  24954. /**
  24955. * Sets the mesh material by the material or multiMaterial `id` property
  24956. * @param id is a string identifying the material or the multiMaterial
  24957. * @returns the current mesh
  24958. */
  24959. setMaterialByID(id: string): Mesh;
  24960. /**
  24961. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24962. * @returns an array of IAnimatable
  24963. */
  24964. getAnimatables(): IAnimatable[];
  24965. /**
  24966. * Modifies the mesh geometry according to the passed transformation matrix.
  24967. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24968. * The mesh normals are modified using the same transformation.
  24969. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24970. * @param transform defines the transform matrix to use
  24971. * @see http://doc.babylonjs.com/resources/baking_transformations
  24972. * @returns the current mesh
  24973. */
  24974. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24975. /**
  24976. * Modifies the mesh geometry according to its own current World Matrix.
  24977. * The mesh World Matrix is then reset.
  24978. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24979. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24980. * @see http://doc.babylonjs.com/resources/baking_transformations
  24981. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24982. * @returns the current mesh
  24983. */
  24984. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24985. /** @hidden */
  24986. get _positions(): Nullable<Vector3[]>;
  24987. /** @hidden */
  24988. _resetPointsArrayCache(): Mesh;
  24989. /** @hidden */
  24990. _generatePointsArray(): boolean;
  24991. /**
  24992. * Returns a new Mesh object generated from the current mesh properties.
  24993. * This method must not get confused with createInstance()
  24994. * @param name is a string, the name given to the new mesh
  24995. * @param newParent can be any Node object (default `null`)
  24996. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24997. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24998. * @returns a new mesh
  24999. */
  25000. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25001. /**
  25002. * Releases resources associated with this mesh.
  25003. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25004. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25005. */
  25006. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25007. /** @hidden */
  25008. _disposeInstanceSpecificData(): void;
  25009. /**
  25010. * Modifies the mesh geometry according to a displacement map.
  25011. * 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.
  25012. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25013. * @param url is a string, the URL from the image file is to be downloaded.
  25014. * @param minHeight is the lower limit of the displacement.
  25015. * @param maxHeight is the upper limit of the displacement.
  25016. * @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.
  25017. * @param uvOffset is an optional vector2 used to offset UV.
  25018. * @param uvScale is an optional vector2 used to scale UV.
  25019. * @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.
  25020. * @returns the Mesh.
  25021. */
  25022. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25023. /**
  25024. * Modifies the mesh geometry according to a displacementMap buffer.
  25025. * 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.
  25026. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25027. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25028. * @param heightMapWidth is the width of the buffer image.
  25029. * @param heightMapHeight is the height of the buffer image.
  25030. * @param minHeight is the lower limit of the displacement.
  25031. * @param maxHeight is the upper limit of the displacement.
  25032. * @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.
  25033. * @param uvOffset is an optional vector2 used to offset UV.
  25034. * @param uvScale is an optional vector2 used to scale UV.
  25035. * @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.
  25036. * @returns the Mesh.
  25037. */
  25038. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25039. /**
  25040. * Modify the mesh to get a flat shading rendering.
  25041. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25042. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25043. * @returns current mesh
  25044. */
  25045. convertToFlatShadedMesh(): Mesh;
  25046. /**
  25047. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25048. * In other words, more vertices, no more indices and a single bigger VBO.
  25049. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25050. * @returns current mesh
  25051. */
  25052. convertToUnIndexedMesh(): Mesh;
  25053. /**
  25054. * Inverses facet orientations.
  25055. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25056. * @param flipNormals will also inverts the normals
  25057. * @returns current mesh
  25058. */
  25059. flipFaces(flipNormals?: boolean): Mesh;
  25060. /**
  25061. * Increase the number of facets and hence vertices in a mesh
  25062. * Vertex normals are interpolated from existing vertex normals
  25063. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25064. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25065. */
  25066. increaseVertices(numberPerEdge: number): void;
  25067. /**
  25068. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25069. * This will undo any application of covertToFlatShadedMesh
  25070. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25071. */
  25072. forceSharedVertices(): void;
  25073. /** @hidden */
  25074. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25075. /** @hidden */
  25076. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25077. /**
  25078. * Creates a new InstancedMesh object from the mesh model.
  25079. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25080. * @param name defines the name of the new instance
  25081. * @returns a new InstancedMesh
  25082. */
  25083. createInstance(name: string): InstancedMesh;
  25084. /**
  25085. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25086. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25087. * @returns the current mesh
  25088. */
  25089. synchronizeInstances(): Mesh;
  25090. /**
  25091. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25092. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25093. * This should be used together with the simplification to avoid disappearing triangles.
  25094. * @param successCallback an optional success callback to be called after the optimization finished.
  25095. * @returns the current mesh
  25096. */
  25097. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25098. /**
  25099. * Serialize current mesh
  25100. * @param serializationObject defines the object which will receive the serialization data
  25101. */
  25102. serialize(serializationObject: any): void;
  25103. /** @hidden */
  25104. _syncGeometryWithMorphTargetManager(): void;
  25105. /** @hidden */
  25106. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25107. /**
  25108. * Returns a new Mesh object parsed from the source provided.
  25109. * @param parsedMesh is the source
  25110. * @param scene defines the hosting scene
  25111. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25112. * @returns a new Mesh
  25113. */
  25114. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25115. /**
  25116. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25117. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25118. * @param name defines the name of the mesh to create
  25119. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25120. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25121. * @param closePath creates a seam between the first and the last points of each path of the path array
  25122. * @param offset is taken in account only if the `pathArray` is containing a single path
  25123. * @param scene defines the hosting scene
  25124. * @param updatable defines if the mesh must be flagged as updatable
  25125. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25126. * @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)
  25127. * @returns a new Mesh
  25128. */
  25129. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25130. /**
  25131. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25132. * @param name defines the name of the mesh to create
  25133. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25134. * @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
  25135. * @param scene defines the hosting scene
  25136. * @param updatable defines if the mesh must be flagged as updatable
  25137. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25138. * @returns a new Mesh
  25139. */
  25140. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25141. /**
  25142. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25143. * @param name defines the name of the mesh to create
  25144. * @param size sets the size (float) of each box side (default 1)
  25145. * @param scene defines the hosting scene
  25146. * @param updatable defines if the mesh must be flagged as updatable
  25147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25148. * @returns a new Mesh
  25149. */
  25150. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25151. /**
  25152. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25153. * @param name defines the name of the mesh to create
  25154. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25155. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25156. * @param scene defines the hosting scene
  25157. * @param updatable defines if the mesh must be flagged as updatable
  25158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25159. * @returns a new Mesh
  25160. */
  25161. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25162. /**
  25163. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25164. * @param name defines the name of the mesh to create
  25165. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25166. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25167. * @param scene defines the hosting scene
  25168. * @returns a new Mesh
  25169. */
  25170. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25171. /**
  25172. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25173. * @param name defines the name of the mesh to create
  25174. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25175. * @param diameterTop set the top cap diameter (floats, default 1)
  25176. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25177. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25178. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25179. * @param scene defines the hosting scene
  25180. * @param updatable defines if the mesh must be flagged as updatable
  25181. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25182. * @returns a new Mesh
  25183. */
  25184. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25185. /**
  25186. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25187. * @param name defines the name of the mesh to create
  25188. * @param diameter sets the diameter size (float) of the torus (default 1)
  25189. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25190. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25191. * @param scene defines the hosting scene
  25192. * @param updatable defines if the mesh must be flagged as updatable
  25193. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25194. * @returns a new Mesh
  25195. */
  25196. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25197. /**
  25198. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25199. * @param name defines the name of the mesh to create
  25200. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25201. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25202. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25203. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25204. * @param p the number of windings on X axis (positive integers, default 2)
  25205. * @param q the number of windings on Y axis (positive integers, default 3)
  25206. * @param scene defines the hosting scene
  25207. * @param updatable defines if the mesh must be flagged as updatable
  25208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25209. * @returns a new Mesh
  25210. */
  25211. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25212. /**
  25213. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25214. * @param name defines the name of the mesh to create
  25215. * @param points is an array successive Vector3
  25216. * @param scene defines the hosting scene
  25217. * @param updatable defines if the mesh must be flagged as updatable
  25218. * @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).
  25219. * @returns a new Mesh
  25220. */
  25221. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25222. /**
  25223. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25224. * @param name defines the name of the mesh to create
  25225. * @param points is an array successive Vector3
  25226. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25227. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25228. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25229. * @param scene defines the hosting scene
  25230. * @param updatable defines if the mesh must be flagged as updatable
  25231. * @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)
  25232. * @returns a new Mesh
  25233. */
  25234. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25235. /**
  25236. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25237. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25238. * 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.
  25239. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25240. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25241. * Remember you can only change the shape positions, not their number when updating a polygon.
  25242. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25243. * @param name defines the name of the mesh to create
  25244. * @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
  25245. * @param scene defines the hosting scene
  25246. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25247. * @param updatable defines if the mesh must be flagged as updatable
  25248. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25249. * @param earcutInjection can be used to inject your own earcut reference
  25250. * @returns a new Mesh
  25251. */
  25252. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25253. /**
  25254. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25255. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25256. * @param name defines the name of the mesh to create
  25257. * @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
  25258. * @param depth defines the height of extrusion
  25259. * @param scene defines the hosting scene
  25260. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25261. * @param updatable defines if the mesh must be flagged as updatable
  25262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25263. * @param earcutInjection can be used to inject your own earcut reference
  25264. * @returns a new Mesh
  25265. */
  25266. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25267. /**
  25268. * Creates an extruded shape mesh.
  25269. * 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
  25270. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25271. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25272. * @param name defines the name of the mesh to create
  25273. * @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
  25274. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25275. * @param scale is the value to scale the shape
  25276. * @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
  25277. * @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
  25278. * @param scene defines the hosting scene
  25279. * @param updatable defines if the mesh must be flagged as updatable
  25280. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25281. * @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)
  25282. * @returns a new Mesh
  25283. */
  25284. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25285. /**
  25286. * Creates an custom extruded shape mesh.
  25287. * The custom extrusion is a parametric shape.
  25288. * It has no predefined shape. Its final shape will depend on the input parameters.
  25289. * Please consider using the same method from the MeshBuilder class instead
  25290. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25291. * @param name defines the name of the mesh to create
  25292. * @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
  25293. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25294. * @param scaleFunction is a custom Javascript function called on each path point
  25295. * @param rotationFunction is a custom Javascript function called on each path point
  25296. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25297. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25298. * @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
  25299. * @param scene defines the hosting scene
  25300. * @param updatable defines if the mesh must be flagged as updatable
  25301. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25302. * @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)
  25303. * @returns a new Mesh
  25304. */
  25305. 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;
  25306. /**
  25307. * Creates lathe mesh.
  25308. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25309. * Please consider using the same method from the MeshBuilder class instead
  25310. * @param name defines the name of the mesh to create
  25311. * @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
  25312. * @param radius is the radius value of the lathe
  25313. * @param tessellation is the side number of the lathe.
  25314. * @param scene defines the hosting scene
  25315. * @param updatable defines if the mesh must be flagged as updatable
  25316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25317. * @returns a new Mesh
  25318. */
  25319. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25320. /**
  25321. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25322. * @param name defines the name of the mesh to create
  25323. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25324. * @param scene defines the hosting scene
  25325. * @param updatable defines if the mesh must be flagged as updatable
  25326. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25327. * @returns a new Mesh
  25328. */
  25329. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25330. /**
  25331. * Creates a ground mesh.
  25332. * Please consider using the same method from the MeshBuilder class instead
  25333. * @param name defines the name of the mesh to create
  25334. * @param width set the width of the ground
  25335. * @param height set the height of the ground
  25336. * @param subdivisions sets the number of subdivisions per side
  25337. * @param scene defines the hosting scene
  25338. * @param updatable defines if the mesh must be flagged as updatable
  25339. * @returns a new Mesh
  25340. */
  25341. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25342. /**
  25343. * Creates a tiled ground mesh.
  25344. * Please consider using the same method from the MeshBuilder class instead
  25345. * @param name defines the name of the mesh to create
  25346. * @param xmin set the ground minimum X coordinate
  25347. * @param zmin set the ground minimum Y coordinate
  25348. * @param xmax set the ground maximum X coordinate
  25349. * @param zmax set the ground maximum Z coordinate
  25350. * @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
  25351. * @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
  25352. * @param scene defines the hosting scene
  25353. * @param updatable defines if the mesh must be flagged as updatable
  25354. * @returns a new Mesh
  25355. */
  25356. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25357. w: number;
  25358. h: number;
  25359. }, precision: {
  25360. w: number;
  25361. h: number;
  25362. }, scene: Scene, updatable?: boolean): Mesh;
  25363. /**
  25364. * Creates a ground mesh from a height map.
  25365. * Please consider using the same method from the MeshBuilder class instead
  25366. * @see http://doc.babylonjs.com/babylon101/height_map
  25367. * @param name defines the name of the mesh to create
  25368. * @param url sets the URL of the height map image resource
  25369. * @param width set the ground width size
  25370. * @param height set the ground height size
  25371. * @param subdivisions sets the number of subdivision per side
  25372. * @param minHeight is the minimum altitude on the ground
  25373. * @param maxHeight is the maximum altitude on the ground
  25374. * @param scene defines the hosting scene
  25375. * @param updatable defines if the mesh must be flagged as updatable
  25376. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25377. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25378. * @returns a new Mesh
  25379. */
  25380. 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;
  25381. /**
  25382. * Creates a tube mesh.
  25383. * The tube is a parametric shape.
  25384. * It has no predefined shape. Its final shape will depend on the input parameters.
  25385. * Please consider using the same method from the MeshBuilder class instead
  25386. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25387. * @param name defines the name of the mesh to create
  25388. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25389. * @param radius sets the tube radius size
  25390. * @param tessellation is the number of sides on the tubular surface
  25391. * @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
  25392. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25393. * @param scene defines the hosting scene
  25394. * @param updatable defines if the mesh must be flagged as updatable
  25395. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25396. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25397. * @returns a new Mesh
  25398. */
  25399. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25400. (i: number, distance: number): number;
  25401. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25402. /**
  25403. * Creates a polyhedron mesh.
  25404. * Please consider using the same method from the MeshBuilder class instead.
  25405. * * 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
  25406. * * The parameter `size` (positive float, default 1) sets the polygon size
  25407. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25408. * * 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`
  25409. * * 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
  25410. * * 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)`)
  25411. * * 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
  25412. * * 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
  25413. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25414. * * 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
  25415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25416. * @param name defines the name of the mesh to create
  25417. * @param options defines the options used to create the mesh
  25418. * @param scene defines the hosting scene
  25419. * @returns a new Mesh
  25420. */
  25421. static CreatePolyhedron(name: string, options: {
  25422. type?: number;
  25423. size?: number;
  25424. sizeX?: number;
  25425. sizeY?: number;
  25426. sizeZ?: number;
  25427. custom?: any;
  25428. faceUV?: Vector4[];
  25429. faceColors?: Color4[];
  25430. updatable?: boolean;
  25431. sideOrientation?: number;
  25432. }, scene: Scene): Mesh;
  25433. /**
  25434. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25435. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25436. * * 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`)
  25437. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25438. * * 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
  25439. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25440. * * 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
  25441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25442. * @param name defines the name of the mesh
  25443. * @param options defines the options used to create the mesh
  25444. * @param scene defines the hosting scene
  25445. * @returns a new Mesh
  25446. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25447. */
  25448. static CreateIcoSphere(name: string, options: {
  25449. radius?: number;
  25450. flat?: boolean;
  25451. subdivisions?: number;
  25452. sideOrientation?: number;
  25453. updatable?: boolean;
  25454. }, scene: Scene): Mesh;
  25455. /**
  25456. * Creates a decal mesh.
  25457. * Please consider using the same method from the MeshBuilder class instead.
  25458. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25459. * @param name defines the name of the mesh
  25460. * @param sourceMesh defines the mesh receiving the decal
  25461. * @param position sets the position of the decal in world coordinates
  25462. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25463. * @param size sets the decal scaling
  25464. * @param angle sets the angle to rotate the decal
  25465. * @returns a new Mesh
  25466. */
  25467. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25468. /**
  25469. * Prepare internal position array for software CPU skinning
  25470. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25471. */
  25472. setPositionsForCPUSkinning(): Float32Array;
  25473. /**
  25474. * Prepare internal normal array for software CPU skinning
  25475. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25476. */
  25477. setNormalsForCPUSkinning(): Float32Array;
  25478. /**
  25479. * Updates the vertex buffer by applying transformation from the bones
  25480. * @param skeleton defines the skeleton to apply to current mesh
  25481. * @returns the current mesh
  25482. */
  25483. applySkeleton(skeleton: Skeleton): Mesh;
  25484. /**
  25485. * 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
  25486. * @param meshes defines the list of meshes to scan
  25487. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25488. */
  25489. static MinMax(meshes: AbstractMesh[]): {
  25490. min: Vector3;
  25491. max: Vector3;
  25492. };
  25493. /**
  25494. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25495. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25496. * @returns a vector3
  25497. */
  25498. static Center(meshesOrMinMaxVector: {
  25499. min: Vector3;
  25500. max: Vector3;
  25501. } | AbstractMesh[]): Vector3;
  25502. /**
  25503. * Merge the array of meshes into a single mesh for performance reasons.
  25504. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25505. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25506. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25507. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25508. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25509. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25510. * @returns a new mesh
  25511. */
  25512. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25513. /** @hidden */
  25514. addInstance(instance: InstancedMesh): void;
  25515. /** @hidden */
  25516. removeInstance(instance: InstancedMesh): void;
  25517. }
  25518. }
  25519. declare module BABYLON {
  25520. /**
  25521. * This is the base class of all the camera used in the application.
  25522. * @see http://doc.babylonjs.com/features/cameras
  25523. */
  25524. export class Camera extends Node {
  25525. /** @hidden */
  25526. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25527. /**
  25528. * This is the default projection mode used by the cameras.
  25529. * It helps recreating a feeling of perspective and better appreciate depth.
  25530. * This is the best way to simulate real life cameras.
  25531. */
  25532. static readonly PERSPECTIVE_CAMERA: number;
  25533. /**
  25534. * This helps creating camera with an orthographic mode.
  25535. * 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.
  25536. */
  25537. static readonly ORTHOGRAPHIC_CAMERA: number;
  25538. /**
  25539. * This is the default FOV mode for perspective cameras.
  25540. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25541. */
  25542. static readonly FOVMODE_VERTICAL_FIXED: number;
  25543. /**
  25544. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25545. */
  25546. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25547. /**
  25548. * This specifies ther is no need for a camera rig.
  25549. * Basically only one eye is rendered corresponding to the camera.
  25550. */
  25551. static readonly RIG_MODE_NONE: number;
  25552. /**
  25553. * Simulates a camera Rig with one blue eye and one red eye.
  25554. * This can be use with 3d blue and red glasses.
  25555. */
  25556. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25557. /**
  25558. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25559. */
  25560. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25561. /**
  25562. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25563. */
  25564. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25565. /**
  25566. * Defines that both eyes of the camera will be rendered over under each other.
  25567. */
  25568. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25569. /**
  25570. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25571. */
  25572. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25573. /**
  25574. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25575. */
  25576. static readonly RIG_MODE_VR: number;
  25577. /**
  25578. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25579. */
  25580. static readonly RIG_MODE_WEBVR: number;
  25581. /**
  25582. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25583. */
  25584. static readonly RIG_MODE_CUSTOM: number;
  25585. /**
  25586. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25587. */
  25588. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25589. /**
  25590. * Define the input manager associated with the camera.
  25591. */
  25592. inputs: CameraInputsManager<Camera>;
  25593. /** @hidden */
  25594. _position: Vector3;
  25595. /**
  25596. * Define the current local position of the camera in the scene
  25597. */
  25598. get position(): Vector3;
  25599. set position(newPosition: Vector3);
  25600. /**
  25601. * The vector the camera should consider as up.
  25602. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25603. */
  25604. upVector: Vector3;
  25605. /**
  25606. * Define the current limit on the left side for an orthographic camera
  25607. * In scene unit
  25608. */
  25609. orthoLeft: Nullable<number>;
  25610. /**
  25611. * Define the current limit on the right side for an orthographic camera
  25612. * In scene unit
  25613. */
  25614. orthoRight: Nullable<number>;
  25615. /**
  25616. * Define the current limit on the bottom side for an orthographic camera
  25617. * In scene unit
  25618. */
  25619. orthoBottom: Nullable<number>;
  25620. /**
  25621. * Define the current limit on the top side for an orthographic camera
  25622. * In scene unit
  25623. */
  25624. orthoTop: Nullable<number>;
  25625. /**
  25626. * Field Of View is set in Radians. (default is 0.8)
  25627. */
  25628. fov: number;
  25629. /**
  25630. * Define the minimum distance the camera can see from.
  25631. * This is important to note that the depth buffer are not infinite and the closer it starts
  25632. * the more your scene might encounter depth fighting issue.
  25633. */
  25634. minZ: number;
  25635. /**
  25636. * Define the maximum distance the camera can see to.
  25637. * This is important to note that the depth buffer are not infinite and the further it end
  25638. * the more your scene might encounter depth fighting issue.
  25639. */
  25640. maxZ: number;
  25641. /**
  25642. * Define the default inertia of the camera.
  25643. * This helps giving a smooth feeling to the camera movement.
  25644. */
  25645. inertia: number;
  25646. /**
  25647. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25648. */
  25649. mode: number;
  25650. /**
  25651. * Define whether the camera is intermediate.
  25652. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25653. */
  25654. isIntermediate: boolean;
  25655. /**
  25656. * Define the viewport of the camera.
  25657. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25658. */
  25659. viewport: Viewport;
  25660. /**
  25661. * Restricts the camera to viewing objects with the same layerMask.
  25662. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25663. */
  25664. layerMask: number;
  25665. /**
  25666. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25667. */
  25668. fovMode: number;
  25669. /**
  25670. * Rig mode of the camera.
  25671. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25672. * This is normally controlled byt the camera themselves as internal use.
  25673. */
  25674. cameraRigMode: number;
  25675. /**
  25676. * Defines the distance between both "eyes" in case of a RIG
  25677. */
  25678. interaxialDistance: number;
  25679. /**
  25680. * Defines if stereoscopic rendering is done side by side or over under.
  25681. */
  25682. isStereoscopicSideBySide: boolean;
  25683. /**
  25684. * 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
  25685. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25686. * else in the scene. (Eg. security camera)
  25687. *
  25688. * 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)
  25689. */
  25690. customRenderTargets: RenderTargetTexture[];
  25691. /**
  25692. * When set, the camera will render to this render target instead of the default canvas
  25693. *
  25694. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25695. */
  25696. outputRenderTarget: Nullable<RenderTargetTexture>;
  25697. /**
  25698. * Observable triggered when the camera view matrix has changed.
  25699. */
  25700. onViewMatrixChangedObservable: Observable<Camera>;
  25701. /**
  25702. * Observable triggered when the camera Projection matrix has changed.
  25703. */
  25704. onProjectionMatrixChangedObservable: Observable<Camera>;
  25705. /**
  25706. * Observable triggered when the inputs have been processed.
  25707. */
  25708. onAfterCheckInputsObservable: Observable<Camera>;
  25709. /**
  25710. * Observable triggered when reset has been called and applied to the camera.
  25711. */
  25712. onRestoreStateObservable: Observable<Camera>;
  25713. /**
  25714. * Is this camera a part of a rig system?
  25715. */
  25716. isRigCamera: boolean;
  25717. /**
  25718. * If isRigCamera set to true this will be set with the parent camera.
  25719. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25720. */
  25721. rigParent?: Camera;
  25722. /** @hidden */
  25723. _cameraRigParams: any;
  25724. /** @hidden */
  25725. _rigCameras: Camera[];
  25726. /** @hidden */
  25727. _rigPostProcess: Nullable<PostProcess>;
  25728. protected _webvrViewMatrix: Matrix;
  25729. /** @hidden */
  25730. _skipRendering: boolean;
  25731. /** @hidden */
  25732. _projectionMatrix: Matrix;
  25733. /** @hidden */
  25734. _postProcesses: Nullable<PostProcess>[];
  25735. /** @hidden */
  25736. _activeMeshes: SmartArray<AbstractMesh>;
  25737. protected _globalPosition: Vector3;
  25738. /** @hidden */
  25739. _computedViewMatrix: Matrix;
  25740. private _doNotComputeProjectionMatrix;
  25741. private _transformMatrix;
  25742. private _frustumPlanes;
  25743. private _refreshFrustumPlanes;
  25744. private _storedFov;
  25745. private _stateStored;
  25746. /**
  25747. * Instantiates a new camera object.
  25748. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25749. * @see http://doc.babylonjs.com/features/cameras
  25750. * @param name Defines the name of the camera in the scene
  25751. * @param position Defines the position of the camera
  25752. * @param scene Defines the scene the camera belongs too
  25753. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25754. */
  25755. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25756. /**
  25757. * Store current camera state (fov, position, etc..)
  25758. * @returns the camera
  25759. */
  25760. storeState(): Camera;
  25761. /**
  25762. * Restores the camera state values if it has been stored. You must call storeState() first
  25763. */
  25764. protected _restoreStateValues(): boolean;
  25765. /**
  25766. * Restored camera state. You must call storeState() first.
  25767. * @returns true if restored and false otherwise
  25768. */
  25769. restoreState(): boolean;
  25770. /**
  25771. * Gets the class name of the camera.
  25772. * @returns the class name
  25773. */
  25774. getClassName(): string;
  25775. /** @hidden */
  25776. readonly _isCamera: boolean;
  25777. /**
  25778. * Gets a string representation of the camera useful for debug purpose.
  25779. * @param fullDetails Defines that a more verboe level of logging is required
  25780. * @returns the string representation
  25781. */
  25782. toString(fullDetails?: boolean): string;
  25783. /**
  25784. * Gets the current world space position of the camera.
  25785. */
  25786. get globalPosition(): Vector3;
  25787. /**
  25788. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25789. * @returns the active meshe list
  25790. */
  25791. getActiveMeshes(): SmartArray<AbstractMesh>;
  25792. /**
  25793. * Check whether a mesh is part of the current active mesh list of the camera
  25794. * @param mesh Defines the mesh to check
  25795. * @returns true if active, false otherwise
  25796. */
  25797. isActiveMesh(mesh: Mesh): boolean;
  25798. /**
  25799. * Is this camera ready to be used/rendered
  25800. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25801. * @return true if the camera is ready
  25802. */
  25803. isReady(completeCheck?: boolean): boolean;
  25804. /** @hidden */
  25805. _initCache(): void;
  25806. /** @hidden */
  25807. _updateCache(ignoreParentClass?: boolean): void;
  25808. /** @hidden */
  25809. _isSynchronized(): boolean;
  25810. /** @hidden */
  25811. _isSynchronizedViewMatrix(): boolean;
  25812. /** @hidden */
  25813. _isSynchronizedProjectionMatrix(): boolean;
  25814. /**
  25815. * Attach the input controls to a specific dom element to get the input from.
  25816. * @param element Defines the element the controls should be listened from
  25817. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25818. */
  25819. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25820. /**
  25821. * Detach the current controls from the specified dom element.
  25822. * @param element Defines the element to stop listening the inputs from
  25823. */
  25824. detachControl(element: HTMLElement): void;
  25825. /**
  25826. * Update the camera state according to the different inputs gathered during the frame.
  25827. */
  25828. update(): void;
  25829. /** @hidden */
  25830. _checkInputs(): void;
  25831. /** @hidden */
  25832. get rigCameras(): Camera[];
  25833. /**
  25834. * Gets the post process used by the rig cameras
  25835. */
  25836. get rigPostProcess(): Nullable<PostProcess>;
  25837. /**
  25838. * Internal, gets the first post proces.
  25839. * @returns the first post process to be run on this camera.
  25840. */
  25841. _getFirstPostProcess(): Nullable<PostProcess>;
  25842. private _cascadePostProcessesToRigCams;
  25843. /**
  25844. * Attach a post process to the camera.
  25845. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25846. * @param postProcess The post process to attach to the camera
  25847. * @param insertAt The position of the post process in case several of them are in use in the scene
  25848. * @returns the position the post process has been inserted at
  25849. */
  25850. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25851. /**
  25852. * Detach a post process to the camera.
  25853. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25854. * @param postProcess The post process to detach from the camera
  25855. */
  25856. detachPostProcess(postProcess: PostProcess): void;
  25857. /**
  25858. * Gets the current world matrix of the camera
  25859. */
  25860. getWorldMatrix(): Matrix;
  25861. /** @hidden */
  25862. _getViewMatrix(): Matrix;
  25863. /**
  25864. * Gets the current view matrix of the camera.
  25865. * @param force forces the camera to recompute the matrix without looking at the cached state
  25866. * @returns the view matrix
  25867. */
  25868. getViewMatrix(force?: boolean): Matrix;
  25869. /**
  25870. * Freeze the projection matrix.
  25871. * It will prevent the cache check of the camera projection compute and can speed up perf
  25872. * if no parameter of the camera are meant to change
  25873. * @param projection Defines manually a projection if necessary
  25874. */
  25875. freezeProjectionMatrix(projection?: Matrix): void;
  25876. /**
  25877. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25878. */
  25879. unfreezeProjectionMatrix(): void;
  25880. /**
  25881. * Gets the current projection matrix of the camera.
  25882. * @param force forces the camera to recompute the matrix without looking at the cached state
  25883. * @returns the projection matrix
  25884. */
  25885. getProjectionMatrix(force?: boolean): Matrix;
  25886. /**
  25887. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25888. * @returns a Matrix
  25889. */
  25890. getTransformationMatrix(): Matrix;
  25891. private _updateFrustumPlanes;
  25892. /**
  25893. * Checks if a cullable object (mesh...) is in the camera frustum
  25894. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25895. * @param target The object to check
  25896. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25897. * @returns true if the object is in frustum otherwise false
  25898. */
  25899. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25900. /**
  25901. * Checks if a cullable object (mesh...) is in the camera frustum
  25902. * Unlike isInFrustum this cheks the full bounding box
  25903. * @param target The object to check
  25904. * @returns true if the object is in frustum otherwise false
  25905. */
  25906. isCompletelyInFrustum(target: ICullable): boolean;
  25907. /**
  25908. * Gets a ray in the forward direction from the camera.
  25909. * @param length Defines the length of the ray to create
  25910. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25911. * @param origin Defines the start point of the ray which defaults to the camera position
  25912. * @returns the forward ray
  25913. */
  25914. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25915. /**
  25916. * Releases resources associated with this node.
  25917. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25918. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25919. */
  25920. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25921. /** @hidden */
  25922. _isLeftCamera: boolean;
  25923. /**
  25924. * Gets the left camera of a rig setup in case of Rigged Camera
  25925. */
  25926. get isLeftCamera(): boolean;
  25927. /** @hidden */
  25928. _isRightCamera: boolean;
  25929. /**
  25930. * Gets the right camera of a rig setup in case of Rigged Camera
  25931. */
  25932. get isRightCamera(): boolean;
  25933. /**
  25934. * Gets the left camera of a rig setup in case of Rigged Camera
  25935. */
  25936. get leftCamera(): Nullable<FreeCamera>;
  25937. /**
  25938. * Gets the right camera of a rig setup in case of Rigged Camera
  25939. */
  25940. get rightCamera(): Nullable<FreeCamera>;
  25941. /**
  25942. * Gets the left camera target of a rig setup in case of Rigged Camera
  25943. * @returns the target position
  25944. */
  25945. getLeftTarget(): Nullable<Vector3>;
  25946. /**
  25947. * Gets the right camera target of a rig setup in case of Rigged Camera
  25948. * @returns the target position
  25949. */
  25950. getRightTarget(): Nullable<Vector3>;
  25951. /**
  25952. * @hidden
  25953. */
  25954. setCameraRigMode(mode: number, rigParams: any): void;
  25955. /** @hidden */
  25956. static _setStereoscopicRigMode(camera: Camera): void;
  25957. /** @hidden */
  25958. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25959. /** @hidden */
  25960. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25961. /** @hidden */
  25962. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25963. /** @hidden */
  25964. _getVRProjectionMatrix(): Matrix;
  25965. protected _updateCameraRotationMatrix(): void;
  25966. protected _updateWebVRCameraRotationMatrix(): void;
  25967. /**
  25968. * This function MUST be overwritten by the different WebVR cameras available.
  25969. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25970. * @hidden
  25971. */
  25972. _getWebVRProjectionMatrix(): Matrix;
  25973. /**
  25974. * This function MUST be overwritten by the different WebVR cameras available.
  25975. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25976. * @hidden
  25977. */
  25978. _getWebVRViewMatrix(): Matrix;
  25979. /** @hidden */
  25980. setCameraRigParameter(name: string, value: any): void;
  25981. /**
  25982. * needs to be overridden by children so sub has required properties to be copied
  25983. * @hidden
  25984. */
  25985. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25986. /**
  25987. * May need to be overridden by children
  25988. * @hidden
  25989. */
  25990. _updateRigCameras(): void;
  25991. /** @hidden */
  25992. _setupInputs(): void;
  25993. /**
  25994. * Serialiaze the camera setup to a json represention
  25995. * @returns the JSON representation
  25996. */
  25997. serialize(): any;
  25998. /**
  25999. * Clones the current camera.
  26000. * @param name The cloned camera name
  26001. * @returns the cloned camera
  26002. */
  26003. clone(name: string): Camera;
  26004. /**
  26005. * Gets the direction of the camera relative to a given local axis.
  26006. * @param localAxis Defines the reference axis to provide a relative direction.
  26007. * @return the direction
  26008. */
  26009. getDirection(localAxis: Vector3): Vector3;
  26010. /**
  26011. * Returns the current camera absolute rotation
  26012. */
  26013. get absoluteRotation(): Quaternion;
  26014. /**
  26015. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26016. * @param localAxis Defines the reference axis to provide a relative direction.
  26017. * @param result Defines the vector to store the result in
  26018. */
  26019. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26020. /**
  26021. * Gets a camera constructor for a given camera type
  26022. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26023. * @param name The name of the camera the result will be able to instantiate
  26024. * @param scene The scene the result will construct the camera in
  26025. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26026. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26027. * @returns a factory method to construc the camera
  26028. */
  26029. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26030. /**
  26031. * Compute the world matrix of the camera.
  26032. * @returns the camera world matrix
  26033. */
  26034. computeWorldMatrix(): Matrix;
  26035. /**
  26036. * Parse a JSON and creates the camera from the parsed information
  26037. * @param parsedCamera The JSON to parse
  26038. * @param scene The scene to instantiate the camera in
  26039. * @returns the newly constructed camera
  26040. */
  26041. static Parse(parsedCamera: any, scene: Scene): Camera;
  26042. }
  26043. }
  26044. declare module BABYLON {
  26045. /**
  26046. * Class containing static functions to help procedurally build meshes
  26047. */
  26048. export class DiscBuilder {
  26049. /**
  26050. * Creates a plane polygonal mesh. By default, this is a disc
  26051. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26052. * * 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
  26053. * * 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
  26054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26055. * * 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
  26056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26057. * @param name defines the name of the mesh
  26058. * @param options defines the options used to create the mesh
  26059. * @param scene defines the hosting scene
  26060. * @returns the plane polygonal mesh
  26061. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26062. */
  26063. static CreateDisc(name: string, options: {
  26064. radius?: number;
  26065. tessellation?: number;
  26066. arc?: number;
  26067. updatable?: boolean;
  26068. sideOrientation?: number;
  26069. frontUVs?: Vector4;
  26070. backUVs?: Vector4;
  26071. }, scene?: Nullable<Scene>): Mesh;
  26072. }
  26073. }
  26074. declare module BABYLON {
  26075. /**
  26076. * Options to be used when creating a FresnelParameters.
  26077. */
  26078. export type IFresnelParametersCreationOptions = {
  26079. /**
  26080. * Define the color used on edges (grazing angle)
  26081. */
  26082. leftColor?: Color3;
  26083. /**
  26084. * Define the color used on center
  26085. */
  26086. rightColor?: Color3;
  26087. /**
  26088. * Define bias applied to computed fresnel term
  26089. */
  26090. bias?: number;
  26091. /**
  26092. * Defined the power exponent applied to fresnel term
  26093. */
  26094. power?: number;
  26095. /**
  26096. * Define if the fresnel effect is enable or not.
  26097. */
  26098. isEnabled?: boolean;
  26099. };
  26100. /**
  26101. * Serialized format for FresnelParameters.
  26102. */
  26103. export type IFresnelParametersSerialized = {
  26104. /**
  26105. * Define the color used on edges (grazing angle) [as an array]
  26106. */
  26107. leftColor: number[];
  26108. /**
  26109. * Define the color used on center [as an array]
  26110. */
  26111. rightColor: number[];
  26112. /**
  26113. * Define bias applied to computed fresnel term
  26114. */
  26115. bias: number;
  26116. /**
  26117. * Defined the power exponent applied to fresnel term
  26118. */
  26119. power?: number;
  26120. /**
  26121. * Define if the fresnel effect is enable or not.
  26122. */
  26123. isEnabled: boolean;
  26124. };
  26125. /**
  26126. * This represents all the required information to add a fresnel effect on a material:
  26127. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26128. */
  26129. export class FresnelParameters {
  26130. private _isEnabled;
  26131. /**
  26132. * Define if the fresnel effect is enable or not.
  26133. */
  26134. get isEnabled(): boolean;
  26135. set isEnabled(value: boolean);
  26136. /**
  26137. * Define the color used on edges (grazing angle)
  26138. */
  26139. leftColor: Color3;
  26140. /**
  26141. * Define the color used on center
  26142. */
  26143. rightColor: Color3;
  26144. /**
  26145. * Define bias applied to computed fresnel term
  26146. */
  26147. bias: number;
  26148. /**
  26149. * Defined the power exponent applied to fresnel term
  26150. */
  26151. power: number;
  26152. /**
  26153. * Creates a new FresnelParameters object.
  26154. *
  26155. * @param options provide your own settings to optionally to override defaults
  26156. */
  26157. constructor(options?: IFresnelParametersCreationOptions);
  26158. /**
  26159. * Clones the current fresnel and its valuues
  26160. * @returns a clone fresnel configuration
  26161. */
  26162. clone(): FresnelParameters;
  26163. /**
  26164. * Determines equality between FresnelParameters objects
  26165. * @param otherFresnelParameters defines the second operand
  26166. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26167. */
  26168. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26169. /**
  26170. * Serializes the current fresnel parameters to a JSON representation.
  26171. * @return the JSON serialization
  26172. */
  26173. serialize(): IFresnelParametersSerialized;
  26174. /**
  26175. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26176. * @param parsedFresnelParameters Define the JSON representation
  26177. * @returns the parsed parameters
  26178. */
  26179. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26180. }
  26181. }
  26182. declare module BABYLON {
  26183. /**
  26184. * Base class of materials working in push mode in babylon JS
  26185. * @hidden
  26186. */
  26187. export class PushMaterial extends Material {
  26188. protected _activeEffect: Effect;
  26189. protected _normalMatrix: Matrix;
  26190. /**
  26191. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26192. * This means that the material can keep using a previous shader while a new one is being compiled.
  26193. * This is mostly used when shader parallel compilation is supported (true by default)
  26194. */
  26195. allowShaderHotSwapping: boolean;
  26196. constructor(name: string, scene: Scene);
  26197. getEffect(): Effect;
  26198. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26199. /**
  26200. * Binds the given world matrix to the active effect
  26201. *
  26202. * @param world the matrix to bind
  26203. */
  26204. bindOnlyWorldMatrix(world: Matrix): void;
  26205. /**
  26206. * Binds the given normal matrix to the active effect
  26207. *
  26208. * @param normalMatrix the matrix to bind
  26209. */
  26210. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26211. bind(world: Matrix, mesh?: Mesh): void;
  26212. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26213. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26214. }
  26215. }
  26216. declare module BABYLON {
  26217. /**
  26218. * This groups all the flags used to control the materials channel.
  26219. */
  26220. export class MaterialFlags {
  26221. private static _DiffuseTextureEnabled;
  26222. /**
  26223. * Are diffuse textures enabled in the application.
  26224. */
  26225. static get DiffuseTextureEnabled(): boolean;
  26226. static set DiffuseTextureEnabled(value: boolean);
  26227. private static _AmbientTextureEnabled;
  26228. /**
  26229. * Are ambient textures enabled in the application.
  26230. */
  26231. static get AmbientTextureEnabled(): boolean;
  26232. static set AmbientTextureEnabled(value: boolean);
  26233. private static _OpacityTextureEnabled;
  26234. /**
  26235. * Are opacity textures enabled in the application.
  26236. */
  26237. static get OpacityTextureEnabled(): boolean;
  26238. static set OpacityTextureEnabled(value: boolean);
  26239. private static _ReflectionTextureEnabled;
  26240. /**
  26241. * Are reflection textures enabled in the application.
  26242. */
  26243. static get ReflectionTextureEnabled(): boolean;
  26244. static set ReflectionTextureEnabled(value: boolean);
  26245. private static _EmissiveTextureEnabled;
  26246. /**
  26247. * Are emissive textures enabled in the application.
  26248. */
  26249. static get EmissiveTextureEnabled(): boolean;
  26250. static set EmissiveTextureEnabled(value: boolean);
  26251. private static _SpecularTextureEnabled;
  26252. /**
  26253. * Are specular textures enabled in the application.
  26254. */
  26255. static get SpecularTextureEnabled(): boolean;
  26256. static set SpecularTextureEnabled(value: boolean);
  26257. private static _BumpTextureEnabled;
  26258. /**
  26259. * Are bump textures enabled in the application.
  26260. */
  26261. static get BumpTextureEnabled(): boolean;
  26262. static set BumpTextureEnabled(value: boolean);
  26263. private static _LightmapTextureEnabled;
  26264. /**
  26265. * Are lightmap textures enabled in the application.
  26266. */
  26267. static get LightmapTextureEnabled(): boolean;
  26268. static set LightmapTextureEnabled(value: boolean);
  26269. private static _RefractionTextureEnabled;
  26270. /**
  26271. * Are refraction textures enabled in the application.
  26272. */
  26273. static get RefractionTextureEnabled(): boolean;
  26274. static set RefractionTextureEnabled(value: boolean);
  26275. private static _ColorGradingTextureEnabled;
  26276. /**
  26277. * Are color grading textures enabled in the application.
  26278. */
  26279. static get ColorGradingTextureEnabled(): boolean;
  26280. static set ColorGradingTextureEnabled(value: boolean);
  26281. private static _FresnelEnabled;
  26282. /**
  26283. * Are fresnels enabled in the application.
  26284. */
  26285. static get FresnelEnabled(): boolean;
  26286. static set FresnelEnabled(value: boolean);
  26287. private static _ClearCoatTextureEnabled;
  26288. /**
  26289. * Are clear coat textures enabled in the application.
  26290. */
  26291. static get ClearCoatTextureEnabled(): boolean;
  26292. static set ClearCoatTextureEnabled(value: boolean);
  26293. private static _ClearCoatBumpTextureEnabled;
  26294. /**
  26295. * Are clear coat bump textures enabled in the application.
  26296. */
  26297. static get ClearCoatBumpTextureEnabled(): boolean;
  26298. static set ClearCoatBumpTextureEnabled(value: boolean);
  26299. private static _ClearCoatTintTextureEnabled;
  26300. /**
  26301. * Are clear coat tint textures enabled in the application.
  26302. */
  26303. static get ClearCoatTintTextureEnabled(): boolean;
  26304. static set ClearCoatTintTextureEnabled(value: boolean);
  26305. private static _SheenTextureEnabled;
  26306. /**
  26307. * Are sheen textures enabled in the application.
  26308. */
  26309. static get SheenTextureEnabled(): boolean;
  26310. static set SheenTextureEnabled(value: boolean);
  26311. private static _AnisotropicTextureEnabled;
  26312. /**
  26313. * Are anisotropic textures enabled in the application.
  26314. */
  26315. static get AnisotropicTextureEnabled(): boolean;
  26316. static set AnisotropicTextureEnabled(value: boolean);
  26317. private static _ThicknessTextureEnabled;
  26318. /**
  26319. * Are thickness textures enabled in the application.
  26320. */
  26321. static get ThicknessTextureEnabled(): boolean;
  26322. static set ThicknessTextureEnabled(value: boolean);
  26323. }
  26324. }
  26325. declare module BABYLON {
  26326. /** @hidden */
  26327. export var defaultFragmentDeclaration: {
  26328. name: string;
  26329. shader: string;
  26330. };
  26331. }
  26332. declare module BABYLON {
  26333. /** @hidden */
  26334. export var defaultUboDeclaration: {
  26335. name: string;
  26336. shader: string;
  26337. };
  26338. }
  26339. declare module BABYLON {
  26340. /** @hidden */
  26341. export var lightFragmentDeclaration: {
  26342. name: string;
  26343. shader: string;
  26344. };
  26345. }
  26346. declare module BABYLON {
  26347. /** @hidden */
  26348. export var lightUboDeclaration: {
  26349. name: string;
  26350. shader: string;
  26351. };
  26352. }
  26353. declare module BABYLON {
  26354. /** @hidden */
  26355. export var lightsFragmentFunctions: {
  26356. name: string;
  26357. shader: string;
  26358. };
  26359. }
  26360. declare module BABYLON {
  26361. /** @hidden */
  26362. export var shadowsFragmentFunctions: {
  26363. name: string;
  26364. shader: string;
  26365. };
  26366. }
  26367. declare module BABYLON {
  26368. /** @hidden */
  26369. export var fresnelFunction: {
  26370. name: string;
  26371. shader: string;
  26372. };
  26373. }
  26374. declare module BABYLON {
  26375. /** @hidden */
  26376. export var reflectionFunction: {
  26377. name: string;
  26378. shader: string;
  26379. };
  26380. }
  26381. declare module BABYLON {
  26382. /** @hidden */
  26383. export var bumpFragmentFunctions: {
  26384. name: string;
  26385. shader: string;
  26386. };
  26387. }
  26388. declare module BABYLON {
  26389. /** @hidden */
  26390. export var logDepthDeclaration: {
  26391. name: string;
  26392. shader: string;
  26393. };
  26394. }
  26395. declare module BABYLON {
  26396. /** @hidden */
  26397. export var bumpFragment: {
  26398. name: string;
  26399. shader: string;
  26400. };
  26401. }
  26402. declare module BABYLON {
  26403. /** @hidden */
  26404. export var depthPrePass: {
  26405. name: string;
  26406. shader: string;
  26407. };
  26408. }
  26409. declare module BABYLON {
  26410. /** @hidden */
  26411. export var lightFragment: {
  26412. name: string;
  26413. shader: string;
  26414. };
  26415. }
  26416. declare module BABYLON {
  26417. /** @hidden */
  26418. export var logDepthFragment: {
  26419. name: string;
  26420. shader: string;
  26421. };
  26422. }
  26423. declare module BABYLON {
  26424. /** @hidden */
  26425. export var defaultPixelShader: {
  26426. name: string;
  26427. shader: string;
  26428. };
  26429. }
  26430. declare module BABYLON {
  26431. /** @hidden */
  26432. export var defaultVertexDeclaration: {
  26433. name: string;
  26434. shader: string;
  26435. };
  26436. }
  26437. declare module BABYLON {
  26438. /** @hidden */
  26439. export var bumpVertexDeclaration: {
  26440. name: string;
  26441. shader: string;
  26442. };
  26443. }
  26444. declare module BABYLON {
  26445. /** @hidden */
  26446. export var bumpVertex: {
  26447. name: string;
  26448. shader: string;
  26449. };
  26450. }
  26451. declare module BABYLON {
  26452. /** @hidden */
  26453. export var fogVertex: {
  26454. name: string;
  26455. shader: string;
  26456. };
  26457. }
  26458. declare module BABYLON {
  26459. /** @hidden */
  26460. export var shadowsVertex: {
  26461. name: string;
  26462. shader: string;
  26463. };
  26464. }
  26465. declare module BABYLON {
  26466. /** @hidden */
  26467. export var pointCloudVertex: {
  26468. name: string;
  26469. shader: string;
  26470. };
  26471. }
  26472. declare module BABYLON {
  26473. /** @hidden */
  26474. export var logDepthVertex: {
  26475. name: string;
  26476. shader: string;
  26477. };
  26478. }
  26479. declare module BABYLON {
  26480. /** @hidden */
  26481. export var defaultVertexShader: {
  26482. name: string;
  26483. shader: string;
  26484. };
  26485. }
  26486. declare module BABYLON {
  26487. /** @hidden */
  26488. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26489. MAINUV1: boolean;
  26490. MAINUV2: boolean;
  26491. DIFFUSE: boolean;
  26492. DIFFUSEDIRECTUV: number;
  26493. AMBIENT: boolean;
  26494. AMBIENTDIRECTUV: number;
  26495. OPACITY: boolean;
  26496. OPACITYDIRECTUV: number;
  26497. OPACITYRGB: boolean;
  26498. REFLECTION: boolean;
  26499. EMISSIVE: boolean;
  26500. EMISSIVEDIRECTUV: number;
  26501. SPECULAR: boolean;
  26502. SPECULARDIRECTUV: number;
  26503. BUMP: boolean;
  26504. BUMPDIRECTUV: number;
  26505. PARALLAX: boolean;
  26506. PARALLAXOCCLUSION: boolean;
  26507. SPECULAROVERALPHA: boolean;
  26508. CLIPPLANE: boolean;
  26509. CLIPPLANE2: boolean;
  26510. CLIPPLANE3: boolean;
  26511. CLIPPLANE4: boolean;
  26512. CLIPPLANE5: boolean;
  26513. CLIPPLANE6: boolean;
  26514. ALPHATEST: boolean;
  26515. DEPTHPREPASS: boolean;
  26516. ALPHAFROMDIFFUSE: boolean;
  26517. POINTSIZE: boolean;
  26518. FOG: boolean;
  26519. SPECULARTERM: boolean;
  26520. DIFFUSEFRESNEL: boolean;
  26521. OPACITYFRESNEL: boolean;
  26522. REFLECTIONFRESNEL: boolean;
  26523. REFRACTIONFRESNEL: boolean;
  26524. EMISSIVEFRESNEL: boolean;
  26525. FRESNEL: boolean;
  26526. NORMAL: boolean;
  26527. UV1: boolean;
  26528. UV2: boolean;
  26529. VERTEXCOLOR: boolean;
  26530. VERTEXALPHA: boolean;
  26531. NUM_BONE_INFLUENCERS: number;
  26532. BonesPerMesh: number;
  26533. BONETEXTURE: boolean;
  26534. INSTANCES: boolean;
  26535. GLOSSINESS: boolean;
  26536. ROUGHNESS: boolean;
  26537. EMISSIVEASILLUMINATION: boolean;
  26538. LINKEMISSIVEWITHDIFFUSE: boolean;
  26539. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26540. LIGHTMAP: boolean;
  26541. LIGHTMAPDIRECTUV: number;
  26542. OBJECTSPACE_NORMALMAP: boolean;
  26543. USELIGHTMAPASSHADOWMAP: boolean;
  26544. REFLECTIONMAP_3D: boolean;
  26545. REFLECTIONMAP_SPHERICAL: boolean;
  26546. REFLECTIONMAP_PLANAR: boolean;
  26547. REFLECTIONMAP_CUBIC: boolean;
  26548. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26549. REFLECTIONMAP_PROJECTION: boolean;
  26550. REFLECTIONMAP_SKYBOX: boolean;
  26551. REFLECTIONMAP_EXPLICIT: boolean;
  26552. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26553. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26554. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26555. INVERTCUBICMAP: boolean;
  26556. LOGARITHMICDEPTH: boolean;
  26557. REFRACTION: boolean;
  26558. REFRACTIONMAP_3D: boolean;
  26559. REFLECTIONOVERALPHA: boolean;
  26560. TWOSIDEDLIGHTING: boolean;
  26561. SHADOWFLOAT: boolean;
  26562. MORPHTARGETS: boolean;
  26563. MORPHTARGETS_NORMAL: boolean;
  26564. MORPHTARGETS_TANGENT: boolean;
  26565. MORPHTARGETS_UV: boolean;
  26566. NUM_MORPH_INFLUENCERS: number;
  26567. NONUNIFORMSCALING: boolean;
  26568. PREMULTIPLYALPHA: boolean;
  26569. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26570. ALPHABLEND: boolean;
  26571. IMAGEPROCESSING: boolean;
  26572. VIGNETTE: boolean;
  26573. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26574. VIGNETTEBLENDMODEOPAQUE: boolean;
  26575. TONEMAPPING: boolean;
  26576. TONEMAPPING_ACES: boolean;
  26577. CONTRAST: boolean;
  26578. COLORCURVES: boolean;
  26579. COLORGRADING: boolean;
  26580. COLORGRADING3D: boolean;
  26581. SAMPLER3DGREENDEPTH: boolean;
  26582. SAMPLER3DBGRMAP: boolean;
  26583. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26584. MULTIVIEW: boolean;
  26585. /**
  26586. * If the reflection texture on this material is in linear color space
  26587. * @hidden
  26588. */
  26589. IS_REFLECTION_LINEAR: boolean;
  26590. /**
  26591. * If the refraction texture on this material is in linear color space
  26592. * @hidden
  26593. */
  26594. IS_REFRACTION_LINEAR: boolean;
  26595. EXPOSURE: boolean;
  26596. constructor();
  26597. setReflectionMode(modeToEnable: string): void;
  26598. }
  26599. /**
  26600. * This is the default material used in Babylon. It is the best trade off between quality
  26601. * and performances.
  26602. * @see http://doc.babylonjs.com/babylon101/materials
  26603. */
  26604. export class StandardMaterial extends PushMaterial {
  26605. private _diffuseTexture;
  26606. /**
  26607. * The basic texture of the material as viewed under a light.
  26608. */
  26609. diffuseTexture: Nullable<BaseTexture>;
  26610. private _ambientTexture;
  26611. /**
  26612. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26613. */
  26614. ambientTexture: Nullable<BaseTexture>;
  26615. private _opacityTexture;
  26616. /**
  26617. * Define the transparency of the material from a texture.
  26618. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26619. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26620. */
  26621. opacityTexture: Nullable<BaseTexture>;
  26622. private _reflectionTexture;
  26623. /**
  26624. * Define the texture used to display the reflection.
  26625. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26626. */
  26627. reflectionTexture: Nullable<BaseTexture>;
  26628. private _emissiveTexture;
  26629. /**
  26630. * Define texture of the material as if self lit.
  26631. * This will be mixed in the final result even in the absence of light.
  26632. */
  26633. emissiveTexture: Nullable<BaseTexture>;
  26634. private _specularTexture;
  26635. /**
  26636. * Define how the color and intensity of the highlight given by the light in the material.
  26637. */
  26638. specularTexture: Nullable<BaseTexture>;
  26639. private _bumpTexture;
  26640. /**
  26641. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26642. * 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.
  26643. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26644. */
  26645. bumpTexture: Nullable<BaseTexture>;
  26646. private _lightmapTexture;
  26647. /**
  26648. * Complex lighting can be computationally expensive to compute at runtime.
  26649. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26650. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26651. */
  26652. lightmapTexture: Nullable<BaseTexture>;
  26653. private _refractionTexture;
  26654. /**
  26655. * Define the texture used to display the refraction.
  26656. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26657. */
  26658. refractionTexture: Nullable<BaseTexture>;
  26659. /**
  26660. * The color of the material lit by the environmental background lighting.
  26661. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26662. */
  26663. ambientColor: Color3;
  26664. /**
  26665. * The basic color of the material as viewed under a light.
  26666. */
  26667. diffuseColor: Color3;
  26668. /**
  26669. * Define how the color and intensity of the highlight given by the light in the material.
  26670. */
  26671. specularColor: Color3;
  26672. /**
  26673. * Define the color of the material as if self lit.
  26674. * This will be mixed in the final result even in the absence of light.
  26675. */
  26676. emissiveColor: Color3;
  26677. /**
  26678. * Defines how sharp are the highlights in the material.
  26679. * The bigger the value the sharper giving a more glossy feeling to the result.
  26680. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26681. */
  26682. specularPower: number;
  26683. private _useAlphaFromDiffuseTexture;
  26684. /**
  26685. * Does the transparency come from the diffuse texture alpha channel.
  26686. */
  26687. useAlphaFromDiffuseTexture: boolean;
  26688. private _useEmissiveAsIllumination;
  26689. /**
  26690. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26691. */
  26692. useEmissiveAsIllumination: boolean;
  26693. private _linkEmissiveWithDiffuse;
  26694. /**
  26695. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26696. * the emissive level when the final color is close to one.
  26697. */
  26698. linkEmissiveWithDiffuse: boolean;
  26699. private _useSpecularOverAlpha;
  26700. /**
  26701. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26702. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26703. */
  26704. useSpecularOverAlpha: boolean;
  26705. private _useReflectionOverAlpha;
  26706. /**
  26707. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26708. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26709. */
  26710. useReflectionOverAlpha: boolean;
  26711. private _disableLighting;
  26712. /**
  26713. * Does lights from the scene impacts this material.
  26714. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26715. */
  26716. disableLighting: boolean;
  26717. private _useObjectSpaceNormalMap;
  26718. /**
  26719. * Allows using an object space normal map (instead of tangent space).
  26720. */
  26721. useObjectSpaceNormalMap: boolean;
  26722. private _useParallax;
  26723. /**
  26724. * Is parallax enabled or not.
  26725. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26726. */
  26727. useParallax: boolean;
  26728. private _useParallaxOcclusion;
  26729. /**
  26730. * Is parallax occlusion enabled or not.
  26731. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26732. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26733. */
  26734. useParallaxOcclusion: boolean;
  26735. /**
  26736. * 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.
  26737. */
  26738. parallaxScaleBias: number;
  26739. private _roughness;
  26740. /**
  26741. * Helps to define how blurry the reflections should appears in the material.
  26742. */
  26743. roughness: number;
  26744. /**
  26745. * In case of refraction, define the value of the index of refraction.
  26746. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26747. */
  26748. indexOfRefraction: number;
  26749. /**
  26750. * Invert the refraction texture alongside the y axis.
  26751. * It can be useful with procedural textures or probe for instance.
  26752. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26753. */
  26754. invertRefractionY: boolean;
  26755. /**
  26756. * Defines the alpha limits in alpha test mode.
  26757. */
  26758. alphaCutOff: number;
  26759. private _useLightmapAsShadowmap;
  26760. /**
  26761. * In case of light mapping, define whether the map contains light or shadow informations.
  26762. */
  26763. useLightmapAsShadowmap: boolean;
  26764. private _diffuseFresnelParameters;
  26765. /**
  26766. * Define the diffuse fresnel parameters of the material.
  26767. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26768. */
  26769. diffuseFresnelParameters: FresnelParameters;
  26770. private _opacityFresnelParameters;
  26771. /**
  26772. * Define the opacity fresnel parameters of the material.
  26773. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26774. */
  26775. opacityFresnelParameters: FresnelParameters;
  26776. private _reflectionFresnelParameters;
  26777. /**
  26778. * Define the reflection fresnel parameters of the material.
  26779. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26780. */
  26781. reflectionFresnelParameters: FresnelParameters;
  26782. private _refractionFresnelParameters;
  26783. /**
  26784. * Define the refraction fresnel parameters of the material.
  26785. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26786. */
  26787. refractionFresnelParameters: FresnelParameters;
  26788. private _emissiveFresnelParameters;
  26789. /**
  26790. * Define the emissive fresnel parameters of the material.
  26791. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26792. */
  26793. emissiveFresnelParameters: FresnelParameters;
  26794. private _useReflectionFresnelFromSpecular;
  26795. /**
  26796. * If true automatically deducts the fresnels values from the material specularity.
  26797. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26798. */
  26799. useReflectionFresnelFromSpecular: boolean;
  26800. private _useGlossinessFromSpecularMapAlpha;
  26801. /**
  26802. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26803. */
  26804. useGlossinessFromSpecularMapAlpha: boolean;
  26805. private _maxSimultaneousLights;
  26806. /**
  26807. * Defines the maximum number of lights that can be used in the material
  26808. */
  26809. maxSimultaneousLights: number;
  26810. private _invertNormalMapX;
  26811. /**
  26812. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26813. */
  26814. invertNormalMapX: boolean;
  26815. private _invertNormalMapY;
  26816. /**
  26817. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26818. */
  26819. invertNormalMapY: boolean;
  26820. private _twoSidedLighting;
  26821. /**
  26822. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26823. */
  26824. twoSidedLighting: boolean;
  26825. /**
  26826. * Default configuration related to image processing available in the standard Material.
  26827. */
  26828. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26829. /**
  26830. * Gets the image processing configuration used either in this material.
  26831. */
  26832. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26833. /**
  26834. * Sets the Default image processing configuration used either in the this material.
  26835. *
  26836. * If sets to null, the scene one is in use.
  26837. */
  26838. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26839. /**
  26840. * Keep track of the image processing observer to allow dispose and replace.
  26841. */
  26842. private _imageProcessingObserver;
  26843. /**
  26844. * Attaches a new image processing configuration to the Standard Material.
  26845. * @param configuration
  26846. */
  26847. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26848. /**
  26849. * Gets wether the color curves effect is enabled.
  26850. */
  26851. get cameraColorCurvesEnabled(): boolean;
  26852. /**
  26853. * Sets wether the color curves effect is enabled.
  26854. */
  26855. set cameraColorCurvesEnabled(value: boolean);
  26856. /**
  26857. * Gets wether the color grading effect is enabled.
  26858. */
  26859. get cameraColorGradingEnabled(): boolean;
  26860. /**
  26861. * Gets wether the color grading effect is enabled.
  26862. */
  26863. set cameraColorGradingEnabled(value: boolean);
  26864. /**
  26865. * Gets wether tonemapping is enabled or not.
  26866. */
  26867. get cameraToneMappingEnabled(): boolean;
  26868. /**
  26869. * Sets wether tonemapping is enabled or not
  26870. */
  26871. set cameraToneMappingEnabled(value: boolean);
  26872. /**
  26873. * The camera exposure used on this material.
  26874. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26875. * This corresponds to a photographic exposure.
  26876. */
  26877. get cameraExposure(): number;
  26878. /**
  26879. * The camera exposure used on this material.
  26880. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26881. * This corresponds to a photographic exposure.
  26882. */
  26883. set cameraExposure(value: number);
  26884. /**
  26885. * Gets The camera contrast used on this material.
  26886. */
  26887. get cameraContrast(): number;
  26888. /**
  26889. * Sets The camera contrast used on this material.
  26890. */
  26891. set cameraContrast(value: number);
  26892. /**
  26893. * Gets the Color Grading 2D Lookup Texture.
  26894. */
  26895. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26896. /**
  26897. * Sets the Color Grading 2D Lookup Texture.
  26898. */
  26899. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26900. /**
  26901. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26902. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26903. * 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;
  26904. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26905. */
  26906. get cameraColorCurves(): Nullable<ColorCurves>;
  26907. /**
  26908. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26909. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26910. * 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;
  26911. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26912. */
  26913. set cameraColorCurves(value: Nullable<ColorCurves>);
  26914. /**
  26915. * Custom callback helping to override the default shader used in the material.
  26916. */
  26917. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26918. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26919. protected _worldViewProjectionMatrix: Matrix;
  26920. protected _globalAmbientColor: Color3;
  26921. protected _useLogarithmicDepth: boolean;
  26922. protected _rebuildInParallel: boolean;
  26923. /**
  26924. * Instantiates a new standard material.
  26925. * This is the default material used in Babylon. It is the best trade off between quality
  26926. * and performances.
  26927. * @see http://doc.babylonjs.com/babylon101/materials
  26928. * @param name Define the name of the material in the scene
  26929. * @param scene Define the scene the material belong to
  26930. */
  26931. constructor(name: string, scene: Scene);
  26932. /**
  26933. * Gets a boolean indicating that current material needs to register RTT
  26934. */
  26935. get hasRenderTargetTextures(): boolean;
  26936. /**
  26937. * Gets the current class name of the material e.g. "StandardMaterial"
  26938. * Mainly use in serialization.
  26939. * @returns the class name
  26940. */
  26941. getClassName(): string;
  26942. /**
  26943. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26944. * You can try switching to logarithmic depth.
  26945. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26946. */
  26947. get useLogarithmicDepth(): boolean;
  26948. set useLogarithmicDepth(value: boolean);
  26949. /**
  26950. * Specifies if the material will require alpha blending
  26951. * @returns a boolean specifying if alpha blending is needed
  26952. */
  26953. needAlphaBlending(): boolean;
  26954. /**
  26955. * Specifies if this material should be rendered in alpha test mode
  26956. * @returns a boolean specifying if an alpha test is needed.
  26957. */
  26958. needAlphaTesting(): boolean;
  26959. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26960. /**
  26961. * Get the texture used for alpha test purpose.
  26962. * @returns the diffuse texture in case of the standard material.
  26963. */
  26964. getAlphaTestTexture(): Nullable<BaseTexture>;
  26965. /**
  26966. * Get if the submesh is ready to be used and all its information available.
  26967. * Child classes can use it to update shaders
  26968. * @param mesh defines the mesh to check
  26969. * @param subMesh defines which submesh to check
  26970. * @param useInstances specifies that instances should be used
  26971. * @returns a boolean indicating that the submesh is ready or not
  26972. */
  26973. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26974. /**
  26975. * Builds the material UBO layouts.
  26976. * Used internally during the effect preparation.
  26977. */
  26978. buildUniformLayout(): void;
  26979. /**
  26980. * Unbinds the material from the mesh
  26981. */
  26982. unbind(): void;
  26983. /**
  26984. * Binds the submesh to this material by preparing the effect and shader to draw
  26985. * @param world defines the world transformation matrix
  26986. * @param mesh defines the mesh containing the submesh
  26987. * @param subMesh defines the submesh to bind the material to
  26988. */
  26989. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26990. /**
  26991. * Get the list of animatables in the material.
  26992. * @returns the list of animatables object used in the material
  26993. */
  26994. getAnimatables(): IAnimatable[];
  26995. /**
  26996. * Gets the active textures from the material
  26997. * @returns an array of textures
  26998. */
  26999. getActiveTextures(): BaseTexture[];
  27000. /**
  27001. * Specifies if the material uses a texture
  27002. * @param texture defines the texture to check against the material
  27003. * @returns a boolean specifying if the material uses the texture
  27004. */
  27005. hasTexture(texture: BaseTexture): boolean;
  27006. /**
  27007. * Disposes the material
  27008. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27009. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27010. */
  27011. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27012. /**
  27013. * Makes a duplicate of the material, and gives it a new name
  27014. * @param name defines the new name for the duplicated material
  27015. * @returns the cloned material
  27016. */
  27017. clone(name: string): StandardMaterial;
  27018. /**
  27019. * Serializes this material in a JSON representation
  27020. * @returns the serialized material object
  27021. */
  27022. serialize(): any;
  27023. /**
  27024. * Creates a standard material from parsed material data
  27025. * @param source defines the JSON representation of the material
  27026. * @param scene defines the hosting scene
  27027. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27028. * @returns a new standard material
  27029. */
  27030. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27031. /**
  27032. * Are diffuse textures enabled in the application.
  27033. */
  27034. static get DiffuseTextureEnabled(): boolean;
  27035. static set DiffuseTextureEnabled(value: boolean);
  27036. /**
  27037. * Are ambient textures enabled in the application.
  27038. */
  27039. static get AmbientTextureEnabled(): boolean;
  27040. static set AmbientTextureEnabled(value: boolean);
  27041. /**
  27042. * Are opacity textures enabled in the application.
  27043. */
  27044. static get OpacityTextureEnabled(): boolean;
  27045. static set OpacityTextureEnabled(value: boolean);
  27046. /**
  27047. * Are reflection textures enabled in the application.
  27048. */
  27049. static get ReflectionTextureEnabled(): boolean;
  27050. static set ReflectionTextureEnabled(value: boolean);
  27051. /**
  27052. * Are emissive textures enabled in the application.
  27053. */
  27054. static get EmissiveTextureEnabled(): boolean;
  27055. static set EmissiveTextureEnabled(value: boolean);
  27056. /**
  27057. * Are specular textures enabled in the application.
  27058. */
  27059. static get SpecularTextureEnabled(): boolean;
  27060. static set SpecularTextureEnabled(value: boolean);
  27061. /**
  27062. * Are bump textures enabled in the application.
  27063. */
  27064. static get BumpTextureEnabled(): boolean;
  27065. static set BumpTextureEnabled(value: boolean);
  27066. /**
  27067. * Are lightmap textures enabled in the application.
  27068. */
  27069. static get LightmapTextureEnabled(): boolean;
  27070. static set LightmapTextureEnabled(value: boolean);
  27071. /**
  27072. * Are refraction textures enabled in the application.
  27073. */
  27074. static get RefractionTextureEnabled(): boolean;
  27075. static set RefractionTextureEnabled(value: boolean);
  27076. /**
  27077. * Are color grading textures enabled in the application.
  27078. */
  27079. static get ColorGradingTextureEnabled(): boolean;
  27080. static set ColorGradingTextureEnabled(value: boolean);
  27081. /**
  27082. * Are fresnels enabled in the application.
  27083. */
  27084. static get FresnelEnabled(): boolean;
  27085. static set FresnelEnabled(value: boolean);
  27086. }
  27087. }
  27088. declare module BABYLON {
  27089. /**
  27090. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27091. *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.
  27092. * The SPS is also a particle system. It provides some methods to manage the particles.
  27093. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27094. *
  27095. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27096. */
  27097. export class SolidParticleSystem implements IDisposable {
  27098. /**
  27099. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27100. * Example : var p = SPS.particles[i];
  27101. */
  27102. particles: SolidParticle[];
  27103. /**
  27104. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27105. */
  27106. nbParticles: number;
  27107. /**
  27108. * If the particles must ever face the camera (default false). Useful for planar particles.
  27109. */
  27110. billboard: boolean;
  27111. /**
  27112. * Recompute normals when adding a shape
  27113. */
  27114. recomputeNormals: boolean;
  27115. /**
  27116. * This a counter ofr your own usage. It's not set by any SPS functions.
  27117. */
  27118. counter: number;
  27119. /**
  27120. * The SPS name. This name is also given to the underlying mesh.
  27121. */
  27122. name: string;
  27123. /**
  27124. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27125. */
  27126. mesh: Mesh;
  27127. /**
  27128. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27129. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27130. */
  27131. vars: any;
  27132. /**
  27133. * This array is populated when the SPS is set as 'pickable'.
  27134. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27135. * Each element of this array is an object `{idx: int, faceId: int}`.
  27136. * `idx` is the picked particle index in the `SPS.particles` array
  27137. * `faceId` is the picked face index counted within this particle.
  27138. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27139. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27140. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27141. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27142. */
  27143. pickedParticles: {
  27144. idx: number;
  27145. faceId: number;
  27146. }[];
  27147. /**
  27148. * This array is populated when the SPS is set as 'pickable'
  27149. * Each key of this array is a submesh index.
  27150. * Each element of this array is a second array defined like this :
  27151. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27152. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27153. * `idx` is the picked particle index in the `SPS.particles` array
  27154. * `faceId` is the picked face index counted within this particle.
  27155. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27156. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27157. */
  27158. pickedBySubMesh: {
  27159. idx: number;
  27160. faceId: number;
  27161. }[][];
  27162. /**
  27163. * This array is populated when `enableDepthSort` is set to true.
  27164. * Each element of this array is an instance of the class DepthSortedParticle.
  27165. */
  27166. depthSortedParticles: DepthSortedParticle[];
  27167. /**
  27168. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27169. * @hidden
  27170. */
  27171. _bSphereOnly: boolean;
  27172. /**
  27173. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27174. * @hidden
  27175. */
  27176. _bSphereRadiusFactor: number;
  27177. private _scene;
  27178. private _positions;
  27179. private _indices;
  27180. private _normals;
  27181. private _colors;
  27182. private _uvs;
  27183. private _indices32;
  27184. private _positions32;
  27185. private _normals32;
  27186. private _fixedNormal32;
  27187. private _colors32;
  27188. private _uvs32;
  27189. private _index;
  27190. private _updatable;
  27191. private _pickable;
  27192. private _isVisibilityBoxLocked;
  27193. private _alwaysVisible;
  27194. private _depthSort;
  27195. private _expandable;
  27196. private _shapeCounter;
  27197. private _copy;
  27198. private _color;
  27199. private _computeParticleColor;
  27200. private _computeParticleTexture;
  27201. private _computeParticleRotation;
  27202. private _computeParticleVertex;
  27203. private _computeBoundingBox;
  27204. private _depthSortParticles;
  27205. private _camera;
  27206. private _mustUnrotateFixedNormals;
  27207. private _particlesIntersect;
  27208. private _needs32Bits;
  27209. private _isNotBuilt;
  27210. private _lastParticleId;
  27211. private _idxOfId;
  27212. private _multimaterialEnabled;
  27213. private _useModelMaterial;
  27214. private _indicesByMaterial;
  27215. private _materialIndexes;
  27216. private _depthSortFunction;
  27217. private _materialSortFunction;
  27218. private _materials;
  27219. private _multimaterial;
  27220. private _materialIndexesById;
  27221. private _defaultMaterial;
  27222. private _autoUpdateSubMeshes;
  27223. /**
  27224. * Creates a SPS (Solid Particle System) object.
  27225. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27226. * @param scene (Scene) is the scene in which the SPS is added.
  27227. * @param options defines the options of the sps e.g.
  27228. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27229. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27230. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27231. * * 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.
  27232. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27233. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27234. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27235. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27236. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27237. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27238. */
  27239. constructor(name: string, scene: Scene, options?: {
  27240. updatable?: boolean;
  27241. isPickable?: boolean;
  27242. enableDepthSort?: boolean;
  27243. particleIntersection?: boolean;
  27244. boundingSphereOnly?: boolean;
  27245. bSphereRadiusFactor?: number;
  27246. expandable?: boolean;
  27247. useModelMaterial?: boolean;
  27248. enableMultiMaterial?: boolean;
  27249. });
  27250. /**
  27251. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27252. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27253. * @returns the created mesh
  27254. */
  27255. buildMesh(): Mesh;
  27256. /**
  27257. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27258. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27259. * Thus the particles generated from `digest()` have their property `position` set yet.
  27260. * @param mesh ( Mesh ) is the mesh to be digested
  27261. * @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
  27262. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27263. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27264. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27265. * @returns the current SPS
  27266. */
  27267. digest(mesh: Mesh, options?: {
  27268. facetNb?: number;
  27269. number?: number;
  27270. delta?: number;
  27271. storage?: [];
  27272. }): SolidParticleSystem;
  27273. /**
  27274. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27275. * @hidden
  27276. */
  27277. private _unrotateFixedNormals;
  27278. /**
  27279. * Resets the temporary working copy particle
  27280. * @hidden
  27281. */
  27282. private _resetCopy;
  27283. /**
  27284. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27285. * @param p the current index in the positions array to be updated
  27286. * @param ind the current index in the indices array
  27287. * @param shape a Vector3 array, the shape geometry
  27288. * @param positions the positions array to be updated
  27289. * @param meshInd the shape indices array
  27290. * @param indices the indices array to be updated
  27291. * @param meshUV the shape uv array
  27292. * @param uvs the uv array to be updated
  27293. * @param meshCol the shape color array
  27294. * @param colors the color array to be updated
  27295. * @param meshNor the shape normals array
  27296. * @param normals the normals array to be updated
  27297. * @param idx the particle index
  27298. * @param idxInShape the particle index in its shape
  27299. * @param options the addShape() method passed options
  27300. * @model the particle model
  27301. * @hidden
  27302. */
  27303. private _meshBuilder;
  27304. /**
  27305. * Returns a shape Vector3 array from positions float array
  27306. * @param positions float array
  27307. * @returns a vector3 array
  27308. * @hidden
  27309. */
  27310. private _posToShape;
  27311. /**
  27312. * Returns a shapeUV array from a float uvs (array deep copy)
  27313. * @param uvs as a float array
  27314. * @returns a shapeUV array
  27315. * @hidden
  27316. */
  27317. private _uvsToShapeUV;
  27318. /**
  27319. * Adds a new particle object in the particles array
  27320. * @param idx particle index in particles array
  27321. * @param id particle id
  27322. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27323. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27324. * @param model particle ModelShape object
  27325. * @param shapeId model shape identifier
  27326. * @param idxInShape index of the particle in the current model
  27327. * @param bInfo model bounding info object
  27328. * @param storage target storage array, if any
  27329. * @hidden
  27330. */
  27331. private _addParticle;
  27332. /**
  27333. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27334. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27335. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27336. * @param nb (positive integer) the number of particles to be created from this model
  27337. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27338. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27339. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27340. * @returns the number of shapes in the system
  27341. */
  27342. addShape(mesh: Mesh, nb: number, options?: {
  27343. positionFunction?: any;
  27344. vertexFunction?: any;
  27345. storage?: [];
  27346. }): number;
  27347. /**
  27348. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27349. * @hidden
  27350. */
  27351. private _rebuildParticle;
  27352. /**
  27353. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27354. * @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.
  27355. * @returns the SPS.
  27356. */
  27357. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27358. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27359. * Returns an array with the removed particles.
  27360. * 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.
  27361. * The SPS can't be empty so at least one particle needs to remain in place.
  27362. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27363. * @param start index of the first particle to remove
  27364. * @param end index of the last particle to remove (included)
  27365. * @returns an array populated with the removed particles
  27366. */
  27367. removeParticles(start: number, end: number): SolidParticle[];
  27368. /**
  27369. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27370. * @param solidParticleArray an array populated with Solid Particles objects
  27371. * @returns the SPS
  27372. */
  27373. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27374. /**
  27375. * Creates a new particle and modifies the SPS mesh geometry :
  27376. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27377. * - calls _addParticle() to populate the particle array
  27378. * factorized code from addShape() and insertParticlesFromArray()
  27379. * @param idx particle index in the particles array
  27380. * @param i particle index in its shape
  27381. * @param modelShape particle ModelShape object
  27382. * @param shape shape vertex array
  27383. * @param meshInd shape indices array
  27384. * @param meshUV shape uv array
  27385. * @param meshCol shape color array
  27386. * @param meshNor shape normals array
  27387. * @param bbInfo shape bounding info
  27388. * @param storage target particle storage
  27389. * @options addShape() passed options
  27390. * @hidden
  27391. */
  27392. private _insertNewParticle;
  27393. /**
  27394. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27395. * This method calls `updateParticle()` for each particle of the SPS.
  27396. * For an animated SPS, it is usually called within the render loop.
  27397. * 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.
  27398. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27399. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27400. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27401. * @returns the SPS.
  27402. */
  27403. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27404. /**
  27405. * Disposes the SPS.
  27406. */
  27407. dispose(): void;
  27408. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27409. * idx is the particle index in the SPS
  27410. * faceId is the picked face index counted within this particle.
  27411. * Returns null if the pickInfo can't identify a picked particle.
  27412. * @param pickingInfo (PickingInfo object)
  27413. * @returns {idx: number, faceId: number} or null
  27414. */
  27415. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27416. idx: number;
  27417. faceId: number;
  27418. }>;
  27419. /**
  27420. * Returns a SolidParticle object from its identifier : particle.id
  27421. * @param id (integer) the particle Id
  27422. * @returns the searched particle or null if not found in the SPS.
  27423. */
  27424. getParticleById(id: number): Nullable<SolidParticle>;
  27425. /**
  27426. * Returns a new array populated with the particles having the passed shapeId.
  27427. * @param shapeId (integer) the shape identifier
  27428. * @returns a new solid particle array
  27429. */
  27430. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27431. /**
  27432. * Populates the passed array "ref" with the particles having the passed shapeId.
  27433. * @param shapeId the shape identifier
  27434. * @returns the SPS
  27435. * @param ref
  27436. */
  27437. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27438. /**
  27439. * Computes the required SubMeshes according the materials assigned to the particles.
  27440. * @returns the solid particle system.
  27441. * Does nothing if called before the SPS mesh is built.
  27442. */
  27443. computeSubMeshes(): SolidParticleSystem;
  27444. /**
  27445. * Sorts the solid particles by material when MultiMaterial is enabled.
  27446. * Updates the indices32 array.
  27447. * Updates the indicesByMaterial array.
  27448. * Updates the mesh indices array.
  27449. * @returns the SPS
  27450. * @hidden
  27451. */
  27452. private _sortParticlesByMaterial;
  27453. /**
  27454. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27455. * @hidden
  27456. */
  27457. private _setMaterialIndexesById;
  27458. /**
  27459. * Returns an array with unique values of Materials from the passed array
  27460. * @param array the material array to be checked and filtered
  27461. * @hidden
  27462. */
  27463. private _filterUniqueMaterialId;
  27464. /**
  27465. * Sets a new Standard Material as _defaultMaterial if not already set.
  27466. * @hidden
  27467. */
  27468. private _setDefaultMaterial;
  27469. /**
  27470. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27471. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27472. * @returns the SPS.
  27473. */
  27474. refreshVisibleSize(): SolidParticleSystem;
  27475. /**
  27476. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27477. * @param size the size (float) of the visibility box
  27478. * note : this doesn't lock the SPS mesh bounding box.
  27479. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27480. */
  27481. setVisibilityBox(size: number): void;
  27482. /**
  27483. * Gets whether the SPS as always visible or not
  27484. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27485. */
  27486. get isAlwaysVisible(): boolean;
  27487. /**
  27488. * Sets the SPS as always visible or not
  27489. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27490. */
  27491. set isAlwaysVisible(val: boolean);
  27492. /**
  27493. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27494. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27495. */
  27496. set isVisibilityBoxLocked(val: boolean);
  27497. /**
  27498. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27499. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27500. */
  27501. get isVisibilityBoxLocked(): boolean;
  27502. /**
  27503. * Tells to `setParticles()` to compute the particle rotations or not.
  27504. * Default value : true. The SPS is faster when it's set to false.
  27505. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27506. */
  27507. set computeParticleRotation(val: boolean);
  27508. /**
  27509. * Tells to `setParticles()` to compute the particle colors or not.
  27510. * Default value : true. The SPS is faster when it's set to false.
  27511. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27512. */
  27513. set computeParticleColor(val: boolean);
  27514. set computeParticleTexture(val: boolean);
  27515. /**
  27516. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27517. * Default value : false. The SPS is faster when it's set to false.
  27518. * Note : the particle custom vertex positions aren't stored values.
  27519. */
  27520. set computeParticleVertex(val: boolean);
  27521. /**
  27522. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27523. */
  27524. set computeBoundingBox(val: boolean);
  27525. /**
  27526. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27527. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27528. * Default : `true`
  27529. */
  27530. set depthSortParticles(val: boolean);
  27531. /**
  27532. * Gets if `setParticles()` computes the particle rotations or not.
  27533. * Default value : true. The SPS is faster when it's set to false.
  27534. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27535. */
  27536. get computeParticleRotation(): boolean;
  27537. /**
  27538. * Gets if `setParticles()` computes the particle colors or not.
  27539. * Default value : true. The SPS is faster when it's set to false.
  27540. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27541. */
  27542. get computeParticleColor(): boolean;
  27543. /**
  27544. * Gets if `setParticles()` computes the particle textures or not.
  27545. * Default value : true. The SPS is faster when it's set to false.
  27546. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27547. */
  27548. get computeParticleTexture(): boolean;
  27549. /**
  27550. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27551. * Default value : false. The SPS is faster when it's set to false.
  27552. * Note : the particle custom vertex positions aren't stored values.
  27553. */
  27554. get computeParticleVertex(): boolean;
  27555. /**
  27556. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27557. */
  27558. get computeBoundingBox(): boolean;
  27559. /**
  27560. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27561. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27562. * Default : `true`
  27563. */
  27564. get depthSortParticles(): boolean;
  27565. /**
  27566. * Gets if the SPS is created as expandable at construction time.
  27567. * Default : `false`
  27568. */
  27569. get expandable(): boolean;
  27570. /**
  27571. * Gets if the SPS supports the Multi Materials
  27572. */
  27573. get multimaterialEnabled(): boolean;
  27574. /**
  27575. * Gets if the SPS uses the model materials for its own multimaterial.
  27576. */
  27577. get useModelMaterial(): boolean;
  27578. /**
  27579. * The SPS used material array.
  27580. */
  27581. get materials(): Material[];
  27582. /**
  27583. * Sets the SPS MultiMaterial from the passed materials.
  27584. * Note : the passed array is internally copied and not used then by reference.
  27585. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27586. */
  27587. setMultiMaterial(materials: Material[]): void;
  27588. /**
  27589. * The SPS computed multimaterial object
  27590. */
  27591. get multimaterial(): MultiMaterial;
  27592. set multimaterial(mm: MultiMaterial);
  27593. /**
  27594. * If the subMeshes must be updated on the next call to setParticles()
  27595. */
  27596. get autoUpdateSubMeshes(): boolean;
  27597. set autoUpdateSubMeshes(val: boolean);
  27598. /**
  27599. * This function does nothing. It may be overwritten to set all the particle first values.
  27600. * The SPS doesn't call this function, you may have to call it by your own.
  27601. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27602. */
  27603. initParticles(): void;
  27604. /**
  27605. * This function does nothing. It may be overwritten to recycle a particle.
  27606. * The SPS doesn't call this function, you may have to call it by your own.
  27607. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27608. * @param particle The particle to recycle
  27609. * @returns the recycled particle
  27610. */
  27611. recycleParticle(particle: SolidParticle): SolidParticle;
  27612. /**
  27613. * Updates a particle : this function should be overwritten by the user.
  27614. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27615. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27616. * @example : just set a particle position or velocity and recycle conditions
  27617. * @param particle The particle to update
  27618. * @returns the updated particle
  27619. */
  27620. updateParticle(particle: SolidParticle): SolidParticle;
  27621. /**
  27622. * Updates a vertex of a particle : it can be overwritten by the user.
  27623. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27624. * @param particle the current particle
  27625. * @param vertex the current index of the current particle
  27626. * @param pt the index of the current vertex in the particle shape
  27627. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27628. * @example : just set a vertex particle position
  27629. * @returns the updated vertex
  27630. */
  27631. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27632. /**
  27633. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27634. * This does nothing and may be overwritten by the user.
  27635. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27636. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27637. * @param update the boolean update value actually passed to setParticles()
  27638. */
  27639. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27640. /**
  27641. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27642. * This will be passed three parameters.
  27643. * This does nothing and may be overwritten by the user.
  27644. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27645. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27646. * @param update the boolean update value actually passed to setParticles()
  27647. */
  27648. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27649. }
  27650. }
  27651. declare module BABYLON {
  27652. /**
  27653. * Represents one particle of a solid particle system.
  27654. */
  27655. export class SolidParticle {
  27656. /**
  27657. * particle global index
  27658. */
  27659. idx: number;
  27660. /**
  27661. * particle identifier
  27662. */
  27663. id: number;
  27664. /**
  27665. * The color of the particle
  27666. */
  27667. color: Nullable<Color4>;
  27668. /**
  27669. * The world space position of the particle.
  27670. */
  27671. position: Vector3;
  27672. /**
  27673. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27674. */
  27675. rotation: Vector3;
  27676. /**
  27677. * The world space rotation quaternion of the particle.
  27678. */
  27679. rotationQuaternion: Nullable<Quaternion>;
  27680. /**
  27681. * The scaling of the particle.
  27682. */
  27683. scaling: Vector3;
  27684. /**
  27685. * The uvs of the particle.
  27686. */
  27687. uvs: Vector4;
  27688. /**
  27689. * The current speed of the particle.
  27690. */
  27691. velocity: Vector3;
  27692. /**
  27693. * The pivot point in the particle local space.
  27694. */
  27695. pivot: Vector3;
  27696. /**
  27697. * Must the particle be translated from its pivot point in its local space ?
  27698. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27699. * Default : false
  27700. */
  27701. translateFromPivot: boolean;
  27702. /**
  27703. * Is the particle active or not ?
  27704. */
  27705. alive: boolean;
  27706. /**
  27707. * Is the particle visible or not ?
  27708. */
  27709. isVisible: boolean;
  27710. /**
  27711. * Index of this particle in the global "positions" array (Internal use)
  27712. * @hidden
  27713. */
  27714. _pos: number;
  27715. /**
  27716. * @hidden Index of this particle in the global "indices" array (Internal use)
  27717. */
  27718. _ind: number;
  27719. /**
  27720. * @hidden ModelShape of this particle (Internal use)
  27721. */
  27722. _model: ModelShape;
  27723. /**
  27724. * ModelShape id of this particle
  27725. */
  27726. shapeId: number;
  27727. /**
  27728. * Index of the particle in its shape id
  27729. */
  27730. idxInShape: number;
  27731. /**
  27732. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27733. */
  27734. _modelBoundingInfo: BoundingInfo;
  27735. /**
  27736. * @hidden Particle BoundingInfo object (Internal use)
  27737. */
  27738. _boundingInfo: BoundingInfo;
  27739. /**
  27740. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27741. */
  27742. _sps: SolidParticleSystem;
  27743. /**
  27744. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27745. */
  27746. _stillInvisible: boolean;
  27747. /**
  27748. * @hidden Last computed particle rotation matrix
  27749. */
  27750. _rotationMatrix: number[];
  27751. /**
  27752. * Parent particle Id, if any.
  27753. * Default null.
  27754. */
  27755. parentId: Nullable<number>;
  27756. /**
  27757. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27758. */
  27759. materialIndex: Nullable<number>;
  27760. /**
  27761. * Custom object or properties.
  27762. */
  27763. props: Nullable<any>;
  27764. /**
  27765. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27766. * The possible values are :
  27767. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27768. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27769. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27770. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27771. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27772. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27773. * */
  27774. cullingStrategy: number;
  27775. /**
  27776. * @hidden Internal global position in the SPS.
  27777. */
  27778. _globalPosition: Vector3;
  27779. /**
  27780. * Creates a Solid Particle object.
  27781. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27782. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27783. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27784. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27785. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27786. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27787. * @param shapeId (integer) is the model shape identifier in the SPS.
  27788. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27789. * @param sps defines the sps it is associated to
  27790. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27791. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27792. */
  27793. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27794. /**
  27795. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27796. * @param target the particle target
  27797. * @returns the current particle
  27798. */
  27799. copyToRef(target: SolidParticle): SolidParticle;
  27800. /**
  27801. * Legacy support, changed scale to scaling
  27802. */
  27803. get scale(): Vector3;
  27804. /**
  27805. * Legacy support, changed scale to scaling
  27806. */
  27807. set scale(scale: Vector3);
  27808. /**
  27809. * Legacy support, changed quaternion to rotationQuaternion
  27810. */
  27811. get quaternion(): Nullable<Quaternion>;
  27812. /**
  27813. * Legacy support, changed quaternion to rotationQuaternion
  27814. */
  27815. set quaternion(q: Nullable<Quaternion>);
  27816. /**
  27817. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27818. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27819. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27820. * @returns true if it intersects
  27821. */
  27822. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27823. /**
  27824. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27825. * A particle is in the frustum if its bounding box intersects the frustum
  27826. * @param frustumPlanes defines the frustum to test
  27827. * @returns true if the particle is in the frustum planes
  27828. */
  27829. isInFrustum(frustumPlanes: Plane[]): boolean;
  27830. /**
  27831. * get the rotation matrix of the particle
  27832. * @hidden
  27833. */
  27834. getRotationMatrix(m: Matrix): void;
  27835. }
  27836. /**
  27837. * Represents the shape of the model used by one particle of a solid particle system.
  27838. * SPS internal tool, don't use it manually.
  27839. */
  27840. export class ModelShape {
  27841. /**
  27842. * The shape id
  27843. * @hidden
  27844. */
  27845. shapeID: number;
  27846. /**
  27847. * flat array of model positions (internal use)
  27848. * @hidden
  27849. */
  27850. _shape: Vector3[];
  27851. /**
  27852. * flat array of model UVs (internal use)
  27853. * @hidden
  27854. */
  27855. _shapeUV: number[];
  27856. /**
  27857. * color array of the model
  27858. * @hidden
  27859. */
  27860. _shapeColors: number[];
  27861. /**
  27862. * indices array of the model
  27863. * @hidden
  27864. */
  27865. _indices: number[];
  27866. /**
  27867. * normals array of the model
  27868. * @hidden
  27869. */
  27870. _normals: number[];
  27871. /**
  27872. * length of the shape in the model indices array (internal use)
  27873. * @hidden
  27874. */
  27875. _indicesLength: number;
  27876. /**
  27877. * Custom position function (internal use)
  27878. * @hidden
  27879. */
  27880. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27881. /**
  27882. * Custom vertex function (internal use)
  27883. * @hidden
  27884. */
  27885. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27886. /**
  27887. * Model material (internal use)
  27888. * @hidden
  27889. */
  27890. _material: Nullable<Material>;
  27891. /**
  27892. * 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.
  27893. * SPS internal tool, don't use it manually.
  27894. * @hidden
  27895. */
  27896. 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>);
  27897. }
  27898. /**
  27899. * Represents a Depth Sorted Particle in the solid particle system.
  27900. * @hidden
  27901. */
  27902. export class DepthSortedParticle {
  27903. /**
  27904. * Particle index
  27905. */
  27906. idx: number;
  27907. /**
  27908. * Index of the particle in the "indices" array
  27909. */
  27910. ind: number;
  27911. /**
  27912. * Length of the particle shape in the "indices" array
  27913. */
  27914. indicesLength: number;
  27915. /**
  27916. * Squared distance from the particle to the camera
  27917. */
  27918. sqDistance: number;
  27919. /**
  27920. * Material index when used with MultiMaterials
  27921. */
  27922. materialIndex: number;
  27923. /**
  27924. * Creates a new sorted particle
  27925. * @param materialIndex
  27926. */
  27927. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  27928. }
  27929. }
  27930. declare module BABYLON {
  27931. /**
  27932. * @hidden
  27933. */
  27934. export class _MeshCollisionData {
  27935. _checkCollisions: boolean;
  27936. _collisionMask: number;
  27937. _collisionGroup: number;
  27938. _surroundingMeshes: Nullable<AbstractMesh[]>;
  27939. _collider: Nullable<Collider>;
  27940. _oldPositionForCollisions: Vector3;
  27941. _diffPositionForCollisions: Vector3;
  27942. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27943. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27944. }
  27945. }
  27946. declare module BABYLON {
  27947. /** @hidden */
  27948. class _FacetDataStorage {
  27949. facetPositions: Vector3[];
  27950. facetNormals: Vector3[];
  27951. facetPartitioning: number[][];
  27952. facetNb: number;
  27953. partitioningSubdivisions: number;
  27954. partitioningBBoxRatio: number;
  27955. facetDataEnabled: boolean;
  27956. facetParameters: any;
  27957. bbSize: Vector3;
  27958. subDiv: {
  27959. max: number;
  27960. X: number;
  27961. Y: number;
  27962. Z: number;
  27963. };
  27964. facetDepthSort: boolean;
  27965. facetDepthSortEnabled: boolean;
  27966. depthSortedIndices: IndicesArray;
  27967. depthSortedFacets: {
  27968. ind: number;
  27969. sqDistance: number;
  27970. }[];
  27971. facetDepthSortFunction: (f1: {
  27972. ind: number;
  27973. sqDistance: number;
  27974. }, f2: {
  27975. ind: number;
  27976. sqDistance: number;
  27977. }) => number;
  27978. facetDepthSortFrom: Vector3;
  27979. facetDepthSortOrigin: Vector3;
  27980. invertedMatrix: Matrix;
  27981. }
  27982. /**
  27983. * @hidden
  27984. **/
  27985. class _InternalAbstractMeshDataInfo {
  27986. _hasVertexAlpha: boolean;
  27987. _useVertexColors: boolean;
  27988. _numBoneInfluencers: number;
  27989. _applyFog: boolean;
  27990. _receiveShadows: boolean;
  27991. _facetData: _FacetDataStorage;
  27992. _visibility: number;
  27993. _skeleton: Nullable<Skeleton>;
  27994. _layerMask: number;
  27995. _computeBonesUsingShaders: boolean;
  27996. _isActive: boolean;
  27997. _onlyForInstances: boolean;
  27998. _isActiveIntermediate: boolean;
  27999. _onlyForInstancesIntermediate: boolean;
  28000. _actAsRegularMesh: boolean;
  28001. }
  28002. /**
  28003. * Class used to store all common mesh properties
  28004. */
  28005. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28006. /** No occlusion */
  28007. static OCCLUSION_TYPE_NONE: number;
  28008. /** Occlusion set to optimisitic */
  28009. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28010. /** Occlusion set to strict */
  28011. static OCCLUSION_TYPE_STRICT: number;
  28012. /** Use an accurante occlusion algorithm */
  28013. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28014. /** Use a conservative occlusion algorithm */
  28015. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28017. * Test order :
  28018. * Is the bounding sphere outside the frustum ?
  28019. * If not, are the bounding box vertices outside the frustum ?
  28020. * It not, then the cullable object is in the frustum.
  28021. */
  28022. static readonly CULLINGSTRATEGY_STANDARD: number;
  28023. /** Culling strategy : Bounding Sphere Only.
  28024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28025. * It's also less accurate than the standard because some not visible objects can still be selected.
  28026. * Test : is the bounding sphere outside the frustum ?
  28027. * If not, then the cullable object is in the frustum.
  28028. */
  28029. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28030. /** Culling strategy : Optimistic Inclusion.
  28031. * This in an inclusion test first, then the standard exclusion test.
  28032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28033. * 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.
  28034. * Anyway, it's as accurate as the standard strategy.
  28035. * Test :
  28036. * Is the cullable object bounding sphere center in the frustum ?
  28037. * If not, apply the default culling strategy.
  28038. */
  28039. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28043. * 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.
  28044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28045. * Test :
  28046. * Is the cullable object bounding sphere center in the frustum ?
  28047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28048. */
  28049. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28050. /**
  28051. * No billboard
  28052. */
  28053. static get BILLBOARDMODE_NONE(): number;
  28054. /** Billboard on X axis */
  28055. static get BILLBOARDMODE_X(): number;
  28056. /** Billboard on Y axis */
  28057. static get BILLBOARDMODE_Y(): number;
  28058. /** Billboard on Z axis */
  28059. static get BILLBOARDMODE_Z(): number;
  28060. /** Billboard on all axes */
  28061. static get BILLBOARDMODE_ALL(): number;
  28062. /** Billboard on using position instead of orientation */
  28063. static get BILLBOARDMODE_USE_POSITION(): number;
  28064. /** @hidden */
  28065. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28066. /**
  28067. * The culling strategy to use to check whether the mesh must be rendered or not.
  28068. * This value can be changed at any time and will be used on the next render mesh selection.
  28069. * The possible values are :
  28070. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28071. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28072. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28073. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28074. * Please read each static variable documentation to get details about the culling process.
  28075. * */
  28076. cullingStrategy: number;
  28077. /**
  28078. * Gets the number of facets in the mesh
  28079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28080. */
  28081. get facetNb(): number;
  28082. /**
  28083. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28085. */
  28086. get partitioningSubdivisions(): number;
  28087. set partitioningSubdivisions(nb: number);
  28088. /**
  28089. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28090. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28092. */
  28093. get partitioningBBoxRatio(): number;
  28094. set partitioningBBoxRatio(ratio: number);
  28095. /**
  28096. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28097. * Works only for updatable meshes.
  28098. * Doesn't work with multi-materials
  28099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28100. */
  28101. get mustDepthSortFacets(): boolean;
  28102. set mustDepthSortFacets(sort: boolean);
  28103. /**
  28104. * The location (Vector3) where the facet depth sort must be computed from.
  28105. * By default, the active camera position.
  28106. * Used only when facet depth sort is enabled
  28107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28108. */
  28109. get facetDepthSortFrom(): Vector3;
  28110. set facetDepthSortFrom(location: Vector3);
  28111. /**
  28112. * gets a boolean indicating if facetData is enabled
  28113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28114. */
  28115. get isFacetDataEnabled(): boolean;
  28116. /** @hidden */
  28117. _updateNonUniformScalingState(value: boolean): boolean;
  28118. /**
  28119. * An event triggered when this mesh collides with another one
  28120. */
  28121. onCollideObservable: Observable<AbstractMesh>;
  28122. /** Set a function to call when this mesh collides with another one */
  28123. set onCollide(callback: () => void);
  28124. /**
  28125. * An event triggered when the collision's position changes
  28126. */
  28127. onCollisionPositionChangeObservable: Observable<Vector3>;
  28128. /** Set a function to call when the collision's position changes */
  28129. set onCollisionPositionChange(callback: () => void);
  28130. /**
  28131. * An event triggered when material is changed
  28132. */
  28133. onMaterialChangedObservable: Observable<AbstractMesh>;
  28134. /**
  28135. * Gets or sets the orientation for POV movement & rotation
  28136. */
  28137. definedFacingForward: boolean;
  28138. /** @hidden */
  28139. _occlusionQuery: Nullable<WebGLQuery>;
  28140. /** @hidden */
  28141. _renderingGroup: Nullable<RenderingGroup>;
  28142. /**
  28143. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28144. */
  28145. get visibility(): number;
  28146. /**
  28147. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28148. */
  28149. set visibility(value: number);
  28150. /** Gets or sets the alpha index used to sort transparent meshes
  28151. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28152. */
  28153. alphaIndex: number;
  28154. /**
  28155. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28156. */
  28157. isVisible: boolean;
  28158. /**
  28159. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28160. */
  28161. isPickable: boolean;
  28162. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28163. showSubMeshesBoundingBox: boolean;
  28164. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28165. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28166. */
  28167. isBlocker: boolean;
  28168. /**
  28169. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28170. */
  28171. enablePointerMoveEvents: boolean;
  28172. /**
  28173. * Specifies the rendering group id for this mesh (0 by default)
  28174. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28175. */
  28176. renderingGroupId: number;
  28177. private _material;
  28178. /** Gets or sets current material */
  28179. get material(): Nullable<Material>;
  28180. set material(value: Nullable<Material>);
  28181. /**
  28182. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28183. * @see http://doc.babylonjs.com/babylon101/shadows
  28184. */
  28185. get receiveShadows(): boolean;
  28186. set receiveShadows(value: boolean);
  28187. /** Defines color to use when rendering outline */
  28188. outlineColor: Color3;
  28189. /** Define width to use when rendering outline */
  28190. outlineWidth: number;
  28191. /** Defines color to use when rendering overlay */
  28192. overlayColor: Color3;
  28193. /** Defines alpha to use when rendering overlay */
  28194. overlayAlpha: number;
  28195. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28196. get hasVertexAlpha(): boolean;
  28197. set hasVertexAlpha(value: boolean);
  28198. /** 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) */
  28199. get useVertexColors(): boolean;
  28200. set useVertexColors(value: boolean);
  28201. /**
  28202. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28203. */
  28204. get computeBonesUsingShaders(): boolean;
  28205. set computeBonesUsingShaders(value: boolean);
  28206. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28207. get numBoneInfluencers(): number;
  28208. set numBoneInfluencers(value: number);
  28209. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28210. get applyFog(): boolean;
  28211. set applyFog(value: boolean);
  28212. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28213. useOctreeForRenderingSelection: boolean;
  28214. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28215. useOctreeForPicking: boolean;
  28216. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28217. useOctreeForCollisions: boolean;
  28218. /**
  28219. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28220. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28221. */
  28222. get layerMask(): number;
  28223. set layerMask(value: number);
  28224. /**
  28225. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28226. */
  28227. alwaysSelectAsActiveMesh: boolean;
  28228. /**
  28229. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28230. */
  28231. doNotSyncBoundingInfo: boolean;
  28232. /**
  28233. * Gets or sets the current action manager
  28234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28235. */
  28236. actionManager: Nullable<AbstractActionManager>;
  28237. private _meshCollisionData;
  28238. /**
  28239. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28241. */
  28242. ellipsoid: Vector3;
  28243. /**
  28244. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28245. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28246. */
  28247. ellipsoidOffset: Vector3;
  28248. /**
  28249. * Gets or sets a collision mask used to mask collisions (default is -1).
  28250. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28251. */
  28252. get collisionMask(): number;
  28253. set collisionMask(mask: number);
  28254. /**
  28255. * Gets or sets the current collision group mask (-1 by default).
  28256. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28257. */
  28258. get collisionGroup(): number;
  28259. set collisionGroup(mask: number);
  28260. /**
  28261. * Gets or sets current surrounding meshes (null by default).
  28262. *
  28263. * By default collision detection is tested against every mesh in the scene.
  28264. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28265. * meshes will be tested for the collision.
  28266. *
  28267. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28268. */
  28269. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28270. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28271. /**
  28272. * Defines edge width used when edgesRenderer is enabled
  28273. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28274. */
  28275. edgesWidth: number;
  28276. /**
  28277. * Defines edge color used when edgesRenderer is enabled
  28278. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28279. */
  28280. edgesColor: Color4;
  28281. /** @hidden */
  28282. _edgesRenderer: Nullable<IEdgesRenderer>;
  28283. /** @hidden */
  28284. _masterMesh: Nullable<AbstractMesh>;
  28285. /** @hidden */
  28286. _boundingInfo: Nullable<BoundingInfo>;
  28287. /** @hidden */
  28288. _renderId: number;
  28289. /**
  28290. * Gets or sets the list of subMeshes
  28291. * @see http://doc.babylonjs.com/how_to/multi_materials
  28292. */
  28293. subMeshes: SubMesh[];
  28294. /** @hidden */
  28295. _intersectionsInProgress: AbstractMesh[];
  28296. /** @hidden */
  28297. _unIndexed: boolean;
  28298. /** @hidden */
  28299. _lightSources: Light[];
  28300. /** Gets the list of lights affecting that mesh */
  28301. get lightSources(): Light[];
  28302. /** @hidden */
  28303. get _positions(): Nullable<Vector3[]>;
  28304. /** @hidden */
  28305. _waitingData: {
  28306. lods: Nullable<any>;
  28307. actions: Nullable<any>;
  28308. freezeWorldMatrix: Nullable<boolean>;
  28309. };
  28310. /** @hidden */
  28311. _bonesTransformMatrices: Nullable<Float32Array>;
  28312. /** @hidden */
  28313. _transformMatrixTexture: Nullable<RawTexture>;
  28314. /**
  28315. * Gets or sets a skeleton to apply skining transformations
  28316. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28317. */
  28318. set skeleton(value: Nullable<Skeleton>);
  28319. get skeleton(): Nullable<Skeleton>;
  28320. /**
  28321. * An event triggered when the mesh is rebuilt.
  28322. */
  28323. onRebuildObservable: Observable<AbstractMesh>;
  28324. /**
  28325. * Creates a new AbstractMesh
  28326. * @param name defines the name of the mesh
  28327. * @param scene defines the hosting scene
  28328. */
  28329. constructor(name: string, scene?: Nullable<Scene>);
  28330. /**
  28331. * Returns the string "AbstractMesh"
  28332. * @returns "AbstractMesh"
  28333. */
  28334. getClassName(): string;
  28335. /**
  28336. * Gets a string representation of the current mesh
  28337. * @param fullDetails defines a boolean indicating if full details must be included
  28338. * @returns a string representation of the current mesh
  28339. */
  28340. toString(fullDetails?: boolean): string;
  28341. /**
  28342. * @hidden
  28343. */
  28344. protected _getEffectiveParent(): Nullable<Node>;
  28345. /** @hidden */
  28346. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28347. /** @hidden */
  28348. _rebuild(): void;
  28349. /** @hidden */
  28350. _resyncLightSources(): void;
  28351. /** @hidden */
  28352. _resyncLightSource(light: Light): void;
  28353. /** @hidden */
  28354. _unBindEffect(): void;
  28355. /** @hidden */
  28356. _removeLightSource(light: Light, dispose: boolean): void;
  28357. private _markSubMeshesAsDirty;
  28358. /** @hidden */
  28359. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28360. /** @hidden */
  28361. _markSubMeshesAsAttributesDirty(): void;
  28362. /** @hidden */
  28363. _markSubMeshesAsMiscDirty(): void;
  28364. /**
  28365. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28366. */
  28367. get scaling(): Vector3;
  28368. set scaling(newScaling: Vector3);
  28369. /**
  28370. * Returns true if the mesh is blocked. Implemented by child classes
  28371. */
  28372. get isBlocked(): boolean;
  28373. /**
  28374. * Returns the mesh itself by default. Implemented by child classes
  28375. * @param camera defines the camera to use to pick the right LOD level
  28376. * @returns the currentAbstractMesh
  28377. */
  28378. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28379. /**
  28380. * Returns 0 by default. Implemented by child classes
  28381. * @returns an integer
  28382. */
  28383. getTotalVertices(): number;
  28384. /**
  28385. * Returns a positive integer : the total number of indices in this mesh geometry.
  28386. * @returns the numner of indices or zero if the mesh has no geometry.
  28387. */
  28388. getTotalIndices(): number;
  28389. /**
  28390. * Returns null by default. Implemented by child classes
  28391. * @returns null
  28392. */
  28393. getIndices(): Nullable<IndicesArray>;
  28394. /**
  28395. * Returns the array of the requested vertex data kind. Implemented by child classes
  28396. * @param kind defines the vertex data kind to use
  28397. * @returns null
  28398. */
  28399. getVerticesData(kind: string): Nullable<FloatArray>;
  28400. /**
  28401. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28402. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28403. * Note that a new underlying VertexBuffer object is created each call.
  28404. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28405. * @param kind defines vertex data kind:
  28406. * * VertexBuffer.PositionKind
  28407. * * VertexBuffer.UVKind
  28408. * * VertexBuffer.UV2Kind
  28409. * * VertexBuffer.UV3Kind
  28410. * * VertexBuffer.UV4Kind
  28411. * * VertexBuffer.UV5Kind
  28412. * * VertexBuffer.UV6Kind
  28413. * * VertexBuffer.ColorKind
  28414. * * VertexBuffer.MatricesIndicesKind
  28415. * * VertexBuffer.MatricesIndicesExtraKind
  28416. * * VertexBuffer.MatricesWeightsKind
  28417. * * VertexBuffer.MatricesWeightsExtraKind
  28418. * @param data defines the data source
  28419. * @param updatable defines if the data must be flagged as updatable (or static)
  28420. * @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
  28421. * @returns the current mesh
  28422. */
  28423. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28424. /**
  28425. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28426. * If the mesh has no geometry, it is simply returned as it is.
  28427. * @param kind defines vertex data kind:
  28428. * * VertexBuffer.PositionKind
  28429. * * VertexBuffer.UVKind
  28430. * * VertexBuffer.UV2Kind
  28431. * * VertexBuffer.UV3Kind
  28432. * * VertexBuffer.UV4Kind
  28433. * * VertexBuffer.UV5Kind
  28434. * * VertexBuffer.UV6Kind
  28435. * * VertexBuffer.ColorKind
  28436. * * VertexBuffer.MatricesIndicesKind
  28437. * * VertexBuffer.MatricesIndicesExtraKind
  28438. * * VertexBuffer.MatricesWeightsKind
  28439. * * VertexBuffer.MatricesWeightsExtraKind
  28440. * @param data defines the data source
  28441. * @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
  28442. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28443. * @returns the current mesh
  28444. */
  28445. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28446. /**
  28447. * Sets the mesh indices,
  28448. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28449. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28450. * @param totalVertices Defines the total number of vertices
  28451. * @returns the current mesh
  28452. */
  28453. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28454. /**
  28455. * Gets a boolean indicating if specific vertex data is present
  28456. * @param kind defines the vertex data kind to use
  28457. * @returns true is data kind is present
  28458. */
  28459. isVerticesDataPresent(kind: string): boolean;
  28460. /**
  28461. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28462. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28463. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28464. * @returns a BoundingInfo
  28465. */
  28466. getBoundingInfo(): BoundingInfo;
  28467. /**
  28468. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28469. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28470. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28471. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28472. * @returns the current mesh
  28473. */
  28474. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28475. /**
  28476. * Overwrite the current bounding info
  28477. * @param boundingInfo defines the new bounding info
  28478. * @returns the current mesh
  28479. */
  28480. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28481. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28482. get useBones(): boolean;
  28483. /** @hidden */
  28484. _preActivate(): void;
  28485. /** @hidden */
  28486. _preActivateForIntermediateRendering(renderId: number): void;
  28487. /** @hidden */
  28488. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28489. /** @hidden */
  28490. _postActivate(): void;
  28491. /** @hidden */
  28492. _freeze(): void;
  28493. /** @hidden */
  28494. _unFreeze(): void;
  28495. /**
  28496. * Gets the current world matrix
  28497. * @returns a Matrix
  28498. */
  28499. getWorldMatrix(): Matrix;
  28500. /** @hidden */
  28501. _getWorldMatrixDeterminant(): number;
  28502. /**
  28503. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28504. */
  28505. get isAnInstance(): boolean;
  28506. /**
  28507. * Gets a boolean indicating if this mesh has instances
  28508. */
  28509. get hasInstances(): boolean;
  28510. /**
  28511. * Perform relative position change from the point of view of behind the front of the mesh.
  28512. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28513. * Supports definition of mesh facing forward or backward
  28514. * @param amountRight defines the distance on the right axis
  28515. * @param amountUp defines the distance on the up axis
  28516. * @param amountForward defines the distance on the forward axis
  28517. * @returns the current mesh
  28518. */
  28519. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28520. /**
  28521. * Calculate relative position change from the point of view of behind the front of the mesh.
  28522. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28523. * Supports definition of mesh facing forward or backward
  28524. * @param amountRight defines the distance on the right axis
  28525. * @param amountUp defines the distance on the up axis
  28526. * @param amountForward defines the distance on the forward axis
  28527. * @returns the new displacement vector
  28528. */
  28529. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28530. /**
  28531. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28532. * Supports definition of mesh facing forward or backward
  28533. * @param flipBack defines the flip
  28534. * @param twirlClockwise defines the twirl
  28535. * @param tiltRight defines the tilt
  28536. * @returns the current mesh
  28537. */
  28538. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28539. /**
  28540. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28541. * Supports definition of mesh facing forward or backward.
  28542. * @param flipBack defines the flip
  28543. * @param twirlClockwise defines the twirl
  28544. * @param tiltRight defines the tilt
  28545. * @returns the new rotation vector
  28546. */
  28547. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28548. /**
  28549. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28550. * This means the mesh underlying bounding box and sphere are recomputed.
  28551. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28552. * @returns the current mesh
  28553. */
  28554. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28555. /** @hidden */
  28556. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28557. /** @hidden */
  28558. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28559. /** @hidden */
  28560. _updateBoundingInfo(): AbstractMesh;
  28561. /** @hidden */
  28562. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28563. /** @hidden */
  28564. protected _afterComputeWorldMatrix(): void;
  28565. /** @hidden */
  28566. get _effectiveMesh(): AbstractMesh;
  28567. /**
  28568. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28569. * A mesh is in the frustum if its bounding box intersects the frustum
  28570. * @param frustumPlanes defines the frustum to test
  28571. * @returns true if the mesh is in the frustum planes
  28572. */
  28573. isInFrustum(frustumPlanes: Plane[]): boolean;
  28574. /**
  28575. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28576. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28577. * @param frustumPlanes defines the frustum to test
  28578. * @returns true if the mesh is completely in the frustum planes
  28579. */
  28580. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28581. /**
  28582. * True if the mesh intersects another mesh or a SolidParticle object
  28583. * @param mesh defines a target mesh or SolidParticle to test
  28584. * @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)
  28585. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28586. * @returns true if there is an intersection
  28587. */
  28588. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28589. /**
  28590. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28591. * @param point defines the point to test
  28592. * @returns true if there is an intersection
  28593. */
  28594. intersectsPoint(point: Vector3): boolean;
  28595. /**
  28596. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28597. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28598. */
  28599. get checkCollisions(): boolean;
  28600. set checkCollisions(collisionEnabled: boolean);
  28601. /**
  28602. * Gets Collider object used to compute collisions (not physics)
  28603. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28604. */
  28605. get collider(): Nullable<Collider>;
  28606. /**
  28607. * Move the mesh using collision engine
  28608. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28609. * @param displacement defines the requested displacement vector
  28610. * @returns the current mesh
  28611. */
  28612. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28613. private _onCollisionPositionChange;
  28614. /** @hidden */
  28615. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28616. /** @hidden */
  28617. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28618. /** @hidden */
  28619. _checkCollision(collider: Collider): AbstractMesh;
  28620. /** @hidden */
  28621. _generatePointsArray(): boolean;
  28622. /**
  28623. * Checks if the passed Ray intersects with the mesh
  28624. * @param ray defines the ray to use
  28625. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28626. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28627. * @returns the picking info
  28628. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28629. */
  28630. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28631. /**
  28632. * Clones the current mesh
  28633. * @param name defines the mesh name
  28634. * @param newParent defines the new mesh parent
  28635. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28636. * @returns the new mesh
  28637. */
  28638. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28639. /**
  28640. * Disposes all the submeshes of the current meshnp
  28641. * @returns the current mesh
  28642. */
  28643. releaseSubMeshes(): AbstractMesh;
  28644. /**
  28645. * Releases resources associated with this abstract mesh.
  28646. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28647. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28648. */
  28649. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28650. /**
  28651. * Adds the passed mesh as a child to the current mesh
  28652. * @param mesh defines the child mesh
  28653. * @returns the current mesh
  28654. */
  28655. addChild(mesh: AbstractMesh): AbstractMesh;
  28656. /**
  28657. * Removes the passed mesh from the current mesh children list
  28658. * @param mesh defines the child mesh
  28659. * @returns the current mesh
  28660. */
  28661. removeChild(mesh: AbstractMesh): AbstractMesh;
  28662. /** @hidden */
  28663. private _initFacetData;
  28664. /**
  28665. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28666. * This method can be called within the render loop.
  28667. * 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
  28668. * @returns the current mesh
  28669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28670. */
  28671. updateFacetData(): AbstractMesh;
  28672. /**
  28673. * Returns the facetLocalNormals array.
  28674. * The normals are expressed in the mesh local spac
  28675. * @returns an array of Vector3
  28676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28677. */
  28678. getFacetLocalNormals(): Vector3[];
  28679. /**
  28680. * Returns the facetLocalPositions array.
  28681. * The facet positions are expressed in the mesh local space
  28682. * @returns an array of Vector3
  28683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28684. */
  28685. getFacetLocalPositions(): Vector3[];
  28686. /**
  28687. * Returns the facetLocalPartioning array
  28688. * @returns an array of array of numbers
  28689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28690. */
  28691. getFacetLocalPartitioning(): number[][];
  28692. /**
  28693. * Returns the i-th facet position in the world system.
  28694. * This method allocates a new Vector3 per call
  28695. * @param i defines the facet index
  28696. * @returns a new Vector3
  28697. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28698. */
  28699. getFacetPosition(i: number): Vector3;
  28700. /**
  28701. * Sets the reference Vector3 with the i-th facet position in the world system
  28702. * @param i defines the facet index
  28703. * @param ref defines the target vector
  28704. * @returns the current mesh
  28705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28706. */
  28707. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28708. /**
  28709. * Returns the i-th facet normal in the world system.
  28710. * This method allocates a new Vector3 per call
  28711. * @param i defines the facet index
  28712. * @returns a new Vector3
  28713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28714. */
  28715. getFacetNormal(i: number): Vector3;
  28716. /**
  28717. * Sets the reference Vector3 with the i-th facet normal in the world system
  28718. * @param i defines the facet index
  28719. * @param ref defines the target vector
  28720. * @returns the current mesh
  28721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28722. */
  28723. getFacetNormalToRef(i: number, ref: Vector3): this;
  28724. /**
  28725. * 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)
  28726. * @param x defines x coordinate
  28727. * @param y defines y coordinate
  28728. * @param z defines z coordinate
  28729. * @returns the array of facet indexes
  28730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28731. */
  28732. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28733. /**
  28734. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28735. * @param projected sets as the (x,y,z) world projection on the facet
  28736. * @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
  28737. * @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
  28738. * @param x defines x coordinate
  28739. * @param y defines y coordinate
  28740. * @param z defines z coordinate
  28741. * @returns the face index if found (or null instead)
  28742. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28743. */
  28744. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28745. /**
  28746. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28747. * @param projected sets as the (x,y,z) local projection on the facet
  28748. * @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
  28749. * @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
  28750. * @param x defines x coordinate
  28751. * @param y defines y coordinate
  28752. * @param z defines z coordinate
  28753. * @returns the face index if found (or null instead)
  28754. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28755. */
  28756. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28757. /**
  28758. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28759. * @returns the parameters
  28760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28761. */
  28762. getFacetDataParameters(): any;
  28763. /**
  28764. * Disables the feature FacetData and frees the related memory
  28765. * @returns the current mesh
  28766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28767. */
  28768. disableFacetData(): AbstractMesh;
  28769. /**
  28770. * Updates the AbstractMesh indices array
  28771. * @param indices defines the data source
  28772. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28773. * @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)
  28774. * @returns the current mesh
  28775. */
  28776. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28777. /**
  28778. * Creates new normals data for the mesh
  28779. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28780. * @returns the current mesh
  28781. */
  28782. createNormals(updatable: boolean): AbstractMesh;
  28783. /**
  28784. * Align the mesh with a normal
  28785. * @param normal defines the normal to use
  28786. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28787. * @returns the current mesh
  28788. */
  28789. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28790. /** @hidden */
  28791. _checkOcclusionQuery(): boolean;
  28792. /**
  28793. * Disables the mesh edge rendering mode
  28794. * @returns the currentAbstractMesh
  28795. */
  28796. disableEdgesRendering(): AbstractMesh;
  28797. /**
  28798. * Enables the edge rendering mode on the mesh.
  28799. * This mode makes the mesh edges visible
  28800. * @param epsilon defines the maximal distance between two angles to detect a face
  28801. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28802. * @returns the currentAbstractMesh
  28803. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28804. */
  28805. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28806. }
  28807. }
  28808. declare module BABYLON {
  28809. /**
  28810. * Interface used to define ActionEvent
  28811. */
  28812. export interface IActionEvent {
  28813. /** The mesh or sprite that triggered the action */
  28814. source: any;
  28815. /** The X mouse cursor position at the time of the event */
  28816. pointerX: number;
  28817. /** The Y mouse cursor position at the time of the event */
  28818. pointerY: number;
  28819. /** The mesh that is currently pointed at (can be null) */
  28820. meshUnderPointer: Nullable<AbstractMesh>;
  28821. /** the original (browser) event that triggered the ActionEvent */
  28822. sourceEvent?: any;
  28823. /** additional data for the event */
  28824. additionalData?: any;
  28825. }
  28826. /**
  28827. * ActionEvent is the event being sent when an action is triggered.
  28828. */
  28829. export class ActionEvent implements IActionEvent {
  28830. /** The mesh or sprite that triggered the action */
  28831. source: any;
  28832. /** The X mouse cursor position at the time of the event */
  28833. pointerX: number;
  28834. /** The Y mouse cursor position at the time of the event */
  28835. pointerY: number;
  28836. /** The mesh that is currently pointed at (can be null) */
  28837. meshUnderPointer: Nullable<AbstractMesh>;
  28838. /** the original (browser) event that triggered the ActionEvent */
  28839. sourceEvent?: any;
  28840. /** additional data for the event */
  28841. additionalData?: any;
  28842. /**
  28843. * Creates a new ActionEvent
  28844. * @param source The mesh or sprite that triggered the action
  28845. * @param pointerX The X mouse cursor position at the time of the event
  28846. * @param pointerY The Y mouse cursor position at the time of the event
  28847. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28848. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28849. * @param additionalData additional data for the event
  28850. */
  28851. constructor(
  28852. /** The mesh or sprite that triggered the action */
  28853. source: any,
  28854. /** The X mouse cursor position at the time of the event */
  28855. pointerX: number,
  28856. /** The Y mouse cursor position at the time of the event */
  28857. pointerY: number,
  28858. /** The mesh that is currently pointed at (can be null) */
  28859. meshUnderPointer: Nullable<AbstractMesh>,
  28860. /** the original (browser) event that triggered the ActionEvent */
  28861. sourceEvent?: any,
  28862. /** additional data for the event */
  28863. additionalData?: any);
  28864. /**
  28865. * Helper function to auto-create an ActionEvent from a source mesh.
  28866. * @param source The source mesh that triggered the event
  28867. * @param evt The original (browser) event
  28868. * @param additionalData additional data for the event
  28869. * @returns the new ActionEvent
  28870. */
  28871. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28872. /**
  28873. * Helper function to auto-create an ActionEvent from a source sprite
  28874. * @param source The source sprite that triggered the event
  28875. * @param scene Scene associated with the sprite
  28876. * @param evt The original (browser) event
  28877. * @param additionalData additional data for the event
  28878. * @returns the new ActionEvent
  28879. */
  28880. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28881. /**
  28882. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28883. * @param scene the scene where the event occurred
  28884. * @param evt The original (browser) event
  28885. * @returns the new ActionEvent
  28886. */
  28887. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28888. /**
  28889. * Helper function to auto-create an ActionEvent from a primitive
  28890. * @param prim defines the target primitive
  28891. * @param pointerPos defines the pointer position
  28892. * @param evt The original (browser) event
  28893. * @param additionalData additional data for the event
  28894. * @returns the new ActionEvent
  28895. */
  28896. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28897. }
  28898. }
  28899. declare module BABYLON {
  28900. /**
  28901. * Abstract class used to decouple action Manager from scene and meshes.
  28902. * Do not instantiate.
  28903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28904. */
  28905. export abstract class AbstractActionManager implements IDisposable {
  28906. /** Gets the list of active triggers */
  28907. static Triggers: {
  28908. [key: string]: number;
  28909. };
  28910. /** Gets the cursor to use when hovering items */
  28911. hoverCursor: string;
  28912. /** Gets the list of actions */
  28913. actions: IAction[];
  28914. /**
  28915. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28916. */
  28917. isRecursive: boolean;
  28918. /**
  28919. * Releases all associated resources
  28920. */
  28921. abstract dispose(): void;
  28922. /**
  28923. * Does this action manager has pointer triggers
  28924. */
  28925. abstract get hasPointerTriggers(): boolean;
  28926. /**
  28927. * Does this action manager has pick triggers
  28928. */
  28929. abstract get hasPickTriggers(): boolean;
  28930. /**
  28931. * Process a specific trigger
  28932. * @param trigger defines the trigger to process
  28933. * @param evt defines the event details to be processed
  28934. */
  28935. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28936. /**
  28937. * Does this action manager handles actions of any of the given triggers
  28938. * @param triggers defines the triggers to be tested
  28939. * @return a boolean indicating whether one (or more) of the triggers is handled
  28940. */
  28941. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28942. /**
  28943. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28944. * speed.
  28945. * @param triggerA defines the trigger to be tested
  28946. * @param triggerB defines the trigger to be tested
  28947. * @return a boolean indicating whether one (or more) of the triggers is handled
  28948. */
  28949. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28950. /**
  28951. * Does this action manager handles actions of a given trigger
  28952. * @param trigger defines the trigger to be tested
  28953. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28954. * @return whether the trigger is handled
  28955. */
  28956. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28957. /**
  28958. * Serialize this manager to a JSON object
  28959. * @param name defines the property name to store this manager
  28960. * @returns a JSON representation of this manager
  28961. */
  28962. abstract serialize(name: string): any;
  28963. /**
  28964. * Registers an action to this action manager
  28965. * @param action defines the action to be registered
  28966. * @return the action amended (prepared) after registration
  28967. */
  28968. abstract registerAction(action: IAction): Nullable<IAction>;
  28969. /**
  28970. * Unregisters an action to this action manager
  28971. * @param action defines the action to be unregistered
  28972. * @return a boolean indicating whether the action has been unregistered
  28973. */
  28974. abstract unregisterAction(action: IAction): Boolean;
  28975. /**
  28976. * Does exist one action manager with at least one trigger
  28977. **/
  28978. static get HasTriggers(): boolean;
  28979. /**
  28980. * Does exist one action manager with at least one pick trigger
  28981. **/
  28982. static get HasPickTriggers(): boolean;
  28983. /**
  28984. * Does exist one action manager that handles actions of a given trigger
  28985. * @param trigger defines the trigger to be tested
  28986. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28987. **/
  28988. static HasSpecificTrigger(trigger: number): boolean;
  28989. }
  28990. }
  28991. declare module BABYLON {
  28992. /**
  28993. * Defines how a node can be built from a string name.
  28994. */
  28995. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28996. /**
  28997. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28998. */
  28999. export class Node implements IBehaviorAware<Node> {
  29000. /** @hidden */
  29001. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29002. private static _NodeConstructors;
  29003. /**
  29004. * Add a new node constructor
  29005. * @param type defines the type name of the node to construct
  29006. * @param constructorFunc defines the constructor function
  29007. */
  29008. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29009. /**
  29010. * Returns a node constructor based on type name
  29011. * @param type defines the type name
  29012. * @param name defines the new node name
  29013. * @param scene defines the hosting scene
  29014. * @param options defines optional options to transmit to constructors
  29015. * @returns the new constructor or null
  29016. */
  29017. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29018. /**
  29019. * Gets or sets the name of the node
  29020. */
  29021. name: string;
  29022. /**
  29023. * Gets or sets the id of the node
  29024. */
  29025. id: string;
  29026. /**
  29027. * Gets or sets the unique id of the node
  29028. */
  29029. uniqueId: number;
  29030. /**
  29031. * Gets or sets a string used to store user defined state for the node
  29032. */
  29033. state: string;
  29034. /**
  29035. * Gets or sets an object used to store user defined information for the node
  29036. */
  29037. metadata: any;
  29038. /**
  29039. * For internal use only. Please do not use.
  29040. */
  29041. reservedDataStore: any;
  29042. /**
  29043. * List of inspectable custom properties (used by the Inspector)
  29044. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29045. */
  29046. inspectableCustomProperties: IInspectable[];
  29047. private _doNotSerialize;
  29048. /**
  29049. * Gets or sets a boolean used to define if the node must be serialized
  29050. */
  29051. get doNotSerialize(): boolean;
  29052. set doNotSerialize(value: boolean);
  29053. /** @hidden */
  29054. _isDisposed: boolean;
  29055. /**
  29056. * Gets a list of Animations associated with the node
  29057. */
  29058. animations: Animation[];
  29059. protected _ranges: {
  29060. [name: string]: Nullable<AnimationRange>;
  29061. };
  29062. /**
  29063. * Callback raised when the node is ready to be used
  29064. */
  29065. onReady: Nullable<(node: Node) => void>;
  29066. private _isEnabled;
  29067. private _isParentEnabled;
  29068. private _isReady;
  29069. /** @hidden */
  29070. _currentRenderId: number;
  29071. private _parentUpdateId;
  29072. /** @hidden */
  29073. _childUpdateId: number;
  29074. /** @hidden */
  29075. _waitingParentId: Nullable<string>;
  29076. /** @hidden */
  29077. _scene: Scene;
  29078. /** @hidden */
  29079. _cache: any;
  29080. private _parentNode;
  29081. private _children;
  29082. /** @hidden */
  29083. _worldMatrix: Matrix;
  29084. /** @hidden */
  29085. _worldMatrixDeterminant: number;
  29086. /** @hidden */
  29087. _worldMatrixDeterminantIsDirty: boolean;
  29088. /** @hidden */
  29089. private _sceneRootNodesIndex;
  29090. /**
  29091. * Gets a boolean indicating if the node has been disposed
  29092. * @returns true if the node was disposed
  29093. */
  29094. isDisposed(): boolean;
  29095. /**
  29096. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29097. * @see https://doc.babylonjs.com/how_to/parenting
  29098. */
  29099. set parent(parent: Nullable<Node>);
  29100. get parent(): Nullable<Node>;
  29101. /** @hidden */
  29102. _addToSceneRootNodes(): void;
  29103. /** @hidden */
  29104. _removeFromSceneRootNodes(): void;
  29105. private _animationPropertiesOverride;
  29106. /**
  29107. * Gets or sets the animation properties override
  29108. */
  29109. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29110. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29111. /**
  29112. * Gets a string idenfifying the name of the class
  29113. * @returns "Node" string
  29114. */
  29115. getClassName(): string;
  29116. /** @hidden */
  29117. readonly _isNode: boolean;
  29118. /**
  29119. * An event triggered when the mesh is disposed
  29120. */
  29121. onDisposeObservable: Observable<Node>;
  29122. private _onDisposeObserver;
  29123. /**
  29124. * Sets a callback that will be raised when the node will be disposed
  29125. */
  29126. set onDispose(callback: () => void);
  29127. /**
  29128. * Creates a new Node
  29129. * @param name the name and id to be given to this node
  29130. * @param scene the scene this node will be added to
  29131. */
  29132. constructor(name: string, scene?: Nullable<Scene>);
  29133. /**
  29134. * Gets the scene of the node
  29135. * @returns a scene
  29136. */
  29137. getScene(): Scene;
  29138. /**
  29139. * Gets the engine of the node
  29140. * @returns a Engine
  29141. */
  29142. getEngine(): Engine;
  29143. private _behaviors;
  29144. /**
  29145. * Attach a behavior to the node
  29146. * @see http://doc.babylonjs.com/features/behaviour
  29147. * @param behavior defines the behavior to attach
  29148. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29149. * @returns the current Node
  29150. */
  29151. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29152. /**
  29153. * Remove an attached behavior
  29154. * @see http://doc.babylonjs.com/features/behaviour
  29155. * @param behavior defines the behavior to attach
  29156. * @returns the current Node
  29157. */
  29158. removeBehavior(behavior: Behavior<Node>): Node;
  29159. /**
  29160. * Gets the list of attached behaviors
  29161. * @see http://doc.babylonjs.com/features/behaviour
  29162. */
  29163. get behaviors(): Behavior<Node>[];
  29164. /**
  29165. * Gets an attached behavior by name
  29166. * @param name defines the name of the behavior to look for
  29167. * @see http://doc.babylonjs.com/features/behaviour
  29168. * @returns null if behavior was not found else the requested behavior
  29169. */
  29170. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29171. /**
  29172. * Returns the latest update of the World matrix
  29173. * @returns a Matrix
  29174. */
  29175. getWorldMatrix(): Matrix;
  29176. /** @hidden */
  29177. _getWorldMatrixDeterminant(): number;
  29178. /**
  29179. * Returns directly the latest state of the mesh World matrix.
  29180. * A Matrix is returned.
  29181. */
  29182. get worldMatrixFromCache(): Matrix;
  29183. /** @hidden */
  29184. _initCache(): void;
  29185. /** @hidden */
  29186. updateCache(force?: boolean): void;
  29187. /** @hidden */
  29188. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29189. /** @hidden */
  29190. _updateCache(ignoreParentClass?: boolean): void;
  29191. /** @hidden */
  29192. _isSynchronized(): boolean;
  29193. /** @hidden */
  29194. _markSyncedWithParent(): void;
  29195. /** @hidden */
  29196. isSynchronizedWithParent(): boolean;
  29197. /** @hidden */
  29198. isSynchronized(): boolean;
  29199. /**
  29200. * Is this node ready to be used/rendered
  29201. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29202. * @return true if the node is ready
  29203. */
  29204. isReady(completeCheck?: boolean): boolean;
  29205. /**
  29206. * Is this node enabled?
  29207. * 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
  29208. * @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
  29209. * @return whether this node (and its parent) is enabled
  29210. */
  29211. isEnabled(checkAncestors?: boolean): boolean;
  29212. /** @hidden */
  29213. protected _syncParentEnabledState(): void;
  29214. /**
  29215. * Set the enabled state of this node
  29216. * @param value defines the new enabled state
  29217. */
  29218. setEnabled(value: boolean): void;
  29219. /**
  29220. * Is this node a descendant of the given node?
  29221. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29222. * @param ancestor defines the parent node to inspect
  29223. * @returns a boolean indicating if this node is a descendant of the given node
  29224. */
  29225. isDescendantOf(ancestor: Node): boolean;
  29226. /** @hidden */
  29227. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29228. /**
  29229. * Will return all nodes that have this node as ascendant
  29230. * @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
  29231. * @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
  29232. * @return all children nodes of all types
  29233. */
  29234. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29235. /**
  29236. * Get all child-meshes of this node
  29237. * @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)
  29238. * @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
  29239. * @returns an array of AbstractMesh
  29240. */
  29241. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29242. /**
  29243. * Get all direct children of this node
  29244. * @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
  29245. * @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)
  29246. * @returns an array of Node
  29247. */
  29248. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29249. /** @hidden */
  29250. _setReady(state: boolean): void;
  29251. /**
  29252. * Get an animation by name
  29253. * @param name defines the name of the animation to look for
  29254. * @returns null if not found else the requested animation
  29255. */
  29256. getAnimationByName(name: string): Nullable<Animation>;
  29257. /**
  29258. * Creates an animation range for this node
  29259. * @param name defines the name of the range
  29260. * @param from defines the starting key
  29261. * @param to defines the end key
  29262. */
  29263. createAnimationRange(name: string, from: number, to: number): void;
  29264. /**
  29265. * Delete a specific animation range
  29266. * @param name defines the name of the range to delete
  29267. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29268. */
  29269. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29270. /**
  29271. * Get an animation range by name
  29272. * @param name defines the name of the animation range to look for
  29273. * @returns null if not found else the requested animation range
  29274. */
  29275. getAnimationRange(name: string): Nullable<AnimationRange>;
  29276. /**
  29277. * Gets the list of all animation ranges defined on this node
  29278. * @returns an array
  29279. */
  29280. getAnimationRanges(): Nullable<AnimationRange>[];
  29281. /**
  29282. * Will start the animation sequence
  29283. * @param name defines the range frames for animation sequence
  29284. * @param loop defines if the animation should loop (false by default)
  29285. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29286. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29287. * @returns the object created for this animation. If range does not exist, it will return null
  29288. */
  29289. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29290. /**
  29291. * Serialize animation ranges into a JSON compatible object
  29292. * @returns serialization object
  29293. */
  29294. serializeAnimationRanges(): any;
  29295. /**
  29296. * Computes the world matrix of the node
  29297. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29298. * @returns the world matrix
  29299. */
  29300. computeWorldMatrix(force?: boolean): Matrix;
  29301. /**
  29302. * Releases resources associated with this node.
  29303. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29304. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29305. */
  29306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29307. /**
  29308. * Parse animation range data from a serialization object and store them into a given node
  29309. * @param node defines where to store the animation ranges
  29310. * @param parsedNode defines the serialization object to read data from
  29311. * @param scene defines the hosting scene
  29312. */
  29313. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29314. /**
  29315. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29316. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29317. * @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
  29318. * @returns the new bounding vectors
  29319. */
  29320. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29321. min: Vector3;
  29322. max: Vector3;
  29323. };
  29324. }
  29325. }
  29326. declare module BABYLON {
  29327. /**
  29328. * @hidden
  29329. */
  29330. export class _IAnimationState {
  29331. key: number;
  29332. repeatCount: number;
  29333. workValue?: any;
  29334. loopMode?: number;
  29335. offsetValue?: any;
  29336. highLimitValue?: any;
  29337. }
  29338. /**
  29339. * Class used to store any kind of animation
  29340. */
  29341. export class Animation {
  29342. /**Name of the animation */
  29343. name: string;
  29344. /**Property to animate */
  29345. targetProperty: string;
  29346. /**The frames per second of the animation */
  29347. framePerSecond: number;
  29348. /**The data type of the animation */
  29349. dataType: number;
  29350. /**The loop mode of the animation */
  29351. loopMode?: number | undefined;
  29352. /**Specifies if blending should be enabled */
  29353. enableBlending?: boolean | undefined;
  29354. /**
  29355. * Use matrix interpolation instead of using direct key value when animating matrices
  29356. */
  29357. static AllowMatricesInterpolation: boolean;
  29358. /**
  29359. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29360. */
  29361. static AllowMatrixDecomposeForInterpolation: boolean;
  29362. /**
  29363. * Stores the key frames of the animation
  29364. */
  29365. private _keys;
  29366. /**
  29367. * Stores the easing function of the animation
  29368. */
  29369. private _easingFunction;
  29370. /**
  29371. * @hidden Internal use only
  29372. */
  29373. _runtimeAnimations: RuntimeAnimation[];
  29374. /**
  29375. * The set of event that will be linked to this animation
  29376. */
  29377. private _events;
  29378. /**
  29379. * Stores an array of target property paths
  29380. */
  29381. targetPropertyPath: string[];
  29382. /**
  29383. * Stores the blending speed of the animation
  29384. */
  29385. blendingSpeed: number;
  29386. /**
  29387. * Stores the animation ranges for the animation
  29388. */
  29389. private _ranges;
  29390. /**
  29391. * @hidden Internal use
  29392. */
  29393. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29394. /**
  29395. * Sets up an animation
  29396. * @param property The property to animate
  29397. * @param animationType The animation type to apply
  29398. * @param framePerSecond The frames per second of the animation
  29399. * @param easingFunction The easing function used in the animation
  29400. * @returns The created animation
  29401. */
  29402. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29403. /**
  29404. * Create and start an animation on a node
  29405. * @param name defines the name of the global animation that will be run on all nodes
  29406. * @param node defines the root node where the animation will take place
  29407. * @param targetProperty defines property to animate
  29408. * @param framePerSecond defines the number of frame per second yo use
  29409. * @param totalFrame defines the number of frames in total
  29410. * @param from defines the initial value
  29411. * @param to defines the final value
  29412. * @param loopMode defines which loop mode you want to use (off by default)
  29413. * @param easingFunction defines the easing function to use (linear by default)
  29414. * @param onAnimationEnd defines the callback to call when animation end
  29415. * @returns the animatable created for this animation
  29416. */
  29417. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29418. /**
  29419. * Create and start an animation on a node and its descendants
  29420. * @param name defines the name of the global animation that will be run on all nodes
  29421. * @param node defines the root node where the animation will take place
  29422. * @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
  29423. * @param targetProperty defines property to animate
  29424. * @param framePerSecond defines the number of frame per second to use
  29425. * @param totalFrame defines the number of frames in total
  29426. * @param from defines the initial value
  29427. * @param to defines the final value
  29428. * @param loopMode defines which loop mode you want to use (off by default)
  29429. * @param easingFunction defines the easing function to use (linear by default)
  29430. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29431. * @returns the list of animatables created for all nodes
  29432. * @example https://www.babylonjs-playground.com/#MH0VLI
  29433. */
  29434. 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[]>;
  29435. /**
  29436. * Creates a new animation, merges it with the existing animations and starts it
  29437. * @param name Name of the animation
  29438. * @param node Node which contains the scene that begins the animations
  29439. * @param targetProperty Specifies which property to animate
  29440. * @param framePerSecond The frames per second of the animation
  29441. * @param totalFrame The total number of frames
  29442. * @param from The frame at the beginning of the animation
  29443. * @param to The frame at the end of the animation
  29444. * @param loopMode Specifies the loop mode of the animation
  29445. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29446. * @param onAnimationEnd Callback to run once the animation is complete
  29447. * @returns Nullable animation
  29448. */
  29449. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29450. /**
  29451. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29452. * @param sourceAnimation defines the Animation containing keyframes to convert
  29453. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29454. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29455. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29456. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29457. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29458. */
  29459. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29460. /**
  29461. * Transition property of an host to the target Value
  29462. * @param property The property to transition
  29463. * @param targetValue The target Value of the property
  29464. * @param host The object where the property to animate belongs
  29465. * @param scene Scene used to run the animation
  29466. * @param frameRate Framerate (in frame/s) to use
  29467. * @param transition The transition type we want to use
  29468. * @param duration The duration of the animation, in milliseconds
  29469. * @param onAnimationEnd Callback trigger at the end of the animation
  29470. * @returns Nullable animation
  29471. */
  29472. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29473. /**
  29474. * Return the array of runtime animations currently using this animation
  29475. */
  29476. get runtimeAnimations(): RuntimeAnimation[];
  29477. /**
  29478. * Specifies if any of the runtime animations are currently running
  29479. */
  29480. get hasRunningRuntimeAnimations(): boolean;
  29481. /**
  29482. * Initializes the animation
  29483. * @param name Name of the animation
  29484. * @param targetProperty Property to animate
  29485. * @param framePerSecond The frames per second of the animation
  29486. * @param dataType The data type of the animation
  29487. * @param loopMode The loop mode of the animation
  29488. * @param enableBlending Specifies if blending should be enabled
  29489. */
  29490. constructor(
  29491. /**Name of the animation */
  29492. name: string,
  29493. /**Property to animate */
  29494. targetProperty: string,
  29495. /**The frames per second of the animation */
  29496. framePerSecond: number,
  29497. /**The data type of the animation */
  29498. dataType: number,
  29499. /**The loop mode of the animation */
  29500. loopMode?: number | undefined,
  29501. /**Specifies if blending should be enabled */
  29502. enableBlending?: boolean | undefined);
  29503. /**
  29504. * Converts the animation to a string
  29505. * @param fullDetails support for multiple levels of logging within scene loading
  29506. * @returns String form of the animation
  29507. */
  29508. toString(fullDetails?: boolean): string;
  29509. /**
  29510. * Add an event to this animation
  29511. * @param event Event to add
  29512. */
  29513. addEvent(event: AnimationEvent): void;
  29514. /**
  29515. * Remove all events found at the given frame
  29516. * @param frame The frame to remove events from
  29517. */
  29518. removeEvents(frame: number): void;
  29519. /**
  29520. * Retrieves all the events from the animation
  29521. * @returns Events from the animation
  29522. */
  29523. getEvents(): AnimationEvent[];
  29524. /**
  29525. * Creates an animation range
  29526. * @param name Name of the animation range
  29527. * @param from Starting frame of the animation range
  29528. * @param to Ending frame of the animation
  29529. */
  29530. createRange(name: string, from: number, to: number): void;
  29531. /**
  29532. * Deletes an animation range by name
  29533. * @param name Name of the animation range to delete
  29534. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29535. */
  29536. deleteRange(name: string, deleteFrames?: boolean): void;
  29537. /**
  29538. * Gets the animation range by name, or null if not defined
  29539. * @param name Name of the animation range
  29540. * @returns Nullable animation range
  29541. */
  29542. getRange(name: string): Nullable<AnimationRange>;
  29543. /**
  29544. * Gets the key frames from the animation
  29545. * @returns The key frames of the animation
  29546. */
  29547. getKeys(): Array<IAnimationKey>;
  29548. /**
  29549. * Gets the highest frame rate of the animation
  29550. * @returns Highest frame rate of the animation
  29551. */
  29552. getHighestFrame(): number;
  29553. /**
  29554. * Gets the easing function of the animation
  29555. * @returns Easing function of the animation
  29556. */
  29557. getEasingFunction(): IEasingFunction;
  29558. /**
  29559. * Sets the easing function of the animation
  29560. * @param easingFunction A custom mathematical formula for animation
  29561. */
  29562. setEasingFunction(easingFunction: EasingFunction): void;
  29563. /**
  29564. * Interpolates a scalar linearly
  29565. * @param startValue Start value of the animation curve
  29566. * @param endValue End value of the animation curve
  29567. * @param gradient Scalar amount to interpolate
  29568. * @returns Interpolated scalar value
  29569. */
  29570. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29571. /**
  29572. * Interpolates a scalar cubically
  29573. * @param startValue Start value of the animation curve
  29574. * @param outTangent End tangent of the animation
  29575. * @param endValue End value of the animation curve
  29576. * @param inTangent Start tangent of the animation curve
  29577. * @param gradient Scalar amount to interpolate
  29578. * @returns Interpolated scalar value
  29579. */
  29580. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29581. /**
  29582. * Interpolates a quaternion using a spherical linear interpolation
  29583. * @param startValue Start value of the animation curve
  29584. * @param endValue End value of the animation curve
  29585. * @param gradient Scalar amount to interpolate
  29586. * @returns Interpolated quaternion value
  29587. */
  29588. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29589. /**
  29590. * Interpolates a quaternion cubically
  29591. * @param startValue Start value of the animation curve
  29592. * @param outTangent End tangent of the animation curve
  29593. * @param endValue End value of the animation curve
  29594. * @param inTangent Start tangent of the animation curve
  29595. * @param gradient Scalar amount to interpolate
  29596. * @returns Interpolated quaternion value
  29597. */
  29598. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29599. /**
  29600. * Interpolates a Vector3 linearl
  29601. * @param startValue Start value of the animation curve
  29602. * @param endValue End value of the animation curve
  29603. * @param gradient Scalar amount to interpolate
  29604. * @returns Interpolated scalar value
  29605. */
  29606. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29607. /**
  29608. * Interpolates a Vector3 cubically
  29609. * @param startValue Start value of the animation curve
  29610. * @param outTangent End tangent of the animation
  29611. * @param endValue End value of the animation curve
  29612. * @param inTangent Start tangent of the animation curve
  29613. * @param gradient Scalar amount to interpolate
  29614. * @returns InterpolatedVector3 value
  29615. */
  29616. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29617. /**
  29618. * Interpolates a Vector2 linearly
  29619. * @param startValue Start value of the animation curve
  29620. * @param endValue End value of the animation curve
  29621. * @param gradient Scalar amount to interpolate
  29622. * @returns Interpolated Vector2 value
  29623. */
  29624. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29625. /**
  29626. * Interpolates a Vector2 cubically
  29627. * @param startValue Start value of the animation curve
  29628. * @param outTangent End tangent of the animation
  29629. * @param endValue End value of the animation curve
  29630. * @param inTangent Start tangent of the animation curve
  29631. * @param gradient Scalar amount to interpolate
  29632. * @returns Interpolated Vector2 value
  29633. */
  29634. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29635. /**
  29636. * Interpolates a size linearly
  29637. * @param startValue Start value of the animation curve
  29638. * @param endValue End value of the animation curve
  29639. * @param gradient Scalar amount to interpolate
  29640. * @returns Interpolated Size value
  29641. */
  29642. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29643. /**
  29644. * Interpolates a Color3 linearly
  29645. * @param startValue Start value of the animation curve
  29646. * @param endValue End value of the animation curve
  29647. * @param gradient Scalar amount to interpolate
  29648. * @returns Interpolated Color3 value
  29649. */
  29650. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29651. /**
  29652. * Interpolates a Color4 linearly
  29653. * @param startValue Start value of the animation curve
  29654. * @param endValue End value of the animation curve
  29655. * @param gradient Scalar amount to interpolate
  29656. * @returns Interpolated Color3 value
  29657. */
  29658. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29659. /**
  29660. * @hidden Internal use only
  29661. */
  29662. _getKeyValue(value: any): any;
  29663. /**
  29664. * @hidden Internal use only
  29665. */
  29666. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29667. /**
  29668. * Defines the function to use to interpolate matrices
  29669. * @param startValue defines the start matrix
  29670. * @param endValue defines the end matrix
  29671. * @param gradient defines the gradient between both matrices
  29672. * @param result defines an optional target matrix where to store the interpolation
  29673. * @returns the interpolated matrix
  29674. */
  29675. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29676. /**
  29677. * Makes a copy of the animation
  29678. * @returns Cloned animation
  29679. */
  29680. clone(): Animation;
  29681. /**
  29682. * Sets the key frames of the animation
  29683. * @param values The animation key frames to set
  29684. */
  29685. setKeys(values: Array<IAnimationKey>): void;
  29686. /**
  29687. * Serializes the animation to an object
  29688. * @returns Serialized object
  29689. */
  29690. serialize(): any;
  29691. /**
  29692. * Float animation type
  29693. */
  29694. static readonly ANIMATIONTYPE_FLOAT: number;
  29695. /**
  29696. * Vector3 animation type
  29697. */
  29698. static readonly ANIMATIONTYPE_VECTOR3: number;
  29699. /**
  29700. * Quaternion animation type
  29701. */
  29702. static readonly ANIMATIONTYPE_QUATERNION: number;
  29703. /**
  29704. * Matrix animation type
  29705. */
  29706. static readonly ANIMATIONTYPE_MATRIX: number;
  29707. /**
  29708. * Color3 animation type
  29709. */
  29710. static readonly ANIMATIONTYPE_COLOR3: number;
  29711. /**
  29712. * Color3 animation type
  29713. */
  29714. static readonly ANIMATIONTYPE_COLOR4: number;
  29715. /**
  29716. * Vector2 animation type
  29717. */
  29718. static readonly ANIMATIONTYPE_VECTOR2: number;
  29719. /**
  29720. * Size animation type
  29721. */
  29722. static readonly ANIMATIONTYPE_SIZE: number;
  29723. /**
  29724. * Relative Loop Mode
  29725. */
  29726. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29727. /**
  29728. * Cycle Loop Mode
  29729. */
  29730. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29731. /**
  29732. * Constant Loop Mode
  29733. */
  29734. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29735. /** @hidden */
  29736. static _UniversalLerp(left: any, right: any, amount: number): any;
  29737. /**
  29738. * Parses an animation object and creates an animation
  29739. * @param parsedAnimation Parsed animation object
  29740. * @returns Animation object
  29741. */
  29742. static Parse(parsedAnimation: any): Animation;
  29743. /**
  29744. * Appends the serialized animations from the source animations
  29745. * @param source Source containing the animations
  29746. * @param destination Target to store the animations
  29747. */
  29748. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29749. }
  29750. }
  29751. declare module BABYLON {
  29752. /**
  29753. * Interface containing an array of animations
  29754. */
  29755. export interface IAnimatable {
  29756. /**
  29757. * Array of animations
  29758. */
  29759. animations: Nullable<Array<Animation>>;
  29760. }
  29761. }
  29762. declare module BABYLON {
  29763. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29764. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29765. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29766. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29767. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29768. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29769. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29770. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29771. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29772. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29773. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29774. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29775. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29776. /**
  29777. * Decorator used to define property that can be serialized as reference to a camera
  29778. * @param sourceName defines the name of the property to decorate
  29779. */
  29780. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29781. /**
  29782. * Class used to help serialization objects
  29783. */
  29784. export class SerializationHelper {
  29785. /** @hidden */
  29786. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29787. /** @hidden */
  29788. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29789. /** @hidden */
  29790. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29791. /** @hidden */
  29792. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29793. /**
  29794. * Appends the serialized animations from the source animations
  29795. * @param source Source containing the animations
  29796. * @param destination Target to store the animations
  29797. */
  29798. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29799. /**
  29800. * Static function used to serialized a specific entity
  29801. * @param entity defines the entity to serialize
  29802. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29803. * @returns a JSON compatible object representing the serialization of the entity
  29804. */
  29805. static Serialize<T>(entity: T, serializationObject?: any): any;
  29806. /**
  29807. * Creates a new entity from a serialization data object
  29808. * @param creationFunction defines a function used to instanciated the new entity
  29809. * @param source defines the source serialization data
  29810. * @param scene defines the hosting scene
  29811. * @param rootUrl defines the root url for resources
  29812. * @returns a new entity
  29813. */
  29814. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29815. /**
  29816. * Clones an object
  29817. * @param creationFunction defines the function used to instanciate the new object
  29818. * @param source defines the source object
  29819. * @returns the cloned object
  29820. */
  29821. static Clone<T>(creationFunction: () => T, source: T): T;
  29822. /**
  29823. * Instanciates a new object based on a source one (some data will be shared between both object)
  29824. * @param creationFunction defines the function used to instanciate the new object
  29825. * @param source defines the source object
  29826. * @returns the new object
  29827. */
  29828. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29829. }
  29830. }
  29831. declare module BABYLON {
  29832. /**
  29833. * Class used to manipulate GUIDs
  29834. */
  29835. export class GUID {
  29836. /**
  29837. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29838. * Be aware Math.random() could cause collisions, but:
  29839. * "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"
  29840. * @returns a pseudo random id
  29841. */
  29842. static RandomId(): string;
  29843. }
  29844. }
  29845. declare module BABYLON {
  29846. /**
  29847. * Base class of all the textures in babylon.
  29848. * It groups all the common properties the materials, post process, lights... might need
  29849. * in order to make a correct use of the texture.
  29850. */
  29851. export class BaseTexture implements IAnimatable {
  29852. /**
  29853. * Default anisotropic filtering level for the application.
  29854. * It is set to 4 as a good tradeoff between perf and quality.
  29855. */
  29856. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29857. /**
  29858. * Gets or sets the unique id of the texture
  29859. */
  29860. uniqueId: number;
  29861. /**
  29862. * Define the name of the texture.
  29863. */
  29864. name: string;
  29865. /**
  29866. * Gets or sets an object used to store user defined information.
  29867. */
  29868. metadata: any;
  29869. /**
  29870. * For internal use only. Please do not use.
  29871. */
  29872. reservedDataStore: any;
  29873. private _hasAlpha;
  29874. /**
  29875. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29876. */
  29877. set hasAlpha(value: boolean);
  29878. get hasAlpha(): boolean;
  29879. /**
  29880. * Defines if the alpha value should be determined via the rgb values.
  29881. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29882. */
  29883. getAlphaFromRGB: boolean;
  29884. /**
  29885. * Intensity or strength of the texture.
  29886. * It is commonly used by materials to fine tune the intensity of the texture
  29887. */
  29888. level: number;
  29889. /**
  29890. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29891. * This is part of the texture as textures usually maps to one uv set.
  29892. */
  29893. coordinatesIndex: number;
  29894. private _coordinatesMode;
  29895. /**
  29896. * How a texture is mapped.
  29897. *
  29898. * | Value | Type | Description |
  29899. * | ----- | ----------------------------------- | ----------- |
  29900. * | 0 | EXPLICIT_MODE | |
  29901. * | 1 | SPHERICAL_MODE | |
  29902. * | 2 | PLANAR_MODE | |
  29903. * | 3 | CUBIC_MODE | |
  29904. * | 4 | PROJECTION_MODE | |
  29905. * | 5 | SKYBOX_MODE | |
  29906. * | 6 | INVCUBIC_MODE | |
  29907. * | 7 | EQUIRECTANGULAR_MODE | |
  29908. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29909. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29910. */
  29911. set coordinatesMode(value: number);
  29912. get coordinatesMode(): number;
  29913. /**
  29914. * | Value | Type | Description |
  29915. * | ----- | ------------------ | ----------- |
  29916. * | 0 | CLAMP_ADDRESSMODE | |
  29917. * | 1 | WRAP_ADDRESSMODE | |
  29918. * | 2 | MIRROR_ADDRESSMODE | |
  29919. */
  29920. wrapU: number;
  29921. /**
  29922. * | Value | Type | Description |
  29923. * | ----- | ------------------ | ----------- |
  29924. * | 0 | CLAMP_ADDRESSMODE | |
  29925. * | 1 | WRAP_ADDRESSMODE | |
  29926. * | 2 | MIRROR_ADDRESSMODE | |
  29927. */
  29928. wrapV: number;
  29929. /**
  29930. * | Value | Type | Description |
  29931. * | ----- | ------------------ | ----------- |
  29932. * | 0 | CLAMP_ADDRESSMODE | |
  29933. * | 1 | WRAP_ADDRESSMODE | |
  29934. * | 2 | MIRROR_ADDRESSMODE | |
  29935. */
  29936. wrapR: number;
  29937. /**
  29938. * With compliant hardware and browser (supporting anisotropic filtering)
  29939. * this defines the level of anisotropic filtering in the texture.
  29940. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29941. */
  29942. anisotropicFilteringLevel: number;
  29943. /**
  29944. * Define if the texture is a cube texture or if false a 2d texture.
  29945. */
  29946. get isCube(): boolean;
  29947. set isCube(value: boolean);
  29948. /**
  29949. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29950. */
  29951. get is3D(): boolean;
  29952. set is3D(value: boolean);
  29953. /**
  29954. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29955. */
  29956. get is2DArray(): boolean;
  29957. set is2DArray(value: boolean);
  29958. /**
  29959. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29960. * HDR texture are usually stored in linear space.
  29961. * This only impacts the PBR and Background materials
  29962. */
  29963. gammaSpace: boolean;
  29964. /**
  29965. * Gets or sets whether or not the texture contains RGBD data.
  29966. */
  29967. get isRGBD(): boolean;
  29968. set isRGBD(value: boolean);
  29969. /**
  29970. * Is Z inverted in the texture (useful in a cube texture).
  29971. */
  29972. invertZ: boolean;
  29973. /**
  29974. * Are mip maps generated for this texture or not.
  29975. */
  29976. get noMipmap(): boolean;
  29977. /**
  29978. * @hidden
  29979. */
  29980. lodLevelInAlpha: boolean;
  29981. /**
  29982. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29983. */
  29984. get lodGenerationOffset(): number;
  29985. set lodGenerationOffset(value: number);
  29986. /**
  29987. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29988. */
  29989. get lodGenerationScale(): number;
  29990. set lodGenerationScale(value: number);
  29991. /**
  29992. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29993. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29994. * average roughness values.
  29995. */
  29996. get linearSpecularLOD(): boolean;
  29997. set linearSpecularLOD(value: boolean);
  29998. /**
  29999. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30000. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30001. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30002. */
  30003. get irradianceTexture(): Nullable<BaseTexture>;
  30004. set irradianceTexture(value: Nullable<BaseTexture>);
  30005. /**
  30006. * Define if the texture is a render target.
  30007. */
  30008. isRenderTarget: boolean;
  30009. /**
  30010. * Define the unique id of the texture in the scene.
  30011. */
  30012. get uid(): string;
  30013. /**
  30014. * Return a string representation of the texture.
  30015. * @returns the texture as a string
  30016. */
  30017. toString(): string;
  30018. /**
  30019. * Get the class name of the texture.
  30020. * @returns "BaseTexture"
  30021. */
  30022. getClassName(): string;
  30023. /**
  30024. * Define the list of animation attached to the texture.
  30025. */
  30026. animations: Animation[];
  30027. /**
  30028. * An event triggered when the texture is disposed.
  30029. */
  30030. onDisposeObservable: Observable<BaseTexture>;
  30031. private _onDisposeObserver;
  30032. /**
  30033. * Callback triggered when the texture has been disposed.
  30034. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30035. */
  30036. set onDispose(callback: () => void);
  30037. /**
  30038. * Define the current state of the loading sequence when in delayed load mode.
  30039. */
  30040. delayLoadState: number;
  30041. private _scene;
  30042. /** @hidden */
  30043. _texture: Nullable<InternalTexture>;
  30044. private _uid;
  30045. /**
  30046. * Define if the texture is preventinga material to render or not.
  30047. * If not and the texture is not ready, the engine will use a default black texture instead.
  30048. */
  30049. get isBlocking(): boolean;
  30050. /**
  30051. * Instantiates a new BaseTexture.
  30052. * Base class of all the textures in babylon.
  30053. * It groups all the common properties the materials, post process, lights... might need
  30054. * in order to make a correct use of the texture.
  30055. * @param scene Define the scene the texture blongs to
  30056. */
  30057. constructor(scene: Nullable<Scene>);
  30058. /**
  30059. * Get the scene the texture belongs to.
  30060. * @returns the scene or null if undefined
  30061. */
  30062. getScene(): Nullable<Scene>;
  30063. /**
  30064. * Get the texture transform matrix used to offset tile the texture for istance.
  30065. * @returns the transformation matrix
  30066. */
  30067. getTextureMatrix(): Matrix;
  30068. /**
  30069. * Get the texture reflection matrix used to rotate/transform the reflection.
  30070. * @returns the reflection matrix
  30071. */
  30072. getReflectionTextureMatrix(): Matrix;
  30073. /**
  30074. * Get the underlying lower level texture from Babylon.
  30075. * @returns the insternal texture
  30076. */
  30077. getInternalTexture(): Nullable<InternalTexture>;
  30078. /**
  30079. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30080. * @returns true if ready or not blocking
  30081. */
  30082. isReadyOrNotBlocking(): boolean;
  30083. /**
  30084. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30085. * @returns true if fully ready
  30086. */
  30087. isReady(): boolean;
  30088. private _cachedSize;
  30089. /**
  30090. * Get the size of the texture.
  30091. * @returns the texture size.
  30092. */
  30093. getSize(): ISize;
  30094. /**
  30095. * Get the base size of the texture.
  30096. * It can be different from the size if the texture has been resized for POT for instance
  30097. * @returns the base size
  30098. */
  30099. getBaseSize(): ISize;
  30100. /**
  30101. * Update the sampling mode of the texture.
  30102. * Default is Trilinear mode.
  30103. *
  30104. * | Value | Type | Description |
  30105. * | ----- | ------------------ | ----------- |
  30106. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30107. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30108. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30109. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30110. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30111. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30112. * | 7 | NEAREST_LINEAR | |
  30113. * | 8 | NEAREST_NEAREST | |
  30114. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30115. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30116. * | 11 | LINEAR_LINEAR | |
  30117. * | 12 | LINEAR_NEAREST | |
  30118. *
  30119. * > _mag_: magnification filter (close to the viewer)
  30120. * > _min_: minification filter (far from the viewer)
  30121. * > _mip_: filter used between mip map levels
  30122. *@param samplingMode Define the new sampling mode of the texture
  30123. */
  30124. updateSamplingMode(samplingMode: number): void;
  30125. /**
  30126. * Scales the texture if is `canRescale()`
  30127. * @param ratio the resize factor we want to use to rescale
  30128. */
  30129. scale(ratio: number): void;
  30130. /**
  30131. * Get if the texture can rescale.
  30132. */
  30133. get canRescale(): boolean;
  30134. /** @hidden */
  30135. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30136. /** @hidden */
  30137. _rebuild(): void;
  30138. /**
  30139. * Triggers the load sequence in delayed load mode.
  30140. */
  30141. delayLoad(): void;
  30142. /**
  30143. * Clones the texture.
  30144. * @returns the cloned texture
  30145. */
  30146. clone(): Nullable<BaseTexture>;
  30147. /**
  30148. * Get the texture underlying type (INT, FLOAT...)
  30149. */
  30150. get textureType(): number;
  30151. /**
  30152. * Get the texture underlying format (RGB, RGBA...)
  30153. */
  30154. get textureFormat(): number;
  30155. /**
  30156. * Indicates that textures need to be re-calculated for all materials
  30157. */
  30158. protected _markAllSubMeshesAsTexturesDirty(): void;
  30159. /**
  30160. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30161. * This will returns an RGBA array buffer containing either in values (0-255) or
  30162. * float values (0-1) depending of the underlying buffer type.
  30163. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30164. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30165. * @param buffer defines a user defined buffer to fill with data (can be null)
  30166. * @returns The Array buffer containing the pixels data.
  30167. */
  30168. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30169. /**
  30170. * Release and destroy the underlying lower level texture aka internalTexture.
  30171. */
  30172. releaseInternalTexture(): void;
  30173. /** @hidden */
  30174. get _lodTextureHigh(): Nullable<BaseTexture>;
  30175. /** @hidden */
  30176. get _lodTextureMid(): Nullable<BaseTexture>;
  30177. /** @hidden */
  30178. get _lodTextureLow(): Nullable<BaseTexture>;
  30179. /**
  30180. * Dispose the texture and release its associated resources.
  30181. */
  30182. dispose(): void;
  30183. /**
  30184. * Serialize the texture into a JSON representation that can be parsed later on.
  30185. * @returns the JSON representation of the texture
  30186. */
  30187. serialize(): any;
  30188. /**
  30189. * Helper function to be called back once a list of texture contains only ready textures.
  30190. * @param textures Define the list of textures to wait for
  30191. * @param callback Define the callback triggered once the entire list will be ready
  30192. */
  30193. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30194. }
  30195. }
  30196. declare module BABYLON {
  30197. /**
  30198. * Options to be used when creating an effect.
  30199. */
  30200. export interface IEffectCreationOptions {
  30201. /**
  30202. * Atrributes that will be used in the shader.
  30203. */
  30204. attributes: string[];
  30205. /**
  30206. * Uniform varible names that will be set in the shader.
  30207. */
  30208. uniformsNames: string[];
  30209. /**
  30210. * Uniform buffer variable names that will be set in the shader.
  30211. */
  30212. uniformBuffersNames: string[];
  30213. /**
  30214. * Sampler texture variable names that will be set in the shader.
  30215. */
  30216. samplers: string[];
  30217. /**
  30218. * Define statements that will be set in the shader.
  30219. */
  30220. defines: any;
  30221. /**
  30222. * Possible fallbacks for this effect to improve performance when needed.
  30223. */
  30224. fallbacks: Nullable<IEffectFallbacks>;
  30225. /**
  30226. * Callback that will be called when the shader is compiled.
  30227. */
  30228. onCompiled: Nullable<(effect: Effect) => void>;
  30229. /**
  30230. * Callback that will be called if an error occurs during shader compilation.
  30231. */
  30232. onError: Nullable<(effect: Effect, errors: string) => void>;
  30233. /**
  30234. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30235. */
  30236. indexParameters?: any;
  30237. /**
  30238. * Max number of lights that can be used in the shader.
  30239. */
  30240. maxSimultaneousLights?: number;
  30241. /**
  30242. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30243. */
  30244. transformFeedbackVaryings?: Nullable<string[]>;
  30245. }
  30246. /**
  30247. * Effect containing vertex and fragment shader that can be executed on an object.
  30248. */
  30249. export class Effect implements IDisposable {
  30250. /**
  30251. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30252. */
  30253. static ShadersRepository: string;
  30254. /**
  30255. * Enable logging of the shader code when a compilation error occurs
  30256. */
  30257. static LogShaderCodeOnCompilationError: boolean;
  30258. /**
  30259. * Name of the effect.
  30260. */
  30261. name: any;
  30262. /**
  30263. * String container all the define statements that should be set on the shader.
  30264. */
  30265. defines: string;
  30266. /**
  30267. * Callback that will be called when the shader is compiled.
  30268. */
  30269. onCompiled: Nullable<(effect: Effect) => void>;
  30270. /**
  30271. * Callback that will be called if an error occurs during shader compilation.
  30272. */
  30273. onError: Nullable<(effect: Effect, errors: string) => void>;
  30274. /**
  30275. * Callback that will be called when effect is bound.
  30276. */
  30277. onBind: Nullable<(effect: Effect) => void>;
  30278. /**
  30279. * Unique ID of the effect.
  30280. */
  30281. uniqueId: number;
  30282. /**
  30283. * Observable that will be called when the shader is compiled.
  30284. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30285. */
  30286. onCompileObservable: Observable<Effect>;
  30287. /**
  30288. * Observable that will be called if an error occurs during shader compilation.
  30289. */
  30290. onErrorObservable: Observable<Effect>;
  30291. /** @hidden */
  30292. _onBindObservable: Nullable<Observable<Effect>>;
  30293. /**
  30294. * @hidden
  30295. * Specifies if the effect was previously ready
  30296. */
  30297. _wasPreviouslyReady: boolean;
  30298. /**
  30299. * Observable that will be called when effect is bound.
  30300. */
  30301. get onBindObservable(): Observable<Effect>;
  30302. /** @hidden */
  30303. _bonesComputationForcedToCPU: boolean;
  30304. private static _uniqueIdSeed;
  30305. private _engine;
  30306. private _uniformBuffersNames;
  30307. private _uniformsNames;
  30308. private _samplerList;
  30309. private _samplers;
  30310. private _isReady;
  30311. private _compilationError;
  30312. private _allFallbacksProcessed;
  30313. private _attributesNames;
  30314. private _attributes;
  30315. private _attributeLocationByName;
  30316. private _uniforms;
  30317. /**
  30318. * Key for the effect.
  30319. * @hidden
  30320. */
  30321. _key: string;
  30322. private _indexParameters;
  30323. private _fallbacks;
  30324. private _vertexSourceCode;
  30325. private _fragmentSourceCode;
  30326. private _vertexSourceCodeOverride;
  30327. private _fragmentSourceCodeOverride;
  30328. private _transformFeedbackVaryings;
  30329. /**
  30330. * Compiled shader to webGL program.
  30331. * @hidden
  30332. */
  30333. _pipelineContext: Nullable<IPipelineContext>;
  30334. private _valueCache;
  30335. private static _baseCache;
  30336. /**
  30337. * Instantiates an effect.
  30338. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30339. * @param baseName Name of the effect.
  30340. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30341. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30342. * @param samplers List of sampler variables that will be passed to the shader.
  30343. * @param engine Engine to be used to render the effect
  30344. * @param defines Define statements to be added to the shader.
  30345. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30346. * @param onCompiled Callback that will be called when the shader is compiled.
  30347. * @param onError Callback that will be called if an error occurs during shader compilation.
  30348. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30349. */
  30350. 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);
  30351. private _useFinalCode;
  30352. /**
  30353. * Unique key for this effect
  30354. */
  30355. get key(): string;
  30356. /**
  30357. * If the effect has been compiled and prepared.
  30358. * @returns if the effect is compiled and prepared.
  30359. */
  30360. isReady(): boolean;
  30361. private _isReadyInternal;
  30362. /**
  30363. * The engine the effect was initialized with.
  30364. * @returns the engine.
  30365. */
  30366. getEngine(): Engine;
  30367. /**
  30368. * The pipeline context for this effect
  30369. * @returns the associated pipeline context
  30370. */
  30371. getPipelineContext(): Nullable<IPipelineContext>;
  30372. /**
  30373. * The set of names of attribute variables for the shader.
  30374. * @returns An array of attribute names.
  30375. */
  30376. getAttributesNames(): string[];
  30377. /**
  30378. * Returns the attribute at the given index.
  30379. * @param index The index of the attribute.
  30380. * @returns The location of the attribute.
  30381. */
  30382. getAttributeLocation(index: number): number;
  30383. /**
  30384. * Returns the attribute based on the name of the variable.
  30385. * @param name of the attribute to look up.
  30386. * @returns the attribute location.
  30387. */
  30388. getAttributeLocationByName(name: string): number;
  30389. /**
  30390. * The number of attributes.
  30391. * @returns the numnber of attributes.
  30392. */
  30393. getAttributesCount(): number;
  30394. /**
  30395. * Gets the index of a uniform variable.
  30396. * @param uniformName of the uniform to look up.
  30397. * @returns the index.
  30398. */
  30399. getUniformIndex(uniformName: string): number;
  30400. /**
  30401. * Returns the attribute based on the name of the variable.
  30402. * @param uniformName of the uniform to look up.
  30403. * @returns the location of the uniform.
  30404. */
  30405. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30406. /**
  30407. * Returns an array of sampler variable names
  30408. * @returns The array of sampler variable neames.
  30409. */
  30410. getSamplers(): string[];
  30411. /**
  30412. * The error from the last compilation.
  30413. * @returns the error string.
  30414. */
  30415. getCompilationError(): string;
  30416. /**
  30417. * Gets a boolean indicating that all fallbacks were used during compilation
  30418. * @returns true if all fallbacks were used
  30419. */
  30420. allFallbacksProcessed(): boolean;
  30421. /**
  30422. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30423. * @param func The callback to be used.
  30424. */
  30425. executeWhenCompiled(func: (effect: Effect) => void): void;
  30426. private _checkIsReady;
  30427. private _loadShader;
  30428. /**
  30429. * Recompiles the webGL program
  30430. * @param vertexSourceCode The source code for the vertex shader.
  30431. * @param fragmentSourceCode The source code for the fragment shader.
  30432. * @param onCompiled Callback called when completed.
  30433. * @param onError Callback called on error.
  30434. * @hidden
  30435. */
  30436. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30437. /**
  30438. * Prepares the effect
  30439. * @hidden
  30440. */
  30441. _prepareEffect(): void;
  30442. private _getShaderCodeAndErrorLine;
  30443. private _processCompilationErrors;
  30444. /**
  30445. * Checks if the effect is supported. (Must be called after compilation)
  30446. */
  30447. get isSupported(): boolean;
  30448. /**
  30449. * Binds a texture to the engine to be used as output of the shader.
  30450. * @param channel Name of the output variable.
  30451. * @param texture Texture to bind.
  30452. * @hidden
  30453. */
  30454. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30455. /**
  30456. * Sets a texture on the engine to be used in the shader.
  30457. * @param channel Name of the sampler variable.
  30458. * @param texture Texture to set.
  30459. */
  30460. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30461. /**
  30462. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30463. * @param channel Name of the sampler variable.
  30464. * @param texture Texture to set.
  30465. */
  30466. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30467. /**
  30468. * Sets an array of textures on the engine to be used in the shader.
  30469. * @param channel Name of the variable.
  30470. * @param textures Textures to set.
  30471. */
  30472. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30473. /**
  30474. * 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)
  30475. * @param channel Name of the sampler variable.
  30476. * @param postProcess Post process to get the input texture from.
  30477. */
  30478. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30479. /**
  30480. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30481. * 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)
  30482. * @param channel Name of the sampler variable.
  30483. * @param postProcess Post process to get the output texture from.
  30484. */
  30485. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30486. /** @hidden */
  30487. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30488. /** @hidden */
  30489. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30490. /** @hidden */
  30491. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30492. /** @hidden */
  30493. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30494. /**
  30495. * Binds a buffer to a uniform.
  30496. * @param buffer Buffer to bind.
  30497. * @param name Name of the uniform variable to bind to.
  30498. */
  30499. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30500. /**
  30501. * Binds block to a uniform.
  30502. * @param blockName Name of the block to bind.
  30503. * @param index Index to bind.
  30504. */
  30505. bindUniformBlock(blockName: string, index: number): void;
  30506. /**
  30507. * Sets an interger value on a uniform variable.
  30508. * @param uniformName Name of the variable.
  30509. * @param value Value to be set.
  30510. * @returns this effect.
  30511. */
  30512. setInt(uniformName: string, value: number): Effect;
  30513. /**
  30514. * Sets an int array on a uniform variable.
  30515. * @param uniformName Name of the variable.
  30516. * @param array array to be set.
  30517. * @returns this effect.
  30518. */
  30519. setIntArray(uniformName: string, array: Int32Array): Effect;
  30520. /**
  30521. * 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)
  30522. * @param uniformName Name of the variable.
  30523. * @param array array to be set.
  30524. * @returns this effect.
  30525. */
  30526. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30527. /**
  30528. * 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)
  30529. * @param uniformName Name of the variable.
  30530. * @param array array to be set.
  30531. * @returns this effect.
  30532. */
  30533. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30534. /**
  30535. * 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)
  30536. * @param uniformName Name of the variable.
  30537. * @param array array to be set.
  30538. * @returns this effect.
  30539. */
  30540. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30541. /**
  30542. * Sets an float array on a uniform variable.
  30543. * @param uniformName Name of the variable.
  30544. * @param array array to be set.
  30545. * @returns this effect.
  30546. */
  30547. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30548. /**
  30549. * 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)
  30550. * @param uniformName Name of the variable.
  30551. * @param array array to be set.
  30552. * @returns this effect.
  30553. */
  30554. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30555. /**
  30556. * 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)
  30557. * @param uniformName Name of the variable.
  30558. * @param array array to be set.
  30559. * @returns this effect.
  30560. */
  30561. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30562. /**
  30563. * 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)
  30564. * @param uniformName Name of the variable.
  30565. * @param array array to be set.
  30566. * @returns this effect.
  30567. */
  30568. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30569. /**
  30570. * Sets an array on a uniform variable.
  30571. * @param uniformName Name of the variable.
  30572. * @param array array to be set.
  30573. * @returns this effect.
  30574. */
  30575. setArray(uniformName: string, array: number[]): Effect;
  30576. /**
  30577. * 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)
  30578. * @param uniformName Name of the variable.
  30579. * @param array array to be set.
  30580. * @returns this effect.
  30581. */
  30582. setArray2(uniformName: string, array: number[]): Effect;
  30583. /**
  30584. * 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)
  30585. * @param uniformName Name of the variable.
  30586. * @param array array to be set.
  30587. * @returns this effect.
  30588. */
  30589. setArray3(uniformName: string, array: number[]): Effect;
  30590. /**
  30591. * 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)
  30592. * @param uniformName Name of the variable.
  30593. * @param array array to be set.
  30594. * @returns this effect.
  30595. */
  30596. setArray4(uniformName: string, array: number[]): Effect;
  30597. /**
  30598. * Sets matrices on a uniform variable.
  30599. * @param uniformName Name of the variable.
  30600. * @param matrices matrices to be set.
  30601. * @returns this effect.
  30602. */
  30603. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30604. /**
  30605. * Sets matrix on a uniform variable.
  30606. * @param uniformName Name of the variable.
  30607. * @param matrix matrix to be set.
  30608. * @returns this effect.
  30609. */
  30610. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30611. /**
  30612. * 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)
  30613. * @param uniformName Name of the variable.
  30614. * @param matrix matrix to be set.
  30615. * @returns this effect.
  30616. */
  30617. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30618. /**
  30619. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30620. * @param uniformName Name of the variable.
  30621. * @param matrix matrix to be set.
  30622. * @returns this effect.
  30623. */
  30624. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30625. /**
  30626. * Sets a float on a uniform variable.
  30627. * @param uniformName Name of the variable.
  30628. * @param value value to be set.
  30629. * @returns this effect.
  30630. */
  30631. setFloat(uniformName: string, value: number): Effect;
  30632. /**
  30633. * Sets a boolean on a uniform variable.
  30634. * @param uniformName Name of the variable.
  30635. * @param bool value to be set.
  30636. * @returns this effect.
  30637. */
  30638. setBool(uniformName: string, bool: boolean): Effect;
  30639. /**
  30640. * Sets a Vector2 on a uniform variable.
  30641. * @param uniformName Name of the variable.
  30642. * @param vector2 vector2 to be set.
  30643. * @returns this effect.
  30644. */
  30645. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30646. /**
  30647. * Sets a float2 on a uniform variable.
  30648. * @param uniformName Name of the variable.
  30649. * @param x First float in float2.
  30650. * @param y Second float in float2.
  30651. * @returns this effect.
  30652. */
  30653. setFloat2(uniformName: string, x: number, y: number): Effect;
  30654. /**
  30655. * Sets a Vector3 on a uniform variable.
  30656. * @param uniformName Name of the variable.
  30657. * @param vector3 Value to be set.
  30658. * @returns this effect.
  30659. */
  30660. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30661. /**
  30662. * Sets a float3 on a uniform variable.
  30663. * @param uniformName Name of the variable.
  30664. * @param x First float in float3.
  30665. * @param y Second float in float3.
  30666. * @param z Third float in float3.
  30667. * @returns this effect.
  30668. */
  30669. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30670. /**
  30671. * Sets a Vector4 on a uniform variable.
  30672. * @param uniformName Name of the variable.
  30673. * @param vector4 Value to be set.
  30674. * @returns this effect.
  30675. */
  30676. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30677. /**
  30678. * Sets a float4 on a uniform variable.
  30679. * @param uniformName Name of the variable.
  30680. * @param x First float in float4.
  30681. * @param y Second float in float4.
  30682. * @param z Third float in float4.
  30683. * @param w Fourth float in float4.
  30684. * @returns this effect.
  30685. */
  30686. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30687. /**
  30688. * Sets a Color3 on a uniform variable.
  30689. * @param uniformName Name of the variable.
  30690. * @param color3 Value to be set.
  30691. * @returns this effect.
  30692. */
  30693. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30694. /**
  30695. * Sets a Color4 on a uniform variable.
  30696. * @param uniformName Name of the variable.
  30697. * @param color3 Value to be set.
  30698. * @param alpha Alpha value to be set.
  30699. * @returns this effect.
  30700. */
  30701. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30702. /**
  30703. * Sets a Color4 on a uniform variable
  30704. * @param uniformName defines the name of the variable
  30705. * @param color4 defines the value to be set
  30706. * @returns this effect.
  30707. */
  30708. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30709. /** Release all associated resources */
  30710. dispose(): void;
  30711. /**
  30712. * This function will add a new shader to the shader store
  30713. * @param name the name of the shader
  30714. * @param pixelShader optional pixel shader content
  30715. * @param vertexShader optional vertex shader content
  30716. */
  30717. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30718. /**
  30719. * Store of each shader (The can be looked up using effect.key)
  30720. */
  30721. static ShadersStore: {
  30722. [key: string]: string;
  30723. };
  30724. /**
  30725. * Store of each included file for a shader (The can be looked up using effect.key)
  30726. */
  30727. static IncludesShadersStore: {
  30728. [key: string]: string;
  30729. };
  30730. /**
  30731. * Resets the cache of effects.
  30732. */
  30733. static ResetCache(): void;
  30734. }
  30735. }
  30736. declare module BABYLON {
  30737. /**
  30738. * Interface used to describe the capabilities of the engine relatively to the current browser
  30739. */
  30740. export interface EngineCapabilities {
  30741. /** Maximum textures units per fragment shader */
  30742. maxTexturesImageUnits: number;
  30743. /** Maximum texture units per vertex shader */
  30744. maxVertexTextureImageUnits: number;
  30745. /** Maximum textures units in the entire pipeline */
  30746. maxCombinedTexturesImageUnits: number;
  30747. /** Maximum texture size */
  30748. maxTextureSize: number;
  30749. /** Maximum texture samples */
  30750. maxSamples?: number;
  30751. /** Maximum cube texture size */
  30752. maxCubemapTextureSize: number;
  30753. /** Maximum render texture size */
  30754. maxRenderTextureSize: number;
  30755. /** Maximum number of vertex attributes */
  30756. maxVertexAttribs: number;
  30757. /** Maximum number of varyings */
  30758. maxVaryingVectors: number;
  30759. /** Maximum number of uniforms per vertex shader */
  30760. maxVertexUniformVectors: number;
  30761. /** Maximum number of uniforms per fragment shader */
  30762. maxFragmentUniformVectors: number;
  30763. /** Defines if standard derivates (dx/dy) are supported */
  30764. standardDerivatives: boolean;
  30765. /** Defines if s3tc texture compression is supported */
  30766. s3tc?: WEBGL_compressed_texture_s3tc;
  30767. /** Defines if pvrtc texture compression is supported */
  30768. pvrtc: any;
  30769. /** Defines if etc1 texture compression is supported */
  30770. etc1: any;
  30771. /** Defines if etc2 texture compression is supported */
  30772. etc2: any;
  30773. /** Defines if astc texture compression is supported */
  30774. astc: any;
  30775. /** Defines if float textures are supported */
  30776. textureFloat: boolean;
  30777. /** Defines if vertex array objects are supported */
  30778. vertexArrayObject: boolean;
  30779. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30780. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30781. /** Gets the maximum level of anisotropy supported */
  30782. maxAnisotropy: number;
  30783. /** Defines if instancing is supported */
  30784. instancedArrays: boolean;
  30785. /** Defines if 32 bits indices are supported */
  30786. uintIndices: boolean;
  30787. /** Defines if high precision shaders are supported */
  30788. highPrecisionShaderSupported: boolean;
  30789. /** Defines if depth reading in the fragment shader is supported */
  30790. fragmentDepthSupported: boolean;
  30791. /** Defines if float texture linear filtering is supported*/
  30792. textureFloatLinearFiltering: boolean;
  30793. /** Defines if rendering to float textures is supported */
  30794. textureFloatRender: boolean;
  30795. /** Defines if half float textures are supported*/
  30796. textureHalfFloat: boolean;
  30797. /** Defines if half float texture linear filtering is supported*/
  30798. textureHalfFloatLinearFiltering: boolean;
  30799. /** Defines if rendering to half float textures is supported */
  30800. textureHalfFloatRender: boolean;
  30801. /** Defines if textureLOD shader command is supported */
  30802. textureLOD: boolean;
  30803. /** Defines if draw buffers extension is supported */
  30804. drawBuffersExtension: boolean;
  30805. /** Defines if depth textures are supported */
  30806. depthTextureExtension: boolean;
  30807. /** Defines if float color buffer are supported */
  30808. colorBufferFloat: boolean;
  30809. /** Gets disjoint timer query extension (null if not supported) */
  30810. timerQuery?: EXT_disjoint_timer_query;
  30811. /** Defines if timestamp can be used with timer query */
  30812. canUseTimestampForTimerQuery: boolean;
  30813. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30814. multiview?: any;
  30815. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30816. oculusMultiview?: any;
  30817. /** Function used to let the system compiles shaders in background */
  30818. parallelShaderCompile?: {
  30819. COMPLETION_STATUS_KHR: number;
  30820. };
  30821. /** Max number of texture samples for MSAA */
  30822. maxMSAASamples: number;
  30823. /** Defines if the blend min max extension is supported */
  30824. blendMinMax: boolean;
  30825. }
  30826. }
  30827. declare module BABYLON {
  30828. /**
  30829. * @hidden
  30830. **/
  30831. export class DepthCullingState {
  30832. private _isDepthTestDirty;
  30833. private _isDepthMaskDirty;
  30834. private _isDepthFuncDirty;
  30835. private _isCullFaceDirty;
  30836. private _isCullDirty;
  30837. private _isZOffsetDirty;
  30838. private _isFrontFaceDirty;
  30839. private _depthTest;
  30840. private _depthMask;
  30841. private _depthFunc;
  30842. private _cull;
  30843. private _cullFace;
  30844. private _zOffset;
  30845. private _frontFace;
  30846. /**
  30847. * Initializes the state.
  30848. */
  30849. constructor();
  30850. get isDirty(): boolean;
  30851. get zOffset(): number;
  30852. set zOffset(value: number);
  30853. get cullFace(): Nullable<number>;
  30854. set cullFace(value: Nullable<number>);
  30855. get cull(): Nullable<boolean>;
  30856. set cull(value: Nullable<boolean>);
  30857. get depthFunc(): Nullable<number>;
  30858. set depthFunc(value: Nullable<number>);
  30859. get depthMask(): boolean;
  30860. set depthMask(value: boolean);
  30861. get depthTest(): boolean;
  30862. set depthTest(value: boolean);
  30863. get frontFace(): Nullable<number>;
  30864. set frontFace(value: Nullable<number>);
  30865. reset(): void;
  30866. apply(gl: WebGLRenderingContext): void;
  30867. }
  30868. }
  30869. declare module BABYLON {
  30870. /**
  30871. * @hidden
  30872. **/
  30873. export class StencilState {
  30874. /** 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 */
  30875. static readonly ALWAYS: number;
  30876. /** Passed to stencilOperation to specify that stencil value must be kept */
  30877. static readonly KEEP: number;
  30878. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30879. static readonly REPLACE: number;
  30880. private _isStencilTestDirty;
  30881. private _isStencilMaskDirty;
  30882. private _isStencilFuncDirty;
  30883. private _isStencilOpDirty;
  30884. private _stencilTest;
  30885. private _stencilMask;
  30886. private _stencilFunc;
  30887. private _stencilFuncRef;
  30888. private _stencilFuncMask;
  30889. private _stencilOpStencilFail;
  30890. private _stencilOpDepthFail;
  30891. private _stencilOpStencilDepthPass;
  30892. get isDirty(): boolean;
  30893. get stencilFunc(): number;
  30894. set stencilFunc(value: number);
  30895. get stencilFuncRef(): number;
  30896. set stencilFuncRef(value: number);
  30897. get stencilFuncMask(): number;
  30898. set stencilFuncMask(value: number);
  30899. get stencilOpStencilFail(): number;
  30900. set stencilOpStencilFail(value: number);
  30901. get stencilOpDepthFail(): number;
  30902. set stencilOpDepthFail(value: number);
  30903. get stencilOpStencilDepthPass(): number;
  30904. set stencilOpStencilDepthPass(value: number);
  30905. get stencilMask(): number;
  30906. set stencilMask(value: number);
  30907. get stencilTest(): boolean;
  30908. set stencilTest(value: boolean);
  30909. constructor();
  30910. reset(): void;
  30911. apply(gl: WebGLRenderingContext): void;
  30912. }
  30913. }
  30914. declare module BABYLON {
  30915. /**
  30916. * @hidden
  30917. **/
  30918. export class AlphaState {
  30919. private _isAlphaBlendDirty;
  30920. private _isBlendFunctionParametersDirty;
  30921. private _isBlendEquationParametersDirty;
  30922. private _isBlendConstantsDirty;
  30923. private _alphaBlend;
  30924. private _blendFunctionParameters;
  30925. private _blendEquationParameters;
  30926. private _blendConstants;
  30927. /**
  30928. * Initializes the state.
  30929. */
  30930. constructor();
  30931. get isDirty(): boolean;
  30932. get alphaBlend(): boolean;
  30933. set alphaBlend(value: boolean);
  30934. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30935. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30936. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30937. reset(): void;
  30938. apply(gl: WebGLRenderingContext): void;
  30939. }
  30940. }
  30941. declare module BABYLON {
  30942. /** @hidden */
  30943. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30944. attributeProcessor(attribute: string): string;
  30945. varyingProcessor(varying: string, isFragment: boolean): string;
  30946. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30947. }
  30948. }
  30949. declare module BABYLON {
  30950. /**
  30951. * Interface for attribute information associated with buffer instanciation
  30952. */
  30953. export interface InstancingAttributeInfo {
  30954. /**
  30955. * Name of the GLSL attribute
  30956. * if attribute index is not specified, this is used to retrieve the index from the effect
  30957. */
  30958. attributeName: string;
  30959. /**
  30960. * Index/offset of the attribute in the vertex shader
  30961. * if not specified, this will be computes from the name.
  30962. */
  30963. index?: number;
  30964. /**
  30965. * size of the attribute, 1, 2, 3 or 4
  30966. */
  30967. attributeSize: number;
  30968. /**
  30969. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30970. */
  30971. offset: number;
  30972. /**
  30973. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30974. * default to 1
  30975. */
  30976. divisor?: number;
  30977. /**
  30978. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30979. * default is FLOAT
  30980. */
  30981. attributeType?: number;
  30982. /**
  30983. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30984. */
  30985. normalized?: boolean;
  30986. }
  30987. }
  30988. declare module BABYLON {
  30989. interface ThinEngine {
  30990. /**
  30991. * Update a video texture
  30992. * @param texture defines the texture to update
  30993. * @param video defines the video element to use
  30994. * @param invertY defines if data must be stored with Y axis inverted
  30995. */
  30996. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30997. }
  30998. }
  30999. declare module BABYLON {
  31000. /**
  31001. * Settings for finer control over video usage
  31002. */
  31003. export interface VideoTextureSettings {
  31004. /**
  31005. * Applies `autoplay` to video, if specified
  31006. */
  31007. autoPlay?: boolean;
  31008. /**
  31009. * Applies `loop` to video, if specified
  31010. */
  31011. loop?: boolean;
  31012. /**
  31013. * Automatically updates internal texture from video at every frame in the render loop
  31014. */
  31015. autoUpdateTexture: boolean;
  31016. /**
  31017. * Image src displayed during the video loading or until the user interacts with the video.
  31018. */
  31019. poster?: string;
  31020. }
  31021. /**
  31022. * If you want to display a video in your scene, this is the special texture for that.
  31023. * This special texture works similar to other textures, with the exception of a few parameters.
  31024. * @see https://doc.babylonjs.com/how_to/video_texture
  31025. */
  31026. export class VideoTexture extends Texture {
  31027. /**
  31028. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31029. */
  31030. readonly autoUpdateTexture: boolean;
  31031. /**
  31032. * The video instance used by the texture internally
  31033. */
  31034. readonly video: HTMLVideoElement;
  31035. private _onUserActionRequestedObservable;
  31036. /**
  31037. * Event triggerd when a dom action is required by the user to play the video.
  31038. * This happens due to recent changes in browser policies preventing video to auto start.
  31039. */
  31040. get onUserActionRequestedObservable(): Observable<Texture>;
  31041. private _generateMipMaps;
  31042. private _engine;
  31043. private _stillImageCaptured;
  31044. private _displayingPosterTexture;
  31045. private _settings;
  31046. private _createInternalTextureOnEvent;
  31047. private _frameId;
  31048. private _currentSrc;
  31049. /**
  31050. * Creates a video texture.
  31051. * If you want to display a video in your scene, this is the special texture for that.
  31052. * This special texture works similar to other textures, with the exception of a few parameters.
  31053. * @see https://doc.babylonjs.com/how_to/video_texture
  31054. * @param name optional name, will detect from video source, if not defined
  31055. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31056. * @param scene is obviously the current scene.
  31057. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31058. * @param invertY is false by default but can be used to invert video on Y axis
  31059. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31060. * @param settings allows finer control over video usage
  31061. */
  31062. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31063. private _getName;
  31064. private _getVideo;
  31065. private _createInternalTexture;
  31066. private reset;
  31067. /**
  31068. * @hidden Internal method to initiate `update`.
  31069. */
  31070. _rebuild(): void;
  31071. /**
  31072. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31073. */
  31074. update(): void;
  31075. /**
  31076. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31077. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31078. */
  31079. updateTexture(isVisible: boolean): void;
  31080. protected _updateInternalTexture: () => void;
  31081. /**
  31082. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31083. * @param url New url.
  31084. */
  31085. updateURL(url: string): void;
  31086. /**
  31087. * Clones the texture.
  31088. * @returns the cloned texture
  31089. */
  31090. clone(): VideoTexture;
  31091. /**
  31092. * Dispose the texture and release its associated resources.
  31093. */
  31094. dispose(): void;
  31095. /**
  31096. * Creates a video texture straight from a stream.
  31097. * @param scene Define the scene the texture should be created in
  31098. * @param stream Define the stream the texture should be created from
  31099. * @returns The created video texture as a promise
  31100. */
  31101. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31102. /**
  31103. * Creates a video texture straight from your WebCam video feed.
  31104. * @param scene Define the scene the texture should be created in
  31105. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31106. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31107. * @returns The created video texture as a promise
  31108. */
  31109. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31110. minWidth: number;
  31111. maxWidth: number;
  31112. minHeight: number;
  31113. maxHeight: number;
  31114. deviceId: string;
  31115. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31116. /**
  31117. * Creates a video texture straight from your WebCam video feed.
  31118. * @param scene Define the scene the texture should be created in
  31119. * @param onReady Define a callback to triggered once the texture will be ready
  31120. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31121. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31122. */
  31123. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31124. minWidth: number;
  31125. maxWidth: number;
  31126. minHeight: number;
  31127. maxHeight: number;
  31128. deviceId: string;
  31129. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31130. }
  31131. }
  31132. declare module BABYLON {
  31133. /**
  31134. * Defines the interface used by objects working like Scene
  31135. * @hidden
  31136. */
  31137. export interface ISceneLike {
  31138. _addPendingData(data: any): void;
  31139. _removePendingData(data: any): void;
  31140. offlineProvider: IOfflineProvider;
  31141. }
  31142. /** Interface defining initialization parameters for Engine class */
  31143. export interface EngineOptions extends WebGLContextAttributes {
  31144. /**
  31145. * Defines if the engine should no exceed a specified device ratio
  31146. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31147. */
  31148. limitDeviceRatio?: number;
  31149. /**
  31150. * Defines if webvr should be enabled automatically
  31151. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31152. */
  31153. autoEnableWebVR?: boolean;
  31154. /**
  31155. * Defines if webgl2 should be turned off even if supported
  31156. * @see http://doc.babylonjs.com/features/webgl2
  31157. */
  31158. disableWebGL2Support?: boolean;
  31159. /**
  31160. * Defines if webaudio should be initialized as well
  31161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31162. */
  31163. audioEngine?: boolean;
  31164. /**
  31165. * Defines if animations should run using a deterministic lock step
  31166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31167. */
  31168. deterministicLockstep?: boolean;
  31169. /** Defines the maximum steps to use with deterministic lock step mode */
  31170. lockstepMaxSteps?: number;
  31171. /** Defines the seconds between each deterministic lock step */
  31172. timeStep?: number;
  31173. /**
  31174. * Defines that engine should ignore context lost events
  31175. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31176. */
  31177. doNotHandleContextLost?: boolean;
  31178. /**
  31179. * Defines that engine should ignore modifying touch action attribute and style
  31180. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31181. */
  31182. doNotHandleTouchAction?: boolean;
  31183. /**
  31184. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31185. */
  31186. useHighPrecisionFloats?: boolean;
  31187. }
  31188. /**
  31189. * The base engine class (root of all engines)
  31190. */
  31191. export class ThinEngine {
  31192. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31193. static ExceptionList: ({
  31194. key: string;
  31195. capture: string;
  31196. captureConstraint: number;
  31197. targets: string[];
  31198. } | {
  31199. key: string;
  31200. capture: null;
  31201. captureConstraint: null;
  31202. targets: string[];
  31203. })[];
  31204. /** @hidden */
  31205. static _TextureLoaders: IInternalTextureLoader[];
  31206. /**
  31207. * Returns the current npm package of the sdk
  31208. */
  31209. static get NpmPackage(): string;
  31210. /**
  31211. * Returns the current version of the framework
  31212. */
  31213. static get Version(): string;
  31214. /**
  31215. * Returns a string describing the current engine
  31216. */
  31217. get description(): string;
  31218. /**
  31219. * Gets or sets the epsilon value used by collision engine
  31220. */
  31221. static CollisionsEpsilon: number;
  31222. /**
  31223. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31224. */
  31225. static get ShadersRepository(): string;
  31226. static set ShadersRepository(value: string);
  31227. /** @hidden */
  31228. _shaderProcessor: IShaderProcessor;
  31229. /**
  31230. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31231. */
  31232. forcePOTTextures: boolean;
  31233. /**
  31234. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31235. */
  31236. isFullscreen: boolean;
  31237. /**
  31238. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31239. */
  31240. cullBackFaces: boolean;
  31241. /**
  31242. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31243. */
  31244. renderEvenInBackground: boolean;
  31245. /**
  31246. * Gets or sets a boolean indicating that cache can be kept between frames
  31247. */
  31248. preventCacheWipeBetweenFrames: boolean;
  31249. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31250. validateShaderPrograms: boolean;
  31251. /**
  31252. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31253. * This can provide greater z depth for distant objects.
  31254. */
  31255. useReverseDepthBuffer: boolean;
  31256. /**
  31257. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31258. */
  31259. disableUniformBuffers: boolean;
  31260. /** @hidden */
  31261. _uniformBuffers: UniformBuffer[];
  31262. /**
  31263. * Gets a boolean indicating that the engine supports uniform buffers
  31264. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31265. */
  31266. get supportsUniformBuffers(): boolean;
  31267. /** @hidden */
  31268. _gl: WebGLRenderingContext;
  31269. /** @hidden */
  31270. _webGLVersion: number;
  31271. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31272. protected _windowIsBackground: boolean;
  31273. protected _creationOptions: EngineOptions;
  31274. protected _highPrecisionShadersAllowed: boolean;
  31275. /** @hidden */
  31276. get _shouldUseHighPrecisionShader(): boolean;
  31277. /**
  31278. * Gets a boolean indicating that only power of 2 textures are supported
  31279. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31280. */
  31281. get needPOTTextures(): boolean;
  31282. /** @hidden */
  31283. _badOS: boolean;
  31284. /** @hidden */
  31285. _badDesktopOS: boolean;
  31286. private _hardwareScalingLevel;
  31287. /** @hidden */
  31288. _caps: EngineCapabilities;
  31289. private _isStencilEnable;
  31290. private _glVersion;
  31291. private _glRenderer;
  31292. private _glVendor;
  31293. /** @hidden */
  31294. _videoTextureSupported: boolean;
  31295. protected _renderingQueueLaunched: boolean;
  31296. protected _activeRenderLoops: (() => void)[];
  31297. /**
  31298. * Observable signaled when a context lost event is raised
  31299. */
  31300. onContextLostObservable: Observable<ThinEngine>;
  31301. /**
  31302. * Observable signaled when a context restored event is raised
  31303. */
  31304. onContextRestoredObservable: Observable<ThinEngine>;
  31305. private _onContextLost;
  31306. private _onContextRestored;
  31307. protected _contextWasLost: boolean;
  31308. /** @hidden */
  31309. _doNotHandleContextLost: boolean;
  31310. /**
  31311. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31313. */
  31314. get doNotHandleContextLost(): boolean;
  31315. set doNotHandleContextLost(value: boolean);
  31316. /**
  31317. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31318. */
  31319. disableVertexArrayObjects: boolean;
  31320. /** @hidden */
  31321. protected _colorWrite: boolean;
  31322. /** @hidden */
  31323. protected _colorWriteChanged: boolean;
  31324. /** @hidden */
  31325. protected _depthCullingState: DepthCullingState;
  31326. /** @hidden */
  31327. protected _stencilState: StencilState;
  31328. /** @hidden */
  31329. _alphaState: AlphaState;
  31330. /** @hidden */
  31331. _alphaMode: number;
  31332. /** @hidden */
  31333. _alphaEquation: number;
  31334. /** @hidden */
  31335. _internalTexturesCache: InternalTexture[];
  31336. /** @hidden */
  31337. protected _activeChannel: number;
  31338. private _currentTextureChannel;
  31339. /** @hidden */
  31340. protected _boundTexturesCache: {
  31341. [key: string]: Nullable<InternalTexture>;
  31342. };
  31343. /** @hidden */
  31344. protected _currentEffect: Nullable<Effect>;
  31345. /** @hidden */
  31346. protected _currentProgram: Nullable<WebGLProgram>;
  31347. private _compiledEffects;
  31348. private _vertexAttribArraysEnabled;
  31349. /** @hidden */
  31350. protected _cachedViewport: Nullable<IViewportLike>;
  31351. private _cachedVertexArrayObject;
  31352. /** @hidden */
  31353. protected _cachedVertexBuffers: any;
  31354. /** @hidden */
  31355. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31356. /** @hidden */
  31357. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31358. /** @hidden */
  31359. _currentRenderTarget: Nullable<InternalTexture>;
  31360. private _uintIndicesCurrentlySet;
  31361. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31362. /** @hidden */
  31363. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31364. private _currentBufferPointers;
  31365. private _currentInstanceLocations;
  31366. private _currentInstanceBuffers;
  31367. private _textureUnits;
  31368. /** @hidden */
  31369. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31370. /** @hidden */
  31371. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31372. /** @hidden */
  31373. _boundRenderFunction: any;
  31374. private _vaoRecordInProgress;
  31375. private _mustWipeVertexAttributes;
  31376. private _emptyTexture;
  31377. private _emptyCubeTexture;
  31378. private _emptyTexture3D;
  31379. private _emptyTexture2DArray;
  31380. /** @hidden */
  31381. _frameHandler: number;
  31382. private _nextFreeTextureSlots;
  31383. private _maxSimultaneousTextures;
  31384. private _activeRequests;
  31385. /** @hidden */
  31386. _transformTextureUrl: Nullable<(url: string) => string>;
  31387. protected get _supportsHardwareTextureRescaling(): boolean;
  31388. private _framebufferDimensionsObject;
  31389. /**
  31390. * sets the object from which width and height will be taken from when getting render width and height
  31391. * Will fallback to the gl object
  31392. * @param dimensions the framebuffer width and height that will be used.
  31393. */
  31394. set framebufferDimensionsObject(dimensions: Nullable<{
  31395. framebufferWidth: number;
  31396. framebufferHeight: number;
  31397. }>);
  31398. /**
  31399. * Gets the current viewport
  31400. */
  31401. get currentViewport(): Nullable<IViewportLike>;
  31402. /**
  31403. * Gets the default empty texture
  31404. */
  31405. get emptyTexture(): InternalTexture;
  31406. /**
  31407. * Gets the default empty 3D texture
  31408. */
  31409. get emptyTexture3D(): InternalTexture;
  31410. /**
  31411. * Gets the default empty 2D array texture
  31412. */
  31413. get emptyTexture2DArray(): InternalTexture;
  31414. /**
  31415. * Gets the default empty cube texture
  31416. */
  31417. get emptyCubeTexture(): InternalTexture;
  31418. /**
  31419. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31420. */
  31421. readonly premultipliedAlpha: boolean;
  31422. /**
  31423. * Observable event triggered before each texture is initialized
  31424. */
  31425. onBeforeTextureInitObservable: Observable<Texture>;
  31426. /**
  31427. * Creates a new engine
  31428. * @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
  31429. * @param antialias defines enable antialiasing (default: false)
  31430. * @param options defines further options to be sent to the getContext() function
  31431. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31432. */
  31433. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31434. private _rebuildInternalTextures;
  31435. private _rebuildEffects;
  31436. /**
  31437. * Gets a boolean indicating if all created effects are ready
  31438. * @returns true if all effects are ready
  31439. */
  31440. areAllEffectsReady(): boolean;
  31441. protected _rebuildBuffers(): void;
  31442. protected _initGLContext(): void;
  31443. /**
  31444. * Gets version of the current webGL context
  31445. */
  31446. get webGLVersion(): number;
  31447. /**
  31448. * Gets a string idenfifying the name of the class
  31449. * @returns "Engine" string
  31450. */
  31451. getClassName(): string;
  31452. /**
  31453. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31454. */
  31455. get isStencilEnable(): boolean;
  31456. /** @hidden */
  31457. _prepareWorkingCanvas(): void;
  31458. /**
  31459. * Reset the texture cache to empty state
  31460. */
  31461. resetTextureCache(): void;
  31462. /**
  31463. * Gets an object containing information about the current webGL context
  31464. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31465. */
  31466. getGlInfo(): {
  31467. vendor: string;
  31468. renderer: string;
  31469. version: string;
  31470. };
  31471. /**
  31472. * Defines the hardware scaling level.
  31473. * By default the hardware scaling level is computed from the window device ratio.
  31474. * 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.
  31475. * @param level defines the level to use
  31476. */
  31477. setHardwareScalingLevel(level: number): void;
  31478. /**
  31479. * Gets the current hardware scaling level.
  31480. * By default the hardware scaling level is computed from the window device ratio.
  31481. * 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.
  31482. * @returns a number indicating the current hardware scaling level
  31483. */
  31484. getHardwareScalingLevel(): number;
  31485. /**
  31486. * Gets the list of loaded textures
  31487. * @returns an array containing all loaded textures
  31488. */
  31489. getLoadedTexturesCache(): InternalTexture[];
  31490. /**
  31491. * Gets the object containing all engine capabilities
  31492. * @returns the EngineCapabilities object
  31493. */
  31494. getCaps(): EngineCapabilities;
  31495. /**
  31496. * stop executing a render loop function and remove it from the execution array
  31497. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31498. */
  31499. stopRenderLoop(renderFunction?: () => void): void;
  31500. /** @hidden */
  31501. _renderLoop(): void;
  31502. /**
  31503. * Gets the HTML canvas attached with the current webGL context
  31504. * @returns a HTML canvas
  31505. */
  31506. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31507. /**
  31508. * Gets host window
  31509. * @returns the host window object
  31510. */
  31511. getHostWindow(): Nullable<Window>;
  31512. /**
  31513. * Gets the current render width
  31514. * @param useScreen defines if screen size must be used (or the current render target if any)
  31515. * @returns a number defining the current render width
  31516. */
  31517. getRenderWidth(useScreen?: boolean): number;
  31518. /**
  31519. * Gets the current render height
  31520. * @param useScreen defines if screen size must be used (or the current render target if any)
  31521. * @returns a number defining the current render height
  31522. */
  31523. getRenderHeight(useScreen?: boolean): number;
  31524. /**
  31525. * Can be used to override the current requestAnimationFrame requester.
  31526. * @hidden
  31527. */
  31528. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31529. /**
  31530. * Register and execute a render loop. The engine can have more than one render function
  31531. * @param renderFunction defines the function to continuously execute
  31532. */
  31533. runRenderLoop(renderFunction: () => void): void;
  31534. /**
  31535. * Clear the current render buffer or the current render target (if any is set up)
  31536. * @param color defines the color to use
  31537. * @param backBuffer defines if the back buffer must be cleared
  31538. * @param depth defines if the depth buffer must be cleared
  31539. * @param stencil defines if the stencil buffer must be cleared
  31540. */
  31541. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31542. private _viewportCached;
  31543. /** @hidden */
  31544. _viewport(x: number, y: number, width: number, height: number): void;
  31545. /**
  31546. * Set the WebGL's viewport
  31547. * @param viewport defines the viewport element to be used
  31548. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31549. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31550. */
  31551. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31552. /**
  31553. * Begin a new frame
  31554. */
  31555. beginFrame(): void;
  31556. /**
  31557. * Enf the current frame
  31558. */
  31559. endFrame(): void;
  31560. /**
  31561. * Resize the view according to the canvas' size
  31562. */
  31563. resize(): void;
  31564. /**
  31565. * Force a specific size of the canvas
  31566. * @param width defines the new canvas' width
  31567. * @param height defines the new canvas' height
  31568. */
  31569. setSize(width: number, height: number): void;
  31570. /**
  31571. * Binds the frame buffer to the specified texture.
  31572. * @param texture The texture to render to or null for the default canvas
  31573. * @param faceIndex The face of the texture to render to in case of cube texture
  31574. * @param requiredWidth The width of the target to render to
  31575. * @param requiredHeight The height of the target to render to
  31576. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31577. * @param lodLevel defines the lod level to bind to the frame buffer
  31578. * @param layer defines the 2d array index to bind to frame buffer to
  31579. */
  31580. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31581. /** @hidden */
  31582. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31583. /**
  31584. * Unbind the current render target texture from the webGL context
  31585. * @param texture defines the render target texture to unbind
  31586. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31587. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31588. */
  31589. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31590. /**
  31591. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31592. */
  31593. flushFramebuffer(): void;
  31594. /**
  31595. * Unbind the current render target and bind the default framebuffer
  31596. */
  31597. restoreDefaultFramebuffer(): void;
  31598. /** @hidden */
  31599. protected _resetVertexBufferBinding(): void;
  31600. /**
  31601. * Creates a vertex buffer
  31602. * @param data the data for the vertex buffer
  31603. * @returns the new WebGL static buffer
  31604. */
  31605. createVertexBuffer(data: DataArray): DataBuffer;
  31606. private _createVertexBuffer;
  31607. /**
  31608. * Creates a dynamic vertex buffer
  31609. * @param data the data for the dynamic vertex buffer
  31610. * @returns the new WebGL dynamic buffer
  31611. */
  31612. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31613. protected _resetIndexBufferBinding(): void;
  31614. /**
  31615. * Creates a new index buffer
  31616. * @param indices defines the content of the index buffer
  31617. * @param updatable defines if the index buffer must be updatable
  31618. * @returns a new webGL buffer
  31619. */
  31620. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31621. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31622. /**
  31623. * Bind a webGL buffer to the webGL context
  31624. * @param buffer defines the buffer to bind
  31625. */
  31626. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31627. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31628. private bindBuffer;
  31629. /**
  31630. * update the bound buffer with the given data
  31631. * @param data defines the data to update
  31632. */
  31633. updateArrayBuffer(data: Float32Array): void;
  31634. private _vertexAttribPointer;
  31635. /** @hidden */
  31636. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31637. private _bindVertexBuffersAttributes;
  31638. /**
  31639. * Records a vertex array object
  31640. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31641. * @param vertexBuffers defines the list of vertex buffers to store
  31642. * @param indexBuffer defines the index buffer to store
  31643. * @param effect defines the effect to store
  31644. * @returns the new vertex array object
  31645. */
  31646. recordVertexArrayObject(vertexBuffers: {
  31647. [key: string]: VertexBuffer;
  31648. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31649. /**
  31650. * Bind a specific vertex array object
  31651. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31652. * @param vertexArrayObject defines the vertex array object to bind
  31653. * @param indexBuffer defines the index buffer to bind
  31654. */
  31655. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31656. /**
  31657. * Bind webGl buffers directly to the webGL context
  31658. * @param vertexBuffer defines the vertex buffer to bind
  31659. * @param indexBuffer defines the index buffer to bind
  31660. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31661. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31662. * @param effect defines the effect associated with the vertex buffer
  31663. */
  31664. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31665. private _unbindVertexArrayObject;
  31666. /**
  31667. * Bind a list of vertex buffers to the webGL context
  31668. * @param vertexBuffers defines the list of vertex buffers to bind
  31669. * @param indexBuffer defines the index buffer to bind
  31670. * @param effect defines the effect associated with the vertex buffers
  31671. */
  31672. bindBuffers(vertexBuffers: {
  31673. [key: string]: Nullable<VertexBuffer>;
  31674. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31675. /**
  31676. * Unbind all instance attributes
  31677. */
  31678. unbindInstanceAttributes(): void;
  31679. /**
  31680. * Release and free the memory of a vertex array object
  31681. * @param vao defines the vertex array object to delete
  31682. */
  31683. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31684. /** @hidden */
  31685. _releaseBuffer(buffer: DataBuffer): boolean;
  31686. protected _deleteBuffer(buffer: DataBuffer): void;
  31687. /**
  31688. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31689. * @param instancesBuffer defines the webGL buffer to update and bind
  31690. * @param data defines the data to store in the buffer
  31691. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31692. */
  31693. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31694. /**
  31695. * Bind the content of a webGL buffer used with instantiation
  31696. * @param instancesBuffer defines the webGL buffer to bind
  31697. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31698. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31699. */
  31700. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31701. /**
  31702. * Disable the instance attribute corresponding to the name in parameter
  31703. * @param name defines the name of the attribute to disable
  31704. */
  31705. disableInstanceAttributeByName(name: string): void;
  31706. /**
  31707. * Disable the instance attribute corresponding to the location in parameter
  31708. * @param attributeLocation defines the attribute location of the attribute to disable
  31709. */
  31710. disableInstanceAttribute(attributeLocation: number): void;
  31711. /**
  31712. * Disable the attribute corresponding to the location in parameter
  31713. * @param attributeLocation defines the attribute location of the attribute to disable
  31714. */
  31715. disableAttributeByIndex(attributeLocation: number): void;
  31716. /**
  31717. * Send a draw order
  31718. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31719. * @param indexStart defines the starting index
  31720. * @param indexCount defines the number of index to draw
  31721. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31722. */
  31723. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31724. /**
  31725. * Draw a list of points
  31726. * @param verticesStart defines the index of first vertex to draw
  31727. * @param verticesCount defines the count of vertices to draw
  31728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31729. */
  31730. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31731. /**
  31732. * Draw a list of unindexed primitives
  31733. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31734. * @param verticesStart defines the index of first vertex to draw
  31735. * @param verticesCount defines the count of vertices to draw
  31736. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31737. */
  31738. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31739. /**
  31740. * Draw a list of indexed primitives
  31741. * @param fillMode defines the primitive to use
  31742. * @param indexStart defines the starting index
  31743. * @param indexCount defines the number of index to draw
  31744. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31745. */
  31746. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31747. /**
  31748. * Draw a list of unindexed primitives
  31749. * @param fillMode defines the primitive to use
  31750. * @param verticesStart defines the index of first vertex to draw
  31751. * @param verticesCount defines the count of vertices to draw
  31752. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31753. */
  31754. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31755. private _drawMode;
  31756. /** @hidden */
  31757. protected _reportDrawCall(): void;
  31758. /** @hidden */
  31759. _releaseEffect(effect: Effect): void;
  31760. /** @hidden */
  31761. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31762. /**
  31763. * Create a new effect (used to store vertex/fragment shaders)
  31764. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31765. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31766. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31767. * @param samplers defines an array of string used to represent textures
  31768. * @param defines defines the string containing the defines to use to compile the shaders
  31769. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31770. * @param onCompiled defines a function to call when the effect creation is successful
  31771. * @param onError defines a function to call when the effect creation has failed
  31772. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31773. * @returns the new Effect
  31774. */
  31775. 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;
  31776. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31777. private _compileShader;
  31778. private _compileRawShader;
  31779. /** @hidden */
  31780. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31781. /**
  31782. * Directly creates a webGL program
  31783. * @param pipelineContext defines the pipeline context to attach to
  31784. * @param vertexCode defines the vertex shader code to use
  31785. * @param fragmentCode defines the fragment shader code to use
  31786. * @param context defines the webGL context to use (if not set, the current one will be used)
  31787. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31788. * @returns the new webGL program
  31789. */
  31790. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31791. /**
  31792. * Creates a webGL program
  31793. * @param pipelineContext defines the pipeline context to attach to
  31794. * @param vertexCode defines the vertex shader code to use
  31795. * @param fragmentCode defines the fragment shader code to use
  31796. * @param defines defines the string containing the defines to use to compile the shaders
  31797. * @param context defines the webGL context to use (if not set, the current one will be used)
  31798. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31799. * @returns the new webGL program
  31800. */
  31801. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31802. /**
  31803. * Creates a new pipeline context
  31804. * @returns the new pipeline
  31805. */
  31806. createPipelineContext(): IPipelineContext;
  31807. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31808. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31809. /** @hidden */
  31810. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31811. /** @hidden */
  31812. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31813. /** @hidden */
  31814. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31815. /**
  31816. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31817. * @param pipelineContext defines the pipeline context to use
  31818. * @param uniformsNames defines the list of uniform names
  31819. * @returns an array of webGL uniform locations
  31820. */
  31821. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31822. /**
  31823. * Gets the lsit of active attributes for a given webGL program
  31824. * @param pipelineContext defines the pipeline context to use
  31825. * @param attributesNames defines the list of attribute names to get
  31826. * @returns an array of indices indicating the offset of each attribute
  31827. */
  31828. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31829. /**
  31830. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31831. * @param effect defines the effect to activate
  31832. */
  31833. enableEffect(effect: Nullable<Effect>): void;
  31834. /**
  31835. * Set the value of an uniform to a number (int)
  31836. * @param uniform defines the webGL uniform location where to store the value
  31837. * @param value defines the int number to store
  31838. */
  31839. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31840. /**
  31841. * Set the value of an uniform to an array of int32
  31842. * @param uniform defines the webGL uniform location where to store the value
  31843. * @param array defines the array of int32 to store
  31844. */
  31845. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31846. /**
  31847. * Set the value of an uniform to an array of int32 (stored as vec2)
  31848. * @param uniform defines the webGL uniform location where to store the value
  31849. * @param array defines the array of int32 to store
  31850. */
  31851. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31852. /**
  31853. * Set the value of an uniform to an array of int32 (stored as vec3)
  31854. * @param uniform defines the webGL uniform location where to store the value
  31855. * @param array defines the array of int32 to store
  31856. */
  31857. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31858. /**
  31859. * Set the value of an uniform to an array of int32 (stored as vec4)
  31860. * @param uniform defines the webGL uniform location where to store the value
  31861. * @param array defines the array of int32 to store
  31862. */
  31863. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31864. /**
  31865. * Set the value of an uniform to an array of number
  31866. * @param uniform defines the webGL uniform location where to store the value
  31867. * @param array defines the array of number to store
  31868. */
  31869. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31870. /**
  31871. * Set the value of an uniform to an array of number (stored as vec2)
  31872. * @param uniform defines the webGL uniform location where to store the value
  31873. * @param array defines the array of number to store
  31874. */
  31875. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31876. /**
  31877. * Set the value of an uniform to an array of number (stored as vec3)
  31878. * @param uniform defines the webGL uniform location where to store the value
  31879. * @param array defines the array of number to store
  31880. */
  31881. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31882. /**
  31883. * Set the value of an uniform to an array of number (stored as vec4)
  31884. * @param uniform defines the webGL uniform location where to store the value
  31885. * @param array defines the array of number to store
  31886. */
  31887. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31888. /**
  31889. * Set the value of an uniform to an array of float32 (stored as matrices)
  31890. * @param uniform defines the webGL uniform location where to store the value
  31891. * @param matrices defines the array of float32 to store
  31892. */
  31893. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31894. /**
  31895. * Set the value of an uniform to a matrix (3x3)
  31896. * @param uniform defines the webGL uniform location where to store the value
  31897. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31898. */
  31899. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31900. /**
  31901. * Set the value of an uniform to a matrix (2x2)
  31902. * @param uniform defines the webGL uniform location where to store the value
  31903. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31904. */
  31905. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31906. /**
  31907. * Set the value of an uniform to a number (float)
  31908. * @param uniform defines the webGL uniform location where to store the value
  31909. * @param value defines the float number to store
  31910. */
  31911. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31912. /**
  31913. * Set the value of an uniform to a vec2
  31914. * @param uniform defines the webGL uniform location where to store the value
  31915. * @param x defines the 1st component of the value
  31916. * @param y defines the 2nd component of the value
  31917. */
  31918. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31919. /**
  31920. * Set the value of an uniform to a vec3
  31921. * @param uniform defines the webGL uniform location where to store the value
  31922. * @param x defines the 1st component of the value
  31923. * @param y defines the 2nd component of the value
  31924. * @param z defines the 3rd component of the value
  31925. */
  31926. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31927. /**
  31928. * Set the value of an uniform to a vec4
  31929. * @param uniform defines the webGL uniform location where to store the value
  31930. * @param x defines the 1st component of the value
  31931. * @param y defines the 2nd component of the value
  31932. * @param z defines the 3rd component of the value
  31933. * @param w defines the 4th component of the value
  31934. */
  31935. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31936. /**
  31937. * Apply all cached states (depth, culling, stencil and alpha)
  31938. */
  31939. applyStates(): void;
  31940. /**
  31941. * Enable or disable color writing
  31942. * @param enable defines the state to set
  31943. */
  31944. setColorWrite(enable: boolean): void;
  31945. /**
  31946. * Gets a boolean indicating if color writing is enabled
  31947. * @returns the current color writing state
  31948. */
  31949. getColorWrite(): boolean;
  31950. /**
  31951. * Gets the depth culling state manager
  31952. */
  31953. get depthCullingState(): DepthCullingState;
  31954. /**
  31955. * Gets the alpha state manager
  31956. */
  31957. get alphaState(): AlphaState;
  31958. /**
  31959. * Gets the stencil state manager
  31960. */
  31961. get stencilState(): StencilState;
  31962. /**
  31963. * Clears the list of texture accessible through engine.
  31964. * This can help preventing texture load conflict due to name collision.
  31965. */
  31966. clearInternalTexturesCache(): void;
  31967. /**
  31968. * Force the entire cache to be cleared
  31969. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31970. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31971. */
  31972. wipeCaches(bruteForce?: boolean): void;
  31973. /** @hidden */
  31974. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31975. min: number;
  31976. mag: number;
  31977. };
  31978. /** @hidden */
  31979. _createTexture(): WebGLTexture;
  31980. /**
  31981. * Usually called from Texture.ts.
  31982. * Passed information to create a WebGLTexture
  31983. * @param url defines a value which contains one of the following:
  31984. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31985. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31986. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31987. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31988. * @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)
  31989. * @param scene needed for loading to the correct scene
  31990. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31991. * @param onLoad optional callback to be called upon successful completion
  31992. * @param onError optional callback to be called upon failure
  31993. * @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
  31994. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31995. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31996. * @param forcedExtension defines the extension to use to pick the right loader
  31997. * @param mimeType defines an optional mime type
  31998. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31999. */
  32000. 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;
  32001. /**
  32002. * Loads an image as an HTMLImageElement.
  32003. * @param input url string, ArrayBuffer, or Blob to load
  32004. * @param onLoad callback called when the image successfully loads
  32005. * @param onError callback called when the image fails to load
  32006. * @param offlineProvider offline provider for caching
  32007. * @param mimeType optional mime type
  32008. * @returns the HTMLImageElement of the loaded image
  32009. * @hidden
  32010. */
  32011. 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>;
  32012. /**
  32013. * @hidden
  32014. */
  32015. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32016. /**
  32017. * Creates a raw texture
  32018. * @param data defines the data to store in the texture
  32019. * @param width defines the width of the texture
  32020. * @param height defines the height of the texture
  32021. * @param format defines the format of the data
  32022. * @param generateMipMaps defines if the engine should generate the mip levels
  32023. * @param invertY defines if data must be stored with Y axis inverted
  32024. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32025. * @param compression defines the compression used (null by default)
  32026. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32027. * @returns the raw texture inside an InternalTexture
  32028. */
  32029. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32030. /**
  32031. * Creates a new raw cube texture
  32032. * @param data defines the array of data to use to create each face
  32033. * @param size defines the size of the textures
  32034. * @param format defines the format of the data
  32035. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32036. * @param generateMipMaps defines if the engine should generate the mip levels
  32037. * @param invertY defines if data must be stored with Y axis inverted
  32038. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32039. * @param compression defines the compression used (null by default)
  32040. * @returns the cube texture as an InternalTexture
  32041. */
  32042. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32043. /**
  32044. * Creates a new raw 3D texture
  32045. * @param data defines the data used to create the texture
  32046. * @param width defines the width of the texture
  32047. * @param height defines the height of the texture
  32048. * @param depth defines the depth of the texture
  32049. * @param format defines the format of the texture
  32050. * @param generateMipMaps defines if the engine must generate mip levels
  32051. * @param invertY defines if data must be stored with Y axis inverted
  32052. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32053. * @param compression defines the compressed used (can be null)
  32054. * @param textureType defines the compressed used (can be null)
  32055. * @returns a new raw 3D texture (stored in an InternalTexture)
  32056. */
  32057. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32058. /**
  32059. * Creates a new raw 2D array texture
  32060. * @param data defines the data used to create the texture
  32061. * @param width defines the width of the texture
  32062. * @param height defines the height of the texture
  32063. * @param depth defines the number of layers of the texture
  32064. * @param format defines the format of the texture
  32065. * @param generateMipMaps defines if the engine must generate mip levels
  32066. * @param invertY defines if data must be stored with Y axis inverted
  32067. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32068. * @param compression defines the compressed used (can be null)
  32069. * @param textureType defines the compressed used (can be null)
  32070. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32071. */
  32072. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32073. private _unpackFlipYCached;
  32074. /**
  32075. * In case you are sharing the context with other applications, it might
  32076. * be interested to not cache the unpack flip y state to ensure a consistent
  32077. * value would be set.
  32078. */
  32079. enableUnpackFlipYCached: boolean;
  32080. /** @hidden */
  32081. _unpackFlipY(value: boolean): void;
  32082. /** @hidden */
  32083. _getUnpackAlignement(): number;
  32084. private _getTextureTarget;
  32085. /**
  32086. * Update the sampling mode of a given texture
  32087. * @param samplingMode defines the required sampling mode
  32088. * @param texture defines the texture to update
  32089. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32090. */
  32091. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32092. /**
  32093. * Update the sampling mode of a given texture
  32094. * @param texture defines the texture to update
  32095. * @param wrapU defines the texture wrap mode of the u coordinates
  32096. * @param wrapV defines the texture wrap mode of the v coordinates
  32097. * @param wrapR defines the texture wrap mode of the r coordinates
  32098. */
  32099. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32100. /** @hidden */
  32101. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32102. width: number;
  32103. height: number;
  32104. layers?: number;
  32105. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32106. /** @hidden */
  32107. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32108. /** @hidden */
  32109. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32110. /**
  32111. * Update a portion of an internal texture
  32112. * @param texture defines the texture to update
  32113. * @param imageData defines the data to store into the texture
  32114. * @param xOffset defines the x coordinates of the update rectangle
  32115. * @param yOffset defines the y coordinates of the update rectangle
  32116. * @param width defines the width of the update rectangle
  32117. * @param height defines the height of the update rectangle
  32118. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32119. * @param lod defines the lod level to update (0 by default)
  32120. */
  32121. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32122. /** @hidden */
  32123. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32124. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32125. private _prepareWebGLTexture;
  32126. /** @hidden */
  32127. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32128. private _getDepthStencilBuffer;
  32129. /** @hidden */
  32130. _releaseFramebufferObjects(texture: InternalTexture): void;
  32131. /** @hidden */
  32132. _releaseTexture(texture: InternalTexture): void;
  32133. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32134. protected _setProgram(program: WebGLProgram): void;
  32135. protected _boundUniforms: {
  32136. [key: number]: WebGLUniformLocation;
  32137. };
  32138. /**
  32139. * Binds an effect to the webGL context
  32140. * @param effect defines the effect to bind
  32141. */
  32142. bindSamplers(effect: Effect): void;
  32143. private _activateCurrentTexture;
  32144. /** @hidden */
  32145. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32146. /** @hidden */
  32147. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32148. /**
  32149. * Unbind all textures from the webGL context
  32150. */
  32151. unbindAllTextures(): void;
  32152. /**
  32153. * Sets a texture to the according uniform.
  32154. * @param channel The texture channel
  32155. * @param uniform The uniform to set
  32156. * @param texture The texture to apply
  32157. */
  32158. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32159. private _bindSamplerUniformToChannel;
  32160. private _getTextureWrapMode;
  32161. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32162. /**
  32163. * Sets an array of texture to the webGL context
  32164. * @param channel defines the channel where the texture array must be set
  32165. * @param uniform defines the associated uniform location
  32166. * @param textures defines the array of textures to bind
  32167. */
  32168. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32169. /** @hidden */
  32170. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32171. private _setTextureParameterFloat;
  32172. private _setTextureParameterInteger;
  32173. /**
  32174. * Unbind all vertex attributes from the webGL context
  32175. */
  32176. unbindAllAttributes(): void;
  32177. /**
  32178. * 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
  32179. */
  32180. releaseEffects(): void;
  32181. /**
  32182. * Dispose and release all associated resources
  32183. */
  32184. dispose(): void;
  32185. /**
  32186. * Attach a new callback raised when context lost event is fired
  32187. * @param callback defines the callback to call
  32188. */
  32189. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32190. /**
  32191. * Attach a new callback raised when context restored event is fired
  32192. * @param callback defines the callback to call
  32193. */
  32194. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32195. /**
  32196. * Get the current error code of the webGL context
  32197. * @returns the error code
  32198. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32199. */
  32200. getError(): number;
  32201. private _canRenderToFloatFramebuffer;
  32202. private _canRenderToHalfFloatFramebuffer;
  32203. private _canRenderToFramebuffer;
  32204. /** @hidden */
  32205. _getWebGLTextureType(type: number): number;
  32206. /** @hidden */
  32207. _getInternalFormat(format: number): number;
  32208. /** @hidden */
  32209. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32210. /** @hidden */
  32211. _getRGBAMultiSampleBufferFormat(type: number): number;
  32212. /** @hidden */
  32213. _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;
  32214. /**
  32215. * Loads a file from a url
  32216. * @param url url to load
  32217. * @param onSuccess callback called when the file successfully loads
  32218. * @param onProgress callback called while file is loading (if the server supports this mode)
  32219. * @param offlineProvider defines the offline provider for caching
  32220. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32221. * @param onError callback called when the file fails to load
  32222. * @returns a file request object
  32223. * @hidden
  32224. */
  32225. 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;
  32226. /**
  32227. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32228. * @param x defines the x coordinate of the rectangle where pixels must be read
  32229. * @param y defines the y coordinate of the rectangle where pixels must be read
  32230. * @param width defines the width of the rectangle where pixels must be read
  32231. * @param height defines the height of the rectangle where pixels must be read
  32232. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32233. * @returns a Uint8Array containing RGBA colors
  32234. */
  32235. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32236. private static _isSupported;
  32237. /**
  32238. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32239. * @returns true if the engine can be created
  32240. * @ignorenaming
  32241. */
  32242. static isSupported(): boolean;
  32243. /**
  32244. * Find the next highest power of two.
  32245. * @param x Number to start search from.
  32246. * @return Next highest power of two.
  32247. */
  32248. static CeilingPOT(x: number): number;
  32249. /**
  32250. * Find the next lowest power of two.
  32251. * @param x Number to start search from.
  32252. * @return Next lowest power of two.
  32253. */
  32254. static FloorPOT(x: number): number;
  32255. /**
  32256. * Find the nearest power of two.
  32257. * @param x Number to start search from.
  32258. * @return Next nearest power of two.
  32259. */
  32260. static NearestPOT(x: number): number;
  32261. /**
  32262. * Get the closest exponent of two
  32263. * @param value defines the value to approximate
  32264. * @param max defines the maximum value to return
  32265. * @param mode defines how to define the closest value
  32266. * @returns closest exponent of two of the given value
  32267. */
  32268. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32269. /**
  32270. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32271. * @param func - the function to be called
  32272. * @param requester - the object that will request the next frame. Falls back to window.
  32273. * @returns frame number
  32274. */
  32275. static QueueNewFrame(func: () => void, requester?: any): number;
  32276. /**
  32277. * Gets host document
  32278. * @returns the host document object
  32279. */
  32280. getHostDocument(): Nullable<Document>;
  32281. }
  32282. }
  32283. declare module BABYLON {
  32284. /**
  32285. * Class representing spherical harmonics coefficients to the 3rd degree
  32286. */
  32287. export class SphericalHarmonics {
  32288. /**
  32289. * Defines whether or not the harmonics have been prescaled for rendering.
  32290. */
  32291. preScaled: boolean;
  32292. /**
  32293. * The l0,0 coefficients of the spherical harmonics
  32294. */
  32295. l00: Vector3;
  32296. /**
  32297. * The l1,-1 coefficients of the spherical harmonics
  32298. */
  32299. l1_1: Vector3;
  32300. /**
  32301. * The l1,0 coefficients of the spherical harmonics
  32302. */
  32303. l10: Vector3;
  32304. /**
  32305. * The l1,1 coefficients of the spherical harmonics
  32306. */
  32307. l11: Vector3;
  32308. /**
  32309. * The l2,-2 coefficients of the spherical harmonics
  32310. */
  32311. l2_2: Vector3;
  32312. /**
  32313. * The l2,-1 coefficients of the spherical harmonics
  32314. */
  32315. l2_1: Vector3;
  32316. /**
  32317. * The l2,0 coefficients of the spherical harmonics
  32318. */
  32319. l20: Vector3;
  32320. /**
  32321. * The l2,1 coefficients of the spherical harmonics
  32322. */
  32323. l21: Vector3;
  32324. /**
  32325. * The l2,2 coefficients of the spherical harmonics
  32326. */
  32327. l22: Vector3;
  32328. /**
  32329. * Adds a light to the spherical harmonics
  32330. * @param direction the direction of the light
  32331. * @param color the color of the light
  32332. * @param deltaSolidAngle the delta solid angle of the light
  32333. */
  32334. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32335. /**
  32336. * Scales the spherical harmonics by the given amount
  32337. * @param scale the amount to scale
  32338. */
  32339. scaleInPlace(scale: number): void;
  32340. /**
  32341. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32342. *
  32343. * ```
  32344. * E_lm = A_l * L_lm
  32345. * ```
  32346. *
  32347. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32348. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32349. * the scaling factors are given in equation 9.
  32350. */
  32351. convertIncidentRadianceToIrradiance(): void;
  32352. /**
  32353. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32354. *
  32355. * ```
  32356. * L = (1/pi) * E * rho
  32357. * ```
  32358. *
  32359. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32360. */
  32361. convertIrradianceToLambertianRadiance(): void;
  32362. /**
  32363. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32364. * required operations at run time.
  32365. *
  32366. * This is simply done by scaling back the SH with Ylm constants parameter.
  32367. * The trigonometric part being applied by the shader at run time.
  32368. */
  32369. preScaleForRendering(): void;
  32370. /**
  32371. * Constructs a spherical harmonics from an array.
  32372. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32373. * @returns the spherical harmonics
  32374. */
  32375. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32376. /**
  32377. * Gets the spherical harmonics from polynomial
  32378. * @param polynomial the spherical polynomial
  32379. * @returns the spherical harmonics
  32380. */
  32381. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32382. }
  32383. /**
  32384. * Class representing spherical polynomial coefficients to the 3rd degree
  32385. */
  32386. export class SphericalPolynomial {
  32387. private _harmonics;
  32388. /**
  32389. * The spherical harmonics used to create the polynomials.
  32390. */
  32391. get preScaledHarmonics(): SphericalHarmonics;
  32392. /**
  32393. * The x coefficients of the spherical polynomial
  32394. */
  32395. x: Vector3;
  32396. /**
  32397. * The y coefficients of the spherical polynomial
  32398. */
  32399. y: Vector3;
  32400. /**
  32401. * The z coefficients of the spherical polynomial
  32402. */
  32403. z: Vector3;
  32404. /**
  32405. * The xx coefficients of the spherical polynomial
  32406. */
  32407. xx: Vector3;
  32408. /**
  32409. * The yy coefficients of the spherical polynomial
  32410. */
  32411. yy: Vector3;
  32412. /**
  32413. * The zz coefficients of the spherical polynomial
  32414. */
  32415. zz: Vector3;
  32416. /**
  32417. * The xy coefficients of the spherical polynomial
  32418. */
  32419. xy: Vector3;
  32420. /**
  32421. * The yz coefficients of the spherical polynomial
  32422. */
  32423. yz: Vector3;
  32424. /**
  32425. * The zx coefficients of the spherical polynomial
  32426. */
  32427. zx: Vector3;
  32428. /**
  32429. * Adds an ambient color to the spherical polynomial
  32430. * @param color the color to add
  32431. */
  32432. addAmbient(color: Color3): void;
  32433. /**
  32434. * Scales the spherical polynomial by the given amount
  32435. * @param scale the amount to scale
  32436. */
  32437. scaleInPlace(scale: number): void;
  32438. /**
  32439. * Gets the spherical polynomial from harmonics
  32440. * @param harmonics the spherical harmonics
  32441. * @returns the spherical polynomial
  32442. */
  32443. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32444. /**
  32445. * Constructs a spherical polynomial from an array.
  32446. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32447. * @returns the spherical polynomial
  32448. */
  32449. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32450. }
  32451. }
  32452. declare module BABYLON {
  32453. /**
  32454. * Defines the source of the internal texture
  32455. */
  32456. export enum InternalTextureSource {
  32457. /**
  32458. * The source of the texture data is unknown
  32459. */
  32460. Unknown = 0,
  32461. /**
  32462. * Texture data comes from an URL
  32463. */
  32464. Url = 1,
  32465. /**
  32466. * Texture data is only used for temporary storage
  32467. */
  32468. Temp = 2,
  32469. /**
  32470. * Texture data comes from raw data (ArrayBuffer)
  32471. */
  32472. Raw = 3,
  32473. /**
  32474. * Texture content is dynamic (video or dynamic texture)
  32475. */
  32476. Dynamic = 4,
  32477. /**
  32478. * Texture content is generated by rendering to it
  32479. */
  32480. RenderTarget = 5,
  32481. /**
  32482. * Texture content is part of a multi render target process
  32483. */
  32484. MultiRenderTarget = 6,
  32485. /**
  32486. * Texture data comes from a cube data file
  32487. */
  32488. Cube = 7,
  32489. /**
  32490. * Texture data comes from a raw cube data
  32491. */
  32492. CubeRaw = 8,
  32493. /**
  32494. * Texture data come from a prefiltered cube data file
  32495. */
  32496. CubePrefiltered = 9,
  32497. /**
  32498. * Texture content is raw 3D data
  32499. */
  32500. Raw3D = 10,
  32501. /**
  32502. * Texture content is raw 2D array data
  32503. */
  32504. Raw2DArray = 11,
  32505. /**
  32506. * Texture content is a depth texture
  32507. */
  32508. Depth = 12,
  32509. /**
  32510. * Texture data comes from a raw cube data encoded with RGBD
  32511. */
  32512. CubeRawRGBD = 13
  32513. }
  32514. /**
  32515. * Class used to store data associated with WebGL texture data for the engine
  32516. * This class should not be used directly
  32517. */
  32518. export class InternalTexture {
  32519. /** @hidden */
  32520. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32521. /**
  32522. * Defines if the texture is ready
  32523. */
  32524. isReady: boolean;
  32525. /**
  32526. * Defines if the texture is a cube texture
  32527. */
  32528. isCube: boolean;
  32529. /**
  32530. * Defines if the texture contains 3D data
  32531. */
  32532. is3D: boolean;
  32533. /**
  32534. * Defines if the texture contains 2D array data
  32535. */
  32536. is2DArray: boolean;
  32537. /**
  32538. * Defines if the texture contains multiview data
  32539. */
  32540. isMultiview: boolean;
  32541. /**
  32542. * Gets the URL used to load this texture
  32543. */
  32544. url: string;
  32545. /**
  32546. * Gets the sampling mode of the texture
  32547. */
  32548. samplingMode: number;
  32549. /**
  32550. * Gets a boolean indicating if the texture needs mipmaps generation
  32551. */
  32552. generateMipMaps: boolean;
  32553. /**
  32554. * Gets the number of samples used by the texture (WebGL2+ only)
  32555. */
  32556. samples: number;
  32557. /**
  32558. * Gets the type of the texture (int, float...)
  32559. */
  32560. type: number;
  32561. /**
  32562. * Gets the format of the texture (RGB, RGBA...)
  32563. */
  32564. format: number;
  32565. /**
  32566. * Observable called when the texture is loaded
  32567. */
  32568. onLoadedObservable: Observable<InternalTexture>;
  32569. /**
  32570. * Gets the width of the texture
  32571. */
  32572. width: number;
  32573. /**
  32574. * Gets the height of the texture
  32575. */
  32576. height: number;
  32577. /**
  32578. * Gets the depth of the texture
  32579. */
  32580. depth: number;
  32581. /**
  32582. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32583. */
  32584. baseWidth: number;
  32585. /**
  32586. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32587. */
  32588. baseHeight: number;
  32589. /**
  32590. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32591. */
  32592. baseDepth: number;
  32593. /**
  32594. * Gets a boolean indicating if the texture is inverted on Y axis
  32595. */
  32596. invertY: boolean;
  32597. /** @hidden */
  32598. _invertVScale: boolean;
  32599. /** @hidden */
  32600. _associatedChannel: number;
  32601. /** @hidden */
  32602. _source: InternalTextureSource;
  32603. /** @hidden */
  32604. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32605. /** @hidden */
  32606. _bufferView: Nullable<ArrayBufferView>;
  32607. /** @hidden */
  32608. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32609. /** @hidden */
  32610. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32611. /** @hidden */
  32612. _size: number;
  32613. /** @hidden */
  32614. _extension: string;
  32615. /** @hidden */
  32616. _files: Nullable<string[]>;
  32617. /** @hidden */
  32618. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32619. /** @hidden */
  32620. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32621. /** @hidden */
  32622. _framebuffer: Nullable<WebGLFramebuffer>;
  32623. /** @hidden */
  32624. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32625. /** @hidden */
  32626. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32627. /** @hidden */
  32628. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32629. /** @hidden */
  32630. _attachments: Nullable<number[]>;
  32631. /** @hidden */
  32632. _cachedCoordinatesMode: Nullable<number>;
  32633. /** @hidden */
  32634. _cachedWrapU: Nullable<number>;
  32635. /** @hidden */
  32636. _cachedWrapV: Nullable<number>;
  32637. /** @hidden */
  32638. _cachedWrapR: Nullable<number>;
  32639. /** @hidden */
  32640. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32641. /** @hidden */
  32642. _isDisabled: boolean;
  32643. /** @hidden */
  32644. _compression: Nullable<string>;
  32645. /** @hidden */
  32646. _generateStencilBuffer: boolean;
  32647. /** @hidden */
  32648. _generateDepthBuffer: boolean;
  32649. /** @hidden */
  32650. _comparisonFunction: number;
  32651. /** @hidden */
  32652. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32653. /** @hidden */
  32654. _lodGenerationScale: number;
  32655. /** @hidden */
  32656. _lodGenerationOffset: number;
  32657. /** @hidden */
  32658. _depthStencilTexture: Nullable<InternalTexture>;
  32659. /** @hidden */
  32660. _colorTextureArray: Nullable<WebGLTexture>;
  32661. /** @hidden */
  32662. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32663. /** @hidden */
  32664. _lodTextureHigh: Nullable<BaseTexture>;
  32665. /** @hidden */
  32666. _lodTextureMid: Nullable<BaseTexture>;
  32667. /** @hidden */
  32668. _lodTextureLow: Nullable<BaseTexture>;
  32669. /** @hidden */
  32670. _isRGBD: boolean;
  32671. /** @hidden */
  32672. _linearSpecularLOD: boolean;
  32673. /** @hidden */
  32674. _irradianceTexture: Nullable<BaseTexture>;
  32675. /** @hidden */
  32676. _webGLTexture: Nullable<WebGLTexture>;
  32677. /** @hidden */
  32678. _references: number;
  32679. private _engine;
  32680. /**
  32681. * Gets the Engine the texture belongs to.
  32682. * @returns The babylon engine
  32683. */
  32684. getEngine(): ThinEngine;
  32685. /**
  32686. * Gets the data source type of the texture
  32687. */
  32688. get source(): InternalTextureSource;
  32689. /**
  32690. * Creates a new InternalTexture
  32691. * @param engine defines the engine to use
  32692. * @param source defines the type of data that will be used
  32693. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32694. */
  32695. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32696. /**
  32697. * Increments the number of references (ie. the number of Texture that point to it)
  32698. */
  32699. incrementReferences(): void;
  32700. /**
  32701. * Change the size of the texture (not the size of the content)
  32702. * @param width defines the new width
  32703. * @param height defines the new height
  32704. * @param depth defines the new depth (1 by default)
  32705. */
  32706. updateSize(width: int, height: int, depth?: int): void;
  32707. /** @hidden */
  32708. _rebuild(): void;
  32709. /** @hidden */
  32710. _swapAndDie(target: InternalTexture): void;
  32711. /**
  32712. * Dispose the current allocated resources
  32713. */
  32714. dispose(): void;
  32715. }
  32716. }
  32717. declare module BABYLON {
  32718. /**
  32719. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32721. */
  32722. export class Analyser {
  32723. /**
  32724. * Gets or sets the smoothing
  32725. * @ignorenaming
  32726. */
  32727. SMOOTHING: number;
  32728. /**
  32729. * Gets or sets the FFT table size
  32730. * @ignorenaming
  32731. */
  32732. FFT_SIZE: number;
  32733. /**
  32734. * Gets or sets the bar graph amplitude
  32735. * @ignorenaming
  32736. */
  32737. BARGRAPHAMPLITUDE: number;
  32738. /**
  32739. * Gets or sets the position of the debug canvas
  32740. * @ignorenaming
  32741. */
  32742. DEBUGCANVASPOS: {
  32743. x: number;
  32744. y: number;
  32745. };
  32746. /**
  32747. * Gets or sets the debug canvas size
  32748. * @ignorenaming
  32749. */
  32750. DEBUGCANVASSIZE: {
  32751. width: number;
  32752. height: number;
  32753. };
  32754. private _byteFreqs;
  32755. private _byteTime;
  32756. private _floatFreqs;
  32757. private _webAudioAnalyser;
  32758. private _debugCanvas;
  32759. private _debugCanvasContext;
  32760. private _scene;
  32761. private _registerFunc;
  32762. private _audioEngine;
  32763. /**
  32764. * Creates a new analyser
  32765. * @param scene defines hosting scene
  32766. */
  32767. constructor(scene: Scene);
  32768. /**
  32769. * Get the number of data values you will have to play with for the visualization
  32770. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32771. * @returns a number
  32772. */
  32773. getFrequencyBinCount(): number;
  32774. /**
  32775. * Gets the current frequency data as a byte array
  32776. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32777. * @returns a Uint8Array
  32778. */
  32779. getByteFrequencyData(): Uint8Array;
  32780. /**
  32781. * Gets the current waveform as a byte array
  32782. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32783. * @returns a Uint8Array
  32784. */
  32785. getByteTimeDomainData(): Uint8Array;
  32786. /**
  32787. * Gets the current frequency data as a float array
  32788. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32789. * @returns a Float32Array
  32790. */
  32791. getFloatFrequencyData(): Float32Array;
  32792. /**
  32793. * Renders the debug canvas
  32794. */
  32795. drawDebugCanvas(): void;
  32796. /**
  32797. * Stops rendering the debug canvas and removes it
  32798. */
  32799. stopDebugCanvas(): void;
  32800. /**
  32801. * Connects two audio nodes
  32802. * @param inputAudioNode defines first node to connect
  32803. * @param outputAudioNode defines second node to connect
  32804. */
  32805. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32806. /**
  32807. * Releases all associated resources
  32808. */
  32809. dispose(): void;
  32810. }
  32811. }
  32812. declare module BABYLON {
  32813. /**
  32814. * This represents an audio engine and it is responsible
  32815. * to play, synchronize and analyse sounds throughout the application.
  32816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32817. */
  32818. export interface IAudioEngine extends IDisposable {
  32819. /**
  32820. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32821. */
  32822. readonly canUseWebAudio: boolean;
  32823. /**
  32824. * Gets the current AudioContext if available.
  32825. */
  32826. readonly audioContext: Nullable<AudioContext>;
  32827. /**
  32828. * The master gain node defines the global audio volume of your audio engine.
  32829. */
  32830. readonly masterGain: GainNode;
  32831. /**
  32832. * Gets whether or not mp3 are supported by your browser.
  32833. */
  32834. readonly isMP3supported: boolean;
  32835. /**
  32836. * Gets whether or not ogg are supported by your browser.
  32837. */
  32838. readonly isOGGsupported: boolean;
  32839. /**
  32840. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32841. * @ignoreNaming
  32842. */
  32843. WarnedWebAudioUnsupported: boolean;
  32844. /**
  32845. * Defines if the audio engine relies on a custom unlocked button.
  32846. * In this case, the embedded button will not be displayed.
  32847. */
  32848. useCustomUnlockedButton: boolean;
  32849. /**
  32850. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32851. */
  32852. readonly unlocked: boolean;
  32853. /**
  32854. * Event raised when audio has been unlocked on the browser.
  32855. */
  32856. onAudioUnlockedObservable: Observable<AudioEngine>;
  32857. /**
  32858. * Event raised when audio has been locked on the browser.
  32859. */
  32860. onAudioLockedObservable: Observable<AudioEngine>;
  32861. /**
  32862. * Flags the audio engine in Locked state.
  32863. * This happens due to new browser policies preventing audio to autoplay.
  32864. */
  32865. lock(): void;
  32866. /**
  32867. * Unlocks the audio engine once a user action has been done on the dom.
  32868. * This is helpful to resume play once browser policies have been satisfied.
  32869. */
  32870. unlock(): void;
  32871. /**
  32872. * Gets the global volume sets on the master gain.
  32873. * @returns the global volume if set or -1 otherwise
  32874. */
  32875. getGlobalVolume(): number;
  32876. /**
  32877. * Sets the global volume of your experience (sets on the master gain).
  32878. * @param newVolume Defines the new global volume of the application
  32879. */
  32880. setGlobalVolume(newVolume: number): void;
  32881. /**
  32882. * Connect the audio engine to an audio analyser allowing some amazing
  32883. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32885. * @param analyser The analyser to connect to the engine
  32886. */
  32887. connectToAnalyser(analyser: Analyser): void;
  32888. }
  32889. /**
  32890. * This represents the default audio engine used in babylon.
  32891. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32893. */
  32894. export class AudioEngine implements IAudioEngine {
  32895. private _audioContext;
  32896. private _audioContextInitialized;
  32897. private _muteButton;
  32898. private _hostElement;
  32899. /**
  32900. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32901. */
  32902. canUseWebAudio: boolean;
  32903. /**
  32904. * The master gain node defines the global audio volume of your audio engine.
  32905. */
  32906. masterGain: GainNode;
  32907. /**
  32908. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32909. * @ignoreNaming
  32910. */
  32911. WarnedWebAudioUnsupported: boolean;
  32912. /**
  32913. * Gets whether or not mp3 are supported by your browser.
  32914. */
  32915. isMP3supported: boolean;
  32916. /**
  32917. * Gets whether or not ogg are supported by your browser.
  32918. */
  32919. isOGGsupported: boolean;
  32920. /**
  32921. * Gets whether audio has been unlocked on the device.
  32922. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32923. * a user interaction has happened.
  32924. */
  32925. unlocked: boolean;
  32926. /**
  32927. * Defines if the audio engine relies on a custom unlocked button.
  32928. * In this case, the embedded button will not be displayed.
  32929. */
  32930. useCustomUnlockedButton: boolean;
  32931. /**
  32932. * Event raised when audio has been unlocked on the browser.
  32933. */
  32934. onAudioUnlockedObservable: Observable<AudioEngine>;
  32935. /**
  32936. * Event raised when audio has been locked on the browser.
  32937. */
  32938. onAudioLockedObservable: Observable<AudioEngine>;
  32939. /**
  32940. * Gets the current AudioContext if available.
  32941. */
  32942. get audioContext(): Nullable<AudioContext>;
  32943. private _connectedAnalyser;
  32944. /**
  32945. * Instantiates a new audio engine.
  32946. *
  32947. * There should be only one per page as some browsers restrict the number
  32948. * of audio contexts you can create.
  32949. * @param hostElement defines the host element where to display the mute icon if necessary
  32950. */
  32951. constructor(hostElement?: Nullable<HTMLElement>);
  32952. /**
  32953. * Flags the audio engine in Locked state.
  32954. * This happens due to new browser policies preventing audio to autoplay.
  32955. */
  32956. lock(): void;
  32957. /**
  32958. * Unlocks the audio engine once a user action has been done on the dom.
  32959. * This is helpful to resume play once browser policies have been satisfied.
  32960. */
  32961. unlock(): void;
  32962. private _resumeAudioContext;
  32963. private _initializeAudioContext;
  32964. private _tryToRun;
  32965. private _triggerRunningState;
  32966. private _triggerSuspendedState;
  32967. private _displayMuteButton;
  32968. private _moveButtonToTopLeft;
  32969. private _onResize;
  32970. private _hideMuteButton;
  32971. /**
  32972. * Destroy and release the resources associated with the audio ccontext.
  32973. */
  32974. dispose(): void;
  32975. /**
  32976. * Gets the global volume sets on the master gain.
  32977. * @returns the global volume if set or -1 otherwise
  32978. */
  32979. getGlobalVolume(): number;
  32980. /**
  32981. * Sets the global volume of your experience (sets on the master gain).
  32982. * @param newVolume Defines the new global volume of the application
  32983. */
  32984. setGlobalVolume(newVolume: number): void;
  32985. /**
  32986. * Connect the audio engine to an audio analyser allowing some amazing
  32987. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32989. * @param analyser The analyser to connect to the engine
  32990. */
  32991. connectToAnalyser(analyser: Analyser): void;
  32992. }
  32993. }
  32994. declare module BABYLON {
  32995. /**
  32996. * Interface used to present a loading screen while loading a scene
  32997. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32998. */
  32999. export interface ILoadingScreen {
  33000. /**
  33001. * Function called to display the loading screen
  33002. */
  33003. displayLoadingUI: () => void;
  33004. /**
  33005. * Function called to hide the loading screen
  33006. */
  33007. hideLoadingUI: () => void;
  33008. /**
  33009. * Gets or sets the color to use for the background
  33010. */
  33011. loadingUIBackgroundColor: string;
  33012. /**
  33013. * Gets or sets the text to display while loading
  33014. */
  33015. loadingUIText: string;
  33016. }
  33017. /**
  33018. * Class used for the default loading screen
  33019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33020. */
  33021. export class DefaultLoadingScreen implements ILoadingScreen {
  33022. private _renderingCanvas;
  33023. private _loadingText;
  33024. private _loadingDivBackgroundColor;
  33025. private _loadingDiv;
  33026. private _loadingTextDiv;
  33027. /** Gets or sets the logo url to use for the default loading screen */
  33028. static DefaultLogoUrl: string;
  33029. /** Gets or sets the spinner url to use for the default loading screen */
  33030. static DefaultSpinnerUrl: string;
  33031. /**
  33032. * Creates a new default loading screen
  33033. * @param _renderingCanvas defines the canvas used to render the scene
  33034. * @param _loadingText defines the default text to display
  33035. * @param _loadingDivBackgroundColor defines the default background color
  33036. */
  33037. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33038. /**
  33039. * Function called to display the loading screen
  33040. */
  33041. displayLoadingUI(): void;
  33042. /**
  33043. * Function called to hide the loading screen
  33044. */
  33045. hideLoadingUI(): void;
  33046. /**
  33047. * Gets or sets the text to display while loading
  33048. */
  33049. set loadingUIText(text: string);
  33050. get loadingUIText(): string;
  33051. /**
  33052. * Gets or sets the color to use for the background
  33053. */
  33054. get loadingUIBackgroundColor(): string;
  33055. set loadingUIBackgroundColor(color: string);
  33056. private _resizeLoadingUI;
  33057. }
  33058. }
  33059. declare module BABYLON {
  33060. /**
  33061. * Interface for any object that can request an animation frame
  33062. */
  33063. export interface ICustomAnimationFrameRequester {
  33064. /**
  33065. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33066. */
  33067. renderFunction?: Function;
  33068. /**
  33069. * Called to request the next frame to render to
  33070. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33071. */
  33072. requestAnimationFrame: Function;
  33073. /**
  33074. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33075. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33076. */
  33077. requestID?: number;
  33078. }
  33079. }
  33080. declare module BABYLON {
  33081. /**
  33082. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33083. */
  33084. export class PerformanceMonitor {
  33085. private _enabled;
  33086. private _rollingFrameTime;
  33087. private _lastFrameTimeMs;
  33088. /**
  33089. * constructor
  33090. * @param frameSampleSize The number of samples required to saturate the sliding window
  33091. */
  33092. constructor(frameSampleSize?: number);
  33093. /**
  33094. * Samples current frame
  33095. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33096. */
  33097. sampleFrame(timeMs?: number): void;
  33098. /**
  33099. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33100. */
  33101. get averageFrameTime(): number;
  33102. /**
  33103. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33104. */
  33105. get averageFrameTimeVariance(): number;
  33106. /**
  33107. * Returns the frame time of the most recent frame
  33108. */
  33109. get instantaneousFrameTime(): number;
  33110. /**
  33111. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33112. */
  33113. get averageFPS(): number;
  33114. /**
  33115. * Returns the average framerate in frames per second using the most recent frame time
  33116. */
  33117. get instantaneousFPS(): number;
  33118. /**
  33119. * Returns true if enough samples have been taken to completely fill the sliding window
  33120. */
  33121. get isSaturated(): boolean;
  33122. /**
  33123. * Enables contributions to the sliding window sample set
  33124. */
  33125. enable(): void;
  33126. /**
  33127. * Disables contributions to the sliding window sample set
  33128. * Samples will not be interpolated over the disabled period
  33129. */
  33130. disable(): void;
  33131. /**
  33132. * Returns true if sampling is enabled
  33133. */
  33134. get isEnabled(): boolean;
  33135. /**
  33136. * Resets performance monitor
  33137. */
  33138. reset(): void;
  33139. }
  33140. /**
  33141. * RollingAverage
  33142. *
  33143. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33144. */
  33145. export class RollingAverage {
  33146. /**
  33147. * Current average
  33148. */
  33149. average: number;
  33150. /**
  33151. * Current variance
  33152. */
  33153. variance: number;
  33154. protected _samples: Array<number>;
  33155. protected _sampleCount: number;
  33156. protected _pos: number;
  33157. protected _m2: number;
  33158. /**
  33159. * constructor
  33160. * @param length The number of samples required to saturate the sliding window
  33161. */
  33162. constructor(length: number);
  33163. /**
  33164. * Adds a sample to the sample set
  33165. * @param v The sample value
  33166. */
  33167. add(v: number): void;
  33168. /**
  33169. * Returns previously added values or null if outside of history or outside the sliding window domain
  33170. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33171. * @return Value previously recorded with add() or null if outside of range
  33172. */
  33173. history(i: number): number;
  33174. /**
  33175. * Returns true if enough samples have been taken to completely fill the sliding window
  33176. * @return true if sample-set saturated
  33177. */
  33178. isSaturated(): boolean;
  33179. /**
  33180. * Resets the rolling average (equivalent to 0 samples taken so far)
  33181. */
  33182. reset(): void;
  33183. /**
  33184. * Wraps a value around the sample range boundaries
  33185. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33186. * @return Wrapped position in sample range
  33187. */
  33188. protected _wrapPosition(i: number): number;
  33189. }
  33190. }
  33191. declare module BABYLON {
  33192. /**
  33193. * This class is used to track a performance counter which is number based.
  33194. * The user has access to many properties which give statistics of different nature.
  33195. *
  33196. * The implementer can track two kinds of Performance Counter: time and count.
  33197. * 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.
  33198. * 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.
  33199. */
  33200. export class PerfCounter {
  33201. /**
  33202. * Gets or sets a global boolean to turn on and off all the counters
  33203. */
  33204. static Enabled: boolean;
  33205. /**
  33206. * Returns the smallest value ever
  33207. */
  33208. get min(): number;
  33209. /**
  33210. * Returns the biggest value ever
  33211. */
  33212. get max(): number;
  33213. /**
  33214. * Returns the average value since the performance counter is running
  33215. */
  33216. get average(): number;
  33217. /**
  33218. * Returns the average value of the last second the counter was monitored
  33219. */
  33220. get lastSecAverage(): number;
  33221. /**
  33222. * Returns the current value
  33223. */
  33224. get current(): number;
  33225. /**
  33226. * Gets the accumulated total
  33227. */
  33228. get total(): number;
  33229. /**
  33230. * Gets the total value count
  33231. */
  33232. get count(): number;
  33233. /**
  33234. * Creates a new counter
  33235. */
  33236. constructor();
  33237. /**
  33238. * Call this method to start monitoring a new frame.
  33239. * 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.
  33240. */
  33241. fetchNewFrame(): void;
  33242. /**
  33243. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33244. * @param newCount the count value to add to the monitored count
  33245. * @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.
  33246. */
  33247. addCount(newCount: number, fetchResult: boolean): void;
  33248. /**
  33249. * Start monitoring this performance counter
  33250. */
  33251. beginMonitoring(): void;
  33252. /**
  33253. * Compute the time lapsed since the previous beginMonitoring() call.
  33254. * @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
  33255. */
  33256. endMonitoring(newFrame?: boolean): void;
  33257. private _fetchResult;
  33258. private _startMonitoringTime;
  33259. private _min;
  33260. private _max;
  33261. private _average;
  33262. private _current;
  33263. private _totalValueCount;
  33264. private _totalAccumulated;
  33265. private _lastSecAverage;
  33266. private _lastSecAccumulated;
  33267. private _lastSecTime;
  33268. private _lastSecValueCount;
  33269. }
  33270. }
  33271. declare module BABYLON {
  33272. interface ThinEngine {
  33273. /**
  33274. * Sets alpha constants used by some alpha blending modes
  33275. * @param r defines the red component
  33276. * @param g defines the green component
  33277. * @param b defines the blue component
  33278. * @param a defines the alpha component
  33279. */
  33280. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33281. /**
  33282. * Sets the current alpha mode
  33283. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33284. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33285. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33286. */
  33287. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33288. /**
  33289. * Gets the current alpha mode
  33290. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33291. * @returns the current alpha mode
  33292. */
  33293. getAlphaMode(): number;
  33294. /**
  33295. * Sets the current alpha equation
  33296. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33297. */
  33298. setAlphaEquation(equation: number): void;
  33299. /**
  33300. * Gets the current alpha equation.
  33301. * @returns the current alpha equation
  33302. */
  33303. getAlphaEquation(): number;
  33304. }
  33305. }
  33306. declare module BABYLON {
  33307. /**
  33308. * Defines the interface used by display changed events
  33309. */
  33310. export interface IDisplayChangedEventArgs {
  33311. /** Gets the vrDisplay object (if any) */
  33312. vrDisplay: Nullable<any>;
  33313. /** Gets a boolean indicating if webVR is supported */
  33314. vrSupported: boolean;
  33315. }
  33316. /**
  33317. * Defines the interface used by objects containing a viewport (like a camera)
  33318. */
  33319. interface IViewportOwnerLike {
  33320. /**
  33321. * Gets or sets the viewport
  33322. */
  33323. viewport: IViewportLike;
  33324. }
  33325. /**
  33326. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33327. */
  33328. export class Engine extends ThinEngine {
  33329. /** Defines that alpha blending is disabled */
  33330. static readonly ALPHA_DISABLE: number;
  33331. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33332. static readonly ALPHA_ADD: number;
  33333. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33334. static readonly ALPHA_COMBINE: number;
  33335. /** Defines that alpha blending to DEST - SRC * DEST */
  33336. static readonly ALPHA_SUBTRACT: number;
  33337. /** Defines that alpha blending to SRC * DEST */
  33338. static readonly ALPHA_MULTIPLY: number;
  33339. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33340. static readonly ALPHA_MAXIMIZED: number;
  33341. /** Defines that alpha blending to SRC + DEST */
  33342. static readonly ALPHA_ONEONE: number;
  33343. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33344. static readonly ALPHA_PREMULTIPLIED: number;
  33345. /**
  33346. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33347. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33348. */
  33349. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33350. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33351. static readonly ALPHA_INTERPOLATE: number;
  33352. /**
  33353. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33354. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33355. */
  33356. static readonly ALPHA_SCREENMODE: number;
  33357. /** Defines that the ressource is not delayed*/
  33358. static readonly DELAYLOADSTATE_NONE: number;
  33359. /** Defines that the ressource was successfully delay loaded */
  33360. static readonly DELAYLOADSTATE_LOADED: number;
  33361. /** Defines that the ressource is currently delay loading */
  33362. static readonly DELAYLOADSTATE_LOADING: number;
  33363. /** Defines that the ressource is delayed and has not started loading */
  33364. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33365. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33366. static readonly NEVER: number;
  33367. /** 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 */
  33368. static readonly ALWAYS: number;
  33369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33370. static readonly LESS: number;
  33371. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33372. static readonly EQUAL: number;
  33373. /** 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 */
  33374. static readonly LEQUAL: number;
  33375. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33376. static readonly GREATER: number;
  33377. /** 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 */
  33378. static readonly GEQUAL: number;
  33379. /** 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 */
  33380. static readonly NOTEQUAL: number;
  33381. /** Passed to stencilOperation to specify that stencil value must be kept */
  33382. static readonly KEEP: number;
  33383. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33384. static readonly REPLACE: number;
  33385. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33386. static readonly INCR: number;
  33387. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33388. static readonly DECR: number;
  33389. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33390. static readonly INVERT: number;
  33391. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33392. static readonly INCR_WRAP: number;
  33393. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33394. static readonly DECR_WRAP: number;
  33395. /** Texture is not repeating outside of 0..1 UVs */
  33396. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33397. /** Texture is repeating outside of 0..1 UVs */
  33398. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33399. /** Texture is repeating and mirrored */
  33400. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33401. /** ALPHA */
  33402. static readonly TEXTUREFORMAT_ALPHA: number;
  33403. /** LUMINANCE */
  33404. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33405. /** LUMINANCE_ALPHA */
  33406. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33407. /** RGB */
  33408. static readonly TEXTUREFORMAT_RGB: number;
  33409. /** RGBA */
  33410. static readonly TEXTUREFORMAT_RGBA: number;
  33411. /** RED */
  33412. static readonly TEXTUREFORMAT_RED: number;
  33413. /** RED (2nd reference) */
  33414. static readonly TEXTUREFORMAT_R: number;
  33415. /** RG */
  33416. static readonly TEXTUREFORMAT_RG: number;
  33417. /** RED_INTEGER */
  33418. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33419. /** RED_INTEGER (2nd reference) */
  33420. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33421. /** RG_INTEGER */
  33422. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33423. /** RGB_INTEGER */
  33424. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33425. /** RGBA_INTEGER */
  33426. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33427. /** UNSIGNED_BYTE */
  33428. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33429. /** UNSIGNED_BYTE (2nd reference) */
  33430. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33431. /** FLOAT */
  33432. static readonly TEXTURETYPE_FLOAT: number;
  33433. /** HALF_FLOAT */
  33434. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33435. /** BYTE */
  33436. static readonly TEXTURETYPE_BYTE: number;
  33437. /** SHORT */
  33438. static readonly TEXTURETYPE_SHORT: number;
  33439. /** UNSIGNED_SHORT */
  33440. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33441. /** INT */
  33442. static readonly TEXTURETYPE_INT: number;
  33443. /** UNSIGNED_INT */
  33444. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33445. /** UNSIGNED_SHORT_4_4_4_4 */
  33446. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33447. /** UNSIGNED_SHORT_5_5_5_1 */
  33448. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33449. /** UNSIGNED_SHORT_5_6_5 */
  33450. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33451. /** UNSIGNED_INT_2_10_10_10_REV */
  33452. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33453. /** UNSIGNED_INT_24_8 */
  33454. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33455. /** UNSIGNED_INT_10F_11F_11F_REV */
  33456. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33457. /** UNSIGNED_INT_5_9_9_9_REV */
  33458. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33459. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33460. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33461. /** nearest is mag = nearest and min = nearest and mip = linear */
  33462. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33463. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33464. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33465. /** Trilinear is mag = linear and min = linear and mip = linear */
  33466. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33467. /** nearest is mag = nearest and min = nearest and mip = linear */
  33468. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33469. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33470. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33471. /** Trilinear is mag = linear and min = linear and mip = linear */
  33472. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33473. /** mag = nearest and min = nearest and mip = nearest */
  33474. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33475. /** mag = nearest and min = linear and mip = nearest */
  33476. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33477. /** mag = nearest and min = linear and mip = linear */
  33478. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33479. /** mag = nearest and min = linear and mip = none */
  33480. static readonly TEXTURE_NEAREST_LINEAR: number;
  33481. /** mag = nearest and min = nearest and mip = none */
  33482. static readonly TEXTURE_NEAREST_NEAREST: number;
  33483. /** mag = linear and min = nearest and mip = nearest */
  33484. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33485. /** mag = linear and min = nearest and mip = linear */
  33486. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33487. /** mag = linear and min = linear and mip = none */
  33488. static readonly TEXTURE_LINEAR_LINEAR: number;
  33489. /** mag = linear and min = nearest and mip = none */
  33490. static readonly TEXTURE_LINEAR_NEAREST: number;
  33491. /** Explicit coordinates mode */
  33492. static readonly TEXTURE_EXPLICIT_MODE: number;
  33493. /** Spherical coordinates mode */
  33494. static readonly TEXTURE_SPHERICAL_MODE: number;
  33495. /** Planar coordinates mode */
  33496. static readonly TEXTURE_PLANAR_MODE: number;
  33497. /** Cubic coordinates mode */
  33498. static readonly TEXTURE_CUBIC_MODE: number;
  33499. /** Projection coordinates mode */
  33500. static readonly TEXTURE_PROJECTION_MODE: number;
  33501. /** Skybox coordinates mode */
  33502. static readonly TEXTURE_SKYBOX_MODE: number;
  33503. /** Inverse Cubic coordinates mode */
  33504. static readonly TEXTURE_INVCUBIC_MODE: number;
  33505. /** Equirectangular coordinates mode */
  33506. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33507. /** Equirectangular Fixed coordinates mode */
  33508. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33509. /** Equirectangular Fixed Mirrored coordinates mode */
  33510. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33511. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33512. static readonly SCALEMODE_FLOOR: number;
  33513. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33514. static readonly SCALEMODE_NEAREST: number;
  33515. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33516. static readonly SCALEMODE_CEILING: number;
  33517. /**
  33518. * Returns the current npm package of the sdk
  33519. */
  33520. static get NpmPackage(): string;
  33521. /**
  33522. * Returns the current version of the framework
  33523. */
  33524. static get Version(): string;
  33525. /** Gets the list of created engines */
  33526. static get Instances(): Engine[];
  33527. /**
  33528. * Gets the latest created engine
  33529. */
  33530. static get LastCreatedEngine(): Nullable<Engine>;
  33531. /**
  33532. * Gets the latest created scene
  33533. */
  33534. static get LastCreatedScene(): Nullable<Scene>;
  33535. /**
  33536. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33537. * @param flag defines which part of the materials must be marked as dirty
  33538. * @param predicate defines a predicate used to filter which materials should be affected
  33539. */
  33540. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33541. /**
  33542. * Method called to create the default loading screen.
  33543. * This can be overriden in your own app.
  33544. * @param canvas The rendering canvas element
  33545. * @returns The loading screen
  33546. */
  33547. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33548. /**
  33549. * Method called to create the default rescale post process on each engine.
  33550. */
  33551. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33552. /**
  33553. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33554. **/
  33555. enableOfflineSupport: boolean;
  33556. /**
  33557. * 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)
  33558. **/
  33559. disableManifestCheck: boolean;
  33560. /**
  33561. * Gets the list of created scenes
  33562. */
  33563. scenes: Scene[];
  33564. /**
  33565. * Event raised when a new scene is created
  33566. */
  33567. onNewSceneAddedObservable: Observable<Scene>;
  33568. /**
  33569. * Gets the list of created postprocesses
  33570. */
  33571. postProcesses: PostProcess[];
  33572. /**
  33573. * Gets a boolean indicating if the pointer is currently locked
  33574. */
  33575. isPointerLock: boolean;
  33576. /**
  33577. * Observable event triggered each time the rendering canvas is resized
  33578. */
  33579. onResizeObservable: Observable<Engine>;
  33580. /**
  33581. * Observable event triggered each time the canvas loses focus
  33582. */
  33583. onCanvasBlurObservable: Observable<Engine>;
  33584. /**
  33585. * Observable event triggered each time the canvas gains focus
  33586. */
  33587. onCanvasFocusObservable: Observable<Engine>;
  33588. /**
  33589. * Observable event triggered each time the canvas receives pointerout event
  33590. */
  33591. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33592. /**
  33593. * Observable raised when the engine begins a new frame
  33594. */
  33595. onBeginFrameObservable: Observable<Engine>;
  33596. /**
  33597. * If set, will be used to request the next animation frame for the render loop
  33598. */
  33599. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33600. /**
  33601. * Observable raised when the engine ends the current frame
  33602. */
  33603. onEndFrameObservable: Observable<Engine>;
  33604. /**
  33605. * Observable raised when the engine is about to compile a shader
  33606. */
  33607. onBeforeShaderCompilationObservable: Observable<Engine>;
  33608. /**
  33609. * Observable raised when the engine has jsut compiled a shader
  33610. */
  33611. onAfterShaderCompilationObservable: Observable<Engine>;
  33612. /**
  33613. * Gets the audio engine
  33614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33615. * @ignorenaming
  33616. */
  33617. static audioEngine: IAudioEngine;
  33618. /**
  33619. * Default AudioEngine factory responsible of creating the Audio Engine.
  33620. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33621. */
  33622. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33623. /**
  33624. * Default offline support factory responsible of creating a tool used to store data locally.
  33625. * By default, this will create a Database object if the workload has been embedded.
  33626. */
  33627. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33628. private _loadingScreen;
  33629. private _pointerLockRequested;
  33630. private _dummyFramebuffer;
  33631. private _rescalePostProcess;
  33632. private _deterministicLockstep;
  33633. private _lockstepMaxSteps;
  33634. private _timeStep;
  33635. protected get _supportsHardwareTextureRescaling(): boolean;
  33636. private _fps;
  33637. private _deltaTime;
  33638. /** @hidden */
  33639. _drawCalls: PerfCounter;
  33640. /** 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 */
  33641. canvasTabIndex: number;
  33642. /**
  33643. * Turn this value on if you want to pause FPS computation when in background
  33644. */
  33645. disablePerformanceMonitorInBackground: boolean;
  33646. private _performanceMonitor;
  33647. /**
  33648. * Gets the performance monitor attached to this engine
  33649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33650. */
  33651. get performanceMonitor(): PerformanceMonitor;
  33652. private _onFocus;
  33653. private _onBlur;
  33654. private _onCanvasPointerOut;
  33655. private _onCanvasBlur;
  33656. private _onCanvasFocus;
  33657. private _onFullscreenChange;
  33658. private _onPointerLockChange;
  33659. /**
  33660. * Gets the HTML element used to attach event listeners
  33661. * @returns a HTML element
  33662. */
  33663. getInputElement(): Nullable<HTMLElement>;
  33664. /**
  33665. * Creates a new engine
  33666. * @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
  33667. * @param antialias defines enable antialiasing (default: false)
  33668. * @param options defines further options to be sent to the getContext() function
  33669. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33670. */
  33671. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33672. /**
  33673. * Gets current aspect ratio
  33674. * @param viewportOwner defines the camera to use to get the aspect ratio
  33675. * @param useScreen defines if screen size must be used (or the current render target if any)
  33676. * @returns a number defining the aspect ratio
  33677. */
  33678. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33679. /**
  33680. * Gets current screen aspect ratio
  33681. * @returns a number defining the aspect ratio
  33682. */
  33683. getScreenAspectRatio(): number;
  33684. /**
  33685. * Gets the client rect of the HTML canvas attached with the current webGL context
  33686. * @returns a client rectanglee
  33687. */
  33688. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33689. /**
  33690. * Gets the client rect of the HTML element used for events
  33691. * @returns a client rectanglee
  33692. */
  33693. getInputElementClientRect(): Nullable<ClientRect>;
  33694. /**
  33695. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33696. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33697. * @returns true if engine is in deterministic lock step mode
  33698. */
  33699. isDeterministicLockStep(): boolean;
  33700. /**
  33701. * Gets the max steps when engine is running in deterministic lock step
  33702. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33703. * @returns the max steps
  33704. */
  33705. getLockstepMaxSteps(): number;
  33706. /**
  33707. * Returns the time in ms between steps when using deterministic lock step.
  33708. * @returns time step in (ms)
  33709. */
  33710. getTimeStep(): number;
  33711. /**
  33712. * Force the mipmap generation for the given render target texture
  33713. * @param texture defines the render target texture to use
  33714. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33715. */
  33716. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33717. /** States */
  33718. /**
  33719. * Set various states to the webGL context
  33720. * @param culling defines backface culling state
  33721. * @param zOffset defines the value to apply to zOffset (0 by default)
  33722. * @param force defines if states must be applied even if cache is up to date
  33723. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33724. */
  33725. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33726. /**
  33727. * Set the z offset to apply to current rendering
  33728. * @param value defines the offset to apply
  33729. */
  33730. setZOffset(value: number): void;
  33731. /**
  33732. * Gets the current value of the zOffset
  33733. * @returns the current zOffset state
  33734. */
  33735. getZOffset(): number;
  33736. /**
  33737. * Enable or disable depth buffering
  33738. * @param enable defines the state to set
  33739. */
  33740. setDepthBuffer(enable: boolean): void;
  33741. /**
  33742. * Gets a boolean indicating if depth writing is enabled
  33743. * @returns the current depth writing state
  33744. */
  33745. getDepthWrite(): boolean;
  33746. /**
  33747. * Enable or disable depth writing
  33748. * @param enable defines the state to set
  33749. */
  33750. setDepthWrite(enable: boolean): void;
  33751. /**
  33752. * Gets a boolean indicating if stencil buffer is enabled
  33753. * @returns the current stencil buffer state
  33754. */
  33755. getStencilBuffer(): boolean;
  33756. /**
  33757. * Enable or disable the stencil buffer
  33758. * @param enable defines if the stencil buffer must be enabled or disabled
  33759. */
  33760. setStencilBuffer(enable: boolean): void;
  33761. /**
  33762. * Gets the current stencil mask
  33763. * @returns a number defining the new stencil mask to use
  33764. */
  33765. getStencilMask(): number;
  33766. /**
  33767. * Sets the current stencil mask
  33768. * @param mask defines the new stencil mask to use
  33769. */
  33770. setStencilMask(mask: number): void;
  33771. /**
  33772. * Gets the current stencil function
  33773. * @returns a number defining the stencil function to use
  33774. */
  33775. getStencilFunction(): number;
  33776. /**
  33777. * Gets the current stencil reference value
  33778. * @returns a number defining the stencil reference value to use
  33779. */
  33780. getStencilFunctionReference(): number;
  33781. /**
  33782. * Gets the current stencil mask
  33783. * @returns a number defining the stencil mask to use
  33784. */
  33785. getStencilFunctionMask(): number;
  33786. /**
  33787. * Sets the current stencil function
  33788. * @param stencilFunc defines the new stencil function to use
  33789. */
  33790. setStencilFunction(stencilFunc: number): void;
  33791. /**
  33792. * Sets the current stencil reference
  33793. * @param reference defines the new stencil reference to use
  33794. */
  33795. setStencilFunctionReference(reference: number): void;
  33796. /**
  33797. * Sets the current stencil mask
  33798. * @param mask defines the new stencil mask to use
  33799. */
  33800. setStencilFunctionMask(mask: number): void;
  33801. /**
  33802. * Gets the current stencil operation when stencil fails
  33803. * @returns a number defining stencil operation to use when stencil fails
  33804. */
  33805. getStencilOperationFail(): number;
  33806. /**
  33807. * Gets the current stencil operation when depth fails
  33808. * @returns a number defining stencil operation to use when depth fails
  33809. */
  33810. getStencilOperationDepthFail(): number;
  33811. /**
  33812. * Gets the current stencil operation when stencil passes
  33813. * @returns a number defining stencil operation to use when stencil passes
  33814. */
  33815. getStencilOperationPass(): number;
  33816. /**
  33817. * Sets the stencil operation to use when stencil fails
  33818. * @param operation defines the stencil operation to use when stencil fails
  33819. */
  33820. setStencilOperationFail(operation: number): void;
  33821. /**
  33822. * Sets the stencil operation to use when depth fails
  33823. * @param operation defines the stencil operation to use when depth fails
  33824. */
  33825. setStencilOperationDepthFail(operation: number): void;
  33826. /**
  33827. * Sets the stencil operation to use when stencil passes
  33828. * @param operation defines the stencil operation to use when stencil passes
  33829. */
  33830. setStencilOperationPass(operation: number): void;
  33831. /**
  33832. * Sets a boolean indicating if the dithering state is enabled or disabled
  33833. * @param value defines the dithering state
  33834. */
  33835. setDitheringState(value: boolean): void;
  33836. /**
  33837. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33838. * @param value defines the rasterizer state
  33839. */
  33840. setRasterizerState(value: boolean): void;
  33841. /**
  33842. * Gets the current depth function
  33843. * @returns a number defining the depth function
  33844. */
  33845. getDepthFunction(): Nullable<number>;
  33846. /**
  33847. * Sets the current depth function
  33848. * @param depthFunc defines the function to use
  33849. */
  33850. setDepthFunction(depthFunc: number): void;
  33851. /**
  33852. * Sets the current depth function to GREATER
  33853. */
  33854. setDepthFunctionToGreater(): void;
  33855. /**
  33856. * Sets the current depth function to GEQUAL
  33857. */
  33858. setDepthFunctionToGreaterOrEqual(): void;
  33859. /**
  33860. * Sets the current depth function to LESS
  33861. */
  33862. setDepthFunctionToLess(): void;
  33863. /**
  33864. * Sets the current depth function to LEQUAL
  33865. */
  33866. setDepthFunctionToLessOrEqual(): void;
  33867. private _cachedStencilBuffer;
  33868. private _cachedStencilFunction;
  33869. private _cachedStencilMask;
  33870. private _cachedStencilOperationPass;
  33871. private _cachedStencilOperationFail;
  33872. private _cachedStencilOperationDepthFail;
  33873. private _cachedStencilReference;
  33874. /**
  33875. * Caches the the state of the stencil buffer
  33876. */
  33877. cacheStencilState(): void;
  33878. /**
  33879. * Restores the state of the stencil buffer
  33880. */
  33881. restoreStencilState(): void;
  33882. /**
  33883. * Directly set the WebGL Viewport
  33884. * @param x defines the x coordinate of the viewport (in screen space)
  33885. * @param y defines the y coordinate of the viewport (in screen space)
  33886. * @param width defines the width of the viewport (in screen space)
  33887. * @param height defines the height of the viewport (in screen space)
  33888. * @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
  33889. */
  33890. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33891. /**
  33892. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33893. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33894. * @param y defines the y-coordinate of the corner of the clear rectangle
  33895. * @param width defines the width of the clear rectangle
  33896. * @param height defines the height of the clear rectangle
  33897. * @param clearColor defines the clear color
  33898. */
  33899. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33900. /**
  33901. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33902. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33903. * @param y defines the y-coordinate of the corner of the clear rectangle
  33904. * @param width defines the width of the clear rectangle
  33905. * @param height defines the height of the clear rectangle
  33906. */
  33907. enableScissor(x: number, y: number, width: number, height: number): void;
  33908. /**
  33909. * Disable previously set scissor test rectangle
  33910. */
  33911. disableScissor(): void;
  33912. protected _reportDrawCall(): void;
  33913. /**
  33914. * Initializes a webVR display and starts listening to display change events
  33915. * The onVRDisplayChangedObservable will be notified upon these changes
  33916. * @returns The onVRDisplayChangedObservable
  33917. */
  33918. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33919. /** @hidden */
  33920. _prepareVRComponent(): void;
  33921. /** @hidden */
  33922. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33923. /** @hidden */
  33924. _submitVRFrame(): void;
  33925. /**
  33926. * Call this function to leave webVR mode
  33927. * Will do nothing if webVR is not supported or if there is no webVR device
  33928. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33929. */
  33930. disableVR(): void;
  33931. /**
  33932. * Gets a boolean indicating that the system is in VR mode and is presenting
  33933. * @returns true if VR mode is engaged
  33934. */
  33935. isVRPresenting(): boolean;
  33936. /** @hidden */
  33937. _requestVRFrame(): void;
  33938. /** @hidden */
  33939. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33940. /**
  33941. * Gets the source code of the vertex shader associated with a specific webGL program
  33942. * @param program defines the program to use
  33943. * @returns a string containing the source code of the vertex shader associated with the program
  33944. */
  33945. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33946. /**
  33947. * Gets the source code of the fragment shader associated with a specific webGL program
  33948. * @param program defines the program to use
  33949. * @returns a string containing the source code of the fragment shader associated with the program
  33950. */
  33951. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33952. /**
  33953. * Sets a depth stencil texture from a render target to the according uniform.
  33954. * @param channel The texture channel
  33955. * @param uniform The uniform to set
  33956. * @param texture The render target texture containing the depth stencil texture to apply
  33957. */
  33958. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33959. /**
  33960. * Sets a texture to the webGL context from a postprocess
  33961. * @param channel defines the channel to use
  33962. * @param postProcess defines the source postprocess
  33963. */
  33964. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33965. /**
  33966. * Binds the output of the passed in post process to the texture channel specified
  33967. * @param channel The channel the texture should be bound to
  33968. * @param postProcess The post process which's output should be bound
  33969. */
  33970. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33971. /** @hidden */
  33972. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33973. protected _rebuildBuffers(): void;
  33974. /** @hidden */
  33975. _renderFrame(): void;
  33976. _renderLoop(): void;
  33977. /** @hidden */
  33978. _renderViews(): boolean;
  33979. /**
  33980. * Toggle full screen mode
  33981. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33982. */
  33983. switchFullscreen(requestPointerLock: boolean): void;
  33984. /**
  33985. * Enters full screen mode
  33986. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33987. */
  33988. enterFullscreen(requestPointerLock: boolean): void;
  33989. /**
  33990. * Exits full screen mode
  33991. */
  33992. exitFullscreen(): void;
  33993. /**
  33994. * Enters Pointerlock mode
  33995. */
  33996. enterPointerlock(): void;
  33997. /**
  33998. * Exits Pointerlock mode
  33999. */
  34000. exitPointerlock(): void;
  34001. /**
  34002. * Begin a new frame
  34003. */
  34004. beginFrame(): void;
  34005. /**
  34006. * Enf the current frame
  34007. */
  34008. endFrame(): void;
  34009. resize(): void;
  34010. /**
  34011. * Force a specific size of the canvas
  34012. * @param width defines the new canvas' width
  34013. * @param height defines the new canvas' height
  34014. */
  34015. setSize(width: number, height: number): void;
  34016. /**
  34017. * Updates a dynamic vertex buffer.
  34018. * @param vertexBuffer the vertex buffer to update
  34019. * @param data the data used to update the vertex buffer
  34020. * @param byteOffset the byte offset of the data
  34021. * @param byteLength the byte length of the data
  34022. */
  34023. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34024. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34025. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34026. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34027. _releaseTexture(texture: InternalTexture): void;
  34028. /**
  34029. * @hidden
  34030. * Rescales a texture
  34031. * @param source input texutre
  34032. * @param destination destination texture
  34033. * @param scene scene to use to render the resize
  34034. * @param internalFormat format to use when resizing
  34035. * @param onComplete callback to be called when resize has completed
  34036. */
  34037. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34038. /**
  34039. * Gets the current framerate
  34040. * @returns a number representing the framerate
  34041. */
  34042. getFps(): number;
  34043. /**
  34044. * Gets the time spent between current and previous frame
  34045. * @returns a number representing the delta time in ms
  34046. */
  34047. getDeltaTime(): number;
  34048. private _measureFps;
  34049. /** @hidden */
  34050. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34051. /**
  34052. * Update a dynamic index buffer
  34053. * @param indexBuffer defines the target index buffer
  34054. * @param indices defines the data to update
  34055. * @param offset defines the offset in the target index buffer where update should start
  34056. */
  34057. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34058. /**
  34059. * Updates the sample count of a render target texture
  34060. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34061. * @param texture defines the texture to update
  34062. * @param samples defines the sample count to set
  34063. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34064. */
  34065. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34066. /**
  34067. * Updates a depth texture Comparison Mode and Function.
  34068. * If the comparison Function is equal to 0, the mode will be set to none.
  34069. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34070. * @param texture The texture to set the comparison function for
  34071. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34072. */
  34073. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34074. /**
  34075. * Creates a webGL buffer to use with instanciation
  34076. * @param capacity defines the size of the buffer
  34077. * @returns the webGL buffer
  34078. */
  34079. createInstancesBuffer(capacity: number): DataBuffer;
  34080. /**
  34081. * Delete a webGL buffer used with instanciation
  34082. * @param buffer defines the webGL buffer to delete
  34083. */
  34084. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34085. private _clientWaitAsync;
  34086. /** @hidden */
  34087. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34088. /** @hidden */
  34089. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34090. dispose(): void;
  34091. private _disableTouchAction;
  34092. /**
  34093. * Display the loading screen
  34094. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34095. */
  34096. displayLoadingUI(): void;
  34097. /**
  34098. * Hide the loading screen
  34099. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34100. */
  34101. hideLoadingUI(): void;
  34102. /**
  34103. * Gets the current loading screen object
  34104. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34105. */
  34106. get loadingScreen(): ILoadingScreen;
  34107. /**
  34108. * Sets the current loading screen object
  34109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34110. */
  34111. set loadingScreen(loadingScreen: ILoadingScreen);
  34112. /**
  34113. * Sets the current loading screen text
  34114. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34115. */
  34116. set loadingUIText(text: string);
  34117. /**
  34118. * Sets the current loading screen background color
  34119. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34120. */
  34121. set loadingUIBackgroundColor(color: string);
  34122. /** Pointerlock and fullscreen */
  34123. /**
  34124. * Ask the browser to promote the current element to pointerlock mode
  34125. * @param element defines the DOM element to promote
  34126. */
  34127. static _RequestPointerlock(element: HTMLElement): void;
  34128. /**
  34129. * Asks the browser to exit pointerlock mode
  34130. */
  34131. static _ExitPointerlock(): void;
  34132. /**
  34133. * Ask the browser to promote the current element to fullscreen rendering mode
  34134. * @param element defines the DOM element to promote
  34135. */
  34136. static _RequestFullscreen(element: HTMLElement): void;
  34137. /**
  34138. * Asks the browser to exit fullscreen mode
  34139. */
  34140. static _ExitFullscreen(): void;
  34141. }
  34142. }
  34143. declare module BABYLON {
  34144. /**
  34145. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34146. * during the life time of the application.
  34147. */
  34148. export class EngineStore {
  34149. /** Gets the list of created engines */
  34150. static Instances: Engine[];
  34151. /** @hidden */
  34152. static _LastCreatedScene: Nullable<Scene>;
  34153. /**
  34154. * Gets the latest created engine
  34155. */
  34156. static get LastCreatedEngine(): Nullable<Engine>;
  34157. /**
  34158. * Gets the latest created scene
  34159. */
  34160. static get LastCreatedScene(): Nullable<Scene>;
  34161. /**
  34162. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34163. * @ignorenaming
  34164. */
  34165. static UseFallbackTexture: boolean;
  34166. /**
  34167. * Texture content used if a texture cannot loaded
  34168. * @ignorenaming
  34169. */
  34170. static FallbackTexture: string;
  34171. }
  34172. }
  34173. declare module BABYLON {
  34174. /**
  34175. * Helper class that provides a small promise polyfill
  34176. */
  34177. export class PromisePolyfill {
  34178. /**
  34179. * Static function used to check if the polyfill is required
  34180. * If this is the case then the function will inject the polyfill to window.Promise
  34181. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34182. */
  34183. static Apply(force?: boolean): void;
  34184. }
  34185. }
  34186. declare module BABYLON {
  34187. /**
  34188. * Interface for screenshot methods with describe argument called `size` as object with options
  34189. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34190. */
  34191. export interface IScreenshotSize {
  34192. /**
  34193. * number in pixels for canvas height
  34194. */
  34195. height?: number;
  34196. /**
  34197. * multiplier allowing render at a higher or lower resolution
  34198. * If value is defined then height and width will be ignored and taken from camera
  34199. */
  34200. precision?: number;
  34201. /**
  34202. * number in pixels for canvas width
  34203. */
  34204. width?: number;
  34205. }
  34206. }
  34207. declare module BABYLON {
  34208. interface IColor4Like {
  34209. r: float;
  34210. g: float;
  34211. b: float;
  34212. a: float;
  34213. }
  34214. /**
  34215. * Class containing a set of static utilities functions
  34216. */
  34217. export class Tools {
  34218. /**
  34219. * Gets or sets the base URL to use to load assets
  34220. */
  34221. static get BaseUrl(): string;
  34222. static set BaseUrl(value: string);
  34223. /**
  34224. * Enable/Disable Custom HTTP Request Headers globally.
  34225. * default = false
  34226. * @see CustomRequestHeaders
  34227. */
  34228. static UseCustomRequestHeaders: boolean;
  34229. /**
  34230. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34231. * i.e. when loading files, where the server/service expects an Authorization header
  34232. */
  34233. static CustomRequestHeaders: {
  34234. [key: string]: string;
  34235. };
  34236. /**
  34237. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34238. */
  34239. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34240. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34241. /**
  34242. * Default behaviour for cors in the application.
  34243. * It can be a string if the expected behavior is identical in the entire app.
  34244. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34245. */
  34246. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34247. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34248. /**
  34249. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34250. * @ignorenaming
  34251. */
  34252. static get UseFallbackTexture(): boolean;
  34253. static set UseFallbackTexture(value: boolean);
  34254. /**
  34255. * Use this object to register external classes like custom textures or material
  34256. * to allow the laoders to instantiate them
  34257. */
  34258. static get RegisteredExternalClasses(): {
  34259. [key: string]: Object;
  34260. };
  34261. static set RegisteredExternalClasses(classes: {
  34262. [key: string]: Object;
  34263. });
  34264. /**
  34265. * Texture content used if a texture cannot loaded
  34266. * @ignorenaming
  34267. */
  34268. static get fallbackTexture(): string;
  34269. static set fallbackTexture(value: string);
  34270. /**
  34271. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34272. * @param u defines the coordinate on X axis
  34273. * @param v defines the coordinate on Y axis
  34274. * @param width defines the width of the source data
  34275. * @param height defines the height of the source data
  34276. * @param pixels defines the source byte array
  34277. * @param color defines the output color
  34278. */
  34279. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34280. /**
  34281. * Interpolates between a and b via alpha
  34282. * @param a The lower value (returned when alpha = 0)
  34283. * @param b The upper value (returned when alpha = 1)
  34284. * @param alpha The interpolation-factor
  34285. * @return The mixed value
  34286. */
  34287. static Mix(a: number, b: number, alpha: number): number;
  34288. /**
  34289. * Tries to instantiate a new object from a given class name
  34290. * @param className defines the class name to instantiate
  34291. * @returns the new object or null if the system was not able to do the instantiation
  34292. */
  34293. static Instantiate(className: string): any;
  34294. /**
  34295. * Provides a slice function that will work even on IE
  34296. * @param data defines the array to slice
  34297. * @param start defines the start of the data (optional)
  34298. * @param end defines the end of the data (optional)
  34299. * @returns the new sliced array
  34300. */
  34301. static Slice<T>(data: T, start?: number, end?: number): T;
  34302. /**
  34303. * Polyfill for setImmediate
  34304. * @param action defines the action to execute after the current execution block
  34305. */
  34306. static SetImmediate(action: () => void): void;
  34307. /**
  34308. * Function indicating if a number is an exponent of 2
  34309. * @param value defines the value to test
  34310. * @returns true if the value is an exponent of 2
  34311. */
  34312. static IsExponentOfTwo(value: number): boolean;
  34313. private static _tmpFloatArray;
  34314. /**
  34315. * Returns the nearest 32-bit single precision float representation of a Number
  34316. * @param value A Number. If the parameter is of a different type, it will get converted
  34317. * to a number or to NaN if it cannot be converted
  34318. * @returns number
  34319. */
  34320. static FloatRound(value: number): number;
  34321. /**
  34322. * Extracts the filename from a path
  34323. * @param path defines the path to use
  34324. * @returns the filename
  34325. */
  34326. static GetFilename(path: string): string;
  34327. /**
  34328. * Extracts the "folder" part of a path (everything before the filename).
  34329. * @param uri The URI to extract the info from
  34330. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34331. * @returns The "folder" part of the path
  34332. */
  34333. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34334. /**
  34335. * Extracts text content from a DOM element hierarchy
  34336. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34337. */
  34338. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34339. /**
  34340. * Convert an angle in radians to degrees
  34341. * @param angle defines the angle to convert
  34342. * @returns the angle in degrees
  34343. */
  34344. static ToDegrees(angle: number): number;
  34345. /**
  34346. * Convert an angle in degrees to radians
  34347. * @param angle defines the angle to convert
  34348. * @returns the angle in radians
  34349. */
  34350. static ToRadians(angle: number): number;
  34351. /**
  34352. * Returns an array if obj is not an array
  34353. * @param obj defines the object to evaluate as an array
  34354. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34355. * @returns either obj directly if obj is an array or a new array containing obj
  34356. */
  34357. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34358. /**
  34359. * Gets the pointer prefix to use
  34360. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34361. */
  34362. static GetPointerPrefix(): string;
  34363. /**
  34364. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34365. * @param url define the url we are trying
  34366. * @param element define the dom element where to configure the cors policy
  34367. */
  34368. static SetCorsBehavior(url: string | string[], element: {
  34369. crossOrigin: string | null;
  34370. }): void;
  34371. /**
  34372. * Removes unwanted characters from an url
  34373. * @param url defines the url to clean
  34374. * @returns the cleaned url
  34375. */
  34376. static CleanUrl(url: string): string;
  34377. /**
  34378. * Gets or sets a function used to pre-process url before using them to load assets
  34379. */
  34380. static get PreprocessUrl(): (url: string) => string;
  34381. static set PreprocessUrl(processor: (url: string) => string);
  34382. /**
  34383. * Loads an image as an HTMLImageElement.
  34384. * @param input url string, ArrayBuffer, or Blob to load
  34385. * @param onLoad callback called when the image successfully loads
  34386. * @param onError callback called when the image fails to load
  34387. * @param offlineProvider offline provider for caching
  34388. * @param mimeType optional mime type
  34389. * @returns the HTMLImageElement of the loaded image
  34390. */
  34391. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34392. /**
  34393. * Loads a file from a url
  34394. * @param url url string, ArrayBuffer, or Blob to load
  34395. * @param onSuccess callback called when the file successfully loads
  34396. * @param onProgress callback called while file is loading (if the server supports this mode)
  34397. * @param offlineProvider defines the offline provider for caching
  34398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34399. * @param onError callback called when the file fails to load
  34400. * @returns a file request object
  34401. */
  34402. 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;
  34403. /**
  34404. * Loads a file from a url
  34405. * @param url the file url to load
  34406. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34407. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34408. */
  34409. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34410. /**
  34411. * Load a script (identified by an url). When the url returns, the
  34412. * content of this file is added into a new script element, attached to the DOM (body element)
  34413. * @param scriptUrl defines the url of the script to laod
  34414. * @param onSuccess defines the callback called when the script is loaded
  34415. * @param onError defines the callback to call if an error occurs
  34416. * @param scriptId defines the id of the script element
  34417. */
  34418. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34419. /**
  34420. * Load an asynchronous script (identified by an url). When the url returns, the
  34421. * content of this file is added into a new script element, attached to the DOM (body element)
  34422. * @param scriptUrl defines the url of the script to laod
  34423. * @param scriptId defines the id of the script element
  34424. * @returns a promise request object
  34425. */
  34426. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34427. /**
  34428. * Loads a file from a blob
  34429. * @param fileToLoad defines the blob to use
  34430. * @param callback defines the callback to call when data is loaded
  34431. * @param progressCallback defines the callback to call during loading process
  34432. * @returns a file request object
  34433. */
  34434. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34435. /**
  34436. * Reads a file from a File object
  34437. * @param file defines the file to load
  34438. * @param onSuccess defines the callback to call when data is loaded
  34439. * @param onProgress defines the callback to call during loading process
  34440. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34441. * @param onError defines the callback to call when an error occurs
  34442. * @returns a file request object
  34443. */
  34444. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34445. /**
  34446. * Creates a data url from a given string content
  34447. * @param content defines the content to convert
  34448. * @returns the new data url link
  34449. */
  34450. static FileAsURL(content: string): string;
  34451. /**
  34452. * Format the given number to a specific decimal format
  34453. * @param value defines the number to format
  34454. * @param decimals defines the number of decimals to use
  34455. * @returns the formatted string
  34456. */
  34457. static Format(value: number, decimals?: number): string;
  34458. /**
  34459. * Tries to copy an object by duplicating every property
  34460. * @param source defines the source object
  34461. * @param destination defines the target object
  34462. * @param doNotCopyList defines a list of properties to avoid
  34463. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34464. */
  34465. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34466. /**
  34467. * Gets a boolean indicating if the given object has no own property
  34468. * @param obj defines the object to test
  34469. * @returns true if object has no own property
  34470. */
  34471. static IsEmpty(obj: any): boolean;
  34472. /**
  34473. * Function used to register events at window level
  34474. * @param windowElement defines the Window object to use
  34475. * @param events defines the events to register
  34476. */
  34477. static RegisterTopRootEvents(windowElement: Window, events: {
  34478. name: string;
  34479. handler: Nullable<(e: FocusEvent) => any>;
  34480. }[]): void;
  34481. /**
  34482. * Function used to unregister events from window level
  34483. * @param windowElement defines the Window object to use
  34484. * @param events defines the events to unregister
  34485. */
  34486. static UnregisterTopRootEvents(windowElement: Window, events: {
  34487. name: string;
  34488. handler: Nullable<(e: FocusEvent) => any>;
  34489. }[]): void;
  34490. /**
  34491. * @ignore
  34492. */
  34493. static _ScreenshotCanvas: HTMLCanvasElement;
  34494. /**
  34495. * Dumps the current bound framebuffer
  34496. * @param width defines the rendering width
  34497. * @param height defines the rendering height
  34498. * @param engine defines the hosting engine
  34499. * @param successCallback defines the callback triggered once the data are available
  34500. * @param mimeType defines the mime type of the result
  34501. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34502. */
  34503. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34504. /**
  34505. * Converts the canvas data to blob.
  34506. * This acts as a polyfill for browsers not supporting the to blob function.
  34507. * @param canvas Defines the canvas to extract the data from
  34508. * @param successCallback Defines the callback triggered once the data are available
  34509. * @param mimeType Defines the mime type of the result
  34510. */
  34511. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34512. /**
  34513. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34514. * @param successCallback defines the callback triggered once the data are available
  34515. * @param mimeType defines the mime type of the result
  34516. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34517. */
  34518. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34519. /**
  34520. * Downloads a blob in the browser
  34521. * @param blob defines the blob to download
  34522. * @param fileName defines the name of the downloaded file
  34523. */
  34524. static Download(blob: Blob, fileName: string): void;
  34525. /**
  34526. * Captures a screenshot of the current rendering
  34527. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34528. * @param engine defines the rendering engine
  34529. * @param camera defines the source camera
  34530. * @param size This parameter can be set to a single number or to an object with the
  34531. * following (optional) properties: precision, width, height. If a single number is passed,
  34532. * it will be used for both width and height. If an object is passed, the screenshot size
  34533. * will be derived from the parameters. The precision property is a multiplier allowing
  34534. * rendering at a higher or lower resolution
  34535. * @param successCallback defines the callback receives a single parameter which contains the
  34536. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34537. * src parameter of an <img> to display it
  34538. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34539. * Check your browser for supported MIME types
  34540. */
  34541. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34542. /**
  34543. * Captures a screenshot of the current rendering
  34544. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34545. * @param engine defines the rendering engine
  34546. * @param camera defines the source camera
  34547. * @param size This parameter can be set to a single number or to an object with the
  34548. * following (optional) properties: precision, width, height. If a single number is passed,
  34549. * it will be used for both width and height. If an object is passed, the screenshot size
  34550. * will be derived from the parameters. The precision property is a multiplier allowing
  34551. * rendering at a higher or lower resolution
  34552. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34553. * Check your browser for supported MIME types
  34554. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34555. * to the src parameter of an <img> to display it
  34556. */
  34557. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34558. /**
  34559. * Generates an image screenshot from the specified camera.
  34560. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34561. * @param engine The engine to use for rendering
  34562. * @param camera The camera to use for rendering
  34563. * @param size This parameter can be set to a single number or to an object with the
  34564. * following (optional) properties: precision, width, height. If a single number is passed,
  34565. * it will be used for both width and height. If an object is passed, the screenshot size
  34566. * will be derived from the parameters. The precision property is a multiplier allowing
  34567. * rendering at a higher or lower resolution
  34568. * @param successCallback The callback receives a single parameter which contains the
  34569. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34570. * src parameter of an <img> to display it
  34571. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34572. * Check your browser for supported MIME types
  34573. * @param samples Texture samples (default: 1)
  34574. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34575. * @param fileName A name for for the downloaded file.
  34576. */
  34577. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34578. /**
  34579. * Generates an image screenshot from the specified camera.
  34580. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34581. * @param engine The engine to use for rendering
  34582. * @param camera The camera to use for rendering
  34583. * @param size This parameter can be set to a single number or to an object with the
  34584. * following (optional) properties: precision, width, height. If a single number is passed,
  34585. * it will be used for both width and height. If an object is passed, the screenshot size
  34586. * will be derived from the parameters. The precision property is a multiplier allowing
  34587. * rendering at a higher or lower resolution
  34588. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34589. * Check your browser for supported MIME types
  34590. * @param samples Texture samples (default: 1)
  34591. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34592. * @param fileName A name for for the downloaded file.
  34593. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34594. * to the src parameter of an <img> to display it
  34595. */
  34596. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34597. /**
  34598. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34599. * Be aware Math.random() could cause collisions, but:
  34600. * "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"
  34601. * @returns a pseudo random id
  34602. */
  34603. static RandomId(): string;
  34604. /**
  34605. * Test if the given uri is a base64 string
  34606. * @param uri The uri to test
  34607. * @return True if the uri is a base64 string or false otherwise
  34608. */
  34609. static IsBase64(uri: string): boolean;
  34610. /**
  34611. * Decode the given base64 uri.
  34612. * @param uri The uri to decode
  34613. * @return The decoded base64 data.
  34614. */
  34615. static DecodeBase64(uri: string): ArrayBuffer;
  34616. /**
  34617. * Gets the absolute url.
  34618. * @param url the input url
  34619. * @return the absolute url
  34620. */
  34621. static GetAbsoluteUrl(url: string): string;
  34622. /**
  34623. * No log
  34624. */
  34625. static readonly NoneLogLevel: number;
  34626. /**
  34627. * Only message logs
  34628. */
  34629. static readonly MessageLogLevel: number;
  34630. /**
  34631. * Only warning logs
  34632. */
  34633. static readonly WarningLogLevel: number;
  34634. /**
  34635. * Only error logs
  34636. */
  34637. static readonly ErrorLogLevel: number;
  34638. /**
  34639. * All logs
  34640. */
  34641. static readonly AllLogLevel: number;
  34642. /**
  34643. * Gets a value indicating the number of loading errors
  34644. * @ignorenaming
  34645. */
  34646. static get errorsCount(): number;
  34647. /**
  34648. * Callback called when a new log is added
  34649. */
  34650. static OnNewCacheEntry: (entry: string) => void;
  34651. /**
  34652. * Log a message to the console
  34653. * @param message defines the message to log
  34654. */
  34655. static Log(message: string): void;
  34656. /**
  34657. * Write a warning message to the console
  34658. * @param message defines the message to log
  34659. */
  34660. static Warn(message: string): void;
  34661. /**
  34662. * Write an error message to the console
  34663. * @param message defines the message to log
  34664. */
  34665. static Error(message: string): void;
  34666. /**
  34667. * Gets current log cache (list of logs)
  34668. */
  34669. static get LogCache(): string;
  34670. /**
  34671. * Clears the log cache
  34672. */
  34673. static ClearLogCache(): void;
  34674. /**
  34675. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34676. */
  34677. static set LogLevels(level: number);
  34678. /**
  34679. * Checks if the window object exists
  34680. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34681. */
  34682. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34683. /**
  34684. * No performance log
  34685. */
  34686. static readonly PerformanceNoneLogLevel: number;
  34687. /**
  34688. * Use user marks to log performance
  34689. */
  34690. static readonly PerformanceUserMarkLogLevel: number;
  34691. /**
  34692. * Log performance to the console
  34693. */
  34694. static readonly PerformanceConsoleLogLevel: number;
  34695. private static _performance;
  34696. /**
  34697. * Sets the current performance log level
  34698. */
  34699. static set PerformanceLogLevel(level: number);
  34700. private static _StartPerformanceCounterDisabled;
  34701. private static _EndPerformanceCounterDisabled;
  34702. private static _StartUserMark;
  34703. private static _EndUserMark;
  34704. private static _StartPerformanceConsole;
  34705. private static _EndPerformanceConsole;
  34706. /**
  34707. * Starts a performance counter
  34708. */
  34709. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34710. /**
  34711. * Ends a specific performance coutner
  34712. */
  34713. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34714. /**
  34715. * Gets either window.performance.now() if supported or Date.now() else
  34716. */
  34717. static get Now(): number;
  34718. /**
  34719. * This method will return the name of the class used to create the instance of the given object.
  34720. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34721. * @param object the object to get the class name from
  34722. * @param isType defines if the object is actually a type
  34723. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34724. */
  34725. static GetClassName(object: any, isType?: boolean): string;
  34726. /**
  34727. * Gets the first element of an array satisfying a given predicate
  34728. * @param array defines the array to browse
  34729. * @param predicate defines the predicate to use
  34730. * @returns null if not found or the element
  34731. */
  34732. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34733. /**
  34734. * This method will return the name of the full name of the class, including its owning module (if any).
  34735. * 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).
  34736. * @param object the object to get the class name from
  34737. * @param isType defines if the object is actually a type
  34738. * @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.
  34739. * @ignorenaming
  34740. */
  34741. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34742. /**
  34743. * Returns a promise that resolves after the given amount of time.
  34744. * @param delay Number of milliseconds to delay
  34745. * @returns Promise that resolves after the given amount of time
  34746. */
  34747. static DelayAsync(delay: number): Promise<void>;
  34748. /**
  34749. * Utility function to detect if the current user agent is Safari
  34750. * @returns whether or not the current user agent is safari
  34751. */
  34752. static IsSafari(): boolean;
  34753. }
  34754. /**
  34755. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34756. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34757. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34758. * @param name The name of the class, case should be preserved
  34759. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34760. */
  34761. export function className(name: string, module?: string): (target: Object) => void;
  34762. /**
  34763. * An implementation of a loop for asynchronous functions.
  34764. */
  34765. export class AsyncLoop {
  34766. /**
  34767. * Defines the number of iterations for the loop
  34768. */
  34769. iterations: number;
  34770. /**
  34771. * Defines the current index of the loop.
  34772. */
  34773. index: number;
  34774. private _done;
  34775. private _fn;
  34776. private _successCallback;
  34777. /**
  34778. * Constructor.
  34779. * @param iterations the number of iterations.
  34780. * @param func the function to run each iteration
  34781. * @param successCallback the callback that will be called upon succesful execution
  34782. * @param offset starting offset.
  34783. */
  34784. constructor(
  34785. /**
  34786. * Defines the number of iterations for the loop
  34787. */
  34788. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34789. /**
  34790. * Execute the next iteration. Must be called after the last iteration was finished.
  34791. */
  34792. executeNext(): void;
  34793. /**
  34794. * Break the loop and run the success callback.
  34795. */
  34796. breakLoop(): void;
  34797. /**
  34798. * Create and run an async loop.
  34799. * @param iterations the number of iterations.
  34800. * @param fn the function to run each iteration
  34801. * @param successCallback the callback that will be called upon succesful execution
  34802. * @param offset starting offset.
  34803. * @returns the created async loop object
  34804. */
  34805. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34806. /**
  34807. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34808. * @param iterations total number of iterations
  34809. * @param syncedIterations number of synchronous iterations in each async iteration.
  34810. * @param fn the function to call each iteration.
  34811. * @param callback a success call back that will be called when iterating stops.
  34812. * @param breakFunction a break condition (optional)
  34813. * @param timeout timeout settings for the setTimeout function. default - 0.
  34814. * @returns the created async loop object
  34815. */
  34816. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34817. }
  34818. }
  34819. declare module BABYLON {
  34820. /**
  34821. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34822. * The underlying implementation relies on an associative array to ensure the best performances.
  34823. * The value can be anything including 'null' but except 'undefined'
  34824. */
  34825. export class StringDictionary<T> {
  34826. /**
  34827. * This will clear this dictionary and copy the content from the 'source' one.
  34828. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34829. * @param source the dictionary to take the content from and copy to this dictionary
  34830. */
  34831. copyFrom(source: StringDictionary<T>): void;
  34832. /**
  34833. * Get a value based from its key
  34834. * @param key the given key to get the matching value from
  34835. * @return the value if found, otherwise undefined is returned
  34836. */
  34837. get(key: string): T | undefined;
  34838. /**
  34839. * Get a value from its key or add it if it doesn't exist.
  34840. * This method will ensure you that a given key/data will be present in the dictionary.
  34841. * @param key the given key to get the matching value from
  34842. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34843. * The factory will only be invoked if there's no data for the given key.
  34844. * @return the value corresponding to the key.
  34845. */
  34846. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34847. /**
  34848. * Get a value from its key if present in the dictionary otherwise add it
  34849. * @param key the key to get the value from
  34850. * @param val if there's no such key/value pair in the dictionary add it with this value
  34851. * @return the value corresponding to the key
  34852. */
  34853. getOrAdd(key: string, val: T): T;
  34854. /**
  34855. * Check if there's a given key in the dictionary
  34856. * @param key the key to check for
  34857. * @return true if the key is present, false otherwise
  34858. */
  34859. contains(key: string): boolean;
  34860. /**
  34861. * Add a new key and its corresponding value
  34862. * @param key the key to add
  34863. * @param value the value corresponding to the key
  34864. * @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
  34865. */
  34866. add(key: string, value: T): boolean;
  34867. /**
  34868. * Update a specific value associated to a key
  34869. * @param key defines the key to use
  34870. * @param value defines the value to store
  34871. * @returns true if the value was updated (or false if the key was not found)
  34872. */
  34873. set(key: string, value: T): boolean;
  34874. /**
  34875. * Get the element of the given key and remove it from the dictionary
  34876. * @param key defines the key to search
  34877. * @returns the value associated with the key or null if not found
  34878. */
  34879. getAndRemove(key: string): Nullable<T>;
  34880. /**
  34881. * Remove a key/value from the dictionary.
  34882. * @param key the key to remove
  34883. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34884. */
  34885. remove(key: string): boolean;
  34886. /**
  34887. * Clear the whole content of the dictionary
  34888. */
  34889. clear(): void;
  34890. /**
  34891. * Gets the current count
  34892. */
  34893. get count(): number;
  34894. /**
  34895. * Execute a callback on each key/val of the dictionary.
  34896. * Note that you can remove any element in this dictionary in the callback implementation
  34897. * @param callback the callback to execute on a given key/value pair
  34898. */
  34899. forEach(callback: (key: string, val: T) => void): void;
  34900. /**
  34901. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34902. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34903. * Note that you can remove any element in this dictionary in the callback implementation
  34904. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34905. * @returns the first item
  34906. */
  34907. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34908. private _count;
  34909. private _data;
  34910. }
  34911. }
  34912. declare module BABYLON {
  34913. /** @hidden */
  34914. export interface ICollisionCoordinator {
  34915. createCollider(): Collider;
  34916. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34917. init(scene: Scene): void;
  34918. }
  34919. /** @hidden */
  34920. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34921. private _scene;
  34922. private _scaledPosition;
  34923. private _scaledVelocity;
  34924. private _finalPosition;
  34925. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34926. createCollider(): Collider;
  34927. init(scene: Scene): void;
  34928. private _collideWithWorld;
  34929. }
  34930. }
  34931. declare module BABYLON {
  34932. /**
  34933. * Class used to manage all inputs for the scene.
  34934. */
  34935. export class InputManager {
  34936. /** The distance in pixel that you have to move to prevent some events */
  34937. static DragMovementThreshold: number;
  34938. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34939. static LongPressDelay: number;
  34940. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34941. static DoubleClickDelay: number;
  34942. /** If you need to check double click without raising a single click at first click, enable this flag */
  34943. static ExclusiveDoubleClickMode: boolean;
  34944. private _wheelEventName;
  34945. private _onPointerMove;
  34946. private _onPointerDown;
  34947. private _onPointerUp;
  34948. private _initClickEvent;
  34949. private _initActionManager;
  34950. private _delayedSimpleClick;
  34951. private _delayedSimpleClickTimeout;
  34952. private _previousDelayedSimpleClickTimeout;
  34953. private _meshPickProceed;
  34954. private _previousButtonPressed;
  34955. private _currentPickResult;
  34956. private _previousPickResult;
  34957. private _totalPointersPressed;
  34958. private _doubleClickOccured;
  34959. private _pointerOverMesh;
  34960. private _pickedDownMesh;
  34961. private _pickedUpMesh;
  34962. private _pointerX;
  34963. private _pointerY;
  34964. private _unTranslatedPointerX;
  34965. private _unTranslatedPointerY;
  34966. private _startingPointerPosition;
  34967. private _previousStartingPointerPosition;
  34968. private _startingPointerTime;
  34969. private _previousStartingPointerTime;
  34970. private _pointerCaptures;
  34971. private _onKeyDown;
  34972. private _onKeyUp;
  34973. private _onCanvasFocusObserver;
  34974. private _onCanvasBlurObserver;
  34975. private _scene;
  34976. /**
  34977. * Creates a new InputManager
  34978. * @param scene defines the hosting scene
  34979. */
  34980. constructor(scene: Scene);
  34981. /**
  34982. * Gets the mesh that is currently under the pointer
  34983. */
  34984. get meshUnderPointer(): Nullable<AbstractMesh>;
  34985. /**
  34986. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34987. */
  34988. get unTranslatedPointer(): Vector2;
  34989. /**
  34990. * Gets or sets the current on-screen X position of the pointer
  34991. */
  34992. get pointerX(): number;
  34993. set pointerX(value: number);
  34994. /**
  34995. * Gets or sets the current on-screen Y position of the pointer
  34996. */
  34997. get pointerY(): number;
  34998. set pointerY(value: number);
  34999. private _updatePointerPosition;
  35000. private _processPointerMove;
  35001. private _setRayOnPointerInfo;
  35002. private _checkPrePointerObservable;
  35003. /**
  35004. * Use this method to simulate a pointer move on a mesh
  35005. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35006. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35007. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35008. */
  35009. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35010. /**
  35011. * Use this method to simulate a pointer down on a mesh
  35012. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35013. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35014. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35015. */
  35016. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35017. private _processPointerDown;
  35018. /** @hidden */
  35019. _isPointerSwiping(): boolean;
  35020. /**
  35021. * Use this method to simulate a pointer up on a mesh
  35022. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35023. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35024. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35025. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35026. */
  35027. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35028. private _processPointerUp;
  35029. /**
  35030. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35031. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35032. * @returns true if the pointer was captured
  35033. */
  35034. isPointerCaptured(pointerId?: number): boolean;
  35035. /**
  35036. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35037. * @param attachUp defines if you want to attach events to pointerup
  35038. * @param attachDown defines if you want to attach events to pointerdown
  35039. * @param attachMove defines if you want to attach events to pointermove
  35040. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35041. */
  35042. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35043. /**
  35044. * Detaches all event handlers
  35045. */
  35046. detachControl(): void;
  35047. /**
  35048. * Force the value of meshUnderPointer
  35049. * @param mesh defines the mesh to use
  35050. */
  35051. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35052. /**
  35053. * Gets the mesh under the pointer
  35054. * @returns a Mesh or null if no mesh is under the pointer
  35055. */
  35056. getPointerOverMesh(): Nullable<AbstractMesh>;
  35057. }
  35058. }
  35059. declare module BABYLON {
  35060. /**
  35061. * Helper class used to generate session unique ID
  35062. */
  35063. export class UniqueIdGenerator {
  35064. private static _UniqueIdCounter;
  35065. /**
  35066. * Gets an unique (relatively to the current scene) Id
  35067. */
  35068. static get UniqueId(): number;
  35069. }
  35070. }
  35071. declare module BABYLON {
  35072. /**
  35073. * This class defines the direct association between an animation and a target
  35074. */
  35075. export class TargetedAnimation {
  35076. /**
  35077. * Animation to perform
  35078. */
  35079. animation: Animation;
  35080. /**
  35081. * Target to animate
  35082. */
  35083. target: any;
  35084. /**
  35085. * Serialize the object
  35086. * @returns the JSON object representing the current entity
  35087. */
  35088. serialize(): any;
  35089. }
  35090. /**
  35091. * Use this class to create coordinated animations on multiple targets
  35092. */
  35093. export class AnimationGroup implements IDisposable {
  35094. /** The name of the animation group */
  35095. name: string;
  35096. private _scene;
  35097. private _targetedAnimations;
  35098. private _animatables;
  35099. private _from;
  35100. private _to;
  35101. private _isStarted;
  35102. private _isPaused;
  35103. private _speedRatio;
  35104. private _loopAnimation;
  35105. private _isAdditive;
  35106. /**
  35107. * Gets or sets the unique id of the node
  35108. */
  35109. uniqueId: number;
  35110. /**
  35111. * This observable will notify when one animation have ended
  35112. */
  35113. onAnimationEndObservable: Observable<TargetedAnimation>;
  35114. /**
  35115. * Observer raised when one animation loops
  35116. */
  35117. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35118. /**
  35119. * Observer raised when all animations have looped
  35120. */
  35121. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35122. /**
  35123. * This observable will notify when all animations have ended.
  35124. */
  35125. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35126. /**
  35127. * This observable will notify when all animations have paused.
  35128. */
  35129. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35130. /**
  35131. * This observable will notify when all animations are playing.
  35132. */
  35133. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35134. /**
  35135. * Gets the first frame
  35136. */
  35137. get from(): number;
  35138. /**
  35139. * Gets the last frame
  35140. */
  35141. get to(): number;
  35142. /**
  35143. * Define if the animations are started
  35144. */
  35145. get isStarted(): boolean;
  35146. /**
  35147. * Gets a value indicating that the current group is playing
  35148. */
  35149. get isPlaying(): boolean;
  35150. /**
  35151. * Gets or sets the speed ratio to use for all animations
  35152. */
  35153. get speedRatio(): number;
  35154. /**
  35155. * Gets or sets the speed ratio to use for all animations
  35156. */
  35157. set speedRatio(value: number);
  35158. /**
  35159. * Gets or sets if all animations should loop or not
  35160. */
  35161. get loopAnimation(): boolean;
  35162. set loopAnimation(value: boolean);
  35163. /**
  35164. * Gets or sets if all animations should be evaluated additively
  35165. */
  35166. get isAdditive(): boolean;
  35167. set isAdditive(value: boolean);
  35168. /**
  35169. * Gets the targeted animations for this animation group
  35170. */
  35171. get targetedAnimations(): Array<TargetedAnimation>;
  35172. /**
  35173. * returning the list of animatables controlled by this animation group.
  35174. */
  35175. get animatables(): Array<Animatable>;
  35176. /**
  35177. * Instantiates a new Animation Group.
  35178. * This helps managing several animations at once.
  35179. * @see http://doc.babylonjs.com/how_to/group
  35180. * @param name Defines the name of the group
  35181. * @param scene Defines the scene the group belongs to
  35182. */
  35183. constructor(
  35184. /** The name of the animation group */
  35185. name: string, scene?: Nullable<Scene>);
  35186. /**
  35187. * Add an animation (with its target) in the group
  35188. * @param animation defines the animation we want to add
  35189. * @param target defines the target of the animation
  35190. * @returns the TargetedAnimation object
  35191. */
  35192. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35193. /**
  35194. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35195. * It can add constant keys at begin or end
  35196. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35197. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35198. * @returns the animation group
  35199. */
  35200. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35201. private _animationLoopCount;
  35202. private _animationLoopFlags;
  35203. private _processLoop;
  35204. /**
  35205. * Start all animations on given targets
  35206. * @param loop defines if animations must loop
  35207. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35208. * @param from defines the from key (optional)
  35209. * @param to defines the to key (optional)
  35210. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35211. * @returns the current animation group
  35212. */
  35213. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35214. /**
  35215. * Pause all animations
  35216. * @returns the animation group
  35217. */
  35218. pause(): AnimationGroup;
  35219. /**
  35220. * Play all animations to initial state
  35221. * This function will start() the animations if they were not started or will restart() them if they were paused
  35222. * @param loop defines if animations must loop
  35223. * @returns the animation group
  35224. */
  35225. play(loop?: boolean): AnimationGroup;
  35226. /**
  35227. * Reset all animations to initial state
  35228. * @returns the animation group
  35229. */
  35230. reset(): AnimationGroup;
  35231. /**
  35232. * Restart animations from key 0
  35233. * @returns the animation group
  35234. */
  35235. restart(): AnimationGroup;
  35236. /**
  35237. * Stop all animations
  35238. * @returns the animation group
  35239. */
  35240. stop(): AnimationGroup;
  35241. /**
  35242. * Set animation weight for all animatables
  35243. * @param weight defines the weight to use
  35244. * @return the animationGroup
  35245. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35246. */
  35247. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35248. /**
  35249. * Synchronize and normalize all animatables with a source animatable
  35250. * @param root defines the root animatable to synchronize with
  35251. * @return the animationGroup
  35252. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35253. */
  35254. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35255. /**
  35256. * Goes to a specific frame in this animation group
  35257. * @param frame the frame number to go to
  35258. * @return the animationGroup
  35259. */
  35260. goToFrame(frame: number): AnimationGroup;
  35261. /**
  35262. * Dispose all associated resources
  35263. */
  35264. dispose(): void;
  35265. private _checkAnimationGroupEnded;
  35266. /**
  35267. * Clone the current animation group and returns a copy
  35268. * @param newName defines the name of the new group
  35269. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35270. * @returns the new aniamtion group
  35271. */
  35272. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35273. /**
  35274. * Serializes the animationGroup to an object
  35275. * @returns Serialized object
  35276. */
  35277. serialize(): any;
  35278. /**
  35279. * Returns a new AnimationGroup object parsed from the source provided.
  35280. * @param parsedAnimationGroup defines the source
  35281. * @param scene defines the scene that will receive the animationGroup
  35282. * @returns a new AnimationGroup
  35283. */
  35284. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35285. /**
  35286. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35287. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35288. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35289. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35290. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35291. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35292. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35293. */
  35294. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35295. /**
  35296. * Returns the string "AnimationGroup"
  35297. * @returns "AnimationGroup"
  35298. */
  35299. getClassName(): string;
  35300. /**
  35301. * Creates a detailled string about the object
  35302. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35303. * @returns a string representing the object
  35304. */
  35305. toString(fullDetails?: boolean): string;
  35306. }
  35307. }
  35308. declare module BABYLON {
  35309. /**
  35310. * Define an interface for all classes that will hold resources
  35311. */
  35312. export interface IDisposable {
  35313. /**
  35314. * Releases all held resources
  35315. */
  35316. dispose(): void;
  35317. }
  35318. /** Interface defining initialization parameters for Scene class */
  35319. export interface SceneOptions {
  35320. /**
  35321. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35322. * It will improve performance when the number of geometries becomes important.
  35323. */
  35324. useGeometryUniqueIdsMap?: boolean;
  35325. /**
  35326. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35327. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35328. */
  35329. useMaterialMeshMap?: boolean;
  35330. /**
  35331. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35332. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35333. */
  35334. useClonedMeshMap?: boolean;
  35335. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35336. virtual?: boolean;
  35337. }
  35338. /**
  35339. * Represents a scene to be rendered by the engine.
  35340. * @see http://doc.babylonjs.com/features/scene
  35341. */
  35342. export class Scene extends AbstractScene implements IAnimatable {
  35343. /** The fog is deactivated */
  35344. static readonly FOGMODE_NONE: number;
  35345. /** The fog density is following an exponential function */
  35346. static readonly FOGMODE_EXP: number;
  35347. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35348. static readonly FOGMODE_EXP2: number;
  35349. /** The fog density is following a linear function. */
  35350. static readonly FOGMODE_LINEAR: number;
  35351. /**
  35352. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35353. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35354. */
  35355. static MinDeltaTime: number;
  35356. /**
  35357. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35358. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35359. */
  35360. static MaxDeltaTime: number;
  35361. /**
  35362. * Factory used to create the default material.
  35363. * @param name The name of the material to create
  35364. * @param scene The scene to create the material for
  35365. * @returns The default material
  35366. */
  35367. static DefaultMaterialFactory(scene: Scene): Material;
  35368. /**
  35369. * Factory used to create the a collision coordinator.
  35370. * @returns The collision coordinator
  35371. */
  35372. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35373. /** @hidden */
  35374. _inputManager: InputManager;
  35375. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35376. cameraToUseForPointers: Nullable<Camera>;
  35377. /** @hidden */
  35378. readonly _isScene: boolean;
  35379. /** @hidden */
  35380. _blockEntityCollection: boolean;
  35381. /**
  35382. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35383. */
  35384. autoClear: boolean;
  35385. /**
  35386. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35387. */
  35388. autoClearDepthAndStencil: boolean;
  35389. /**
  35390. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35391. */
  35392. clearColor: Color4;
  35393. /**
  35394. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35395. */
  35396. ambientColor: Color3;
  35397. /**
  35398. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35399. * It should only be one of the following (if not the default embedded one):
  35400. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35401. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35402. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35403. * The material properties need to be setup according to the type of texture in use.
  35404. */
  35405. environmentBRDFTexture: BaseTexture;
  35406. /** @hidden */
  35407. protected _environmentTexture: Nullable<BaseTexture>;
  35408. /**
  35409. * Texture used in all pbr material as the reflection texture.
  35410. * As in the majority of the scene they are the same (exception for multi room and so on),
  35411. * this is easier to reference from here than from all the materials.
  35412. */
  35413. get environmentTexture(): Nullable<BaseTexture>;
  35414. /**
  35415. * Texture used in all pbr material as the reflection texture.
  35416. * As in the majority of the scene they are the same (exception for multi room and so on),
  35417. * this is easier to set here than in all the materials.
  35418. */
  35419. set environmentTexture(value: Nullable<BaseTexture>);
  35420. /** @hidden */
  35421. protected _environmentIntensity: number;
  35422. /**
  35423. * Intensity of the environment in all pbr material.
  35424. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35425. * As in the majority of the scene they are the same (exception for multi room and so on),
  35426. * this is easier to reference from here than from all the materials.
  35427. */
  35428. get environmentIntensity(): number;
  35429. /**
  35430. * Intensity of the environment in all pbr material.
  35431. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35432. * As in the majority of the scene they are the same (exception for multi room and so on),
  35433. * this is easier to set here than in all the materials.
  35434. */
  35435. set environmentIntensity(value: number);
  35436. /** @hidden */
  35437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35438. /**
  35439. * Default image processing configuration used either in the rendering
  35440. * Forward main pass or through the imageProcessingPostProcess if present.
  35441. * As in the majority of the scene they are the same (exception for multi camera),
  35442. * this is easier to reference from here than from all the materials and post process.
  35443. *
  35444. * No setter as we it is a shared configuration, you can set the values instead.
  35445. */
  35446. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35447. private _forceWireframe;
  35448. /**
  35449. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35450. */
  35451. set forceWireframe(value: boolean);
  35452. get forceWireframe(): boolean;
  35453. private _skipFrustumClipping;
  35454. /**
  35455. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35456. */
  35457. set skipFrustumClipping(value: boolean);
  35458. get skipFrustumClipping(): boolean;
  35459. private _forcePointsCloud;
  35460. /**
  35461. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35462. */
  35463. set forcePointsCloud(value: boolean);
  35464. get forcePointsCloud(): boolean;
  35465. /**
  35466. * Gets or sets the active clipplane 1
  35467. */
  35468. clipPlane: Nullable<Plane>;
  35469. /**
  35470. * Gets or sets the active clipplane 2
  35471. */
  35472. clipPlane2: Nullable<Plane>;
  35473. /**
  35474. * Gets or sets the active clipplane 3
  35475. */
  35476. clipPlane3: Nullable<Plane>;
  35477. /**
  35478. * Gets or sets the active clipplane 4
  35479. */
  35480. clipPlane4: Nullable<Plane>;
  35481. /**
  35482. * Gets or sets the active clipplane 5
  35483. */
  35484. clipPlane5: Nullable<Plane>;
  35485. /**
  35486. * Gets or sets the active clipplane 6
  35487. */
  35488. clipPlane6: Nullable<Plane>;
  35489. /**
  35490. * Gets or sets a boolean indicating if animations are enabled
  35491. */
  35492. animationsEnabled: boolean;
  35493. private _animationPropertiesOverride;
  35494. /**
  35495. * Gets or sets the animation properties override
  35496. */
  35497. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35498. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35499. /**
  35500. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35501. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35502. */
  35503. useConstantAnimationDeltaTime: boolean;
  35504. /**
  35505. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35506. * Please note that it requires to run a ray cast through the scene on every frame
  35507. */
  35508. constantlyUpdateMeshUnderPointer: boolean;
  35509. /**
  35510. * Defines the HTML cursor to use when hovering over interactive elements
  35511. */
  35512. hoverCursor: string;
  35513. /**
  35514. * Defines the HTML default cursor to use (empty by default)
  35515. */
  35516. defaultCursor: string;
  35517. /**
  35518. * Defines whether cursors are handled by the scene.
  35519. */
  35520. doNotHandleCursors: boolean;
  35521. /**
  35522. * This is used to call preventDefault() on pointer down
  35523. * in order to block unwanted artifacts like system double clicks
  35524. */
  35525. preventDefaultOnPointerDown: boolean;
  35526. /**
  35527. * This is used to call preventDefault() on pointer up
  35528. * in order to block unwanted artifacts like system double clicks
  35529. */
  35530. preventDefaultOnPointerUp: boolean;
  35531. /**
  35532. * Gets or sets user defined metadata
  35533. */
  35534. metadata: any;
  35535. /**
  35536. * For internal use only. Please do not use.
  35537. */
  35538. reservedDataStore: any;
  35539. /**
  35540. * Gets the name of the plugin used to load this scene (null by default)
  35541. */
  35542. loadingPluginName: string;
  35543. /**
  35544. * Use this array to add regular expressions used to disable offline support for specific urls
  35545. */
  35546. disableOfflineSupportExceptionRules: RegExp[];
  35547. /**
  35548. * An event triggered when the scene is disposed.
  35549. */
  35550. onDisposeObservable: Observable<Scene>;
  35551. private _onDisposeObserver;
  35552. /** Sets a function to be executed when this scene is disposed. */
  35553. set onDispose(callback: () => void);
  35554. /**
  35555. * An event triggered before rendering the scene (right after animations and physics)
  35556. */
  35557. onBeforeRenderObservable: Observable<Scene>;
  35558. private _onBeforeRenderObserver;
  35559. /** Sets a function to be executed before rendering this scene */
  35560. set beforeRender(callback: Nullable<() => void>);
  35561. /**
  35562. * An event triggered after rendering the scene
  35563. */
  35564. onAfterRenderObservable: Observable<Scene>;
  35565. /**
  35566. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35567. */
  35568. onAfterRenderCameraObservable: Observable<Camera>;
  35569. private _onAfterRenderObserver;
  35570. /** Sets a function to be executed after rendering this scene */
  35571. set afterRender(callback: Nullable<() => void>);
  35572. /**
  35573. * An event triggered before animating the scene
  35574. */
  35575. onBeforeAnimationsObservable: Observable<Scene>;
  35576. /**
  35577. * An event triggered after animations processing
  35578. */
  35579. onAfterAnimationsObservable: Observable<Scene>;
  35580. /**
  35581. * An event triggered before draw calls are ready to be sent
  35582. */
  35583. onBeforeDrawPhaseObservable: Observable<Scene>;
  35584. /**
  35585. * An event triggered after draw calls have been sent
  35586. */
  35587. onAfterDrawPhaseObservable: Observable<Scene>;
  35588. /**
  35589. * An event triggered when the scene is ready
  35590. */
  35591. onReadyObservable: Observable<Scene>;
  35592. /**
  35593. * An event triggered before rendering a camera
  35594. */
  35595. onBeforeCameraRenderObservable: Observable<Camera>;
  35596. private _onBeforeCameraRenderObserver;
  35597. /** Sets a function to be executed before rendering a camera*/
  35598. set beforeCameraRender(callback: () => void);
  35599. /**
  35600. * An event triggered after rendering a camera
  35601. */
  35602. onAfterCameraRenderObservable: Observable<Camera>;
  35603. private _onAfterCameraRenderObserver;
  35604. /** Sets a function to be executed after rendering a camera*/
  35605. set afterCameraRender(callback: () => void);
  35606. /**
  35607. * An event triggered when active meshes evaluation is about to start
  35608. */
  35609. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35610. /**
  35611. * An event triggered when active meshes evaluation is done
  35612. */
  35613. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35614. /**
  35615. * An event triggered when particles rendering is about to start
  35616. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35617. */
  35618. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35619. /**
  35620. * An event triggered when particles rendering is done
  35621. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35622. */
  35623. onAfterParticlesRenderingObservable: Observable<Scene>;
  35624. /**
  35625. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35626. */
  35627. onDataLoadedObservable: Observable<Scene>;
  35628. /**
  35629. * An event triggered when a camera is created
  35630. */
  35631. onNewCameraAddedObservable: Observable<Camera>;
  35632. /**
  35633. * An event triggered when a camera is removed
  35634. */
  35635. onCameraRemovedObservable: Observable<Camera>;
  35636. /**
  35637. * An event triggered when a light is created
  35638. */
  35639. onNewLightAddedObservable: Observable<Light>;
  35640. /**
  35641. * An event triggered when a light is removed
  35642. */
  35643. onLightRemovedObservable: Observable<Light>;
  35644. /**
  35645. * An event triggered when a geometry is created
  35646. */
  35647. onNewGeometryAddedObservable: Observable<Geometry>;
  35648. /**
  35649. * An event triggered when a geometry is removed
  35650. */
  35651. onGeometryRemovedObservable: Observable<Geometry>;
  35652. /**
  35653. * An event triggered when a transform node is created
  35654. */
  35655. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35656. /**
  35657. * An event triggered when a transform node is removed
  35658. */
  35659. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35660. /**
  35661. * An event triggered when a mesh is created
  35662. */
  35663. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35664. /**
  35665. * An event triggered when a mesh is removed
  35666. */
  35667. onMeshRemovedObservable: Observable<AbstractMesh>;
  35668. /**
  35669. * An event triggered when a skeleton is created
  35670. */
  35671. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35672. /**
  35673. * An event triggered when a skeleton is removed
  35674. */
  35675. onSkeletonRemovedObservable: Observable<Skeleton>;
  35676. /**
  35677. * An event triggered when a material is created
  35678. */
  35679. onNewMaterialAddedObservable: Observable<Material>;
  35680. /**
  35681. * An event triggered when a material is removed
  35682. */
  35683. onMaterialRemovedObservable: Observable<Material>;
  35684. /**
  35685. * An event triggered when a texture is created
  35686. */
  35687. onNewTextureAddedObservable: Observable<BaseTexture>;
  35688. /**
  35689. * An event triggered when a texture is removed
  35690. */
  35691. onTextureRemovedObservable: Observable<BaseTexture>;
  35692. /**
  35693. * An event triggered when render targets are about to be rendered
  35694. * Can happen multiple times per frame.
  35695. */
  35696. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35697. /**
  35698. * An event triggered when render targets were rendered.
  35699. * Can happen multiple times per frame.
  35700. */
  35701. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35702. /**
  35703. * An event triggered before calculating deterministic simulation step
  35704. */
  35705. onBeforeStepObservable: Observable<Scene>;
  35706. /**
  35707. * An event triggered after calculating deterministic simulation step
  35708. */
  35709. onAfterStepObservable: Observable<Scene>;
  35710. /**
  35711. * An event triggered when the activeCamera property is updated
  35712. */
  35713. onActiveCameraChanged: Observable<Scene>;
  35714. /**
  35715. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35716. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35717. * 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)
  35718. */
  35719. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35720. /**
  35721. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35722. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35723. * 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)
  35724. */
  35725. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35726. /**
  35727. * This Observable will when a mesh has been imported into the scene.
  35728. */
  35729. onMeshImportedObservable: Observable<AbstractMesh>;
  35730. /**
  35731. * This Observable will when an animation file has been imported into the scene.
  35732. */
  35733. onAnimationFileImportedObservable: Observable<Scene>;
  35734. /**
  35735. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35736. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35737. */
  35738. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35739. /** @hidden */
  35740. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35741. /**
  35742. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35743. */
  35744. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35745. /**
  35746. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35747. */
  35748. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35749. /**
  35750. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35751. */
  35752. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35753. /** Callback called when a pointer move is detected */
  35754. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35755. /** Callback called when a pointer down is detected */
  35756. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35757. /** Callback called when a pointer up is detected */
  35758. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35759. /** Callback called when a pointer pick is detected */
  35760. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35761. /**
  35762. * 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).
  35763. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35764. */
  35765. onPrePointerObservable: Observable<PointerInfoPre>;
  35766. /**
  35767. * Observable event triggered each time an input event is received from the rendering canvas
  35768. */
  35769. onPointerObservable: Observable<PointerInfo>;
  35770. /**
  35771. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35772. */
  35773. get unTranslatedPointer(): Vector2;
  35774. /**
  35775. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35776. */
  35777. static get DragMovementThreshold(): number;
  35778. static set DragMovementThreshold(value: number);
  35779. /**
  35780. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35781. */
  35782. static get LongPressDelay(): number;
  35783. static set LongPressDelay(value: number);
  35784. /**
  35785. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35786. */
  35787. static get DoubleClickDelay(): number;
  35788. static set DoubleClickDelay(value: number);
  35789. /** If you need to check double click without raising a single click at first click, enable this flag */
  35790. static get ExclusiveDoubleClickMode(): boolean;
  35791. static set ExclusiveDoubleClickMode(value: boolean);
  35792. /** @hidden */
  35793. _mirroredCameraPosition: Nullable<Vector3>;
  35794. /**
  35795. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35796. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35797. */
  35798. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35799. /**
  35800. * Observable event triggered each time an keyboard event is received from the hosting window
  35801. */
  35802. onKeyboardObservable: Observable<KeyboardInfo>;
  35803. private _useRightHandedSystem;
  35804. /**
  35805. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35806. */
  35807. set useRightHandedSystem(value: boolean);
  35808. get useRightHandedSystem(): boolean;
  35809. private _timeAccumulator;
  35810. private _currentStepId;
  35811. private _currentInternalStep;
  35812. /**
  35813. * Sets the step Id used by deterministic lock step
  35814. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35815. * @param newStepId defines the step Id
  35816. */
  35817. setStepId(newStepId: number): void;
  35818. /**
  35819. * Gets the step Id used by deterministic lock step
  35820. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35821. * @returns the step Id
  35822. */
  35823. getStepId(): number;
  35824. /**
  35825. * Gets the internal step used by deterministic lock step
  35826. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35827. * @returns the internal step
  35828. */
  35829. getInternalStep(): number;
  35830. private _fogEnabled;
  35831. /**
  35832. * Gets or sets a boolean indicating if fog is enabled on this scene
  35833. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35834. * (Default is true)
  35835. */
  35836. set fogEnabled(value: boolean);
  35837. get fogEnabled(): boolean;
  35838. private _fogMode;
  35839. /**
  35840. * Gets or sets the fog mode to use
  35841. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35842. * | mode | value |
  35843. * | --- | --- |
  35844. * | FOGMODE_NONE | 0 |
  35845. * | FOGMODE_EXP | 1 |
  35846. * | FOGMODE_EXP2 | 2 |
  35847. * | FOGMODE_LINEAR | 3 |
  35848. */
  35849. set fogMode(value: number);
  35850. get fogMode(): number;
  35851. /**
  35852. * Gets or sets the fog color to use
  35853. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35854. * (Default is Color3(0.2, 0.2, 0.3))
  35855. */
  35856. fogColor: Color3;
  35857. /**
  35858. * Gets or sets the fog density to use
  35859. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35860. * (Default is 0.1)
  35861. */
  35862. fogDensity: number;
  35863. /**
  35864. * Gets or sets the fog start distance to use
  35865. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35866. * (Default is 0)
  35867. */
  35868. fogStart: number;
  35869. /**
  35870. * Gets or sets the fog end distance to use
  35871. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35872. * (Default is 1000)
  35873. */
  35874. fogEnd: number;
  35875. private _shadowsEnabled;
  35876. /**
  35877. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35878. */
  35879. set shadowsEnabled(value: boolean);
  35880. get shadowsEnabled(): boolean;
  35881. private _lightsEnabled;
  35882. /**
  35883. * Gets or sets a boolean indicating if lights are enabled on this scene
  35884. */
  35885. set lightsEnabled(value: boolean);
  35886. get lightsEnabled(): boolean;
  35887. /** All of the active cameras added to this scene. */
  35888. activeCameras: Camera[];
  35889. /** @hidden */
  35890. _activeCamera: Nullable<Camera>;
  35891. /** Gets or sets the current active camera */
  35892. get activeCamera(): Nullable<Camera>;
  35893. set activeCamera(value: Nullable<Camera>);
  35894. private _defaultMaterial;
  35895. /** The default material used on meshes when no material is affected */
  35896. get defaultMaterial(): Material;
  35897. /** The default material used on meshes when no material is affected */
  35898. set defaultMaterial(value: Material);
  35899. private _texturesEnabled;
  35900. /**
  35901. * Gets or sets a boolean indicating if textures are enabled on this scene
  35902. */
  35903. set texturesEnabled(value: boolean);
  35904. get texturesEnabled(): boolean;
  35905. /**
  35906. * Gets or sets a boolean indicating if particles are enabled on this scene
  35907. */
  35908. particlesEnabled: boolean;
  35909. /**
  35910. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35911. */
  35912. spritesEnabled: boolean;
  35913. private _skeletonsEnabled;
  35914. /**
  35915. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35916. */
  35917. set skeletonsEnabled(value: boolean);
  35918. get skeletonsEnabled(): boolean;
  35919. /**
  35920. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35921. */
  35922. lensFlaresEnabled: boolean;
  35923. /**
  35924. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35925. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35926. */
  35927. collisionsEnabled: boolean;
  35928. private _collisionCoordinator;
  35929. /** @hidden */
  35930. get collisionCoordinator(): ICollisionCoordinator;
  35931. /**
  35932. * Defines the gravity applied to this scene (used only for collisions)
  35933. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35934. */
  35935. gravity: Vector3;
  35936. /**
  35937. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35938. */
  35939. postProcessesEnabled: boolean;
  35940. /**
  35941. * The list of postprocesses added to the scene
  35942. */
  35943. postProcesses: PostProcess[];
  35944. /**
  35945. * Gets the current postprocess manager
  35946. */
  35947. postProcessManager: PostProcessManager;
  35948. /**
  35949. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35950. */
  35951. renderTargetsEnabled: boolean;
  35952. /**
  35953. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35954. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35955. */
  35956. dumpNextRenderTargets: boolean;
  35957. /**
  35958. * The list of user defined render targets added to the scene
  35959. */
  35960. customRenderTargets: RenderTargetTexture[];
  35961. /**
  35962. * Defines if texture loading must be delayed
  35963. * If true, textures will only be loaded when they need to be rendered
  35964. */
  35965. useDelayedTextureLoading: boolean;
  35966. /**
  35967. * Gets the list of meshes imported to the scene through SceneLoader
  35968. */
  35969. importedMeshesFiles: String[];
  35970. /**
  35971. * Gets or sets a boolean indicating if probes are enabled on this scene
  35972. */
  35973. probesEnabled: boolean;
  35974. /**
  35975. * Gets or sets the current offline provider to use to store scene data
  35976. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35977. */
  35978. offlineProvider: IOfflineProvider;
  35979. /**
  35980. * Gets or sets the action manager associated with the scene
  35981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35982. */
  35983. actionManager: AbstractActionManager;
  35984. private _meshesForIntersections;
  35985. /**
  35986. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35987. */
  35988. proceduralTexturesEnabled: boolean;
  35989. private _engine;
  35990. private _totalVertices;
  35991. /** @hidden */
  35992. _activeIndices: PerfCounter;
  35993. /** @hidden */
  35994. _activeParticles: PerfCounter;
  35995. /** @hidden */
  35996. _activeBones: PerfCounter;
  35997. private _animationRatio;
  35998. /** @hidden */
  35999. _animationTimeLast: number;
  36000. /** @hidden */
  36001. _animationTime: number;
  36002. /**
  36003. * Gets or sets a general scale for animation speed
  36004. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36005. */
  36006. animationTimeScale: number;
  36007. /** @hidden */
  36008. _cachedMaterial: Nullable<Material>;
  36009. /** @hidden */
  36010. _cachedEffect: Nullable<Effect>;
  36011. /** @hidden */
  36012. _cachedVisibility: Nullable<number>;
  36013. private _renderId;
  36014. private _frameId;
  36015. private _executeWhenReadyTimeoutId;
  36016. private _intermediateRendering;
  36017. private _viewUpdateFlag;
  36018. private _projectionUpdateFlag;
  36019. /** @hidden */
  36020. _toBeDisposed: Nullable<IDisposable>[];
  36021. private _activeRequests;
  36022. /** @hidden */
  36023. _pendingData: any[];
  36024. private _isDisposed;
  36025. /**
  36026. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36027. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36028. */
  36029. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36030. private _activeMeshes;
  36031. private _processedMaterials;
  36032. private _renderTargets;
  36033. /** @hidden */
  36034. _activeParticleSystems: SmartArray<IParticleSystem>;
  36035. private _activeSkeletons;
  36036. private _softwareSkinnedMeshes;
  36037. private _renderingManager;
  36038. /** @hidden */
  36039. _activeAnimatables: Animatable[];
  36040. private _transformMatrix;
  36041. private _sceneUbo;
  36042. /** @hidden */
  36043. _viewMatrix: Matrix;
  36044. private _projectionMatrix;
  36045. /** @hidden */
  36046. _forcedViewPosition: Nullable<Vector3>;
  36047. /** @hidden */
  36048. _frustumPlanes: Plane[];
  36049. /**
  36050. * Gets the list of frustum planes (built from the active camera)
  36051. */
  36052. get frustumPlanes(): Plane[];
  36053. /**
  36054. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36055. * This is useful if there are more lights that the maximum simulteanous authorized
  36056. */
  36057. requireLightSorting: boolean;
  36058. /** @hidden */
  36059. readonly useMaterialMeshMap: boolean;
  36060. /** @hidden */
  36061. readonly useClonedMeshMap: boolean;
  36062. private _externalData;
  36063. private _uid;
  36064. /**
  36065. * @hidden
  36066. * Backing store of defined scene components.
  36067. */
  36068. _components: ISceneComponent[];
  36069. /**
  36070. * @hidden
  36071. * Backing store of defined scene components.
  36072. */
  36073. _serializableComponents: ISceneSerializableComponent[];
  36074. /**
  36075. * List of components to register on the next registration step.
  36076. */
  36077. private _transientComponents;
  36078. /**
  36079. * Registers the transient components if needed.
  36080. */
  36081. private _registerTransientComponents;
  36082. /**
  36083. * @hidden
  36084. * Add a component to the scene.
  36085. * Note that the ccomponent could be registered on th next frame if this is called after
  36086. * the register component stage.
  36087. * @param component Defines the component to add to the scene
  36088. */
  36089. _addComponent(component: ISceneComponent): void;
  36090. /**
  36091. * @hidden
  36092. * Gets a component from the scene.
  36093. * @param name defines the name of the component to retrieve
  36094. * @returns the component or null if not present
  36095. */
  36096. _getComponent(name: string): Nullable<ISceneComponent>;
  36097. /**
  36098. * @hidden
  36099. * Defines the actions happening before camera updates.
  36100. */
  36101. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36102. /**
  36103. * @hidden
  36104. * Defines the actions happening before clear the canvas.
  36105. */
  36106. _beforeClearStage: Stage<SimpleStageAction>;
  36107. /**
  36108. * @hidden
  36109. * Defines the actions when collecting render targets for the frame.
  36110. */
  36111. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36112. /**
  36113. * @hidden
  36114. * Defines the actions happening for one camera in the frame.
  36115. */
  36116. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36117. /**
  36118. * @hidden
  36119. * Defines the actions happening during the per mesh ready checks.
  36120. */
  36121. _isReadyForMeshStage: Stage<MeshStageAction>;
  36122. /**
  36123. * @hidden
  36124. * Defines the actions happening before evaluate active mesh checks.
  36125. */
  36126. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36127. /**
  36128. * @hidden
  36129. * Defines the actions happening during the evaluate sub mesh checks.
  36130. */
  36131. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36132. /**
  36133. * @hidden
  36134. * Defines the actions happening during the active mesh stage.
  36135. */
  36136. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36137. /**
  36138. * @hidden
  36139. * Defines the actions happening during the per camera render target step.
  36140. */
  36141. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36142. /**
  36143. * @hidden
  36144. * Defines the actions happening just before the active camera is drawing.
  36145. */
  36146. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36147. /**
  36148. * @hidden
  36149. * Defines the actions happening just before a render target is drawing.
  36150. */
  36151. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36152. /**
  36153. * @hidden
  36154. * Defines the actions happening just before a rendering group is drawing.
  36155. */
  36156. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36157. /**
  36158. * @hidden
  36159. * Defines the actions happening just before a mesh is drawing.
  36160. */
  36161. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36162. /**
  36163. * @hidden
  36164. * Defines the actions happening just after a mesh has been drawn.
  36165. */
  36166. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36167. /**
  36168. * @hidden
  36169. * Defines the actions happening just after a rendering group has been drawn.
  36170. */
  36171. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36172. /**
  36173. * @hidden
  36174. * Defines the actions happening just after the active camera has been drawn.
  36175. */
  36176. _afterCameraDrawStage: Stage<CameraStageAction>;
  36177. /**
  36178. * @hidden
  36179. * Defines the actions happening just after a render target has been drawn.
  36180. */
  36181. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36182. /**
  36183. * @hidden
  36184. * Defines the actions happening just after rendering all cameras and computing intersections.
  36185. */
  36186. _afterRenderStage: Stage<SimpleStageAction>;
  36187. /**
  36188. * @hidden
  36189. * Defines the actions happening when a pointer move event happens.
  36190. */
  36191. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36192. /**
  36193. * @hidden
  36194. * Defines the actions happening when a pointer down event happens.
  36195. */
  36196. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36197. /**
  36198. * @hidden
  36199. * Defines the actions happening when a pointer up event happens.
  36200. */
  36201. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36202. /**
  36203. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36204. */
  36205. private geometriesByUniqueId;
  36206. /**
  36207. * Creates a new Scene
  36208. * @param engine defines the engine to use to render this scene
  36209. * @param options defines the scene options
  36210. */
  36211. constructor(engine: Engine, options?: SceneOptions);
  36212. /**
  36213. * Gets a string idenfifying the name of the class
  36214. * @returns "Scene" string
  36215. */
  36216. getClassName(): string;
  36217. private _defaultMeshCandidates;
  36218. /**
  36219. * @hidden
  36220. */
  36221. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36222. private _defaultSubMeshCandidates;
  36223. /**
  36224. * @hidden
  36225. */
  36226. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36227. /**
  36228. * Sets the default candidate providers for the scene.
  36229. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36230. * and getCollidingSubMeshCandidates to their default function
  36231. */
  36232. setDefaultCandidateProviders(): void;
  36233. /**
  36234. * Gets the mesh that is currently under the pointer
  36235. */
  36236. get meshUnderPointer(): Nullable<AbstractMesh>;
  36237. /**
  36238. * Gets or sets the current on-screen X position of the pointer
  36239. */
  36240. get pointerX(): number;
  36241. set pointerX(value: number);
  36242. /**
  36243. * Gets or sets the current on-screen Y position of the pointer
  36244. */
  36245. get pointerY(): number;
  36246. set pointerY(value: number);
  36247. /**
  36248. * Gets the cached material (ie. the latest rendered one)
  36249. * @returns the cached material
  36250. */
  36251. getCachedMaterial(): Nullable<Material>;
  36252. /**
  36253. * Gets the cached effect (ie. the latest rendered one)
  36254. * @returns the cached effect
  36255. */
  36256. getCachedEffect(): Nullable<Effect>;
  36257. /**
  36258. * Gets the cached visibility state (ie. the latest rendered one)
  36259. * @returns the cached visibility state
  36260. */
  36261. getCachedVisibility(): Nullable<number>;
  36262. /**
  36263. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36264. * @param material defines the current material
  36265. * @param effect defines the current effect
  36266. * @param visibility defines the current visibility state
  36267. * @returns true if one parameter is not cached
  36268. */
  36269. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36270. /**
  36271. * Gets the engine associated with the scene
  36272. * @returns an Engine
  36273. */
  36274. getEngine(): Engine;
  36275. /**
  36276. * Gets the total number of vertices rendered per frame
  36277. * @returns the total number of vertices rendered per frame
  36278. */
  36279. getTotalVertices(): number;
  36280. /**
  36281. * Gets the performance counter for total vertices
  36282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36283. */
  36284. get totalVerticesPerfCounter(): PerfCounter;
  36285. /**
  36286. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36287. * @returns the total number of active indices rendered per frame
  36288. */
  36289. getActiveIndices(): number;
  36290. /**
  36291. * Gets the performance counter for active indices
  36292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36293. */
  36294. get totalActiveIndicesPerfCounter(): PerfCounter;
  36295. /**
  36296. * Gets the total number of active particles rendered per frame
  36297. * @returns the total number of active particles rendered per frame
  36298. */
  36299. getActiveParticles(): number;
  36300. /**
  36301. * Gets the performance counter for active particles
  36302. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36303. */
  36304. get activeParticlesPerfCounter(): PerfCounter;
  36305. /**
  36306. * Gets the total number of active bones rendered per frame
  36307. * @returns the total number of active bones rendered per frame
  36308. */
  36309. getActiveBones(): number;
  36310. /**
  36311. * Gets the performance counter for active bones
  36312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36313. */
  36314. get activeBonesPerfCounter(): PerfCounter;
  36315. /**
  36316. * Gets the array of active meshes
  36317. * @returns an array of AbstractMesh
  36318. */
  36319. getActiveMeshes(): SmartArray<AbstractMesh>;
  36320. /**
  36321. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36322. * @returns a number
  36323. */
  36324. getAnimationRatio(): number;
  36325. /**
  36326. * Gets an unique Id for the current render phase
  36327. * @returns a number
  36328. */
  36329. getRenderId(): number;
  36330. /**
  36331. * Gets an unique Id for the current frame
  36332. * @returns a number
  36333. */
  36334. getFrameId(): number;
  36335. /** Call this function if you want to manually increment the render Id*/
  36336. incrementRenderId(): void;
  36337. private _createUbo;
  36338. /**
  36339. * Use this method to simulate a pointer move on a mesh
  36340. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36341. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36342. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36343. * @returns the current scene
  36344. */
  36345. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36346. /**
  36347. * Use this method to simulate a pointer down on a mesh
  36348. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36349. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36350. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36351. * @returns the current scene
  36352. */
  36353. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36354. /**
  36355. * Use this method to simulate a pointer up on a mesh
  36356. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36357. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36358. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36359. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36360. * @returns the current scene
  36361. */
  36362. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36363. /**
  36364. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36365. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36366. * @returns true if the pointer was captured
  36367. */
  36368. isPointerCaptured(pointerId?: number): boolean;
  36369. /**
  36370. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36371. * @param attachUp defines if you want to attach events to pointerup
  36372. * @param attachDown defines if you want to attach events to pointerdown
  36373. * @param attachMove defines if you want to attach events to pointermove
  36374. */
  36375. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36376. /** Detaches all event handlers*/
  36377. detachControl(): void;
  36378. /**
  36379. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36380. * Delay loaded resources are not taking in account
  36381. * @return true if all required resources are ready
  36382. */
  36383. isReady(): boolean;
  36384. /** Resets all cached information relative to material (including effect and visibility) */
  36385. resetCachedMaterial(): void;
  36386. /**
  36387. * Registers a function to be called before every frame render
  36388. * @param func defines the function to register
  36389. */
  36390. registerBeforeRender(func: () => void): void;
  36391. /**
  36392. * Unregisters a function called before every frame render
  36393. * @param func defines the function to unregister
  36394. */
  36395. unregisterBeforeRender(func: () => void): void;
  36396. /**
  36397. * Registers a function to be called after every frame render
  36398. * @param func defines the function to register
  36399. */
  36400. registerAfterRender(func: () => void): void;
  36401. /**
  36402. * Unregisters a function called after every frame render
  36403. * @param func defines the function to unregister
  36404. */
  36405. unregisterAfterRender(func: () => void): void;
  36406. private _executeOnceBeforeRender;
  36407. /**
  36408. * The provided function will run before render once and will be disposed afterwards.
  36409. * A timeout delay can be provided so that the function will be executed in N ms.
  36410. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36411. * @param func The function to be executed.
  36412. * @param timeout optional delay in ms
  36413. */
  36414. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36415. /** @hidden */
  36416. _addPendingData(data: any): void;
  36417. /** @hidden */
  36418. _removePendingData(data: any): void;
  36419. /**
  36420. * Returns the number of items waiting to be loaded
  36421. * @returns the number of items waiting to be loaded
  36422. */
  36423. getWaitingItemsCount(): number;
  36424. /**
  36425. * Returns a boolean indicating if the scene is still loading data
  36426. */
  36427. get isLoading(): boolean;
  36428. /**
  36429. * Registers a function to be executed when the scene is ready
  36430. * @param {Function} func - the function to be executed
  36431. */
  36432. executeWhenReady(func: () => void): void;
  36433. /**
  36434. * Returns a promise that resolves when the scene is ready
  36435. * @returns A promise that resolves when the scene is ready
  36436. */
  36437. whenReadyAsync(): Promise<void>;
  36438. /** @hidden */
  36439. _checkIsReady(): void;
  36440. /**
  36441. * Gets all animatable attached to the scene
  36442. */
  36443. get animatables(): Animatable[];
  36444. /**
  36445. * Resets the last animation time frame.
  36446. * Useful to override when animations start running when loading a scene for the first time.
  36447. */
  36448. resetLastAnimationTimeFrame(): void;
  36449. /**
  36450. * Gets the current view matrix
  36451. * @returns a Matrix
  36452. */
  36453. getViewMatrix(): Matrix;
  36454. /**
  36455. * Gets the current projection matrix
  36456. * @returns a Matrix
  36457. */
  36458. getProjectionMatrix(): Matrix;
  36459. /**
  36460. * Gets the current transform matrix
  36461. * @returns a Matrix made of View * Projection
  36462. */
  36463. getTransformMatrix(): Matrix;
  36464. /**
  36465. * Sets the current transform matrix
  36466. * @param viewL defines the View matrix to use
  36467. * @param projectionL defines the Projection matrix to use
  36468. * @param viewR defines the right View matrix to use (if provided)
  36469. * @param projectionR defines the right Projection matrix to use (if provided)
  36470. */
  36471. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36472. /**
  36473. * Gets the uniform buffer used to store scene data
  36474. * @returns a UniformBuffer
  36475. */
  36476. getSceneUniformBuffer(): UniformBuffer;
  36477. /**
  36478. * Gets an unique (relatively to the current scene) Id
  36479. * @returns an unique number for the scene
  36480. */
  36481. getUniqueId(): number;
  36482. /**
  36483. * Add a mesh to the list of scene's meshes
  36484. * @param newMesh defines the mesh to add
  36485. * @param recursive if all child meshes should also be added to the scene
  36486. */
  36487. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36488. /**
  36489. * Remove a mesh for the list of scene's meshes
  36490. * @param toRemove defines the mesh to remove
  36491. * @param recursive if all child meshes should also be removed from the scene
  36492. * @returns the index where the mesh was in the mesh list
  36493. */
  36494. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36495. /**
  36496. * Add a transform node to the list of scene's transform nodes
  36497. * @param newTransformNode defines the transform node to add
  36498. */
  36499. addTransformNode(newTransformNode: TransformNode): void;
  36500. /**
  36501. * Remove a transform node for the list of scene's transform nodes
  36502. * @param toRemove defines the transform node to remove
  36503. * @returns the index where the transform node was in the transform node list
  36504. */
  36505. removeTransformNode(toRemove: TransformNode): number;
  36506. /**
  36507. * Remove a skeleton for the list of scene's skeletons
  36508. * @param toRemove defines the skeleton to remove
  36509. * @returns the index where the skeleton was in the skeleton list
  36510. */
  36511. removeSkeleton(toRemove: Skeleton): number;
  36512. /**
  36513. * Remove a morph target for the list of scene's morph targets
  36514. * @param toRemove defines the morph target to remove
  36515. * @returns the index where the morph target was in the morph target list
  36516. */
  36517. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36518. /**
  36519. * Remove a light for the list of scene's lights
  36520. * @param toRemove defines the light to remove
  36521. * @returns the index where the light was in the light list
  36522. */
  36523. removeLight(toRemove: Light): number;
  36524. /**
  36525. * Remove a camera for the list of scene's cameras
  36526. * @param toRemove defines the camera to remove
  36527. * @returns the index where the camera was in the camera list
  36528. */
  36529. removeCamera(toRemove: Camera): number;
  36530. /**
  36531. * Remove a particle system for the list of scene's particle systems
  36532. * @param toRemove defines the particle system to remove
  36533. * @returns the index where the particle system was in the particle system list
  36534. */
  36535. removeParticleSystem(toRemove: IParticleSystem): number;
  36536. /**
  36537. * Remove a animation for the list of scene's animations
  36538. * @param toRemove defines the animation to remove
  36539. * @returns the index where the animation was in the animation list
  36540. */
  36541. removeAnimation(toRemove: Animation): number;
  36542. /**
  36543. * Will stop the animation of the given target
  36544. * @param target - the target
  36545. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36546. * @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)
  36547. */
  36548. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36549. /**
  36550. * Removes the given animation group from this scene.
  36551. * @param toRemove The animation group to remove
  36552. * @returns The index of the removed animation group
  36553. */
  36554. removeAnimationGroup(toRemove: AnimationGroup): number;
  36555. /**
  36556. * Removes the given multi-material from this scene.
  36557. * @param toRemove The multi-material to remove
  36558. * @returns The index of the removed multi-material
  36559. */
  36560. removeMultiMaterial(toRemove: MultiMaterial): number;
  36561. /**
  36562. * Removes the given material from this scene.
  36563. * @param toRemove The material to remove
  36564. * @returns The index of the removed material
  36565. */
  36566. removeMaterial(toRemove: Material): number;
  36567. /**
  36568. * Removes the given action manager from this scene.
  36569. * @param toRemove The action manager to remove
  36570. * @returns The index of the removed action manager
  36571. */
  36572. removeActionManager(toRemove: AbstractActionManager): number;
  36573. /**
  36574. * Removes the given texture from this scene.
  36575. * @param toRemove The texture to remove
  36576. * @returns The index of the removed texture
  36577. */
  36578. removeTexture(toRemove: BaseTexture): number;
  36579. /**
  36580. * Adds the given light to this scene
  36581. * @param newLight The light to add
  36582. */
  36583. addLight(newLight: Light): void;
  36584. /**
  36585. * Sorts the list list based on light priorities
  36586. */
  36587. sortLightsByPriority(): void;
  36588. /**
  36589. * Adds the given camera to this scene
  36590. * @param newCamera The camera to add
  36591. */
  36592. addCamera(newCamera: Camera): void;
  36593. /**
  36594. * Adds the given skeleton to this scene
  36595. * @param newSkeleton The skeleton to add
  36596. */
  36597. addSkeleton(newSkeleton: Skeleton): void;
  36598. /**
  36599. * Adds the given particle system to this scene
  36600. * @param newParticleSystem The particle system to add
  36601. */
  36602. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36603. /**
  36604. * Adds the given animation to this scene
  36605. * @param newAnimation The animation to add
  36606. */
  36607. addAnimation(newAnimation: Animation): void;
  36608. /**
  36609. * Adds the given animation group to this scene.
  36610. * @param newAnimationGroup The animation group to add
  36611. */
  36612. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36613. /**
  36614. * Adds the given multi-material to this scene
  36615. * @param newMultiMaterial The multi-material to add
  36616. */
  36617. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36618. /**
  36619. * Adds the given material to this scene
  36620. * @param newMaterial The material to add
  36621. */
  36622. addMaterial(newMaterial: Material): void;
  36623. /**
  36624. * Adds the given morph target to this scene
  36625. * @param newMorphTargetManager The morph target to add
  36626. */
  36627. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36628. /**
  36629. * Adds the given geometry to this scene
  36630. * @param newGeometry The geometry to add
  36631. */
  36632. addGeometry(newGeometry: Geometry): void;
  36633. /**
  36634. * Adds the given action manager to this scene
  36635. * @param newActionManager The action manager to add
  36636. */
  36637. addActionManager(newActionManager: AbstractActionManager): void;
  36638. /**
  36639. * Adds the given texture to this scene.
  36640. * @param newTexture The texture to add
  36641. */
  36642. addTexture(newTexture: BaseTexture): void;
  36643. /**
  36644. * Switch active camera
  36645. * @param newCamera defines the new active camera
  36646. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36647. */
  36648. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36649. /**
  36650. * sets the active camera of the scene using its ID
  36651. * @param id defines the camera's ID
  36652. * @return the new active camera or null if none found.
  36653. */
  36654. setActiveCameraByID(id: string): Nullable<Camera>;
  36655. /**
  36656. * sets the active camera of the scene using its name
  36657. * @param name defines the camera's name
  36658. * @returns the new active camera or null if none found.
  36659. */
  36660. setActiveCameraByName(name: string): Nullable<Camera>;
  36661. /**
  36662. * get an animation group using its name
  36663. * @param name defines the material's name
  36664. * @return the animation group or null if none found.
  36665. */
  36666. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36667. /**
  36668. * Get a material using its unique id
  36669. * @param uniqueId defines the material's unique id
  36670. * @return the material or null if none found.
  36671. */
  36672. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36673. /**
  36674. * get a material using its id
  36675. * @param id defines the material's ID
  36676. * @return the material or null if none found.
  36677. */
  36678. getMaterialByID(id: string): Nullable<Material>;
  36679. /**
  36680. * Gets a the last added material using a given id
  36681. * @param id defines the material's ID
  36682. * @return the last material with the given id or null if none found.
  36683. */
  36684. getLastMaterialByID(id: string): Nullable<Material>;
  36685. /**
  36686. * Gets a material using its name
  36687. * @param name defines the material's name
  36688. * @return the material or null if none found.
  36689. */
  36690. getMaterialByName(name: string): Nullable<Material>;
  36691. /**
  36692. * Get a texture using its unique id
  36693. * @param uniqueId defines the texture's unique id
  36694. * @return the texture or null if none found.
  36695. */
  36696. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36697. /**
  36698. * Gets a camera using its id
  36699. * @param id defines the id to look for
  36700. * @returns the camera or null if not found
  36701. */
  36702. getCameraByID(id: string): Nullable<Camera>;
  36703. /**
  36704. * Gets a camera using its unique id
  36705. * @param uniqueId defines the unique id to look for
  36706. * @returns the camera or null if not found
  36707. */
  36708. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36709. /**
  36710. * Gets a camera using its name
  36711. * @param name defines the camera's name
  36712. * @return the camera or null if none found.
  36713. */
  36714. getCameraByName(name: string): Nullable<Camera>;
  36715. /**
  36716. * Gets a bone using its id
  36717. * @param id defines the bone's id
  36718. * @return the bone or null if not found
  36719. */
  36720. getBoneByID(id: string): Nullable<Bone>;
  36721. /**
  36722. * Gets a bone using its id
  36723. * @param name defines the bone's name
  36724. * @return the bone or null if not found
  36725. */
  36726. getBoneByName(name: string): Nullable<Bone>;
  36727. /**
  36728. * Gets a light node using its name
  36729. * @param name defines the the light's name
  36730. * @return the light or null if none found.
  36731. */
  36732. getLightByName(name: string): Nullable<Light>;
  36733. /**
  36734. * Gets a light node using its id
  36735. * @param id defines the light's id
  36736. * @return the light or null if none found.
  36737. */
  36738. getLightByID(id: string): Nullable<Light>;
  36739. /**
  36740. * Gets a light node using its scene-generated unique ID
  36741. * @param uniqueId defines the light's unique id
  36742. * @return the light or null if none found.
  36743. */
  36744. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36745. /**
  36746. * Gets a particle system by id
  36747. * @param id defines the particle system id
  36748. * @return the corresponding system or null if none found
  36749. */
  36750. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36751. /**
  36752. * Gets a geometry using its ID
  36753. * @param id defines the geometry's id
  36754. * @return the geometry or null if none found.
  36755. */
  36756. getGeometryByID(id: string): Nullable<Geometry>;
  36757. private _getGeometryByUniqueID;
  36758. /**
  36759. * Add a new geometry to this scene
  36760. * @param geometry defines the geometry to be added to the scene.
  36761. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36762. * @return a boolean defining if the geometry was added or not
  36763. */
  36764. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36765. /**
  36766. * Removes an existing geometry
  36767. * @param geometry defines the geometry to be removed from the scene
  36768. * @return a boolean defining if the geometry was removed or not
  36769. */
  36770. removeGeometry(geometry: Geometry): boolean;
  36771. /**
  36772. * Gets the list of geometries attached to the scene
  36773. * @returns an array of Geometry
  36774. */
  36775. getGeometries(): Geometry[];
  36776. /**
  36777. * Gets the first added mesh found of a given ID
  36778. * @param id defines the id to search for
  36779. * @return the mesh found or null if not found at all
  36780. */
  36781. getMeshByID(id: string): Nullable<AbstractMesh>;
  36782. /**
  36783. * Gets a list of meshes using their id
  36784. * @param id defines the id to search for
  36785. * @returns a list of meshes
  36786. */
  36787. getMeshesByID(id: string): Array<AbstractMesh>;
  36788. /**
  36789. * Gets the first added transform node found of a given ID
  36790. * @param id defines the id to search for
  36791. * @return the found transform node or null if not found at all.
  36792. */
  36793. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36794. /**
  36795. * Gets a transform node with its auto-generated unique id
  36796. * @param uniqueId efines the unique id to search for
  36797. * @return the found transform node or null if not found at all.
  36798. */
  36799. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36800. /**
  36801. * Gets a list of transform nodes using their id
  36802. * @param id defines the id to search for
  36803. * @returns a list of transform nodes
  36804. */
  36805. getTransformNodesByID(id: string): Array<TransformNode>;
  36806. /**
  36807. * Gets a mesh with its auto-generated unique id
  36808. * @param uniqueId defines the unique id to search for
  36809. * @return the found mesh or null if not found at all.
  36810. */
  36811. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36812. /**
  36813. * Gets a the last added mesh using a given id
  36814. * @param id defines the id to search for
  36815. * @return the found mesh or null if not found at all.
  36816. */
  36817. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36818. /**
  36819. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36820. * @param id defines the id to search for
  36821. * @return the found node or null if not found at all
  36822. */
  36823. getLastEntryByID(id: string): Nullable<Node>;
  36824. /**
  36825. * Gets a node (Mesh, Camera, Light) using a given id
  36826. * @param id defines the id to search for
  36827. * @return the found node or null if not found at all
  36828. */
  36829. getNodeByID(id: string): Nullable<Node>;
  36830. /**
  36831. * Gets a node (Mesh, Camera, Light) using a given name
  36832. * @param name defines the name to search for
  36833. * @return the found node or null if not found at all.
  36834. */
  36835. getNodeByName(name: string): Nullable<Node>;
  36836. /**
  36837. * Gets a mesh using a given name
  36838. * @param name defines the name to search for
  36839. * @return the found mesh or null if not found at all.
  36840. */
  36841. getMeshByName(name: string): Nullable<AbstractMesh>;
  36842. /**
  36843. * Gets a transform node using a given name
  36844. * @param name defines the name to search for
  36845. * @return the found transform node or null if not found at all.
  36846. */
  36847. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36848. /**
  36849. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36850. * @param id defines the id to search for
  36851. * @return the found skeleton or null if not found at all.
  36852. */
  36853. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36854. /**
  36855. * Gets a skeleton using a given auto generated unique id
  36856. * @param uniqueId defines the unique id to search for
  36857. * @return the found skeleton or null if not found at all.
  36858. */
  36859. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36860. /**
  36861. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36862. * @param id defines the id to search for
  36863. * @return the found skeleton or null if not found at all.
  36864. */
  36865. getSkeletonById(id: string): Nullable<Skeleton>;
  36866. /**
  36867. * Gets a skeleton using a given name
  36868. * @param name defines the name to search for
  36869. * @return the found skeleton or null if not found at all.
  36870. */
  36871. getSkeletonByName(name: string): Nullable<Skeleton>;
  36872. /**
  36873. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36874. * @param id defines the id to search for
  36875. * @return the found morph target manager or null if not found at all.
  36876. */
  36877. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36878. /**
  36879. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36880. * @param id defines the id to search for
  36881. * @return the found morph target or null if not found at all.
  36882. */
  36883. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36884. /**
  36885. * Gets a boolean indicating if the given mesh is active
  36886. * @param mesh defines the mesh to look for
  36887. * @returns true if the mesh is in the active list
  36888. */
  36889. isActiveMesh(mesh: AbstractMesh): boolean;
  36890. /**
  36891. * Return a unique id as a string which can serve as an identifier for the scene
  36892. */
  36893. get uid(): string;
  36894. /**
  36895. * Add an externaly attached data from its key.
  36896. * This method call will fail and return false, if such key already exists.
  36897. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36898. * @param key the unique key that identifies the data
  36899. * @param data the data object to associate to the key for this Engine instance
  36900. * @return true if no such key were already present and the data was added successfully, false otherwise
  36901. */
  36902. addExternalData<T>(key: string, data: T): boolean;
  36903. /**
  36904. * Get an externaly attached data from its key
  36905. * @param key the unique key that identifies the data
  36906. * @return the associated data, if present (can be null), or undefined if not present
  36907. */
  36908. getExternalData<T>(key: string): Nullable<T>;
  36909. /**
  36910. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36911. * @param key the unique key that identifies the data
  36912. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36913. * @return the associated data, can be null if the factory returned null.
  36914. */
  36915. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36916. /**
  36917. * Remove an externaly attached data from the Engine instance
  36918. * @param key the unique key that identifies the data
  36919. * @return true if the data was successfully removed, false if it doesn't exist
  36920. */
  36921. removeExternalData(key: string): boolean;
  36922. private _evaluateSubMesh;
  36923. /**
  36924. * Clear the processed materials smart array preventing retention point in material dispose.
  36925. */
  36926. freeProcessedMaterials(): void;
  36927. private _preventFreeActiveMeshesAndRenderingGroups;
  36928. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36929. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36930. * when disposing several meshes in a row or a hierarchy of meshes.
  36931. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36932. */
  36933. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36934. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36935. /**
  36936. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36937. */
  36938. freeActiveMeshes(): void;
  36939. /**
  36940. * Clear the info related to rendering groups preventing retention points during dispose.
  36941. */
  36942. freeRenderingGroups(): void;
  36943. /** @hidden */
  36944. _isInIntermediateRendering(): boolean;
  36945. /**
  36946. * Lambda returning the list of potentially active meshes.
  36947. */
  36948. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36949. /**
  36950. * Lambda returning the list of potentially active sub meshes.
  36951. */
  36952. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36953. /**
  36954. * Lambda returning the list of potentially intersecting sub meshes.
  36955. */
  36956. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36957. /**
  36958. * Lambda returning the list of potentially colliding sub meshes.
  36959. */
  36960. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36961. private _activeMeshesFrozen;
  36962. private _skipEvaluateActiveMeshesCompletely;
  36963. /**
  36964. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36965. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36966. * @returns the current scene
  36967. */
  36968. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36969. /**
  36970. * Use this function to restart evaluating active meshes on every frame
  36971. * @returns the current scene
  36972. */
  36973. unfreezeActiveMeshes(): Scene;
  36974. private _evaluateActiveMeshes;
  36975. private _activeMesh;
  36976. /**
  36977. * Update the transform matrix to update from the current active camera
  36978. * @param force defines a boolean used to force the update even if cache is up to date
  36979. */
  36980. updateTransformMatrix(force?: boolean): void;
  36981. private _bindFrameBuffer;
  36982. /** @hidden */
  36983. _allowPostProcessClearColor: boolean;
  36984. /** @hidden */
  36985. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36986. private _processSubCameras;
  36987. private _checkIntersections;
  36988. /** @hidden */
  36989. _advancePhysicsEngineStep(step: number): void;
  36990. /**
  36991. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36992. */
  36993. getDeterministicFrameTime: () => number;
  36994. /** @hidden */
  36995. _animate(): void;
  36996. /** Execute all animations (for a frame) */
  36997. animate(): void;
  36998. /**
  36999. * Render the scene
  37000. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37001. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37002. */
  37003. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37004. /**
  37005. * Freeze all materials
  37006. * A frozen material will not be updatable but should be faster to render
  37007. */
  37008. freezeMaterials(): void;
  37009. /**
  37010. * Unfreeze all materials
  37011. * A frozen material will not be updatable but should be faster to render
  37012. */
  37013. unfreezeMaterials(): void;
  37014. /**
  37015. * Releases all held ressources
  37016. */
  37017. dispose(): void;
  37018. /**
  37019. * Gets if the scene is already disposed
  37020. */
  37021. get isDisposed(): boolean;
  37022. /**
  37023. * Call this function to reduce memory footprint of the scene.
  37024. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37025. */
  37026. clearCachedVertexData(): void;
  37027. /**
  37028. * This function will remove the local cached buffer data from texture.
  37029. * It will save memory but will prevent the texture from being rebuilt
  37030. */
  37031. cleanCachedTextureBuffer(): void;
  37032. /**
  37033. * Get the world extend vectors with an optional filter
  37034. *
  37035. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37036. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37037. */
  37038. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37039. min: Vector3;
  37040. max: Vector3;
  37041. };
  37042. /**
  37043. * Creates a ray that can be used to pick in the scene
  37044. * @param x defines the x coordinate of the origin (on-screen)
  37045. * @param y defines the y coordinate of the origin (on-screen)
  37046. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37047. * @param camera defines the camera to use for the picking
  37048. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37049. * @returns a Ray
  37050. */
  37051. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37052. /**
  37053. * Creates a ray that can be used to pick in the scene
  37054. * @param x defines the x coordinate of the origin (on-screen)
  37055. * @param y defines the y coordinate of the origin (on-screen)
  37056. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37057. * @param result defines the ray where to store the picking ray
  37058. * @param camera defines the camera to use for the picking
  37059. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37060. * @returns the current scene
  37061. */
  37062. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37063. /**
  37064. * Creates a ray that can be used to pick in the scene
  37065. * @param x defines the x coordinate of the origin (on-screen)
  37066. * @param y defines the y coordinate of the origin (on-screen)
  37067. * @param camera defines the camera to use for the picking
  37068. * @returns a Ray
  37069. */
  37070. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37071. /**
  37072. * Creates a ray that can be used to pick in the scene
  37073. * @param x defines the x coordinate of the origin (on-screen)
  37074. * @param y defines the y coordinate of the origin (on-screen)
  37075. * @param result defines the ray where to store the picking ray
  37076. * @param camera defines the camera to use for the picking
  37077. * @returns the current scene
  37078. */
  37079. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37080. /** Launch a ray to try to pick a mesh in the scene
  37081. * @param x position on screen
  37082. * @param y position on screen
  37083. * @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
  37084. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37085. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37086. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37087. * @returns a PickingInfo
  37088. */
  37089. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37090. /** Use the given ray to pick a mesh in the scene
  37091. * @param ray The ray to use to pick meshes
  37092. * @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
  37093. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37094. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37095. * @returns a PickingInfo
  37096. */
  37097. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37098. /**
  37099. * Launch a ray to try to pick a mesh in the scene
  37100. * @param x X position on screen
  37101. * @param y Y position on screen
  37102. * @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
  37103. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37104. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37105. * @returns an array of PickingInfo
  37106. */
  37107. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37108. /**
  37109. * Launch a ray to try to pick a mesh in the scene
  37110. * @param ray Ray to use
  37111. * @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
  37112. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37113. * @returns an array of PickingInfo
  37114. */
  37115. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37116. /**
  37117. * Force the value of meshUnderPointer
  37118. * @param mesh defines the mesh to use
  37119. */
  37120. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37121. /**
  37122. * Gets the mesh under the pointer
  37123. * @returns a Mesh or null if no mesh is under the pointer
  37124. */
  37125. getPointerOverMesh(): Nullable<AbstractMesh>;
  37126. /** @hidden */
  37127. _rebuildGeometries(): void;
  37128. /** @hidden */
  37129. _rebuildTextures(): void;
  37130. private _getByTags;
  37131. /**
  37132. * Get a list of meshes by tags
  37133. * @param tagsQuery defines the tags query to use
  37134. * @param forEach defines a predicate used to filter results
  37135. * @returns an array of Mesh
  37136. */
  37137. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37138. /**
  37139. * Get a list of cameras by tags
  37140. * @param tagsQuery defines the tags query to use
  37141. * @param forEach defines a predicate used to filter results
  37142. * @returns an array of Camera
  37143. */
  37144. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37145. /**
  37146. * Get a list of lights by tags
  37147. * @param tagsQuery defines the tags query to use
  37148. * @param forEach defines a predicate used to filter results
  37149. * @returns an array of Light
  37150. */
  37151. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37152. /**
  37153. * Get a list of materials by tags
  37154. * @param tagsQuery defines the tags query to use
  37155. * @param forEach defines a predicate used to filter results
  37156. * @returns an array of Material
  37157. */
  37158. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37159. /**
  37160. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37161. * This allowed control for front to back rendering or reversly depending of the special needs.
  37162. *
  37163. * @param renderingGroupId The rendering group id corresponding to its index
  37164. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37165. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37166. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37167. */
  37168. 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;
  37169. /**
  37170. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37171. *
  37172. * @param renderingGroupId The rendering group id corresponding to its index
  37173. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37174. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37175. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37176. */
  37177. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37178. /**
  37179. * Gets the current auto clear configuration for one rendering group of the rendering
  37180. * manager.
  37181. * @param index the rendering group index to get the information for
  37182. * @returns The auto clear setup for the requested rendering group
  37183. */
  37184. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37185. private _blockMaterialDirtyMechanism;
  37186. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37187. get blockMaterialDirtyMechanism(): boolean;
  37188. set blockMaterialDirtyMechanism(value: boolean);
  37189. /**
  37190. * Will flag all materials as dirty to trigger new shader compilation
  37191. * @param flag defines the flag used to specify which material part must be marked as dirty
  37192. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37193. */
  37194. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37195. /** @hidden */
  37196. _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;
  37197. /** @hidden */
  37198. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37199. /** @hidden */
  37200. _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;
  37201. /** @hidden */
  37202. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37203. /** @hidden */
  37204. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37205. /** @hidden */
  37206. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37207. }
  37208. }
  37209. declare module BABYLON {
  37210. /**
  37211. * Set of assets to keep when moving a scene into an asset container.
  37212. */
  37213. export class KeepAssets extends AbstractScene {
  37214. }
  37215. /**
  37216. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37217. */
  37218. export class InstantiatedEntries {
  37219. /**
  37220. * List of new root nodes (eg. nodes with no parent)
  37221. */
  37222. rootNodes: TransformNode[];
  37223. /**
  37224. * List of new skeletons
  37225. */
  37226. skeletons: Skeleton[];
  37227. /**
  37228. * List of new animation groups
  37229. */
  37230. animationGroups: AnimationGroup[];
  37231. }
  37232. /**
  37233. * Container with a set of assets that can be added or removed from a scene.
  37234. */
  37235. export class AssetContainer extends AbstractScene {
  37236. private _wasAddedToScene;
  37237. /**
  37238. * The scene the AssetContainer belongs to.
  37239. */
  37240. scene: Scene;
  37241. /**
  37242. * Instantiates an AssetContainer.
  37243. * @param scene The scene the AssetContainer belongs to.
  37244. */
  37245. constructor(scene: Scene);
  37246. /**
  37247. * Instantiate or clone all meshes and add the new ones to the scene.
  37248. * Skeletons and animation groups will all be cloned
  37249. * @param nameFunction defines an optional function used to get new names for clones
  37250. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37251. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37252. */
  37253. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37254. /**
  37255. * Adds all the assets from the container to the scene.
  37256. */
  37257. addAllToScene(): void;
  37258. /**
  37259. * Removes all the assets in the container from the scene
  37260. */
  37261. removeAllFromScene(): void;
  37262. /**
  37263. * Disposes all the assets in the container
  37264. */
  37265. dispose(): void;
  37266. private _moveAssets;
  37267. /**
  37268. * Removes all the assets contained in the scene and adds them to the container.
  37269. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37270. */
  37271. moveAllFromScene(keepAssets?: KeepAssets): void;
  37272. /**
  37273. * 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.
  37274. * @returns the root mesh
  37275. */
  37276. createRootMesh(): Mesh;
  37277. /**
  37278. * Merge animations from this asset container into a scene
  37279. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37280. * @param animatables set of animatables to retarget to a node from the scene
  37281. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37282. */
  37283. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37284. }
  37285. }
  37286. declare module BABYLON {
  37287. /**
  37288. * Defines how the parser contract is defined.
  37289. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37290. */
  37291. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37292. /**
  37293. * Defines how the individual parser contract is defined.
  37294. * These parser can parse an individual asset
  37295. */
  37296. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37297. /**
  37298. * Base class of the scene acting as a container for the different elements composing a scene.
  37299. * This class is dynamically extended by the different components of the scene increasing
  37300. * flexibility and reducing coupling
  37301. */
  37302. export abstract class AbstractScene {
  37303. /**
  37304. * Stores the list of available parsers in the application.
  37305. */
  37306. private static _BabylonFileParsers;
  37307. /**
  37308. * Stores the list of available individual parsers in the application.
  37309. */
  37310. private static _IndividualBabylonFileParsers;
  37311. /**
  37312. * Adds a parser in the list of available ones
  37313. * @param name Defines the name of the parser
  37314. * @param parser Defines the parser to add
  37315. */
  37316. static AddParser(name: string, parser: BabylonFileParser): void;
  37317. /**
  37318. * Gets a general parser from the list of avaialble ones
  37319. * @param name Defines the name of the parser
  37320. * @returns the requested parser or null
  37321. */
  37322. static GetParser(name: string): Nullable<BabylonFileParser>;
  37323. /**
  37324. * Adds n individual parser in the list of available ones
  37325. * @param name Defines the name of the parser
  37326. * @param parser Defines the parser to add
  37327. */
  37328. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37329. /**
  37330. * Gets an individual parser from the list of avaialble ones
  37331. * @param name Defines the name of the parser
  37332. * @returns the requested parser or null
  37333. */
  37334. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37335. /**
  37336. * Parser json data and populate both a scene and its associated container object
  37337. * @param jsonData Defines the data to parse
  37338. * @param scene Defines the scene to parse the data for
  37339. * @param container Defines the container attached to the parsing sequence
  37340. * @param rootUrl Defines the root url of the data
  37341. */
  37342. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37343. /**
  37344. * Gets the list of root nodes (ie. nodes with no parent)
  37345. */
  37346. rootNodes: Node[];
  37347. /** All of the cameras added to this scene
  37348. * @see http://doc.babylonjs.com/babylon101/cameras
  37349. */
  37350. cameras: Camera[];
  37351. /**
  37352. * All of the lights added to this scene
  37353. * @see http://doc.babylonjs.com/babylon101/lights
  37354. */
  37355. lights: Light[];
  37356. /**
  37357. * All of the (abstract) meshes added to this scene
  37358. */
  37359. meshes: AbstractMesh[];
  37360. /**
  37361. * The list of skeletons added to the scene
  37362. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37363. */
  37364. skeletons: Skeleton[];
  37365. /**
  37366. * All of the particle systems added to this scene
  37367. * @see http://doc.babylonjs.com/babylon101/particles
  37368. */
  37369. particleSystems: IParticleSystem[];
  37370. /**
  37371. * Gets a list of Animations associated with the scene
  37372. */
  37373. animations: Animation[];
  37374. /**
  37375. * All of the animation groups added to this scene
  37376. * @see http://doc.babylonjs.com/how_to/group
  37377. */
  37378. animationGroups: AnimationGroup[];
  37379. /**
  37380. * All of the multi-materials added to this scene
  37381. * @see http://doc.babylonjs.com/how_to/multi_materials
  37382. */
  37383. multiMaterials: MultiMaterial[];
  37384. /**
  37385. * All of the materials added to this scene
  37386. * In the context of a Scene, it is not supposed to be modified manually.
  37387. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37388. * Note also that the order of the Material within the array is not significant and might change.
  37389. * @see http://doc.babylonjs.com/babylon101/materials
  37390. */
  37391. materials: Material[];
  37392. /**
  37393. * The list of morph target managers added to the scene
  37394. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37395. */
  37396. morphTargetManagers: MorphTargetManager[];
  37397. /**
  37398. * The list of geometries used in the scene.
  37399. */
  37400. geometries: Geometry[];
  37401. /**
  37402. * All of the tranform nodes added to this scene
  37403. * In the context of a Scene, it is not supposed to be modified manually.
  37404. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37405. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37406. * @see http://doc.babylonjs.com/how_to/transformnode
  37407. */
  37408. transformNodes: TransformNode[];
  37409. /**
  37410. * ActionManagers available on the scene.
  37411. */
  37412. actionManagers: AbstractActionManager[];
  37413. /**
  37414. * Textures to keep.
  37415. */
  37416. textures: BaseTexture[];
  37417. /**
  37418. * Environment texture for the scene
  37419. */
  37420. environmentTexture: Nullable<BaseTexture>;
  37421. /**
  37422. * @returns all meshes, lights, cameras, transformNodes and bones
  37423. */
  37424. getNodes(): Array<Node>;
  37425. }
  37426. }
  37427. declare module BABYLON {
  37428. /**
  37429. * Interface used to define options for Sound class
  37430. */
  37431. export interface ISoundOptions {
  37432. /**
  37433. * Does the sound autoplay once loaded.
  37434. */
  37435. autoplay?: boolean;
  37436. /**
  37437. * Does the sound loop after it finishes playing once.
  37438. */
  37439. loop?: boolean;
  37440. /**
  37441. * Sound's volume
  37442. */
  37443. volume?: number;
  37444. /**
  37445. * Is it a spatial sound?
  37446. */
  37447. spatialSound?: boolean;
  37448. /**
  37449. * Maximum distance to hear that sound
  37450. */
  37451. maxDistance?: number;
  37452. /**
  37453. * Uses user defined attenuation function
  37454. */
  37455. useCustomAttenuation?: boolean;
  37456. /**
  37457. * Define the roll off factor of spatial sounds.
  37458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37459. */
  37460. rolloffFactor?: number;
  37461. /**
  37462. * Define the reference distance the sound should be heard perfectly.
  37463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37464. */
  37465. refDistance?: number;
  37466. /**
  37467. * Define the distance attenuation model the sound will follow.
  37468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37469. */
  37470. distanceModel?: string;
  37471. /**
  37472. * Defines the playback speed (1 by default)
  37473. */
  37474. playbackRate?: number;
  37475. /**
  37476. * Defines if the sound is from a streaming source
  37477. */
  37478. streaming?: boolean;
  37479. /**
  37480. * Defines an optional length (in seconds) inside the sound file
  37481. */
  37482. length?: number;
  37483. /**
  37484. * Defines an optional offset (in seconds) inside the sound file
  37485. */
  37486. offset?: number;
  37487. /**
  37488. * If true, URLs will not be required to state the audio file codec to use.
  37489. */
  37490. skipCodecCheck?: boolean;
  37491. }
  37492. /**
  37493. * Defines a sound that can be played in the application.
  37494. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37496. */
  37497. export class Sound {
  37498. /**
  37499. * The name of the sound in the scene.
  37500. */
  37501. name: string;
  37502. /**
  37503. * Does the sound autoplay once loaded.
  37504. */
  37505. autoplay: boolean;
  37506. /**
  37507. * Does the sound loop after it finishes playing once.
  37508. */
  37509. loop: boolean;
  37510. /**
  37511. * Does the sound use a custom attenuation curve to simulate the falloff
  37512. * happening when the source gets further away from the camera.
  37513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37514. */
  37515. useCustomAttenuation: boolean;
  37516. /**
  37517. * The sound track id this sound belongs to.
  37518. */
  37519. soundTrackId: number;
  37520. /**
  37521. * Is this sound currently played.
  37522. */
  37523. isPlaying: boolean;
  37524. /**
  37525. * Is this sound currently paused.
  37526. */
  37527. isPaused: boolean;
  37528. /**
  37529. * Does this sound enables spatial sound.
  37530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37531. */
  37532. spatialSound: boolean;
  37533. /**
  37534. * Define the reference distance the sound should be heard perfectly.
  37535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37536. */
  37537. refDistance: number;
  37538. /**
  37539. * Define the roll off factor of spatial sounds.
  37540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37541. */
  37542. rolloffFactor: number;
  37543. /**
  37544. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37546. */
  37547. maxDistance: number;
  37548. /**
  37549. * Define the distance attenuation model the sound will follow.
  37550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37551. */
  37552. distanceModel: string;
  37553. /**
  37554. * @hidden
  37555. * Back Compat
  37556. **/
  37557. onended: () => any;
  37558. /**
  37559. * Observable event when the current playing sound finishes.
  37560. */
  37561. onEndedObservable: Observable<Sound>;
  37562. private _panningModel;
  37563. private _playbackRate;
  37564. private _streaming;
  37565. private _startTime;
  37566. private _startOffset;
  37567. private _position;
  37568. /** @hidden */
  37569. _positionInEmitterSpace: boolean;
  37570. private _localDirection;
  37571. private _volume;
  37572. private _isReadyToPlay;
  37573. private _isDirectional;
  37574. private _readyToPlayCallback;
  37575. private _audioBuffer;
  37576. private _soundSource;
  37577. private _streamingSource;
  37578. private _soundPanner;
  37579. private _soundGain;
  37580. private _inputAudioNode;
  37581. private _outputAudioNode;
  37582. private _coneInnerAngle;
  37583. private _coneOuterAngle;
  37584. private _coneOuterGain;
  37585. private _scene;
  37586. private _connectedTransformNode;
  37587. private _customAttenuationFunction;
  37588. private _registerFunc;
  37589. private _isOutputConnected;
  37590. private _htmlAudioElement;
  37591. private _urlType;
  37592. private _length?;
  37593. private _offset?;
  37594. /** @hidden */
  37595. static _SceneComponentInitialization: (scene: Scene) => void;
  37596. /**
  37597. * Create a sound and attach it to a scene
  37598. * @param name Name of your sound
  37599. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37600. * @param scene defines the scene the sound belongs to
  37601. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37602. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37603. */
  37604. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37605. /**
  37606. * Release the sound and its associated resources
  37607. */
  37608. dispose(): void;
  37609. /**
  37610. * Gets if the sounds is ready to be played or not.
  37611. * @returns true if ready, otherwise false
  37612. */
  37613. isReady(): boolean;
  37614. private _soundLoaded;
  37615. /**
  37616. * Sets the data of the sound from an audiobuffer
  37617. * @param audioBuffer The audioBuffer containing the data
  37618. */
  37619. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37620. /**
  37621. * Updates the current sounds options such as maxdistance, loop...
  37622. * @param options A JSON object containing values named as the object properties
  37623. */
  37624. updateOptions(options: ISoundOptions): void;
  37625. private _createSpatialParameters;
  37626. private _updateSpatialParameters;
  37627. /**
  37628. * Switch the panning model to HRTF:
  37629. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37631. */
  37632. switchPanningModelToHRTF(): void;
  37633. /**
  37634. * Switch the panning model to Equal Power:
  37635. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37637. */
  37638. switchPanningModelToEqualPower(): void;
  37639. private _switchPanningModel;
  37640. /**
  37641. * Connect this sound to a sound track audio node like gain...
  37642. * @param soundTrackAudioNode the sound track audio node to connect to
  37643. */
  37644. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37645. /**
  37646. * Transform this sound into a directional source
  37647. * @param coneInnerAngle Size of the inner cone in degree
  37648. * @param coneOuterAngle Size of the outer cone in degree
  37649. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37650. */
  37651. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37652. /**
  37653. * Gets or sets the inner angle for the directional cone.
  37654. */
  37655. get directionalConeInnerAngle(): number;
  37656. /**
  37657. * Gets or sets the inner angle for the directional cone.
  37658. */
  37659. set directionalConeInnerAngle(value: number);
  37660. /**
  37661. * Gets or sets the outer angle for the directional cone.
  37662. */
  37663. get directionalConeOuterAngle(): number;
  37664. /**
  37665. * Gets or sets the outer angle for the directional cone.
  37666. */
  37667. set directionalConeOuterAngle(value: number);
  37668. /**
  37669. * Sets the position of the emitter if spatial sound is enabled
  37670. * @param newPosition Defines the new posisiton
  37671. */
  37672. setPosition(newPosition: Vector3): void;
  37673. /**
  37674. * Sets the local direction of the emitter if spatial sound is enabled
  37675. * @param newLocalDirection Defines the new local direction
  37676. */
  37677. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37678. private _updateDirection;
  37679. /** @hidden */
  37680. updateDistanceFromListener(): void;
  37681. /**
  37682. * Sets a new custom attenuation function for the sound.
  37683. * @param callback Defines the function used for the attenuation
  37684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37685. */
  37686. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37687. /**
  37688. * Play the sound
  37689. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37690. * @param offset (optional) Start the sound at a specific time in seconds
  37691. * @param length (optional) Sound duration (in seconds)
  37692. */
  37693. play(time?: number, offset?: number, length?: number): void;
  37694. private _onended;
  37695. /**
  37696. * Stop the sound
  37697. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37698. */
  37699. stop(time?: number): void;
  37700. /**
  37701. * Put the sound in pause
  37702. */
  37703. pause(): void;
  37704. /**
  37705. * Sets a dedicated volume for this sounds
  37706. * @param newVolume Define the new volume of the sound
  37707. * @param time Define time for gradual change to new volume
  37708. */
  37709. setVolume(newVolume: number, time?: number): void;
  37710. /**
  37711. * Set the sound play back rate
  37712. * @param newPlaybackRate Define the playback rate the sound should be played at
  37713. */
  37714. setPlaybackRate(newPlaybackRate: number): void;
  37715. /**
  37716. * Gets the volume of the sound.
  37717. * @returns the volume of the sound
  37718. */
  37719. getVolume(): number;
  37720. /**
  37721. * Attach the sound to a dedicated mesh
  37722. * @param transformNode The transform node to connect the sound with
  37723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37724. */
  37725. attachToMesh(transformNode: TransformNode): void;
  37726. /**
  37727. * Detach the sound from the previously attached mesh
  37728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37729. */
  37730. detachFromMesh(): void;
  37731. private _onRegisterAfterWorldMatrixUpdate;
  37732. /**
  37733. * Clone the current sound in the scene.
  37734. * @returns the new sound clone
  37735. */
  37736. clone(): Nullable<Sound>;
  37737. /**
  37738. * Gets the current underlying audio buffer containing the data
  37739. * @returns the audio buffer
  37740. */
  37741. getAudioBuffer(): Nullable<AudioBuffer>;
  37742. /**
  37743. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37744. * @returns the source node
  37745. */
  37746. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37747. /**
  37748. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37749. * @returns the gain node
  37750. */
  37751. getSoundGain(): Nullable<GainNode>;
  37752. /**
  37753. * Serializes the Sound in a JSON representation
  37754. * @returns the JSON representation of the sound
  37755. */
  37756. serialize(): any;
  37757. /**
  37758. * Parse a JSON representation of a sound to innstantiate in a given scene
  37759. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37760. * @param scene Define the scene the new parsed sound should be created in
  37761. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37762. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37763. * @returns the newly parsed sound
  37764. */
  37765. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37766. }
  37767. }
  37768. declare module BABYLON {
  37769. /**
  37770. * This defines an action helpful to play a defined sound on a triggered action.
  37771. */
  37772. export class PlaySoundAction extends Action {
  37773. private _sound;
  37774. /**
  37775. * Instantiate the action
  37776. * @param triggerOptions defines the trigger options
  37777. * @param sound defines the sound to play
  37778. * @param condition defines the trigger related conditions
  37779. */
  37780. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37781. /** @hidden */
  37782. _prepare(): void;
  37783. /**
  37784. * Execute the action and play the sound.
  37785. */
  37786. execute(): void;
  37787. /**
  37788. * Serializes the actions and its related information.
  37789. * @param parent defines the object to serialize in
  37790. * @returns the serialized object
  37791. */
  37792. serialize(parent: any): any;
  37793. }
  37794. /**
  37795. * This defines an action helpful to stop a defined sound on a triggered action.
  37796. */
  37797. export class StopSoundAction extends Action {
  37798. private _sound;
  37799. /**
  37800. * Instantiate the action
  37801. * @param triggerOptions defines the trigger options
  37802. * @param sound defines the sound to stop
  37803. * @param condition defines the trigger related conditions
  37804. */
  37805. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37806. /** @hidden */
  37807. _prepare(): void;
  37808. /**
  37809. * Execute the action and stop the sound.
  37810. */
  37811. execute(): void;
  37812. /**
  37813. * Serializes the actions and its related information.
  37814. * @param parent defines the object to serialize in
  37815. * @returns the serialized object
  37816. */
  37817. serialize(parent: any): any;
  37818. }
  37819. }
  37820. declare module BABYLON {
  37821. /**
  37822. * This defines an action responsible to change the value of a property
  37823. * by interpolating between its current value and the newly set one once triggered.
  37824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37825. */
  37826. export class InterpolateValueAction extends Action {
  37827. /**
  37828. * Defines the path of the property where the value should be interpolated
  37829. */
  37830. propertyPath: string;
  37831. /**
  37832. * Defines the target value at the end of the interpolation.
  37833. */
  37834. value: any;
  37835. /**
  37836. * Defines the time it will take for the property to interpolate to the value.
  37837. */
  37838. duration: number;
  37839. /**
  37840. * Defines if the other scene animations should be stopped when the action has been triggered
  37841. */
  37842. stopOtherAnimations?: boolean;
  37843. /**
  37844. * Defines a callback raised once the interpolation animation has been done.
  37845. */
  37846. onInterpolationDone?: () => void;
  37847. /**
  37848. * Observable triggered once the interpolation animation has been done.
  37849. */
  37850. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37851. private _target;
  37852. private _effectiveTarget;
  37853. private _property;
  37854. /**
  37855. * Instantiate the action
  37856. * @param triggerOptions defines the trigger options
  37857. * @param target defines the object containing the value to interpolate
  37858. * @param propertyPath defines the path to the property in the target object
  37859. * @param value defines the target value at the end of the interpolation
  37860. * @param duration deines the time it will take for the property to interpolate to the value.
  37861. * @param condition defines the trigger related conditions
  37862. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37863. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37864. */
  37865. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37866. /** @hidden */
  37867. _prepare(): void;
  37868. /**
  37869. * Execute the action starts the value interpolation.
  37870. */
  37871. execute(): void;
  37872. /**
  37873. * Serializes the actions and its related information.
  37874. * @param parent defines the object to serialize in
  37875. * @returns the serialized object
  37876. */
  37877. serialize(parent: any): any;
  37878. }
  37879. }
  37880. declare module BABYLON {
  37881. /**
  37882. * Options allowed during the creation of a sound track.
  37883. */
  37884. export interface ISoundTrackOptions {
  37885. /**
  37886. * The volume the sound track should take during creation
  37887. */
  37888. volume?: number;
  37889. /**
  37890. * Define if the sound track is the main sound track of the scene
  37891. */
  37892. mainTrack?: boolean;
  37893. }
  37894. /**
  37895. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37896. * It will be also used in a future release to apply effects on a specific track.
  37897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37898. */
  37899. export class SoundTrack {
  37900. /**
  37901. * The unique identifier of the sound track in the scene.
  37902. */
  37903. id: number;
  37904. /**
  37905. * The list of sounds included in the sound track.
  37906. */
  37907. soundCollection: Array<Sound>;
  37908. private _outputAudioNode;
  37909. private _scene;
  37910. private _connectedAnalyser;
  37911. private _options;
  37912. private _isInitialized;
  37913. /**
  37914. * Creates a new sound track.
  37915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37916. * @param scene Define the scene the sound track belongs to
  37917. * @param options
  37918. */
  37919. constructor(scene: Scene, options?: ISoundTrackOptions);
  37920. private _initializeSoundTrackAudioGraph;
  37921. /**
  37922. * Release the sound track and its associated resources
  37923. */
  37924. dispose(): void;
  37925. /**
  37926. * Adds a sound to this sound track
  37927. * @param sound define the cound to add
  37928. * @ignoreNaming
  37929. */
  37930. AddSound(sound: Sound): void;
  37931. /**
  37932. * Removes a sound to this sound track
  37933. * @param sound define the cound to remove
  37934. * @ignoreNaming
  37935. */
  37936. RemoveSound(sound: Sound): void;
  37937. /**
  37938. * Set a global volume for the full sound track.
  37939. * @param newVolume Define the new volume of the sound track
  37940. */
  37941. setVolume(newVolume: number): void;
  37942. /**
  37943. * Switch the panning model to HRTF:
  37944. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37946. */
  37947. switchPanningModelToHRTF(): void;
  37948. /**
  37949. * Switch the panning model to Equal Power:
  37950. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37952. */
  37953. switchPanningModelToEqualPower(): void;
  37954. /**
  37955. * Connect the sound track to an audio analyser allowing some amazing
  37956. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37958. * @param analyser The analyser to connect to the engine
  37959. */
  37960. connectToAnalyser(analyser: Analyser): void;
  37961. }
  37962. }
  37963. declare module BABYLON {
  37964. interface AbstractScene {
  37965. /**
  37966. * The list of sounds used in the scene.
  37967. */
  37968. sounds: Nullable<Array<Sound>>;
  37969. }
  37970. interface Scene {
  37971. /**
  37972. * @hidden
  37973. * Backing field
  37974. */
  37975. _mainSoundTrack: SoundTrack;
  37976. /**
  37977. * The main sound track played by the scene.
  37978. * It cotains your primary collection of sounds.
  37979. */
  37980. mainSoundTrack: SoundTrack;
  37981. /**
  37982. * The list of sound tracks added to the scene
  37983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37984. */
  37985. soundTracks: Nullable<Array<SoundTrack>>;
  37986. /**
  37987. * Gets a sound using a given name
  37988. * @param name defines the name to search for
  37989. * @return the found sound or null if not found at all.
  37990. */
  37991. getSoundByName(name: string): Nullable<Sound>;
  37992. /**
  37993. * Gets or sets if audio support is enabled
  37994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37995. */
  37996. audioEnabled: boolean;
  37997. /**
  37998. * Gets or sets if audio will be output to headphones
  37999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38000. */
  38001. headphone: boolean;
  38002. /**
  38003. * Gets or sets custom audio listener position provider
  38004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38005. */
  38006. audioListenerPositionProvider: Nullable<() => Vector3>;
  38007. /**
  38008. * Gets or sets a refresh rate when using 3D audio positioning
  38009. */
  38010. audioPositioningRefreshRate: number;
  38011. }
  38012. /**
  38013. * Defines the sound scene component responsible to manage any sounds
  38014. * in a given scene.
  38015. */
  38016. export class AudioSceneComponent implements ISceneSerializableComponent {
  38017. /**
  38018. * The component name helpfull to identify the component in the list of scene components.
  38019. */
  38020. readonly name: string;
  38021. /**
  38022. * The scene the component belongs to.
  38023. */
  38024. scene: Scene;
  38025. private _audioEnabled;
  38026. /**
  38027. * Gets whether audio is enabled or not.
  38028. * Please use related enable/disable method to switch state.
  38029. */
  38030. get audioEnabled(): boolean;
  38031. private _headphone;
  38032. /**
  38033. * Gets whether audio is outputing to headphone or not.
  38034. * Please use the according Switch methods to change output.
  38035. */
  38036. get headphone(): boolean;
  38037. /**
  38038. * Gets or sets a refresh rate when using 3D audio positioning
  38039. */
  38040. audioPositioningRefreshRate: number;
  38041. private _audioListenerPositionProvider;
  38042. /**
  38043. * Gets the current audio listener position provider
  38044. */
  38045. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38046. /**
  38047. * Sets a custom listener position for all sounds in the scene
  38048. * By default, this is the position of the first active camera
  38049. */
  38050. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38051. /**
  38052. * Creates a new instance of the component for the given scene
  38053. * @param scene Defines the scene to register the component in
  38054. */
  38055. constructor(scene: Scene);
  38056. /**
  38057. * Registers the component in a given scene
  38058. */
  38059. register(): void;
  38060. /**
  38061. * Rebuilds the elements related to this component in case of
  38062. * context lost for instance.
  38063. */
  38064. rebuild(): void;
  38065. /**
  38066. * Serializes the component data to the specified json object
  38067. * @param serializationObject The object to serialize to
  38068. */
  38069. serialize(serializationObject: any): void;
  38070. /**
  38071. * Adds all the elements from the container to the scene
  38072. * @param container the container holding the elements
  38073. */
  38074. addFromContainer(container: AbstractScene): void;
  38075. /**
  38076. * Removes all the elements in the container from the scene
  38077. * @param container contains the elements to remove
  38078. * @param dispose if the removed element should be disposed (default: false)
  38079. */
  38080. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38081. /**
  38082. * Disposes the component and the associated ressources.
  38083. */
  38084. dispose(): void;
  38085. /**
  38086. * Disables audio in the associated scene.
  38087. */
  38088. disableAudio(): void;
  38089. /**
  38090. * Enables audio in the associated scene.
  38091. */
  38092. enableAudio(): void;
  38093. /**
  38094. * Switch audio to headphone output.
  38095. */
  38096. switchAudioModeForHeadphones(): void;
  38097. /**
  38098. * Switch audio to normal speakers.
  38099. */
  38100. switchAudioModeForNormalSpeakers(): void;
  38101. private _cachedCameraDirection;
  38102. private _cachedCameraPosition;
  38103. private _lastCheck;
  38104. private _afterRender;
  38105. }
  38106. }
  38107. declare module BABYLON {
  38108. /**
  38109. * Wraps one or more Sound objects and selects one with random weight for playback.
  38110. */
  38111. export class WeightedSound {
  38112. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38113. loop: boolean;
  38114. private _coneInnerAngle;
  38115. private _coneOuterAngle;
  38116. private _volume;
  38117. /** A Sound is currently playing. */
  38118. isPlaying: boolean;
  38119. /** A Sound is currently paused. */
  38120. isPaused: boolean;
  38121. private _sounds;
  38122. private _weights;
  38123. private _currentIndex?;
  38124. /**
  38125. * Creates a new WeightedSound from the list of sounds given.
  38126. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38127. * @param sounds Array of Sounds that will be selected from.
  38128. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38129. */
  38130. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38131. /**
  38132. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38133. */
  38134. get directionalConeInnerAngle(): number;
  38135. /**
  38136. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38137. */
  38138. set directionalConeInnerAngle(value: number);
  38139. /**
  38140. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38141. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38142. */
  38143. get directionalConeOuterAngle(): number;
  38144. /**
  38145. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38146. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38147. */
  38148. set directionalConeOuterAngle(value: number);
  38149. /**
  38150. * Playback volume.
  38151. */
  38152. get volume(): number;
  38153. /**
  38154. * Playback volume.
  38155. */
  38156. set volume(value: number);
  38157. private _onended;
  38158. /**
  38159. * Suspend playback
  38160. */
  38161. pause(): void;
  38162. /**
  38163. * Stop playback
  38164. */
  38165. stop(): void;
  38166. /**
  38167. * Start playback.
  38168. * @param startOffset Position the clip head at a specific time in seconds.
  38169. */
  38170. play(startOffset?: number): void;
  38171. }
  38172. }
  38173. declare module BABYLON {
  38174. /**
  38175. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38176. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38177. */
  38178. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38179. /**
  38180. * Gets the name of the behavior.
  38181. */
  38182. get name(): string;
  38183. /**
  38184. * The easing function used by animations
  38185. */
  38186. static EasingFunction: BackEase;
  38187. /**
  38188. * The easing mode used by animations
  38189. */
  38190. static EasingMode: number;
  38191. /**
  38192. * The duration of the animation, in milliseconds
  38193. */
  38194. transitionDuration: number;
  38195. /**
  38196. * Length of the distance animated by the transition when lower radius is reached
  38197. */
  38198. lowerRadiusTransitionRange: number;
  38199. /**
  38200. * Length of the distance animated by the transition when upper radius is reached
  38201. */
  38202. upperRadiusTransitionRange: number;
  38203. private _autoTransitionRange;
  38204. /**
  38205. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38206. */
  38207. get autoTransitionRange(): boolean;
  38208. /**
  38209. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38210. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38211. */
  38212. set autoTransitionRange(value: boolean);
  38213. private _attachedCamera;
  38214. private _onAfterCheckInputsObserver;
  38215. private _onMeshTargetChangedObserver;
  38216. /**
  38217. * Initializes the behavior.
  38218. */
  38219. init(): void;
  38220. /**
  38221. * Attaches the behavior to its arc rotate camera.
  38222. * @param camera Defines the camera to attach the behavior to
  38223. */
  38224. attach(camera: ArcRotateCamera): void;
  38225. /**
  38226. * Detaches the behavior from its current arc rotate camera.
  38227. */
  38228. detach(): void;
  38229. private _radiusIsAnimating;
  38230. private _radiusBounceTransition;
  38231. private _animatables;
  38232. private _cachedWheelPrecision;
  38233. /**
  38234. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38235. * @param radiusLimit The limit to check against.
  38236. * @return Bool to indicate if at limit.
  38237. */
  38238. private _isRadiusAtLimit;
  38239. /**
  38240. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38241. * @param radiusDelta The delta by which to animate to. Can be negative.
  38242. */
  38243. private _applyBoundRadiusAnimation;
  38244. /**
  38245. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38246. */
  38247. protected _clearAnimationLocks(): void;
  38248. /**
  38249. * Stops and removes all animations that have been applied to the camera
  38250. */
  38251. stopAllAnimations(): void;
  38252. }
  38253. }
  38254. declare module BABYLON {
  38255. /**
  38256. * 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.
  38257. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38258. */
  38259. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38260. /**
  38261. * Gets the name of the behavior.
  38262. */
  38263. get name(): string;
  38264. private _mode;
  38265. private _radiusScale;
  38266. private _positionScale;
  38267. private _defaultElevation;
  38268. private _elevationReturnTime;
  38269. private _elevationReturnWaitTime;
  38270. private _zoomStopsAnimation;
  38271. private _framingTime;
  38272. /**
  38273. * The easing function used by animations
  38274. */
  38275. static EasingFunction: ExponentialEase;
  38276. /**
  38277. * The easing mode used by animations
  38278. */
  38279. static EasingMode: number;
  38280. /**
  38281. * Sets the current mode used by the behavior
  38282. */
  38283. set mode(mode: number);
  38284. /**
  38285. * Gets current mode used by the behavior.
  38286. */
  38287. get mode(): number;
  38288. /**
  38289. * Sets the scale applied to the radius (1 by default)
  38290. */
  38291. set radiusScale(radius: number);
  38292. /**
  38293. * Gets the scale applied to the radius
  38294. */
  38295. get radiusScale(): number;
  38296. /**
  38297. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38298. */
  38299. set positionScale(scale: number);
  38300. /**
  38301. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38302. */
  38303. get positionScale(): number;
  38304. /**
  38305. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38306. * behaviour is triggered, in radians.
  38307. */
  38308. set defaultElevation(elevation: number);
  38309. /**
  38310. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38311. * behaviour is triggered, in radians.
  38312. */
  38313. get defaultElevation(): number;
  38314. /**
  38315. * Sets the time (in milliseconds) taken to return to the default beta position.
  38316. * Negative value indicates camera should not return to default.
  38317. */
  38318. set elevationReturnTime(speed: number);
  38319. /**
  38320. * Gets the time (in milliseconds) taken to return to the default beta position.
  38321. * Negative value indicates camera should not return to default.
  38322. */
  38323. get elevationReturnTime(): number;
  38324. /**
  38325. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38326. */
  38327. set elevationReturnWaitTime(time: number);
  38328. /**
  38329. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38330. */
  38331. get elevationReturnWaitTime(): number;
  38332. /**
  38333. * Sets the flag that indicates if user zooming should stop animation.
  38334. */
  38335. set zoomStopsAnimation(flag: boolean);
  38336. /**
  38337. * Gets the flag that indicates if user zooming should stop animation.
  38338. */
  38339. get zoomStopsAnimation(): boolean;
  38340. /**
  38341. * Sets the transition time when framing the mesh, in milliseconds
  38342. */
  38343. set framingTime(time: number);
  38344. /**
  38345. * Gets the transition time when framing the mesh, in milliseconds
  38346. */
  38347. get framingTime(): number;
  38348. /**
  38349. * Define if the behavior should automatically change the configured
  38350. * camera limits and sensibilities.
  38351. */
  38352. autoCorrectCameraLimitsAndSensibility: boolean;
  38353. private _onPrePointerObservableObserver;
  38354. private _onAfterCheckInputsObserver;
  38355. private _onMeshTargetChangedObserver;
  38356. private _attachedCamera;
  38357. private _isPointerDown;
  38358. private _lastInteractionTime;
  38359. /**
  38360. * Initializes the behavior.
  38361. */
  38362. init(): void;
  38363. /**
  38364. * Attaches the behavior to its arc rotate camera.
  38365. * @param camera Defines the camera to attach the behavior to
  38366. */
  38367. attach(camera: ArcRotateCamera): void;
  38368. /**
  38369. * Detaches the behavior from its current arc rotate camera.
  38370. */
  38371. detach(): void;
  38372. private _animatables;
  38373. private _betaIsAnimating;
  38374. private _betaTransition;
  38375. private _radiusTransition;
  38376. private _vectorTransition;
  38377. /**
  38378. * Targets the given mesh and updates zoom level accordingly.
  38379. * @param mesh The mesh to target.
  38380. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38381. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38382. */
  38383. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38384. /**
  38385. * Targets the given mesh with its children and updates zoom level accordingly.
  38386. * @param mesh The mesh to target.
  38387. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38388. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38389. */
  38390. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38391. /**
  38392. * Targets the given meshes with their children and updates zoom level accordingly.
  38393. * @param meshes The mesh to target.
  38394. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38395. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38396. */
  38397. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38398. /**
  38399. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38400. * @param minimumWorld Determines the smaller position of the bounding box extend
  38401. * @param maximumWorld Determines the bigger position of the bounding box extend
  38402. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38403. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38404. */
  38405. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38406. /**
  38407. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38408. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38409. * frustum width.
  38410. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38411. * to fully enclose the mesh in the viewing frustum.
  38412. */
  38413. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38414. /**
  38415. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38416. * is automatically returned to its default position (expected to be above ground plane).
  38417. */
  38418. private _maintainCameraAboveGround;
  38419. /**
  38420. * Returns the frustum slope based on the canvas ratio and camera FOV
  38421. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38422. */
  38423. private _getFrustumSlope;
  38424. /**
  38425. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38426. */
  38427. private _clearAnimationLocks;
  38428. /**
  38429. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38430. */
  38431. private _applyUserInteraction;
  38432. /**
  38433. * Stops and removes all animations that have been applied to the camera
  38434. */
  38435. stopAllAnimations(): void;
  38436. /**
  38437. * Gets a value indicating if the user is moving the camera
  38438. */
  38439. get isUserIsMoving(): boolean;
  38440. /**
  38441. * The camera can move all the way towards the mesh.
  38442. */
  38443. static IgnoreBoundsSizeMode: number;
  38444. /**
  38445. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38446. */
  38447. static FitFrustumSidesMode: number;
  38448. }
  38449. }
  38450. declare module BABYLON {
  38451. /**
  38452. * Base class for Camera Pointer Inputs.
  38453. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38454. * for example usage.
  38455. */
  38456. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38457. /**
  38458. * Defines the camera the input is attached to.
  38459. */
  38460. abstract camera: Camera;
  38461. /**
  38462. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38463. */
  38464. protected _altKey: boolean;
  38465. protected _ctrlKey: boolean;
  38466. protected _metaKey: boolean;
  38467. protected _shiftKey: boolean;
  38468. /**
  38469. * Which mouse buttons were pressed at time of last mouse event.
  38470. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38471. */
  38472. protected _buttonsPressed: number;
  38473. /**
  38474. * Defines the buttons associated with the input to handle camera move.
  38475. */
  38476. buttons: number[];
  38477. /**
  38478. * Attach the input controls to a specific dom element to get the input from.
  38479. * @param element Defines the element the controls should be listened from
  38480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38481. */
  38482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38483. /**
  38484. * Detach the current controls from the specified dom element.
  38485. * @param element Defines the element to stop listening the inputs from
  38486. */
  38487. detachControl(element: Nullable<HTMLElement>): void;
  38488. /**
  38489. * Gets the class name of the current input.
  38490. * @returns the class name
  38491. */
  38492. getClassName(): string;
  38493. /**
  38494. * Get the friendly name associated with the input class.
  38495. * @returns the input friendly name
  38496. */
  38497. getSimpleName(): string;
  38498. /**
  38499. * Called on pointer POINTERDOUBLETAP event.
  38500. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38501. */
  38502. protected onDoubleTap(type: string): void;
  38503. /**
  38504. * Called on pointer POINTERMOVE event if only a single touch is active.
  38505. * Override this method to provide functionality.
  38506. */
  38507. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38508. /**
  38509. * Called on pointer POINTERMOVE event if multiple touches are active.
  38510. * Override this method to provide functionality.
  38511. */
  38512. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38513. /**
  38514. * Called on JS contextmenu event.
  38515. * Override this method to provide functionality.
  38516. */
  38517. protected onContextMenu(evt: PointerEvent): void;
  38518. /**
  38519. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38520. * press.
  38521. * Override this method to provide functionality.
  38522. */
  38523. protected onButtonDown(evt: PointerEvent): void;
  38524. /**
  38525. * Called each time a new POINTERUP event occurs. Ie, for each button
  38526. * release.
  38527. * Override this method to provide functionality.
  38528. */
  38529. protected onButtonUp(evt: PointerEvent): void;
  38530. /**
  38531. * Called when window becomes inactive.
  38532. * Override this method to provide functionality.
  38533. */
  38534. protected onLostFocus(): void;
  38535. private _pointerInput;
  38536. private _observer;
  38537. private _onLostFocus;
  38538. private pointA;
  38539. private pointB;
  38540. }
  38541. }
  38542. declare module BABYLON {
  38543. /**
  38544. * Manage the pointers inputs to control an arc rotate camera.
  38545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38546. */
  38547. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38548. /**
  38549. * Defines the camera the input is attached to.
  38550. */
  38551. camera: ArcRotateCamera;
  38552. /**
  38553. * Gets the class name of the current input.
  38554. * @returns the class name
  38555. */
  38556. getClassName(): string;
  38557. /**
  38558. * Defines the buttons associated with the input to handle camera move.
  38559. */
  38560. buttons: number[];
  38561. /**
  38562. * Defines the pointer angular sensibility along the X axis or how fast is
  38563. * the camera rotating.
  38564. */
  38565. angularSensibilityX: number;
  38566. /**
  38567. * Defines the pointer angular sensibility along the Y axis or how fast is
  38568. * the camera rotating.
  38569. */
  38570. angularSensibilityY: number;
  38571. /**
  38572. * Defines the pointer pinch precision or how fast is the camera zooming.
  38573. */
  38574. pinchPrecision: number;
  38575. /**
  38576. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38577. * from 0.
  38578. * It defines the percentage of current camera.radius to use as delta when
  38579. * pinch zoom is used.
  38580. */
  38581. pinchDeltaPercentage: number;
  38582. /**
  38583. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38584. * that any object in the plane at the camera's target point will scale
  38585. * perfectly with finger motion.
  38586. * Overrides pinchDeltaPercentage and pinchPrecision.
  38587. */
  38588. useNaturalPinchZoom: boolean;
  38589. /**
  38590. * Defines the pointer panning sensibility or how fast is the camera moving.
  38591. */
  38592. panningSensibility: number;
  38593. /**
  38594. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38595. */
  38596. multiTouchPanning: boolean;
  38597. /**
  38598. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38599. * zoom (pinch) through multitouch.
  38600. */
  38601. multiTouchPanAndZoom: boolean;
  38602. /**
  38603. * Revers pinch action direction.
  38604. */
  38605. pinchInwards: boolean;
  38606. private _isPanClick;
  38607. private _twoFingerActivityCount;
  38608. private _isPinching;
  38609. /**
  38610. * Called on pointer POINTERMOVE event if only a single touch is active.
  38611. */
  38612. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38613. /**
  38614. * Called on pointer POINTERDOUBLETAP event.
  38615. */
  38616. protected onDoubleTap(type: string): void;
  38617. /**
  38618. * Called on pointer POINTERMOVE event if multiple touches are active.
  38619. */
  38620. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38621. /**
  38622. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38623. * press.
  38624. */
  38625. protected onButtonDown(evt: PointerEvent): void;
  38626. /**
  38627. * Called each time a new POINTERUP event occurs. Ie, for each button
  38628. * release.
  38629. */
  38630. protected onButtonUp(evt: PointerEvent): void;
  38631. /**
  38632. * Called when window becomes inactive.
  38633. */
  38634. protected onLostFocus(): void;
  38635. }
  38636. }
  38637. declare module BABYLON {
  38638. /**
  38639. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38641. */
  38642. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38643. /**
  38644. * Defines the camera the input is attached to.
  38645. */
  38646. camera: ArcRotateCamera;
  38647. /**
  38648. * Defines the list of key codes associated with the up action (increase alpha)
  38649. */
  38650. keysUp: number[];
  38651. /**
  38652. * Defines the list of key codes associated with the down action (decrease alpha)
  38653. */
  38654. keysDown: number[];
  38655. /**
  38656. * Defines the list of key codes associated with the left action (increase beta)
  38657. */
  38658. keysLeft: number[];
  38659. /**
  38660. * Defines the list of key codes associated with the right action (decrease beta)
  38661. */
  38662. keysRight: number[];
  38663. /**
  38664. * Defines the list of key codes associated with the reset action.
  38665. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38666. */
  38667. keysReset: number[];
  38668. /**
  38669. * Defines the panning sensibility of the inputs.
  38670. * (How fast is the camera panning)
  38671. */
  38672. panningSensibility: number;
  38673. /**
  38674. * Defines the zooming sensibility of the inputs.
  38675. * (How fast is the camera zooming)
  38676. */
  38677. zoomingSensibility: number;
  38678. /**
  38679. * Defines whether maintaining the alt key down switch the movement mode from
  38680. * orientation to zoom.
  38681. */
  38682. useAltToZoom: boolean;
  38683. /**
  38684. * Rotation speed of the camera
  38685. */
  38686. angularSpeed: number;
  38687. private _keys;
  38688. private _ctrlPressed;
  38689. private _altPressed;
  38690. private _onCanvasBlurObserver;
  38691. private _onKeyboardObserver;
  38692. private _engine;
  38693. private _scene;
  38694. /**
  38695. * Attach the input controls to a specific dom element to get the input from.
  38696. * @param element Defines the element the controls should be listened from
  38697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38698. */
  38699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38700. /**
  38701. * Detach the current controls from the specified dom element.
  38702. * @param element Defines the element to stop listening the inputs from
  38703. */
  38704. detachControl(element: Nullable<HTMLElement>): void;
  38705. /**
  38706. * Update the current camera state depending on the inputs that have been used this frame.
  38707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38708. */
  38709. checkInputs(): void;
  38710. /**
  38711. * Gets the class name of the current intput.
  38712. * @returns the class name
  38713. */
  38714. getClassName(): string;
  38715. /**
  38716. * Get the friendly name associated with the input class.
  38717. * @returns the input friendly name
  38718. */
  38719. getSimpleName(): string;
  38720. }
  38721. }
  38722. declare module BABYLON {
  38723. /**
  38724. * Manage the mouse wheel inputs to control an arc rotate camera.
  38725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38726. */
  38727. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38728. /**
  38729. * Defines the camera the input is attached to.
  38730. */
  38731. camera: ArcRotateCamera;
  38732. /**
  38733. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38734. */
  38735. wheelPrecision: number;
  38736. /**
  38737. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38738. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38739. */
  38740. wheelDeltaPercentage: number;
  38741. private _wheel;
  38742. private _observer;
  38743. private computeDeltaFromMouseWheelLegacyEvent;
  38744. /**
  38745. * Attach the input controls to a specific dom element to get the input from.
  38746. * @param element Defines the element the controls should be listened from
  38747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38748. */
  38749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38750. /**
  38751. * Detach the current controls from the specified dom element.
  38752. * @param element Defines the element to stop listening the inputs from
  38753. */
  38754. detachControl(element: Nullable<HTMLElement>): void;
  38755. /**
  38756. * Gets the class name of the current intput.
  38757. * @returns the class name
  38758. */
  38759. getClassName(): string;
  38760. /**
  38761. * Get the friendly name associated with the input class.
  38762. * @returns the input friendly name
  38763. */
  38764. getSimpleName(): string;
  38765. }
  38766. }
  38767. declare module BABYLON {
  38768. /**
  38769. * Default Inputs manager for the ArcRotateCamera.
  38770. * It groups all the default supported inputs for ease of use.
  38771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38772. */
  38773. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38774. /**
  38775. * Instantiates a new ArcRotateCameraInputsManager.
  38776. * @param camera Defines the camera the inputs belong to
  38777. */
  38778. constructor(camera: ArcRotateCamera);
  38779. /**
  38780. * Add mouse wheel input support to the input manager.
  38781. * @returns the current input manager
  38782. */
  38783. addMouseWheel(): ArcRotateCameraInputsManager;
  38784. /**
  38785. * Add pointers input support to the input manager.
  38786. * @returns the current input manager
  38787. */
  38788. addPointers(): ArcRotateCameraInputsManager;
  38789. /**
  38790. * Add keyboard input support to the input manager.
  38791. * @returns the current input manager
  38792. */
  38793. addKeyboard(): ArcRotateCameraInputsManager;
  38794. }
  38795. }
  38796. declare module BABYLON {
  38797. /**
  38798. * This represents an orbital type of camera.
  38799. *
  38800. * 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.
  38801. * 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.
  38802. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38803. */
  38804. export class ArcRotateCamera extends TargetCamera {
  38805. /**
  38806. * Defines the rotation angle of the camera along the longitudinal axis.
  38807. */
  38808. alpha: number;
  38809. /**
  38810. * Defines the rotation angle of the camera along the latitudinal axis.
  38811. */
  38812. beta: number;
  38813. /**
  38814. * Defines the radius of the camera from it s target point.
  38815. */
  38816. radius: number;
  38817. protected _target: Vector3;
  38818. protected _targetHost: Nullable<AbstractMesh>;
  38819. /**
  38820. * Defines the target point of the camera.
  38821. * The camera looks towards it form the radius distance.
  38822. */
  38823. get target(): Vector3;
  38824. set target(value: Vector3);
  38825. /**
  38826. * Define the current local position of the camera in the scene
  38827. */
  38828. get position(): Vector3;
  38829. set position(newPosition: Vector3);
  38830. protected _upVector: Vector3;
  38831. protected _upToYMatrix: Matrix;
  38832. protected _YToUpMatrix: Matrix;
  38833. /**
  38834. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38835. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38836. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38837. */
  38838. set upVector(vec: Vector3);
  38839. get upVector(): Vector3;
  38840. /**
  38841. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38842. */
  38843. setMatUp(): void;
  38844. /**
  38845. * Current inertia value on the longitudinal axis.
  38846. * The bigger this number the longer it will take for the camera to stop.
  38847. */
  38848. inertialAlphaOffset: number;
  38849. /**
  38850. * Current inertia value on the latitudinal axis.
  38851. * The bigger this number the longer it will take for the camera to stop.
  38852. */
  38853. inertialBetaOffset: number;
  38854. /**
  38855. * Current inertia value on the radius axis.
  38856. * The bigger this number the longer it will take for the camera to stop.
  38857. */
  38858. inertialRadiusOffset: number;
  38859. /**
  38860. * Minimum allowed angle on the longitudinal axis.
  38861. * This can help limiting how the Camera is able to move in the scene.
  38862. */
  38863. lowerAlphaLimit: Nullable<number>;
  38864. /**
  38865. * Maximum allowed angle on the longitudinal axis.
  38866. * This can help limiting how the Camera is able to move in the scene.
  38867. */
  38868. upperAlphaLimit: Nullable<number>;
  38869. /**
  38870. * Minimum allowed angle on the latitudinal axis.
  38871. * This can help limiting how the Camera is able to move in the scene.
  38872. */
  38873. lowerBetaLimit: number;
  38874. /**
  38875. * Maximum allowed angle on the latitudinal axis.
  38876. * This can help limiting how the Camera is able to move in the scene.
  38877. */
  38878. upperBetaLimit: number;
  38879. /**
  38880. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38881. * This can help limiting how the Camera is able to move in the scene.
  38882. */
  38883. lowerRadiusLimit: Nullable<number>;
  38884. /**
  38885. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38886. * This can help limiting how the Camera is able to move in the scene.
  38887. */
  38888. upperRadiusLimit: Nullable<number>;
  38889. /**
  38890. * Defines the current inertia value used during panning of the camera along the X axis.
  38891. */
  38892. inertialPanningX: number;
  38893. /**
  38894. * Defines the current inertia value used during panning of the camera along the Y axis.
  38895. */
  38896. inertialPanningY: number;
  38897. /**
  38898. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38899. * Basically if your fingers moves away from more than this distance you will be considered
  38900. * in pinch mode.
  38901. */
  38902. pinchToPanMaxDistance: number;
  38903. /**
  38904. * Defines the maximum distance the camera can pan.
  38905. * This could help keeping the cammera always in your scene.
  38906. */
  38907. panningDistanceLimit: Nullable<number>;
  38908. /**
  38909. * Defines the target of the camera before paning.
  38910. */
  38911. panningOriginTarget: Vector3;
  38912. /**
  38913. * Defines the value of the inertia used during panning.
  38914. * 0 would mean stop inertia and one would mean no decelleration at all.
  38915. */
  38916. panningInertia: number;
  38917. /**
  38918. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38919. */
  38920. get angularSensibilityX(): number;
  38921. set angularSensibilityX(value: number);
  38922. /**
  38923. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38924. */
  38925. get angularSensibilityY(): number;
  38926. set angularSensibilityY(value: number);
  38927. /**
  38928. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38929. */
  38930. get pinchPrecision(): number;
  38931. set pinchPrecision(value: number);
  38932. /**
  38933. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38934. * It will be used instead of pinchDeltaPrecision if different from 0.
  38935. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38936. */
  38937. get pinchDeltaPercentage(): number;
  38938. set pinchDeltaPercentage(value: number);
  38939. /**
  38940. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38941. * and pinch delta percentage.
  38942. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38943. * that any object in the plane at the camera's target point will scale
  38944. * perfectly with finger motion.
  38945. */
  38946. get useNaturalPinchZoom(): boolean;
  38947. set useNaturalPinchZoom(value: boolean);
  38948. /**
  38949. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38950. */
  38951. get panningSensibility(): number;
  38952. set panningSensibility(value: number);
  38953. /**
  38954. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38955. */
  38956. get keysUp(): number[];
  38957. set keysUp(value: number[]);
  38958. /**
  38959. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38960. */
  38961. get keysDown(): number[];
  38962. set keysDown(value: number[]);
  38963. /**
  38964. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38965. */
  38966. get keysLeft(): number[];
  38967. set keysLeft(value: number[]);
  38968. /**
  38969. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38970. */
  38971. get keysRight(): number[];
  38972. set keysRight(value: number[]);
  38973. /**
  38974. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38975. */
  38976. get wheelPrecision(): number;
  38977. set wheelPrecision(value: number);
  38978. /**
  38979. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38980. * It will be used instead of pinchDeltaPrecision if different from 0.
  38981. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38982. */
  38983. get wheelDeltaPercentage(): number;
  38984. set wheelDeltaPercentage(value: number);
  38985. /**
  38986. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38987. */
  38988. zoomOnFactor: number;
  38989. /**
  38990. * Defines a screen offset for the camera position.
  38991. */
  38992. targetScreenOffset: Vector2;
  38993. /**
  38994. * Allows the camera to be completely reversed.
  38995. * If false the camera can not arrive upside down.
  38996. */
  38997. allowUpsideDown: boolean;
  38998. /**
  38999. * Define if double tap/click is used to restore the previously saved state of the camera.
  39000. */
  39001. useInputToRestoreState: boolean;
  39002. /** @hidden */
  39003. _viewMatrix: Matrix;
  39004. /** @hidden */
  39005. _useCtrlForPanning: boolean;
  39006. /** @hidden */
  39007. _panningMouseButton: number;
  39008. /**
  39009. * Defines the input associated to the camera.
  39010. */
  39011. inputs: ArcRotateCameraInputsManager;
  39012. /** @hidden */
  39013. _reset: () => void;
  39014. /**
  39015. * Defines the allowed panning axis.
  39016. */
  39017. panningAxis: Vector3;
  39018. protected _localDirection: Vector3;
  39019. protected _transformedDirection: Vector3;
  39020. private _bouncingBehavior;
  39021. /**
  39022. * Gets the bouncing behavior of the camera if it has been enabled.
  39023. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39024. */
  39025. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39026. /**
  39027. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39028. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39029. */
  39030. get useBouncingBehavior(): boolean;
  39031. set useBouncingBehavior(value: boolean);
  39032. private _framingBehavior;
  39033. /**
  39034. * Gets the framing behavior of the camera if it has been enabled.
  39035. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39036. */
  39037. get framingBehavior(): Nullable<FramingBehavior>;
  39038. /**
  39039. * Defines if the framing behavior of the camera is enabled on the camera.
  39040. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39041. */
  39042. get useFramingBehavior(): boolean;
  39043. set useFramingBehavior(value: boolean);
  39044. private _autoRotationBehavior;
  39045. /**
  39046. * Gets the auto rotation behavior of the camera if it has been enabled.
  39047. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39048. */
  39049. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39050. /**
  39051. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39052. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39053. */
  39054. get useAutoRotationBehavior(): boolean;
  39055. set useAutoRotationBehavior(value: boolean);
  39056. /**
  39057. * Observable triggered when the mesh target has been changed on the camera.
  39058. */
  39059. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39060. /**
  39061. * Event raised when the camera is colliding with a mesh.
  39062. */
  39063. onCollide: (collidedMesh: AbstractMesh) => void;
  39064. /**
  39065. * Defines whether the camera should check collision with the objects oh the scene.
  39066. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39067. */
  39068. checkCollisions: boolean;
  39069. /**
  39070. * Defines the collision radius of the camera.
  39071. * This simulates a sphere around the camera.
  39072. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39073. */
  39074. collisionRadius: Vector3;
  39075. protected _collider: Collider;
  39076. protected _previousPosition: Vector3;
  39077. protected _collisionVelocity: Vector3;
  39078. protected _newPosition: Vector3;
  39079. protected _previousAlpha: number;
  39080. protected _previousBeta: number;
  39081. protected _previousRadius: number;
  39082. protected _collisionTriggered: boolean;
  39083. protected _targetBoundingCenter: Nullable<Vector3>;
  39084. private _computationVector;
  39085. /**
  39086. * Instantiates a new ArcRotateCamera in a given scene
  39087. * @param name Defines the name of the camera
  39088. * @param alpha Defines the camera rotation along the logitudinal axis
  39089. * @param beta Defines the camera rotation along the latitudinal axis
  39090. * @param radius Defines the camera distance from its target
  39091. * @param target Defines the camera target
  39092. * @param scene Defines the scene the camera belongs to
  39093. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39094. */
  39095. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39096. /** @hidden */
  39097. _initCache(): void;
  39098. /** @hidden */
  39099. _updateCache(ignoreParentClass?: boolean): void;
  39100. protected _getTargetPosition(): Vector3;
  39101. private _storedAlpha;
  39102. private _storedBeta;
  39103. private _storedRadius;
  39104. private _storedTarget;
  39105. private _storedTargetScreenOffset;
  39106. /**
  39107. * Stores the current state of the camera (alpha, beta, radius and target)
  39108. * @returns the camera itself
  39109. */
  39110. storeState(): Camera;
  39111. /**
  39112. * @hidden
  39113. * Restored camera state. You must call storeState() first
  39114. */
  39115. _restoreStateValues(): boolean;
  39116. /** @hidden */
  39117. _isSynchronizedViewMatrix(): boolean;
  39118. /**
  39119. * Attached controls to the current camera.
  39120. * @param element Defines the element the controls should be listened from
  39121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39122. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39123. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39124. */
  39125. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39126. /**
  39127. * Detach the current controls from the camera.
  39128. * The camera will stop reacting to inputs.
  39129. * @param element Defines the element to stop listening the inputs from
  39130. */
  39131. detachControl(element: HTMLElement): void;
  39132. /** @hidden */
  39133. _checkInputs(): void;
  39134. protected _checkLimits(): void;
  39135. /**
  39136. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39137. */
  39138. rebuildAnglesAndRadius(): void;
  39139. /**
  39140. * Use a position to define the current camera related information like alpha, beta and radius
  39141. * @param position Defines the position to set the camera at
  39142. */
  39143. setPosition(position: Vector3): void;
  39144. /**
  39145. * Defines the target the camera should look at.
  39146. * This will automatically adapt alpha beta and radius to fit within the new target.
  39147. * @param target Defines the new target as a Vector or a mesh
  39148. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39149. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39150. */
  39151. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39152. /** @hidden */
  39153. _getViewMatrix(): Matrix;
  39154. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39155. /**
  39156. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39157. * @param meshes Defines the mesh to zoom on
  39158. * @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)
  39159. */
  39160. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39161. /**
  39162. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39163. * The target will be changed but the radius
  39164. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39165. * @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)
  39166. */
  39167. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39168. min: Vector3;
  39169. max: Vector3;
  39170. distance: number;
  39171. }, doNotUpdateMaxZ?: boolean): void;
  39172. /**
  39173. * @override
  39174. * Override Camera.createRigCamera
  39175. */
  39176. createRigCamera(name: string, cameraIndex: number): Camera;
  39177. /**
  39178. * @hidden
  39179. * @override
  39180. * Override Camera._updateRigCameras
  39181. */
  39182. _updateRigCameras(): void;
  39183. /**
  39184. * Destroy the camera and release the current resources hold by it.
  39185. */
  39186. dispose(): void;
  39187. /**
  39188. * Gets the current object class name.
  39189. * @return the class name
  39190. */
  39191. getClassName(): string;
  39192. }
  39193. }
  39194. declare module BABYLON {
  39195. /**
  39196. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39197. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39198. */
  39199. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39200. /**
  39201. * Gets the name of the behavior.
  39202. */
  39203. get name(): string;
  39204. private _zoomStopsAnimation;
  39205. private _idleRotationSpeed;
  39206. private _idleRotationWaitTime;
  39207. private _idleRotationSpinupTime;
  39208. /**
  39209. * Sets the flag that indicates if user zooming should stop animation.
  39210. */
  39211. set zoomStopsAnimation(flag: boolean);
  39212. /**
  39213. * Gets the flag that indicates if user zooming should stop animation.
  39214. */
  39215. get zoomStopsAnimation(): boolean;
  39216. /**
  39217. * Sets the default speed at which the camera rotates around the model.
  39218. */
  39219. set idleRotationSpeed(speed: number);
  39220. /**
  39221. * Gets the default speed at which the camera rotates around the model.
  39222. */
  39223. get idleRotationSpeed(): number;
  39224. /**
  39225. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39226. */
  39227. set idleRotationWaitTime(time: number);
  39228. /**
  39229. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39230. */
  39231. get idleRotationWaitTime(): number;
  39232. /**
  39233. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39234. */
  39235. set idleRotationSpinupTime(time: number);
  39236. /**
  39237. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39238. */
  39239. get idleRotationSpinupTime(): number;
  39240. /**
  39241. * Gets a value indicating if the camera is currently rotating because of this behavior
  39242. */
  39243. get rotationInProgress(): boolean;
  39244. private _onPrePointerObservableObserver;
  39245. private _onAfterCheckInputsObserver;
  39246. private _attachedCamera;
  39247. private _isPointerDown;
  39248. private _lastFrameTime;
  39249. private _lastInteractionTime;
  39250. private _cameraRotationSpeed;
  39251. /**
  39252. * Initializes the behavior.
  39253. */
  39254. init(): void;
  39255. /**
  39256. * Attaches the behavior to its arc rotate camera.
  39257. * @param camera Defines the camera to attach the behavior to
  39258. */
  39259. attach(camera: ArcRotateCamera): void;
  39260. /**
  39261. * Detaches the behavior from its current arc rotate camera.
  39262. */
  39263. detach(): void;
  39264. /**
  39265. * Returns true if user is scrolling.
  39266. * @return true if user is scrolling.
  39267. */
  39268. private _userIsZooming;
  39269. private _lastFrameRadius;
  39270. private _shouldAnimationStopForInteraction;
  39271. /**
  39272. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39273. */
  39274. private _applyUserInteraction;
  39275. private _userIsMoving;
  39276. }
  39277. }
  39278. declare module BABYLON {
  39279. /**
  39280. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39281. */
  39282. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39283. private ui;
  39284. /**
  39285. * The name of the behavior
  39286. */
  39287. name: string;
  39288. /**
  39289. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39290. */
  39291. distanceAwayFromFace: number;
  39292. /**
  39293. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39294. */
  39295. distanceAwayFromBottomOfFace: number;
  39296. private _faceVectors;
  39297. private _target;
  39298. private _scene;
  39299. private _onRenderObserver;
  39300. private _tmpMatrix;
  39301. private _tmpVector;
  39302. /**
  39303. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39304. * @param ui The transform node that should be attched to the mesh
  39305. */
  39306. constructor(ui: TransformNode);
  39307. /**
  39308. * Initializes the behavior
  39309. */
  39310. init(): void;
  39311. private _closestFace;
  39312. private _zeroVector;
  39313. private _lookAtTmpMatrix;
  39314. private _lookAtToRef;
  39315. /**
  39316. * Attaches the AttachToBoxBehavior to the passed in mesh
  39317. * @param target The mesh that the specified node will be attached to
  39318. */
  39319. attach(target: Mesh): void;
  39320. /**
  39321. * Detaches the behavior from the mesh
  39322. */
  39323. detach(): void;
  39324. }
  39325. }
  39326. declare module BABYLON {
  39327. /**
  39328. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39329. */
  39330. export class FadeInOutBehavior implements Behavior<Mesh> {
  39331. /**
  39332. * Time in milliseconds to delay before fading in (Default: 0)
  39333. */
  39334. delay: number;
  39335. /**
  39336. * Time in milliseconds for the mesh to fade in (Default: 300)
  39337. */
  39338. fadeInTime: number;
  39339. private _millisecondsPerFrame;
  39340. private _hovered;
  39341. private _hoverValue;
  39342. private _ownerNode;
  39343. /**
  39344. * Instatiates the FadeInOutBehavior
  39345. */
  39346. constructor();
  39347. /**
  39348. * The name of the behavior
  39349. */
  39350. get name(): string;
  39351. /**
  39352. * Initializes the behavior
  39353. */
  39354. init(): void;
  39355. /**
  39356. * Attaches the fade behavior on the passed in mesh
  39357. * @param ownerNode The mesh that will be faded in/out once attached
  39358. */
  39359. attach(ownerNode: Mesh): void;
  39360. /**
  39361. * Detaches the behavior from the mesh
  39362. */
  39363. detach(): void;
  39364. /**
  39365. * Triggers the mesh to begin fading in or out
  39366. * @param value if the object should fade in or out (true to fade in)
  39367. */
  39368. fadeIn(value: boolean): void;
  39369. private _update;
  39370. private _setAllVisibility;
  39371. }
  39372. }
  39373. declare module BABYLON {
  39374. /**
  39375. * Class containing a set of static utilities functions for managing Pivots
  39376. * @hidden
  39377. */
  39378. export class PivotTools {
  39379. private static _PivotCached;
  39380. private static _OldPivotPoint;
  39381. private static _PivotTranslation;
  39382. private static _PivotTmpVector;
  39383. /** @hidden */
  39384. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39385. /** @hidden */
  39386. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39387. }
  39388. }
  39389. declare module BABYLON {
  39390. /**
  39391. * Class containing static functions to help procedurally build meshes
  39392. */
  39393. export class PlaneBuilder {
  39394. /**
  39395. * Creates a plane mesh
  39396. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39397. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39398. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39400. * * 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
  39401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39402. * @param name defines the name of the mesh
  39403. * @param options defines the options used to create the mesh
  39404. * @param scene defines the hosting scene
  39405. * @returns the plane mesh
  39406. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39407. */
  39408. static CreatePlane(name: string, options: {
  39409. size?: number;
  39410. width?: number;
  39411. height?: number;
  39412. sideOrientation?: number;
  39413. frontUVs?: Vector4;
  39414. backUVs?: Vector4;
  39415. updatable?: boolean;
  39416. sourcePlane?: Plane;
  39417. }, scene?: Nullable<Scene>): Mesh;
  39418. }
  39419. }
  39420. declare module BABYLON {
  39421. /**
  39422. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39423. */
  39424. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39425. private static _AnyMouseID;
  39426. /**
  39427. * Abstract mesh the behavior is set on
  39428. */
  39429. attachedNode: AbstractMesh;
  39430. private _dragPlane;
  39431. private _scene;
  39432. private _pointerObserver;
  39433. private _beforeRenderObserver;
  39434. private static _planeScene;
  39435. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39436. /**
  39437. * 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)
  39438. */
  39439. maxDragAngle: number;
  39440. /**
  39441. * @hidden
  39442. */
  39443. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39444. /**
  39445. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39446. */
  39447. currentDraggingPointerID: number;
  39448. /**
  39449. * The last position where the pointer hit the drag plane in world space
  39450. */
  39451. lastDragPosition: Vector3;
  39452. /**
  39453. * If the behavior is currently in a dragging state
  39454. */
  39455. dragging: boolean;
  39456. /**
  39457. * 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)
  39458. */
  39459. dragDeltaRatio: number;
  39460. /**
  39461. * If the drag plane orientation should be updated during the dragging (Default: true)
  39462. */
  39463. updateDragPlane: boolean;
  39464. private _debugMode;
  39465. private _moving;
  39466. /**
  39467. * Fires each time the attached mesh is dragged with the pointer
  39468. * * delta between last drag position and current drag position in world space
  39469. * * dragDistance along the drag axis
  39470. * * dragPlaneNormal normal of the current drag plane used during the drag
  39471. * * dragPlanePoint in world space where the drag intersects the drag plane
  39472. */
  39473. onDragObservable: Observable<{
  39474. delta: Vector3;
  39475. dragPlanePoint: Vector3;
  39476. dragPlaneNormal: Vector3;
  39477. dragDistance: number;
  39478. pointerId: number;
  39479. }>;
  39480. /**
  39481. * Fires each time a drag begins (eg. mouse down on mesh)
  39482. */
  39483. onDragStartObservable: Observable<{
  39484. dragPlanePoint: Vector3;
  39485. pointerId: number;
  39486. }>;
  39487. /**
  39488. * Fires each time a drag ends (eg. mouse release after drag)
  39489. */
  39490. onDragEndObservable: Observable<{
  39491. dragPlanePoint: Vector3;
  39492. pointerId: number;
  39493. }>;
  39494. /**
  39495. * If the attached mesh should be moved when dragged
  39496. */
  39497. moveAttached: boolean;
  39498. /**
  39499. * If the drag behavior will react to drag events (Default: true)
  39500. */
  39501. enabled: boolean;
  39502. /**
  39503. * If pointer events should start and release the drag (Default: true)
  39504. */
  39505. startAndReleaseDragOnPointerEvents: boolean;
  39506. /**
  39507. * If camera controls should be detached during the drag
  39508. */
  39509. detachCameraControls: boolean;
  39510. /**
  39511. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39512. */
  39513. useObjectOrientationForDragging: boolean;
  39514. private _options;
  39515. /**
  39516. * Gets the options used by the behavior
  39517. */
  39518. get options(): {
  39519. dragAxis?: Vector3;
  39520. dragPlaneNormal?: Vector3;
  39521. };
  39522. /**
  39523. * Sets the options used by the behavior
  39524. */
  39525. set options(options: {
  39526. dragAxis?: Vector3;
  39527. dragPlaneNormal?: Vector3;
  39528. });
  39529. /**
  39530. * Creates a pointer drag behavior that can be attached to a mesh
  39531. * @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)
  39532. */
  39533. constructor(options?: {
  39534. dragAxis?: Vector3;
  39535. dragPlaneNormal?: Vector3;
  39536. });
  39537. /**
  39538. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39539. */
  39540. validateDrag: (targetPosition: Vector3) => boolean;
  39541. /**
  39542. * The name of the behavior
  39543. */
  39544. get name(): string;
  39545. /**
  39546. * Initializes the behavior
  39547. */
  39548. init(): void;
  39549. private _tmpVector;
  39550. private _alternatePickedPoint;
  39551. private _worldDragAxis;
  39552. private _targetPosition;
  39553. private _attachedElement;
  39554. /**
  39555. * Attaches the drag behavior the passed in mesh
  39556. * @param ownerNode The mesh that will be dragged around once attached
  39557. * @param predicate Predicate to use for pick filtering
  39558. */
  39559. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39560. /**
  39561. * Force relase the drag action by code.
  39562. */
  39563. releaseDrag(): void;
  39564. private _startDragRay;
  39565. private _lastPointerRay;
  39566. /**
  39567. * Simulates the start of a pointer drag event on the behavior
  39568. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39569. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39570. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39571. */
  39572. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39573. private _startDrag;
  39574. private _dragDelta;
  39575. private _moveDrag;
  39576. private _pickWithRayOnDragPlane;
  39577. private _pointA;
  39578. private _pointB;
  39579. private _pointC;
  39580. private _lineA;
  39581. private _lineB;
  39582. private _localAxis;
  39583. private _lookAt;
  39584. private _updateDragPlanePosition;
  39585. /**
  39586. * Detaches the behavior from the mesh
  39587. */
  39588. detach(): void;
  39589. }
  39590. }
  39591. declare module BABYLON {
  39592. /**
  39593. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39594. */
  39595. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39596. private _dragBehaviorA;
  39597. private _dragBehaviorB;
  39598. private _startDistance;
  39599. private _initialScale;
  39600. private _targetScale;
  39601. private _ownerNode;
  39602. private _sceneRenderObserver;
  39603. /**
  39604. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39605. */
  39606. constructor();
  39607. /**
  39608. * The name of the behavior
  39609. */
  39610. get name(): string;
  39611. /**
  39612. * Initializes the behavior
  39613. */
  39614. init(): void;
  39615. private _getCurrentDistance;
  39616. /**
  39617. * Attaches the scale behavior the passed in mesh
  39618. * @param ownerNode The mesh that will be scaled around once attached
  39619. */
  39620. attach(ownerNode: Mesh): void;
  39621. /**
  39622. * Detaches the behavior from the mesh
  39623. */
  39624. detach(): void;
  39625. }
  39626. }
  39627. declare module BABYLON {
  39628. /**
  39629. * 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
  39630. */
  39631. export class SixDofDragBehavior implements Behavior<Mesh> {
  39632. private static _virtualScene;
  39633. private _ownerNode;
  39634. private _sceneRenderObserver;
  39635. private _scene;
  39636. private _targetPosition;
  39637. private _virtualOriginMesh;
  39638. private _virtualDragMesh;
  39639. private _pointerObserver;
  39640. private _moving;
  39641. private _startingOrientation;
  39642. private _attachedElement;
  39643. /**
  39644. * 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)
  39645. */
  39646. private zDragFactor;
  39647. /**
  39648. * If the object should rotate to face the drag origin
  39649. */
  39650. rotateDraggedObject: boolean;
  39651. /**
  39652. * If the behavior is currently in a dragging state
  39653. */
  39654. dragging: boolean;
  39655. /**
  39656. * 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)
  39657. */
  39658. dragDeltaRatio: number;
  39659. /**
  39660. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39661. */
  39662. currentDraggingPointerID: number;
  39663. /**
  39664. * If camera controls should be detached during the drag
  39665. */
  39666. detachCameraControls: boolean;
  39667. /**
  39668. * Fires each time a drag starts
  39669. */
  39670. onDragStartObservable: Observable<{}>;
  39671. /**
  39672. * Fires each time a drag ends (eg. mouse release after drag)
  39673. */
  39674. onDragEndObservable: Observable<{}>;
  39675. /**
  39676. * 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
  39677. */
  39678. constructor();
  39679. /**
  39680. * The name of the behavior
  39681. */
  39682. get name(): string;
  39683. /**
  39684. * Initializes the behavior
  39685. */
  39686. init(): void;
  39687. /**
  39688. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39689. */
  39690. private get _pointerCamera();
  39691. /**
  39692. * Attaches the scale behavior the passed in mesh
  39693. * @param ownerNode The mesh that will be scaled around once attached
  39694. */
  39695. attach(ownerNode: Mesh): void;
  39696. /**
  39697. * Detaches the behavior from the mesh
  39698. */
  39699. detach(): void;
  39700. }
  39701. }
  39702. declare module BABYLON {
  39703. /**
  39704. * Class used to apply inverse kinematics to bones
  39705. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39706. */
  39707. export class BoneIKController {
  39708. private static _tmpVecs;
  39709. private static _tmpQuat;
  39710. private static _tmpMats;
  39711. /**
  39712. * Gets or sets the target mesh
  39713. */
  39714. targetMesh: AbstractMesh;
  39715. /** Gets or sets the mesh used as pole */
  39716. poleTargetMesh: AbstractMesh;
  39717. /**
  39718. * Gets or sets the bone used as pole
  39719. */
  39720. poleTargetBone: Nullable<Bone>;
  39721. /**
  39722. * Gets or sets the target position
  39723. */
  39724. targetPosition: Vector3;
  39725. /**
  39726. * Gets or sets the pole target position
  39727. */
  39728. poleTargetPosition: Vector3;
  39729. /**
  39730. * Gets or sets the pole target local offset
  39731. */
  39732. poleTargetLocalOffset: Vector3;
  39733. /**
  39734. * Gets or sets the pole angle
  39735. */
  39736. poleAngle: number;
  39737. /**
  39738. * Gets or sets the mesh associated with the controller
  39739. */
  39740. mesh: AbstractMesh;
  39741. /**
  39742. * 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)
  39743. */
  39744. slerpAmount: number;
  39745. private _bone1Quat;
  39746. private _bone1Mat;
  39747. private _bone2Ang;
  39748. private _bone1;
  39749. private _bone2;
  39750. private _bone1Length;
  39751. private _bone2Length;
  39752. private _maxAngle;
  39753. private _maxReach;
  39754. private _rightHandedSystem;
  39755. private _bendAxis;
  39756. private _slerping;
  39757. private _adjustRoll;
  39758. /**
  39759. * Gets or sets maximum allowed angle
  39760. */
  39761. get maxAngle(): number;
  39762. set maxAngle(value: number);
  39763. /**
  39764. * Creates a new BoneIKController
  39765. * @param mesh defines the mesh to control
  39766. * @param bone defines the bone to control
  39767. * @param options defines options to set up the controller
  39768. */
  39769. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39770. targetMesh?: AbstractMesh;
  39771. poleTargetMesh?: AbstractMesh;
  39772. poleTargetBone?: Bone;
  39773. poleTargetLocalOffset?: Vector3;
  39774. poleAngle?: number;
  39775. bendAxis?: Vector3;
  39776. maxAngle?: number;
  39777. slerpAmount?: number;
  39778. });
  39779. private _setMaxAngle;
  39780. /**
  39781. * Force the controller to update the bones
  39782. */
  39783. update(): void;
  39784. }
  39785. }
  39786. declare module BABYLON {
  39787. /**
  39788. * Class used to make a bone look toward a point in space
  39789. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39790. */
  39791. export class BoneLookController {
  39792. private static _tmpVecs;
  39793. private static _tmpQuat;
  39794. private static _tmpMats;
  39795. /**
  39796. * The target Vector3 that the bone will look at
  39797. */
  39798. target: Vector3;
  39799. /**
  39800. * The mesh that the bone is attached to
  39801. */
  39802. mesh: AbstractMesh;
  39803. /**
  39804. * The bone that will be looking to the target
  39805. */
  39806. bone: Bone;
  39807. /**
  39808. * The up axis of the coordinate system that is used when the bone is rotated
  39809. */
  39810. upAxis: Vector3;
  39811. /**
  39812. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39813. */
  39814. upAxisSpace: Space;
  39815. /**
  39816. * Used to make an adjustment to the yaw of the bone
  39817. */
  39818. adjustYaw: number;
  39819. /**
  39820. * Used to make an adjustment to the pitch of the bone
  39821. */
  39822. adjustPitch: number;
  39823. /**
  39824. * Used to make an adjustment to the roll of the bone
  39825. */
  39826. adjustRoll: number;
  39827. /**
  39828. * 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)
  39829. */
  39830. slerpAmount: number;
  39831. private _minYaw;
  39832. private _maxYaw;
  39833. private _minPitch;
  39834. private _maxPitch;
  39835. private _minYawSin;
  39836. private _minYawCos;
  39837. private _maxYawSin;
  39838. private _maxYawCos;
  39839. private _midYawConstraint;
  39840. private _minPitchTan;
  39841. private _maxPitchTan;
  39842. private _boneQuat;
  39843. private _slerping;
  39844. private _transformYawPitch;
  39845. private _transformYawPitchInv;
  39846. private _firstFrameSkipped;
  39847. private _yawRange;
  39848. private _fowardAxis;
  39849. /**
  39850. * Gets or sets the minimum yaw angle that the bone can look to
  39851. */
  39852. get minYaw(): number;
  39853. set minYaw(value: number);
  39854. /**
  39855. * Gets or sets the maximum yaw angle that the bone can look to
  39856. */
  39857. get maxYaw(): number;
  39858. set maxYaw(value: number);
  39859. /**
  39860. * Gets or sets the minimum pitch angle that the bone can look to
  39861. */
  39862. get minPitch(): number;
  39863. set minPitch(value: number);
  39864. /**
  39865. * Gets or sets the maximum pitch angle that the bone can look to
  39866. */
  39867. get maxPitch(): number;
  39868. set maxPitch(value: number);
  39869. /**
  39870. * Create a BoneLookController
  39871. * @param mesh the mesh that the bone belongs to
  39872. * @param bone the bone that will be looking to the target
  39873. * @param target the target Vector3 to look at
  39874. * @param options optional settings:
  39875. * * maxYaw: the maximum angle the bone will yaw to
  39876. * * minYaw: the minimum angle the bone will yaw to
  39877. * * maxPitch: the maximum angle the bone will pitch to
  39878. * * minPitch: the minimum angle the bone will yaw to
  39879. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39880. * * upAxis: the up axis of the coordinate system
  39881. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39882. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39883. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39884. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39885. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39886. * * adjustRoll: used to make an adjustment to the roll of the bone
  39887. **/
  39888. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39889. maxYaw?: number;
  39890. minYaw?: number;
  39891. maxPitch?: number;
  39892. minPitch?: number;
  39893. slerpAmount?: number;
  39894. upAxis?: Vector3;
  39895. upAxisSpace?: Space;
  39896. yawAxis?: Vector3;
  39897. pitchAxis?: Vector3;
  39898. adjustYaw?: number;
  39899. adjustPitch?: number;
  39900. adjustRoll?: number;
  39901. });
  39902. /**
  39903. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39904. */
  39905. update(): void;
  39906. private _getAngleDiff;
  39907. private _getAngleBetween;
  39908. private _isAngleBetween;
  39909. }
  39910. }
  39911. declare module BABYLON {
  39912. /**
  39913. * Manage the gamepad inputs to control an arc rotate camera.
  39914. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39915. */
  39916. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39917. /**
  39918. * Defines the camera the input is attached to.
  39919. */
  39920. camera: ArcRotateCamera;
  39921. /**
  39922. * Defines the gamepad the input is gathering event from.
  39923. */
  39924. gamepad: Nullable<Gamepad>;
  39925. /**
  39926. * Defines the gamepad rotation sensiblity.
  39927. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39928. */
  39929. gamepadRotationSensibility: number;
  39930. /**
  39931. * Defines the gamepad move sensiblity.
  39932. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39933. */
  39934. gamepadMoveSensibility: number;
  39935. private _yAxisScale;
  39936. /**
  39937. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39938. */
  39939. get invertYAxis(): boolean;
  39940. set invertYAxis(value: boolean);
  39941. private _onGamepadConnectedObserver;
  39942. private _onGamepadDisconnectedObserver;
  39943. /**
  39944. * Attach the input controls to a specific dom element to get the input from.
  39945. * @param element Defines the element the controls should be listened from
  39946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39947. */
  39948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39949. /**
  39950. * Detach the current controls from the specified dom element.
  39951. * @param element Defines the element to stop listening the inputs from
  39952. */
  39953. detachControl(element: Nullable<HTMLElement>): void;
  39954. /**
  39955. * Update the current camera state depending on the inputs that have been used this frame.
  39956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39957. */
  39958. checkInputs(): void;
  39959. /**
  39960. * Gets the class name of the current intput.
  39961. * @returns the class name
  39962. */
  39963. getClassName(): string;
  39964. /**
  39965. * Get the friendly name associated with the input class.
  39966. * @returns the input friendly name
  39967. */
  39968. getSimpleName(): string;
  39969. }
  39970. }
  39971. declare module BABYLON {
  39972. interface ArcRotateCameraInputsManager {
  39973. /**
  39974. * Add orientation input support to the input manager.
  39975. * @returns the current input manager
  39976. */
  39977. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39978. }
  39979. /**
  39980. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39982. */
  39983. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39984. /**
  39985. * Defines the camera the input is attached to.
  39986. */
  39987. camera: ArcRotateCamera;
  39988. /**
  39989. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39990. */
  39991. alphaCorrection: number;
  39992. /**
  39993. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39994. */
  39995. gammaCorrection: number;
  39996. private _alpha;
  39997. private _gamma;
  39998. private _dirty;
  39999. private _deviceOrientationHandler;
  40000. /**
  40001. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40002. */
  40003. constructor();
  40004. /**
  40005. * Attach the input controls to a specific dom element to get the input from.
  40006. * @param element Defines the element the controls should be listened from
  40007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40008. */
  40009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40010. /** @hidden */
  40011. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40012. /**
  40013. * Update the current camera state depending on the inputs that have been used this frame.
  40014. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40015. */
  40016. checkInputs(): void;
  40017. /**
  40018. * Detach the current controls from the specified dom element.
  40019. * @param element Defines the element to stop listening the inputs from
  40020. */
  40021. detachControl(element: Nullable<HTMLElement>): void;
  40022. /**
  40023. * Gets the class name of the current intput.
  40024. * @returns the class name
  40025. */
  40026. getClassName(): string;
  40027. /**
  40028. * Get the friendly name associated with the input class.
  40029. * @returns the input friendly name
  40030. */
  40031. getSimpleName(): string;
  40032. }
  40033. }
  40034. declare module BABYLON {
  40035. /**
  40036. * Listen to mouse events to control the camera.
  40037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40038. */
  40039. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40040. /**
  40041. * Defines the camera the input is attached to.
  40042. */
  40043. camera: FlyCamera;
  40044. /**
  40045. * Defines if touch is enabled. (Default is true.)
  40046. */
  40047. touchEnabled: boolean;
  40048. /**
  40049. * Defines the buttons associated with the input to handle camera rotation.
  40050. */
  40051. buttons: number[];
  40052. /**
  40053. * Assign buttons for Yaw control.
  40054. */
  40055. buttonsYaw: number[];
  40056. /**
  40057. * Assign buttons for Pitch control.
  40058. */
  40059. buttonsPitch: number[];
  40060. /**
  40061. * Assign buttons for Roll control.
  40062. */
  40063. buttonsRoll: number[];
  40064. /**
  40065. * Detect if any button is being pressed while mouse is moved.
  40066. * -1 = Mouse locked.
  40067. * 0 = Left button.
  40068. * 1 = Middle Button.
  40069. * 2 = Right Button.
  40070. */
  40071. activeButton: number;
  40072. /**
  40073. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40074. * Higher values reduce its sensitivity.
  40075. */
  40076. angularSensibility: number;
  40077. private _mousemoveCallback;
  40078. private _observer;
  40079. private _rollObserver;
  40080. private previousPosition;
  40081. private noPreventDefault;
  40082. private element;
  40083. /**
  40084. * Listen to mouse events to control the camera.
  40085. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40087. */
  40088. constructor(touchEnabled?: boolean);
  40089. /**
  40090. * Attach the mouse control to the HTML DOM element.
  40091. * @param element Defines the element that listens to the input events.
  40092. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40093. */
  40094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40095. /**
  40096. * Detach the current controls from the specified dom element.
  40097. * @param element Defines the element to stop listening the inputs from
  40098. */
  40099. detachControl(element: Nullable<HTMLElement>): void;
  40100. /**
  40101. * Gets the class name of the current input.
  40102. * @returns the class name.
  40103. */
  40104. getClassName(): string;
  40105. /**
  40106. * Get the friendly name associated with the input class.
  40107. * @returns the input's friendly name.
  40108. */
  40109. getSimpleName(): string;
  40110. private _pointerInput;
  40111. private _onMouseMove;
  40112. /**
  40113. * Rotate camera by mouse offset.
  40114. */
  40115. private rotateCamera;
  40116. }
  40117. }
  40118. declare module BABYLON {
  40119. /**
  40120. * Default Inputs manager for the FlyCamera.
  40121. * It groups all the default supported inputs for ease of use.
  40122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40123. */
  40124. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40125. /**
  40126. * Instantiates a new FlyCameraInputsManager.
  40127. * @param camera Defines the camera the inputs belong to.
  40128. */
  40129. constructor(camera: FlyCamera);
  40130. /**
  40131. * Add keyboard input support to the input manager.
  40132. * @returns the new FlyCameraKeyboardMoveInput().
  40133. */
  40134. addKeyboard(): FlyCameraInputsManager;
  40135. /**
  40136. * Add mouse input support to the input manager.
  40137. * @param touchEnabled Enable touch screen support.
  40138. * @returns the new FlyCameraMouseInput().
  40139. */
  40140. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40141. }
  40142. }
  40143. declare module BABYLON {
  40144. /**
  40145. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40146. * such as in a 3D Space Shooter or a Flight Simulator.
  40147. */
  40148. export class FlyCamera extends TargetCamera {
  40149. /**
  40150. * Define the collision ellipsoid of the camera.
  40151. * This is helpful for simulating a camera body, like a player's body.
  40152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40153. */
  40154. ellipsoid: Vector3;
  40155. /**
  40156. * Define an offset for the position of the ellipsoid around the camera.
  40157. * This can be helpful if the camera is attached away from the player's body center,
  40158. * such as at its head.
  40159. */
  40160. ellipsoidOffset: Vector3;
  40161. /**
  40162. * Enable or disable collisions of the camera with the rest of the scene objects.
  40163. */
  40164. checkCollisions: boolean;
  40165. /**
  40166. * Enable or disable gravity on the camera.
  40167. */
  40168. applyGravity: boolean;
  40169. /**
  40170. * Define the current direction the camera is moving to.
  40171. */
  40172. cameraDirection: Vector3;
  40173. /**
  40174. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40175. * This overrides and empties cameraRotation.
  40176. */
  40177. rotationQuaternion: Quaternion;
  40178. /**
  40179. * Track Roll to maintain the wanted Rolling when looking around.
  40180. */
  40181. _trackRoll: number;
  40182. /**
  40183. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40184. */
  40185. rollCorrect: number;
  40186. /**
  40187. * Mimic a banked turn, Rolling the camera when Yawing.
  40188. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40189. */
  40190. bankedTurn: boolean;
  40191. /**
  40192. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40193. */
  40194. bankedTurnLimit: number;
  40195. /**
  40196. * Value of 0 disables the banked Roll.
  40197. * Value of 1 is equal to the Yaw angle in radians.
  40198. */
  40199. bankedTurnMultiplier: number;
  40200. /**
  40201. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40202. */
  40203. inputs: FlyCameraInputsManager;
  40204. /**
  40205. * Gets the input sensibility for mouse input.
  40206. * Higher values reduce sensitivity.
  40207. */
  40208. get angularSensibility(): number;
  40209. /**
  40210. * Sets the input sensibility for a mouse input.
  40211. * Higher values reduce sensitivity.
  40212. */
  40213. set angularSensibility(value: number);
  40214. /**
  40215. * Get the keys for camera movement forward.
  40216. */
  40217. get keysForward(): number[];
  40218. /**
  40219. * Set the keys for camera movement forward.
  40220. */
  40221. set keysForward(value: number[]);
  40222. /**
  40223. * Get the keys for camera movement backward.
  40224. */
  40225. get keysBackward(): number[];
  40226. set keysBackward(value: number[]);
  40227. /**
  40228. * Get the keys for camera movement up.
  40229. */
  40230. get keysUp(): number[];
  40231. /**
  40232. * Set the keys for camera movement up.
  40233. */
  40234. set keysUp(value: number[]);
  40235. /**
  40236. * Get the keys for camera movement down.
  40237. */
  40238. get keysDown(): number[];
  40239. /**
  40240. * Set the keys for camera movement down.
  40241. */
  40242. set keysDown(value: number[]);
  40243. /**
  40244. * Get the keys for camera movement left.
  40245. */
  40246. get keysLeft(): number[];
  40247. /**
  40248. * Set the keys for camera movement left.
  40249. */
  40250. set keysLeft(value: number[]);
  40251. /**
  40252. * Set the keys for camera movement right.
  40253. */
  40254. get keysRight(): number[];
  40255. /**
  40256. * Set the keys for camera movement right.
  40257. */
  40258. set keysRight(value: number[]);
  40259. /**
  40260. * Event raised when the camera collides with a mesh in the scene.
  40261. */
  40262. onCollide: (collidedMesh: AbstractMesh) => void;
  40263. private _collider;
  40264. private _needMoveForGravity;
  40265. private _oldPosition;
  40266. private _diffPosition;
  40267. private _newPosition;
  40268. /** @hidden */
  40269. _localDirection: Vector3;
  40270. /** @hidden */
  40271. _transformedDirection: Vector3;
  40272. /**
  40273. * Instantiates a FlyCamera.
  40274. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40275. * such as in a 3D Space Shooter or a Flight Simulator.
  40276. * @param name Define the name of the camera in the scene.
  40277. * @param position Define the starting position of the camera in the scene.
  40278. * @param scene Define the scene the camera belongs to.
  40279. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40280. */
  40281. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40282. /**
  40283. * Attach a control to the HTML DOM element.
  40284. * @param element Defines the element that listens to the input events.
  40285. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40286. */
  40287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40288. /**
  40289. * Detach a control from the HTML DOM element.
  40290. * The camera will stop reacting to that input.
  40291. * @param element Defines the element that listens to the input events.
  40292. */
  40293. detachControl(element: HTMLElement): void;
  40294. private _collisionMask;
  40295. /**
  40296. * Get the mask that the camera ignores in collision events.
  40297. */
  40298. get collisionMask(): number;
  40299. /**
  40300. * Set the mask that the camera ignores in collision events.
  40301. */
  40302. set collisionMask(mask: number);
  40303. /** @hidden */
  40304. _collideWithWorld(displacement: Vector3): void;
  40305. /** @hidden */
  40306. private _onCollisionPositionChange;
  40307. /** @hidden */
  40308. _checkInputs(): void;
  40309. /** @hidden */
  40310. _decideIfNeedsToMove(): boolean;
  40311. /** @hidden */
  40312. _updatePosition(): void;
  40313. /**
  40314. * Restore the Roll to its target value at the rate specified.
  40315. * @param rate - Higher means slower restoring.
  40316. * @hidden
  40317. */
  40318. restoreRoll(rate: number): void;
  40319. /**
  40320. * Destroy the camera and release the current resources held by it.
  40321. */
  40322. dispose(): void;
  40323. /**
  40324. * Get the current object class name.
  40325. * @returns the class name.
  40326. */
  40327. getClassName(): string;
  40328. }
  40329. }
  40330. declare module BABYLON {
  40331. /**
  40332. * Listen to keyboard events to control the camera.
  40333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40334. */
  40335. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40336. /**
  40337. * Defines the camera the input is attached to.
  40338. */
  40339. camera: FlyCamera;
  40340. /**
  40341. * The list of keyboard keys used to control the forward move of the camera.
  40342. */
  40343. keysForward: number[];
  40344. /**
  40345. * The list of keyboard keys used to control the backward move of the camera.
  40346. */
  40347. keysBackward: number[];
  40348. /**
  40349. * The list of keyboard keys used to control the forward move of the camera.
  40350. */
  40351. keysUp: number[];
  40352. /**
  40353. * The list of keyboard keys used to control the backward move of the camera.
  40354. */
  40355. keysDown: number[];
  40356. /**
  40357. * The list of keyboard keys used to control the right strafe move of the camera.
  40358. */
  40359. keysRight: number[];
  40360. /**
  40361. * The list of keyboard keys used to control the left strafe move of the camera.
  40362. */
  40363. keysLeft: number[];
  40364. private _keys;
  40365. private _onCanvasBlurObserver;
  40366. private _onKeyboardObserver;
  40367. private _engine;
  40368. private _scene;
  40369. /**
  40370. * Attach the input controls to a specific dom element to get the input from.
  40371. * @param element Defines the element the controls should be listened from
  40372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40373. */
  40374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40375. /**
  40376. * Detach the current controls from the specified dom element.
  40377. * @param element Defines the element to stop listening the inputs from
  40378. */
  40379. detachControl(element: Nullable<HTMLElement>): void;
  40380. /**
  40381. * Gets the class name of the current intput.
  40382. * @returns the class name
  40383. */
  40384. getClassName(): string;
  40385. /** @hidden */
  40386. _onLostFocus(e: FocusEvent): void;
  40387. /**
  40388. * Get the friendly name associated with the input class.
  40389. * @returns the input friendly name
  40390. */
  40391. getSimpleName(): string;
  40392. /**
  40393. * Update the current camera state depending on the inputs that have been used this frame.
  40394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40395. */
  40396. checkInputs(): void;
  40397. }
  40398. }
  40399. declare module BABYLON {
  40400. /**
  40401. * Manage the mouse wheel inputs to control a follow camera.
  40402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40403. */
  40404. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40405. /**
  40406. * Defines the camera the input is attached to.
  40407. */
  40408. camera: FollowCamera;
  40409. /**
  40410. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40411. */
  40412. axisControlRadius: boolean;
  40413. /**
  40414. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40415. */
  40416. axisControlHeight: boolean;
  40417. /**
  40418. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40419. */
  40420. axisControlRotation: boolean;
  40421. /**
  40422. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40423. * relation to mouseWheel events.
  40424. */
  40425. wheelPrecision: number;
  40426. /**
  40427. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40428. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40429. */
  40430. wheelDeltaPercentage: number;
  40431. private _wheel;
  40432. private _observer;
  40433. /**
  40434. * Attach the input controls to a specific dom element to get the input from.
  40435. * @param element Defines the element the controls should be listened from
  40436. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40437. */
  40438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40439. /**
  40440. * Detach the current controls from the specified dom element.
  40441. * @param element Defines the element to stop listening the inputs from
  40442. */
  40443. detachControl(element: Nullable<HTMLElement>): void;
  40444. /**
  40445. * Gets the class name of the current intput.
  40446. * @returns the class name
  40447. */
  40448. getClassName(): string;
  40449. /**
  40450. * Get the friendly name associated with the input class.
  40451. * @returns the input friendly name
  40452. */
  40453. getSimpleName(): string;
  40454. }
  40455. }
  40456. declare module BABYLON {
  40457. /**
  40458. * Manage the pointers inputs to control an follow camera.
  40459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40460. */
  40461. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40462. /**
  40463. * Defines the camera the input is attached to.
  40464. */
  40465. camera: FollowCamera;
  40466. /**
  40467. * Gets the class name of the current input.
  40468. * @returns the class name
  40469. */
  40470. getClassName(): string;
  40471. /**
  40472. * Defines the pointer angular sensibility along the X axis or how fast is
  40473. * the camera rotating.
  40474. * A negative number will reverse the axis direction.
  40475. */
  40476. angularSensibilityX: number;
  40477. /**
  40478. * Defines the pointer angular sensibility along the Y axis or how fast is
  40479. * the camera rotating.
  40480. * A negative number will reverse the axis direction.
  40481. */
  40482. angularSensibilityY: number;
  40483. /**
  40484. * Defines the pointer pinch precision or how fast is the camera zooming.
  40485. * A negative number will reverse the axis direction.
  40486. */
  40487. pinchPrecision: number;
  40488. /**
  40489. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40490. * from 0.
  40491. * It defines the percentage of current camera.radius to use as delta when
  40492. * pinch zoom is used.
  40493. */
  40494. pinchDeltaPercentage: number;
  40495. /**
  40496. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40497. */
  40498. axisXControlRadius: boolean;
  40499. /**
  40500. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40501. */
  40502. axisXControlHeight: boolean;
  40503. /**
  40504. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40505. */
  40506. axisXControlRotation: boolean;
  40507. /**
  40508. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40509. */
  40510. axisYControlRadius: boolean;
  40511. /**
  40512. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40513. */
  40514. axisYControlHeight: boolean;
  40515. /**
  40516. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40517. */
  40518. axisYControlRotation: boolean;
  40519. /**
  40520. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40521. */
  40522. axisPinchControlRadius: boolean;
  40523. /**
  40524. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40525. */
  40526. axisPinchControlHeight: boolean;
  40527. /**
  40528. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40529. */
  40530. axisPinchControlRotation: boolean;
  40531. /**
  40532. * Log error messages if basic misconfiguration has occurred.
  40533. */
  40534. warningEnable: boolean;
  40535. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40536. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40537. private _warningCounter;
  40538. private _warning;
  40539. }
  40540. }
  40541. declare module BABYLON {
  40542. /**
  40543. * Default Inputs manager for the FollowCamera.
  40544. * It groups all the default supported inputs for ease of use.
  40545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40546. */
  40547. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40548. /**
  40549. * Instantiates a new FollowCameraInputsManager.
  40550. * @param camera Defines the camera the inputs belong to
  40551. */
  40552. constructor(camera: FollowCamera);
  40553. /**
  40554. * Add keyboard input support to the input manager.
  40555. * @returns the current input manager
  40556. */
  40557. addKeyboard(): FollowCameraInputsManager;
  40558. /**
  40559. * Add mouse wheel input support to the input manager.
  40560. * @returns the current input manager
  40561. */
  40562. addMouseWheel(): FollowCameraInputsManager;
  40563. /**
  40564. * Add pointers input support to the input manager.
  40565. * @returns the current input manager
  40566. */
  40567. addPointers(): FollowCameraInputsManager;
  40568. /**
  40569. * Add orientation input support to the input manager.
  40570. * @returns the current input manager
  40571. */
  40572. addVRDeviceOrientation(): FollowCameraInputsManager;
  40573. }
  40574. }
  40575. declare module BABYLON {
  40576. /**
  40577. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40578. * an arc rotate version arcFollowCamera are available.
  40579. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40580. */
  40581. export class FollowCamera extends TargetCamera {
  40582. /**
  40583. * Distance the follow camera should follow an object at
  40584. */
  40585. radius: number;
  40586. /**
  40587. * Minimum allowed distance of the camera to the axis of rotation
  40588. * (The camera can not get closer).
  40589. * This can help limiting how the Camera is able to move in the scene.
  40590. */
  40591. lowerRadiusLimit: Nullable<number>;
  40592. /**
  40593. * Maximum allowed distance of the camera to the axis of rotation
  40594. * (The camera can not get further).
  40595. * This can help limiting how the Camera is able to move in the scene.
  40596. */
  40597. upperRadiusLimit: Nullable<number>;
  40598. /**
  40599. * Define a rotation offset between the camera and the object it follows
  40600. */
  40601. rotationOffset: number;
  40602. /**
  40603. * Minimum allowed angle to camera position relative to target object.
  40604. * This can help limiting how the Camera is able to move in the scene.
  40605. */
  40606. lowerRotationOffsetLimit: Nullable<number>;
  40607. /**
  40608. * Maximum allowed angle to camera position relative to target object.
  40609. * This can help limiting how the Camera is able to move in the scene.
  40610. */
  40611. upperRotationOffsetLimit: Nullable<number>;
  40612. /**
  40613. * Define a height offset between the camera and the object it follows.
  40614. * It can help following an object from the top (like a car chaing a plane)
  40615. */
  40616. heightOffset: number;
  40617. /**
  40618. * Minimum allowed height of camera position relative to target object.
  40619. * This can help limiting how the Camera is able to move in the scene.
  40620. */
  40621. lowerHeightOffsetLimit: Nullable<number>;
  40622. /**
  40623. * Maximum allowed height of camera position relative to target object.
  40624. * This can help limiting how the Camera is able to move in the scene.
  40625. */
  40626. upperHeightOffsetLimit: Nullable<number>;
  40627. /**
  40628. * Define how fast the camera can accelerate to follow it s target.
  40629. */
  40630. cameraAcceleration: number;
  40631. /**
  40632. * Define the speed limit of the camera following an object.
  40633. */
  40634. maxCameraSpeed: number;
  40635. /**
  40636. * Define the target of the camera.
  40637. */
  40638. lockedTarget: Nullable<AbstractMesh>;
  40639. /**
  40640. * Defines the input associated with the camera.
  40641. */
  40642. inputs: FollowCameraInputsManager;
  40643. /**
  40644. * Instantiates the follow camera.
  40645. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40646. * @param name Define the name of the camera in the scene
  40647. * @param position Define the position of the camera
  40648. * @param scene Define the scene the camera belong to
  40649. * @param lockedTarget Define the target of the camera
  40650. */
  40651. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40652. private _follow;
  40653. /**
  40654. * Attached controls to the current camera.
  40655. * @param element Defines the element the controls should be listened from
  40656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40657. */
  40658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40659. /**
  40660. * Detach the current controls from the camera.
  40661. * The camera will stop reacting to inputs.
  40662. * @param element Defines the element to stop listening the inputs from
  40663. */
  40664. detachControl(element: HTMLElement): void;
  40665. /** @hidden */
  40666. _checkInputs(): void;
  40667. private _checkLimits;
  40668. /**
  40669. * Gets the camera class name.
  40670. * @returns the class name
  40671. */
  40672. getClassName(): string;
  40673. }
  40674. /**
  40675. * Arc Rotate version of the follow camera.
  40676. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40677. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40678. */
  40679. export class ArcFollowCamera extends TargetCamera {
  40680. /** The longitudinal angle of the camera */
  40681. alpha: number;
  40682. /** The latitudinal angle of the camera */
  40683. beta: number;
  40684. /** The radius of the camera from its target */
  40685. radius: number;
  40686. /** Define the camera target (the messh it should follow) */
  40687. target: Nullable<AbstractMesh>;
  40688. private _cartesianCoordinates;
  40689. /**
  40690. * Instantiates a new ArcFollowCamera
  40691. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40692. * @param name Define the name of the camera
  40693. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40694. * @param beta Define the rotation angle of the camera around the elevation axis
  40695. * @param radius Define the radius of the camera from its target point
  40696. * @param target Define the target of the camera
  40697. * @param scene Define the scene the camera belongs to
  40698. */
  40699. constructor(name: string,
  40700. /** The longitudinal angle of the camera */
  40701. alpha: number,
  40702. /** The latitudinal angle of the camera */
  40703. beta: number,
  40704. /** The radius of the camera from its target */
  40705. radius: number,
  40706. /** Define the camera target (the messh it should follow) */
  40707. target: Nullable<AbstractMesh>, scene: Scene);
  40708. private _follow;
  40709. /** @hidden */
  40710. _checkInputs(): void;
  40711. /**
  40712. * Returns the class name of the object.
  40713. * It is mostly used internally for serialization purposes.
  40714. */
  40715. getClassName(): string;
  40716. }
  40717. }
  40718. declare module BABYLON {
  40719. /**
  40720. * Manage the keyboard inputs to control the movement of a follow camera.
  40721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40722. */
  40723. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40724. /**
  40725. * Defines the camera the input is attached to.
  40726. */
  40727. camera: FollowCamera;
  40728. /**
  40729. * Defines the list of key codes associated with the up action (increase heightOffset)
  40730. */
  40731. keysHeightOffsetIncr: number[];
  40732. /**
  40733. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40734. */
  40735. keysHeightOffsetDecr: number[];
  40736. /**
  40737. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40738. */
  40739. keysHeightOffsetModifierAlt: boolean;
  40740. /**
  40741. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40742. */
  40743. keysHeightOffsetModifierCtrl: boolean;
  40744. /**
  40745. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40746. */
  40747. keysHeightOffsetModifierShift: boolean;
  40748. /**
  40749. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40750. */
  40751. keysRotationOffsetIncr: number[];
  40752. /**
  40753. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40754. */
  40755. keysRotationOffsetDecr: number[];
  40756. /**
  40757. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40758. */
  40759. keysRotationOffsetModifierAlt: boolean;
  40760. /**
  40761. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40762. */
  40763. keysRotationOffsetModifierCtrl: boolean;
  40764. /**
  40765. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40766. */
  40767. keysRotationOffsetModifierShift: boolean;
  40768. /**
  40769. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40770. */
  40771. keysRadiusIncr: number[];
  40772. /**
  40773. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40774. */
  40775. keysRadiusDecr: number[];
  40776. /**
  40777. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40778. */
  40779. keysRadiusModifierAlt: boolean;
  40780. /**
  40781. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40782. */
  40783. keysRadiusModifierCtrl: boolean;
  40784. /**
  40785. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40786. */
  40787. keysRadiusModifierShift: boolean;
  40788. /**
  40789. * Defines the rate of change of heightOffset.
  40790. */
  40791. heightSensibility: number;
  40792. /**
  40793. * Defines the rate of change of rotationOffset.
  40794. */
  40795. rotationSensibility: number;
  40796. /**
  40797. * Defines the rate of change of radius.
  40798. */
  40799. radiusSensibility: number;
  40800. private _keys;
  40801. private _ctrlPressed;
  40802. private _altPressed;
  40803. private _shiftPressed;
  40804. private _onCanvasBlurObserver;
  40805. private _onKeyboardObserver;
  40806. private _engine;
  40807. private _scene;
  40808. /**
  40809. * Attach the input controls to a specific dom element to get the input from.
  40810. * @param element Defines the element the controls should be listened from
  40811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40812. */
  40813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40814. /**
  40815. * Detach the current controls from the specified dom element.
  40816. * @param element Defines the element to stop listening the inputs from
  40817. */
  40818. detachControl(element: Nullable<HTMLElement>): void;
  40819. /**
  40820. * Update the current camera state depending on the inputs that have been used this frame.
  40821. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40822. */
  40823. checkInputs(): void;
  40824. /**
  40825. * Gets the class name of the current input.
  40826. * @returns the class name
  40827. */
  40828. getClassName(): string;
  40829. /**
  40830. * Get the friendly name associated with the input class.
  40831. * @returns the input friendly name
  40832. */
  40833. getSimpleName(): string;
  40834. /**
  40835. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40836. * allow modification of the heightOffset value.
  40837. */
  40838. private _modifierHeightOffset;
  40839. /**
  40840. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40841. * allow modification of the rotationOffset value.
  40842. */
  40843. private _modifierRotationOffset;
  40844. /**
  40845. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40846. * allow modification of the radius value.
  40847. */
  40848. private _modifierRadius;
  40849. }
  40850. }
  40851. declare module BABYLON {
  40852. interface FreeCameraInputsManager {
  40853. /**
  40854. * @hidden
  40855. */
  40856. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40857. /**
  40858. * Add orientation input support to the input manager.
  40859. * @returns the current input manager
  40860. */
  40861. addDeviceOrientation(): FreeCameraInputsManager;
  40862. }
  40863. /**
  40864. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40865. * Screen rotation is taken into account.
  40866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40867. */
  40868. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40869. private _camera;
  40870. private _screenOrientationAngle;
  40871. private _constantTranform;
  40872. private _screenQuaternion;
  40873. private _alpha;
  40874. private _beta;
  40875. private _gamma;
  40876. /**
  40877. * Can be used to detect if a device orientation sensor is available on a device
  40878. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40879. * @returns a promise that will resolve on orientation change
  40880. */
  40881. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40882. /**
  40883. * @hidden
  40884. */
  40885. _onDeviceOrientationChangedObservable: Observable<void>;
  40886. /**
  40887. * Instantiates a new input
  40888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40889. */
  40890. constructor();
  40891. /**
  40892. * Define the camera controlled by the input.
  40893. */
  40894. get camera(): FreeCamera;
  40895. set camera(camera: FreeCamera);
  40896. /**
  40897. * Attach the input controls to a specific dom element to get the input from.
  40898. * @param element Defines the element the controls should be listened from
  40899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40900. */
  40901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40902. private _orientationChanged;
  40903. private _deviceOrientation;
  40904. /**
  40905. * Detach the current controls from the specified dom element.
  40906. * @param element Defines the element to stop listening the inputs from
  40907. */
  40908. detachControl(element: Nullable<HTMLElement>): void;
  40909. /**
  40910. * Update the current camera state depending on the inputs that have been used this frame.
  40911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40912. */
  40913. checkInputs(): void;
  40914. /**
  40915. * Gets the class name of the current intput.
  40916. * @returns the class name
  40917. */
  40918. getClassName(): string;
  40919. /**
  40920. * Get the friendly name associated with the input class.
  40921. * @returns the input friendly name
  40922. */
  40923. getSimpleName(): string;
  40924. }
  40925. }
  40926. declare module BABYLON {
  40927. /**
  40928. * Manage the gamepad inputs to control a free camera.
  40929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40930. */
  40931. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40932. /**
  40933. * Define the camera the input is attached to.
  40934. */
  40935. camera: FreeCamera;
  40936. /**
  40937. * Define the Gamepad controlling the input
  40938. */
  40939. gamepad: Nullable<Gamepad>;
  40940. /**
  40941. * Defines the gamepad rotation sensiblity.
  40942. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40943. */
  40944. gamepadAngularSensibility: number;
  40945. /**
  40946. * Defines the gamepad move sensiblity.
  40947. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40948. */
  40949. gamepadMoveSensibility: number;
  40950. private _yAxisScale;
  40951. /**
  40952. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40953. */
  40954. get invertYAxis(): boolean;
  40955. set invertYAxis(value: boolean);
  40956. private _onGamepadConnectedObserver;
  40957. private _onGamepadDisconnectedObserver;
  40958. private _cameraTransform;
  40959. private _deltaTransform;
  40960. private _vector3;
  40961. private _vector2;
  40962. /**
  40963. * Attach the input controls to a specific dom element to get the input from.
  40964. * @param element Defines the element the controls should be listened from
  40965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40966. */
  40967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40968. /**
  40969. * Detach the current controls from the specified dom element.
  40970. * @param element Defines the element to stop listening the inputs from
  40971. */
  40972. detachControl(element: Nullable<HTMLElement>): void;
  40973. /**
  40974. * Update the current camera state depending on the inputs that have been used this frame.
  40975. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40976. */
  40977. checkInputs(): void;
  40978. /**
  40979. * Gets the class name of the current intput.
  40980. * @returns the class name
  40981. */
  40982. getClassName(): string;
  40983. /**
  40984. * Get the friendly name associated with the input class.
  40985. * @returns the input friendly name
  40986. */
  40987. getSimpleName(): string;
  40988. }
  40989. }
  40990. declare module BABYLON {
  40991. /**
  40992. * Defines the potential axis of a Joystick
  40993. */
  40994. export enum JoystickAxis {
  40995. /** X axis */
  40996. X = 0,
  40997. /** Y axis */
  40998. Y = 1,
  40999. /** Z axis */
  41000. Z = 2
  41001. }
  41002. /**
  41003. * Class used to define virtual joystick (used in touch mode)
  41004. */
  41005. export class VirtualJoystick {
  41006. /**
  41007. * Gets or sets a boolean indicating that left and right values must be inverted
  41008. */
  41009. reverseLeftRight: boolean;
  41010. /**
  41011. * Gets or sets a boolean indicating that up and down values must be inverted
  41012. */
  41013. reverseUpDown: boolean;
  41014. /**
  41015. * Gets the offset value for the position (ie. the change of the position value)
  41016. */
  41017. deltaPosition: Vector3;
  41018. /**
  41019. * Gets a boolean indicating if the virtual joystick was pressed
  41020. */
  41021. pressed: boolean;
  41022. /**
  41023. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41024. */
  41025. static Canvas: Nullable<HTMLCanvasElement>;
  41026. private static _globalJoystickIndex;
  41027. private static vjCanvasContext;
  41028. private static vjCanvasWidth;
  41029. private static vjCanvasHeight;
  41030. private static halfWidth;
  41031. private _action;
  41032. private _axisTargetedByLeftAndRight;
  41033. private _axisTargetedByUpAndDown;
  41034. private _joystickSensibility;
  41035. private _inversedSensibility;
  41036. private _joystickPointerID;
  41037. private _joystickColor;
  41038. private _joystickPointerPos;
  41039. private _joystickPreviousPointerPos;
  41040. private _joystickPointerStartPos;
  41041. private _deltaJoystickVector;
  41042. private _leftJoystick;
  41043. private _touches;
  41044. private _onPointerDownHandlerRef;
  41045. private _onPointerMoveHandlerRef;
  41046. private _onPointerUpHandlerRef;
  41047. private _onResize;
  41048. /**
  41049. * Creates a new virtual joystick
  41050. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41051. */
  41052. constructor(leftJoystick?: boolean);
  41053. /**
  41054. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41055. * @param newJoystickSensibility defines the new sensibility
  41056. */
  41057. setJoystickSensibility(newJoystickSensibility: number): void;
  41058. private _onPointerDown;
  41059. private _onPointerMove;
  41060. private _onPointerUp;
  41061. /**
  41062. * Change the color of the virtual joystick
  41063. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41064. */
  41065. setJoystickColor(newColor: string): void;
  41066. /**
  41067. * Defines a callback to call when the joystick is touched
  41068. * @param action defines the callback
  41069. */
  41070. setActionOnTouch(action: () => any): void;
  41071. /**
  41072. * Defines which axis you'd like to control for left & right
  41073. * @param axis defines the axis to use
  41074. */
  41075. setAxisForLeftRight(axis: JoystickAxis): void;
  41076. /**
  41077. * Defines which axis you'd like to control for up & down
  41078. * @param axis defines the axis to use
  41079. */
  41080. setAxisForUpDown(axis: JoystickAxis): void;
  41081. private _drawVirtualJoystick;
  41082. /**
  41083. * Release internal HTML canvas
  41084. */
  41085. releaseCanvas(): void;
  41086. }
  41087. }
  41088. declare module BABYLON {
  41089. interface FreeCameraInputsManager {
  41090. /**
  41091. * Add virtual joystick input support to the input manager.
  41092. * @returns the current input manager
  41093. */
  41094. addVirtualJoystick(): FreeCameraInputsManager;
  41095. }
  41096. /**
  41097. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41099. */
  41100. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41101. /**
  41102. * Defines the camera the input is attached to.
  41103. */
  41104. camera: FreeCamera;
  41105. private _leftjoystick;
  41106. private _rightjoystick;
  41107. /**
  41108. * Gets the left stick of the virtual joystick.
  41109. * @returns The virtual Joystick
  41110. */
  41111. getLeftJoystick(): VirtualJoystick;
  41112. /**
  41113. * Gets the right stick of the virtual joystick.
  41114. * @returns The virtual Joystick
  41115. */
  41116. getRightJoystick(): VirtualJoystick;
  41117. /**
  41118. * Update the current camera state depending on the inputs that have been used this frame.
  41119. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41120. */
  41121. checkInputs(): void;
  41122. /**
  41123. * Attach the input controls to a specific dom element to get the input from.
  41124. * @param element Defines the element the controls should be listened from
  41125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41126. */
  41127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41128. /**
  41129. * Detach the current controls from the specified dom element.
  41130. * @param element Defines the element to stop listening the inputs from
  41131. */
  41132. detachControl(element: Nullable<HTMLElement>): void;
  41133. /**
  41134. * Gets the class name of the current intput.
  41135. * @returns the class name
  41136. */
  41137. getClassName(): string;
  41138. /**
  41139. * Get the friendly name associated with the input class.
  41140. * @returns the input friendly name
  41141. */
  41142. getSimpleName(): string;
  41143. }
  41144. }
  41145. declare module BABYLON {
  41146. /**
  41147. * This represents a FPS type of camera controlled by touch.
  41148. * This is like a universal camera minus the Gamepad controls.
  41149. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41150. */
  41151. export class TouchCamera extends FreeCamera {
  41152. /**
  41153. * Defines the touch sensibility for rotation.
  41154. * The higher the faster.
  41155. */
  41156. get touchAngularSensibility(): number;
  41157. set touchAngularSensibility(value: number);
  41158. /**
  41159. * Defines the touch sensibility for move.
  41160. * The higher the faster.
  41161. */
  41162. get touchMoveSensibility(): number;
  41163. set touchMoveSensibility(value: number);
  41164. /**
  41165. * Instantiates a new touch camera.
  41166. * This represents a FPS type of camera controlled by touch.
  41167. * This is like a universal camera minus the Gamepad controls.
  41168. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41169. * @param name Define the name of the camera in the scene
  41170. * @param position Define the start position of the camera in the scene
  41171. * @param scene Define the scene the camera belongs to
  41172. */
  41173. constructor(name: string, position: Vector3, scene: Scene);
  41174. /**
  41175. * Gets the current object class name.
  41176. * @return the class name
  41177. */
  41178. getClassName(): string;
  41179. /** @hidden */
  41180. _setupInputs(): void;
  41181. }
  41182. }
  41183. declare module BABYLON {
  41184. /**
  41185. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41186. * being tilted forward or back and left or right.
  41187. */
  41188. export class DeviceOrientationCamera extends FreeCamera {
  41189. private _initialQuaternion;
  41190. private _quaternionCache;
  41191. private _tmpDragQuaternion;
  41192. private _disablePointerInputWhenUsingDeviceOrientation;
  41193. /**
  41194. * Creates a new device orientation camera
  41195. * @param name The name of the camera
  41196. * @param position The start position camera
  41197. * @param scene The scene the camera belongs to
  41198. */
  41199. constructor(name: string, position: Vector3, scene: Scene);
  41200. /**
  41201. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41202. */
  41203. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41204. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41205. private _dragFactor;
  41206. /**
  41207. * Enabled turning on the y axis when the orientation sensor is active
  41208. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41209. */
  41210. enableHorizontalDragging(dragFactor?: number): void;
  41211. /**
  41212. * Gets the current instance class name ("DeviceOrientationCamera").
  41213. * This helps avoiding instanceof at run time.
  41214. * @returns the class name
  41215. */
  41216. getClassName(): string;
  41217. /**
  41218. * @hidden
  41219. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41220. */
  41221. _checkInputs(): void;
  41222. /**
  41223. * Reset the camera to its default orientation on the specified axis only.
  41224. * @param axis The axis to reset
  41225. */
  41226. resetToCurrentRotation(axis?: Axis): void;
  41227. }
  41228. }
  41229. declare module BABYLON {
  41230. /**
  41231. * Defines supported buttons for XBox360 compatible gamepads
  41232. */
  41233. export enum Xbox360Button {
  41234. /** A */
  41235. A = 0,
  41236. /** B */
  41237. B = 1,
  41238. /** X */
  41239. X = 2,
  41240. /** Y */
  41241. Y = 3,
  41242. /** Left button */
  41243. LB = 4,
  41244. /** Right button */
  41245. RB = 5,
  41246. /** Back */
  41247. Back = 8,
  41248. /** Start */
  41249. Start = 9,
  41250. /** Left stick */
  41251. LeftStick = 10,
  41252. /** Right stick */
  41253. RightStick = 11
  41254. }
  41255. /** Defines values for XBox360 DPad */
  41256. export enum Xbox360Dpad {
  41257. /** Up */
  41258. Up = 12,
  41259. /** Down */
  41260. Down = 13,
  41261. /** Left */
  41262. Left = 14,
  41263. /** Right */
  41264. Right = 15
  41265. }
  41266. /**
  41267. * Defines a XBox360 gamepad
  41268. */
  41269. export class Xbox360Pad extends Gamepad {
  41270. private _leftTrigger;
  41271. private _rightTrigger;
  41272. private _onlefttriggerchanged;
  41273. private _onrighttriggerchanged;
  41274. private _onbuttondown;
  41275. private _onbuttonup;
  41276. private _ondpaddown;
  41277. private _ondpadup;
  41278. /** Observable raised when a button is pressed */
  41279. onButtonDownObservable: Observable<Xbox360Button>;
  41280. /** Observable raised when a button is released */
  41281. onButtonUpObservable: Observable<Xbox360Button>;
  41282. /** Observable raised when a pad is pressed */
  41283. onPadDownObservable: Observable<Xbox360Dpad>;
  41284. /** Observable raised when a pad is released */
  41285. onPadUpObservable: Observable<Xbox360Dpad>;
  41286. private _buttonA;
  41287. private _buttonB;
  41288. private _buttonX;
  41289. private _buttonY;
  41290. private _buttonBack;
  41291. private _buttonStart;
  41292. private _buttonLB;
  41293. private _buttonRB;
  41294. private _buttonLeftStick;
  41295. private _buttonRightStick;
  41296. private _dPadUp;
  41297. private _dPadDown;
  41298. private _dPadLeft;
  41299. private _dPadRight;
  41300. private _isXboxOnePad;
  41301. /**
  41302. * Creates a new XBox360 gamepad object
  41303. * @param id defines the id of this gamepad
  41304. * @param index defines its index
  41305. * @param gamepad defines the internal HTML gamepad object
  41306. * @param xboxOne defines if it is a XBox One gamepad
  41307. */
  41308. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41309. /**
  41310. * Defines the callback to call when left trigger is pressed
  41311. * @param callback defines the callback to use
  41312. */
  41313. onlefttriggerchanged(callback: (value: number) => void): void;
  41314. /**
  41315. * Defines the callback to call when right trigger is pressed
  41316. * @param callback defines the callback to use
  41317. */
  41318. onrighttriggerchanged(callback: (value: number) => void): void;
  41319. /**
  41320. * Gets the left trigger value
  41321. */
  41322. get leftTrigger(): number;
  41323. /**
  41324. * Sets the left trigger value
  41325. */
  41326. set leftTrigger(newValue: number);
  41327. /**
  41328. * Gets the right trigger value
  41329. */
  41330. get rightTrigger(): number;
  41331. /**
  41332. * Sets the right trigger value
  41333. */
  41334. set rightTrigger(newValue: number);
  41335. /**
  41336. * Defines the callback to call when a button is pressed
  41337. * @param callback defines the callback to use
  41338. */
  41339. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41340. /**
  41341. * Defines the callback to call when a button is released
  41342. * @param callback defines the callback to use
  41343. */
  41344. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41345. /**
  41346. * Defines the callback to call when a pad is pressed
  41347. * @param callback defines the callback to use
  41348. */
  41349. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41350. /**
  41351. * Defines the callback to call when a pad is released
  41352. * @param callback defines the callback to use
  41353. */
  41354. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41355. private _setButtonValue;
  41356. private _setDPadValue;
  41357. /**
  41358. * Gets the value of the `A` button
  41359. */
  41360. get buttonA(): number;
  41361. /**
  41362. * Sets the value of the `A` button
  41363. */
  41364. set buttonA(value: number);
  41365. /**
  41366. * Gets the value of the `B` button
  41367. */
  41368. get buttonB(): number;
  41369. /**
  41370. * Sets the value of the `B` button
  41371. */
  41372. set buttonB(value: number);
  41373. /**
  41374. * Gets the value of the `X` button
  41375. */
  41376. get buttonX(): number;
  41377. /**
  41378. * Sets the value of the `X` button
  41379. */
  41380. set buttonX(value: number);
  41381. /**
  41382. * Gets the value of the `Y` button
  41383. */
  41384. get buttonY(): number;
  41385. /**
  41386. * Sets the value of the `Y` button
  41387. */
  41388. set buttonY(value: number);
  41389. /**
  41390. * Gets the value of the `Start` button
  41391. */
  41392. get buttonStart(): number;
  41393. /**
  41394. * Sets the value of the `Start` button
  41395. */
  41396. set buttonStart(value: number);
  41397. /**
  41398. * Gets the value of the `Back` button
  41399. */
  41400. get buttonBack(): number;
  41401. /**
  41402. * Sets the value of the `Back` button
  41403. */
  41404. set buttonBack(value: number);
  41405. /**
  41406. * Gets the value of the `Left` button
  41407. */
  41408. get buttonLB(): number;
  41409. /**
  41410. * Sets the value of the `Left` button
  41411. */
  41412. set buttonLB(value: number);
  41413. /**
  41414. * Gets the value of the `Right` button
  41415. */
  41416. get buttonRB(): number;
  41417. /**
  41418. * Sets the value of the `Right` button
  41419. */
  41420. set buttonRB(value: number);
  41421. /**
  41422. * Gets the value of the Left joystick
  41423. */
  41424. get buttonLeftStick(): number;
  41425. /**
  41426. * Sets the value of the Left joystick
  41427. */
  41428. set buttonLeftStick(value: number);
  41429. /**
  41430. * Gets the value of the Right joystick
  41431. */
  41432. get buttonRightStick(): number;
  41433. /**
  41434. * Sets the value of the Right joystick
  41435. */
  41436. set buttonRightStick(value: number);
  41437. /**
  41438. * Gets the value of D-pad up
  41439. */
  41440. get dPadUp(): number;
  41441. /**
  41442. * Sets the value of D-pad up
  41443. */
  41444. set dPadUp(value: number);
  41445. /**
  41446. * Gets the value of D-pad down
  41447. */
  41448. get dPadDown(): number;
  41449. /**
  41450. * Sets the value of D-pad down
  41451. */
  41452. set dPadDown(value: number);
  41453. /**
  41454. * Gets the value of D-pad left
  41455. */
  41456. get dPadLeft(): number;
  41457. /**
  41458. * Sets the value of D-pad left
  41459. */
  41460. set dPadLeft(value: number);
  41461. /**
  41462. * Gets the value of D-pad right
  41463. */
  41464. get dPadRight(): number;
  41465. /**
  41466. * Sets the value of D-pad right
  41467. */
  41468. set dPadRight(value: number);
  41469. /**
  41470. * Force the gamepad to synchronize with device values
  41471. */
  41472. update(): void;
  41473. /**
  41474. * Disposes the gamepad
  41475. */
  41476. dispose(): void;
  41477. }
  41478. }
  41479. declare module BABYLON {
  41480. /**
  41481. * Defines supported buttons for DualShock compatible gamepads
  41482. */
  41483. export enum DualShockButton {
  41484. /** Cross */
  41485. Cross = 0,
  41486. /** Circle */
  41487. Circle = 1,
  41488. /** Square */
  41489. Square = 2,
  41490. /** Triangle */
  41491. Triangle = 3,
  41492. /** L1 */
  41493. L1 = 4,
  41494. /** R1 */
  41495. R1 = 5,
  41496. /** Share */
  41497. Share = 8,
  41498. /** Options */
  41499. Options = 9,
  41500. /** Left stick */
  41501. LeftStick = 10,
  41502. /** Right stick */
  41503. RightStick = 11
  41504. }
  41505. /** Defines values for DualShock DPad */
  41506. export enum DualShockDpad {
  41507. /** Up */
  41508. Up = 12,
  41509. /** Down */
  41510. Down = 13,
  41511. /** Left */
  41512. Left = 14,
  41513. /** Right */
  41514. Right = 15
  41515. }
  41516. /**
  41517. * Defines a DualShock gamepad
  41518. */
  41519. export class DualShockPad extends Gamepad {
  41520. private _leftTrigger;
  41521. private _rightTrigger;
  41522. private _onlefttriggerchanged;
  41523. private _onrighttriggerchanged;
  41524. private _onbuttondown;
  41525. private _onbuttonup;
  41526. private _ondpaddown;
  41527. private _ondpadup;
  41528. /** Observable raised when a button is pressed */
  41529. onButtonDownObservable: Observable<DualShockButton>;
  41530. /** Observable raised when a button is released */
  41531. onButtonUpObservable: Observable<DualShockButton>;
  41532. /** Observable raised when a pad is pressed */
  41533. onPadDownObservable: Observable<DualShockDpad>;
  41534. /** Observable raised when a pad is released */
  41535. onPadUpObservable: Observable<DualShockDpad>;
  41536. private _buttonCross;
  41537. private _buttonCircle;
  41538. private _buttonSquare;
  41539. private _buttonTriangle;
  41540. private _buttonShare;
  41541. private _buttonOptions;
  41542. private _buttonL1;
  41543. private _buttonR1;
  41544. private _buttonLeftStick;
  41545. private _buttonRightStick;
  41546. private _dPadUp;
  41547. private _dPadDown;
  41548. private _dPadLeft;
  41549. private _dPadRight;
  41550. /**
  41551. * Creates a new DualShock gamepad object
  41552. * @param id defines the id of this gamepad
  41553. * @param index defines its index
  41554. * @param gamepad defines the internal HTML gamepad object
  41555. */
  41556. constructor(id: string, index: number, gamepad: any);
  41557. /**
  41558. * Defines the callback to call when left trigger is pressed
  41559. * @param callback defines the callback to use
  41560. */
  41561. onlefttriggerchanged(callback: (value: number) => void): void;
  41562. /**
  41563. * Defines the callback to call when right trigger is pressed
  41564. * @param callback defines the callback to use
  41565. */
  41566. onrighttriggerchanged(callback: (value: number) => void): void;
  41567. /**
  41568. * Gets the left trigger value
  41569. */
  41570. get leftTrigger(): number;
  41571. /**
  41572. * Sets the left trigger value
  41573. */
  41574. set leftTrigger(newValue: number);
  41575. /**
  41576. * Gets the right trigger value
  41577. */
  41578. get rightTrigger(): number;
  41579. /**
  41580. * Sets the right trigger value
  41581. */
  41582. set rightTrigger(newValue: number);
  41583. /**
  41584. * Defines the callback to call when a button is pressed
  41585. * @param callback defines the callback to use
  41586. */
  41587. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41588. /**
  41589. * Defines the callback to call when a button is released
  41590. * @param callback defines the callback to use
  41591. */
  41592. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41593. /**
  41594. * Defines the callback to call when a pad is pressed
  41595. * @param callback defines the callback to use
  41596. */
  41597. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41598. /**
  41599. * Defines the callback to call when a pad is released
  41600. * @param callback defines the callback to use
  41601. */
  41602. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41603. private _setButtonValue;
  41604. private _setDPadValue;
  41605. /**
  41606. * Gets the value of the `Cross` button
  41607. */
  41608. get buttonCross(): number;
  41609. /**
  41610. * Sets the value of the `Cross` button
  41611. */
  41612. set buttonCross(value: number);
  41613. /**
  41614. * Gets the value of the `Circle` button
  41615. */
  41616. get buttonCircle(): number;
  41617. /**
  41618. * Sets the value of the `Circle` button
  41619. */
  41620. set buttonCircle(value: number);
  41621. /**
  41622. * Gets the value of the `Square` button
  41623. */
  41624. get buttonSquare(): number;
  41625. /**
  41626. * Sets the value of the `Square` button
  41627. */
  41628. set buttonSquare(value: number);
  41629. /**
  41630. * Gets the value of the `Triangle` button
  41631. */
  41632. get buttonTriangle(): number;
  41633. /**
  41634. * Sets the value of the `Triangle` button
  41635. */
  41636. set buttonTriangle(value: number);
  41637. /**
  41638. * Gets the value of the `Options` button
  41639. */
  41640. get buttonOptions(): number;
  41641. /**
  41642. * Sets the value of the `Options` button
  41643. */
  41644. set buttonOptions(value: number);
  41645. /**
  41646. * Gets the value of the `Share` button
  41647. */
  41648. get buttonShare(): number;
  41649. /**
  41650. * Sets the value of the `Share` button
  41651. */
  41652. set buttonShare(value: number);
  41653. /**
  41654. * Gets the value of the `L1` button
  41655. */
  41656. get buttonL1(): number;
  41657. /**
  41658. * Sets the value of the `L1` button
  41659. */
  41660. set buttonL1(value: number);
  41661. /**
  41662. * Gets the value of the `R1` button
  41663. */
  41664. get buttonR1(): number;
  41665. /**
  41666. * Sets the value of the `R1` button
  41667. */
  41668. set buttonR1(value: number);
  41669. /**
  41670. * Gets the value of the Left joystick
  41671. */
  41672. get buttonLeftStick(): number;
  41673. /**
  41674. * Sets the value of the Left joystick
  41675. */
  41676. set buttonLeftStick(value: number);
  41677. /**
  41678. * Gets the value of the Right joystick
  41679. */
  41680. get buttonRightStick(): number;
  41681. /**
  41682. * Sets the value of the Right joystick
  41683. */
  41684. set buttonRightStick(value: number);
  41685. /**
  41686. * Gets the value of D-pad up
  41687. */
  41688. get dPadUp(): number;
  41689. /**
  41690. * Sets the value of D-pad up
  41691. */
  41692. set dPadUp(value: number);
  41693. /**
  41694. * Gets the value of D-pad down
  41695. */
  41696. get dPadDown(): number;
  41697. /**
  41698. * Sets the value of D-pad down
  41699. */
  41700. set dPadDown(value: number);
  41701. /**
  41702. * Gets the value of D-pad left
  41703. */
  41704. get dPadLeft(): number;
  41705. /**
  41706. * Sets the value of D-pad left
  41707. */
  41708. set dPadLeft(value: number);
  41709. /**
  41710. * Gets the value of D-pad right
  41711. */
  41712. get dPadRight(): number;
  41713. /**
  41714. * Sets the value of D-pad right
  41715. */
  41716. set dPadRight(value: number);
  41717. /**
  41718. * Force the gamepad to synchronize with device values
  41719. */
  41720. update(): void;
  41721. /**
  41722. * Disposes the gamepad
  41723. */
  41724. dispose(): void;
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * Manager for handling gamepads
  41730. */
  41731. export class GamepadManager {
  41732. private _scene?;
  41733. private _babylonGamepads;
  41734. private _oneGamepadConnected;
  41735. /** @hidden */
  41736. _isMonitoring: boolean;
  41737. private _gamepadEventSupported;
  41738. private _gamepadSupport?;
  41739. /**
  41740. * observable to be triggered when the gamepad controller has been connected
  41741. */
  41742. onGamepadConnectedObservable: Observable<Gamepad>;
  41743. /**
  41744. * observable to be triggered when the gamepad controller has been disconnected
  41745. */
  41746. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41747. private _onGamepadConnectedEvent;
  41748. private _onGamepadDisconnectedEvent;
  41749. /**
  41750. * Initializes the gamepad manager
  41751. * @param _scene BabylonJS scene
  41752. */
  41753. constructor(_scene?: Scene | undefined);
  41754. /**
  41755. * The gamepads in the game pad manager
  41756. */
  41757. get gamepads(): Gamepad[];
  41758. /**
  41759. * Get the gamepad controllers based on type
  41760. * @param type The type of gamepad controller
  41761. * @returns Nullable gamepad
  41762. */
  41763. getGamepadByType(type?: number): Nullable<Gamepad>;
  41764. /**
  41765. * Disposes the gamepad manager
  41766. */
  41767. dispose(): void;
  41768. private _addNewGamepad;
  41769. private _startMonitoringGamepads;
  41770. private _stopMonitoringGamepads;
  41771. /** @hidden */
  41772. _checkGamepadsStatus(): void;
  41773. private _updateGamepadObjects;
  41774. }
  41775. }
  41776. declare module BABYLON {
  41777. interface Scene {
  41778. /** @hidden */
  41779. _gamepadManager: Nullable<GamepadManager>;
  41780. /**
  41781. * Gets the gamepad manager associated with the scene
  41782. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41783. */
  41784. gamepadManager: GamepadManager;
  41785. }
  41786. /**
  41787. * Interface representing a free camera inputs manager
  41788. */
  41789. interface FreeCameraInputsManager {
  41790. /**
  41791. * Adds gamepad input support to the FreeCameraInputsManager.
  41792. * @returns the FreeCameraInputsManager
  41793. */
  41794. addGamepad(): FreeCameraInputsManager;
  41795. }
  41796. /**
  41797. * Interface representing an arc rotate camera inputs manager
  41798. */
  41799. interface ArcRotateCameraInputsManager {
  41800. /**
  41801. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41802. * @returns the camera inputs manager
  41803. */
  41804. addGamepad(): ArcRotateCameraInputsManager;
  41805. }
  41806. /**
  41807. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41808. */
  41809. export class GamepadSystemSceneComponent implements ISceneComponent {
  41810. /**
  41811. * The component name helpfull to identify the component in the list of scene components.
  41812. */
  41813. readonly name: string;
  41814. /**
  41815. * The scene the component belongs to.
  41816. */
  41817. scene: Scene;
  41818. /**
  41819. * Creates a new instance of the component for the given scene
  41820. * @param scene Defines the scene to register the component in
  41821. */
  41822. constructor(scene: Scene);
  41823. /**
  41824. * Registers the component in a given scene
  41825. */
  41826. register(): void;
  41827. /**
  41828. * Rebuilds the elements related to this component in case of
  41829. * context lost for instance.
  41830. */
  41831. rebuild(): void;
  41832. /**
  41833. * Disposes the component and the associated ressources
  41834. */
  41835. dispose(): void;
  41836. private _beforeCameraUpdate;
  41837. }
  41838. }
  41839. declare module BABYLON {
  41840. /**
  41841. * 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,
  41842. * which still works and will still be found in many Playgrounds.
  41843. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41844. */
  41845. export class UniversalCamera extends TouchCamera {
  41846. /**
  41847. * Defines the gamepad rotation sensiblity.
  41848. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41849. */
  41850. get gamepadAngularSensibility(): number;
  41851. set gamepadAngularSensibility(value: number);
  41852. /**
  41853. * Defines the gamepad move sensiblity.
  41854. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41855. */
  41856. get gamepadMoveSensibility(): number;
  41857. set gamepadMoveSensibility(value: number);
  41858. /**
  41859. * 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,
  41860. * which still works and will still be found in many Playgrounds.
  41861. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41862. * @param name Define the name of the camera in the scene
  41863. * @param position Define the start position of the camera in the scene
  41864. * @param scene Define the scene the camera belongs to
  41865. */
  41866. constructor(name: string, position: Vector3, scene: Scene);
  41867. /**
  41868. * Gets the current object class name.
  41869. * @return the class name
  41870. */
  41871. getClassName(): string;
  41872. }
  41873. }
  41874. declare module BABYLON {
  41875. /**
  41876. * This represents a FPS type of camera. This is only here for back compat purpose.
  41877. * Please use the UniversalCamera instead as both are identical.
  41878. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41879. */
  41880. export class GamepadCamera extends UniversalCamera {
  41881. /**
  41882. * Instantiates a new Gamepad Camera
  41883. * This represents a FPS type of camera. This is only here for back compat purpose.
  41884. * Please use the UniversalCamera instead as both are identical.
  41885. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41886. * @param name Define the name of the camera in the scene
  41887. * @param position Define the start position of the camera in the scene
  41888. * @param scene Define the scene the camera belongs to
  41889. */
  41890. constructor(name: string, position: Vector3, scene: Scene);
  41891. /**
  41892. * Gets the current object class name.
  41893. * @return the class name
  41894. */
  41895. getClassName(): string;
  41896. }
  41897. }
  41898. declare module BABYLON {
  41899. /** @hidden */
  41900. export var passPixelShader: {
  41901. name: string;
  41902. shader: string;
  41903. };
  41904. }
  41905. declare module BABYLON {
  41906. /** @hidden */
  41907. export var passCubePixelShader: {
  41908. name: string;
  41909. shader: string;
  41910. };
  41911. }
  41912. declare module BABYLON {
  41913. /**
  41914. * PassPostProcess which produces an output the same as it's input
  41915. */
  41916. export class PassPostProcess extends PostProcess {
  41917. /**
  41918. * Creates the PassPostProcess
  41919. * @param name The name of the effect.
  41920. * @param options The required width/height ratio to downsize to before computing the render pass.
  41921. * @param camera The camera to apply the render pass to.
  41922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41923. * @param engine The engine which the post process will be applied. (default: current engine)
  41924. * @param reusable If the post process can be reused on the same frame. (default: false)
  41925. * @param textureType The type of texture to be used when performing the post processing.
  41926. * @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)
  41927. */
  41928. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41929. }
  41930. /**
  41931. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41932. */
  41933. export class PassCubePostProcess extends PostProcess {
  41934. private _face;
  41935. /**
  41936. * Gets or sets the cube face to display.
  41937. * * 0 is +X
  41938. * * 1 is -X
  41939. * * 2 is +Y
  41940. * * 3 is -Y
  41941. * * 4 is +Z
  41942. * * 5 is -Z
  41943. */
  41944. get face(): number;
  41945. set face(value: number);
  41946. /**
  41947. * Creates the PassCubePostProcess
  41948. * @param name The name of the effect.
  41949. * @param options The required width/height ratio to downsize to before computing the render pass.
  41950. * @param camera The camera to apply the render pass to.
  41951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41952. * @param engine The engine which the post process will be applied. (default: current engine)
  41953. * @param reusable If the post process can be reused on the same frame. (default: false)
  41954. * @param textureType The type of texture to be used when performing the post processing.
  41955. * @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)
  41956. */
  41957. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41958. }
  41959. }
  41960. declare module BABYLON {
  41961. /** @hidden */
  41962. export var anaglyphPixelShader: {
  41963. name: string;
  41964. shader: string;
  41965. };
  41966. }
  41967. declare module BABYLON {
  41968. /**
  41969. * Postprocess used to generate anaglyphic rendering
  41970. */
  41971. export class AnaglyphPostProcess extends PostProcess {
  41972. private _passedProcess;
  41973. /**
  41974. * Creates a new AnaglyphPostProcess
  41975. * @param name defines postprocess name
  41976. * @param options defines creation options or target ratio scale
  41977. * @param rigCameras defines cameras using this postprocess
  41978. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41979. * @param engine defines hosting engine
  41980. * @param reusable defines if the postprocess will be reused multiple times per frame
  41981. */
  41982. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41983. }
  41984. }
  41985. declare module BABYLON {
  41986. /**
  41987. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41988. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41989. */
  41990. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41991. /**
  41992. * Creates a new AnaglyphArcRotateCamera
  41993. * @param name defines camera name
  41994. * @param alpha defines alpha angle (in radians)
  41995. * @param beta defines beta angle (in radians)
  41996. * @param radius defines radius
  41997. * @param target defines camera target
  41998. * @param interaxialDistance defines distance between each color axis
  41999. * @param scene defines the hosting scene
  42000. */
  42001. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42002. /**
  42003. * Gets camera class name
  42004. * @returns AnaglyphArcRotateCamera
  42005. */
  42006. getClassName(): string;
  42007. }
  42008. }
  42009. declare module BABYLON {
  42010. /**
  42011. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42012. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42013. */
  42014. export class AnaglyphFreeCamera extends FreeCamera {
  42015. /**
  42016. * Creates a new AnaglyphFreeCamera
  42017. * @param name defines camera name
  42018. * @param position defines initial position
  42019. * @param interaxialDistance defines distance between each color axis
  42020. * @param scene defines the hosting scene
  42021. */
  42022. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42023. /**
  42024. * Gets camera class name
  42025. * @returns AnaglyphFreeCamera
  42026. */
  42027. getClassName(): string;
  42028. }
  42029. }
  42030. declare module BABYLON {
  42031. /**
  42032. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42033. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42034. */
  42035. export class AnaglyphGamepadCamera extends GamepadCamera {
  42036. /**
  42037. * Creates a new AnaglyphGamepadCamera
  42038. * @param name defines camera name
  42039. * @param position defines initial position
  42040. * @param interaxialDistance defines distance between each color axis
  42041. * @param scene defines the hosting scene
  42042. */
  42043. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42044. /**
  42045. * Gets camera class name
  42046. * @returns AnaglyphGamepadCamera
  42047. */
  42048. getClassName(): string;
  42049. }
  42050. }
  42051. declare module BABYLON {
  42052. /**
  42053. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42054. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42055. */
  42056. export class AnaglyphUniversalCamera extends UniversalCamera {
  42057. /**
  42058. * Creates a new AnaglyphUniversalCamera
  42059. * @param name defines camera name
  42060. * @param position defines initial position
  42061. * @param interaxialDistance defines distance between each color axis
  42062. * @param scene defines the hosting scene
  42063. */
  42064. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42065. /**
  42066. * Gets camera class name
  42067. * @returns AnaglyphUniversalCamera
  42068. */
  42069. getClassName(): string;
  42070. }
  42071. }
  42072. declare module BABYLON {
  42073. /** @hidden */
  42074. export var stereoscopicInterlacePixelShader: {
  42075. name: string;
  42076. shader: string;
  42077. };
  42078. }
  42079. declare module BABYLON {
  42080. /**
  42081. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42082. */
  42083. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42084. private _stepSize;
  42085. private _passedProcess;
  42086. /**
  42087. * Initializes a StereoscopicInterlacePostProcessI
  42088. * @param name The name of the effect.
  42089. * @param rigCameras The rig cameras to be appled to the post process
  42090. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42091. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42093. * @param engine The engine which the post process will be applied. (default: current engine)
  42094. * @param reusable If the post process can be reused on the same frame. (default: false)
  42095. */
  42096. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42097. }
  42098. /**
  42099. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42100. */
  42101. export class StereoscopicInterlacePostProcess extends PostProcess {
  42102. private _stepSize;
  42103. private _passedProcess;
  42104. /**
  42105. * Initializes a StereoscopicInterlacePostProcess
  42106. * @param name The name of the effect.
  42107. * @param rigCameras The rig cameras to be appled to the post process
  42108. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42110. * @param engine The engine which the post process will be applied. (default: current engine)
  42111. * @param reusable If the post process can be reused on the same frame. (default: false)
  42112. */
  42113. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42114. }
  42115. }
  42116. declare module BABYLON {
  42117. /**
  42118. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42119. * @see http://doc.babylonjs.com/features/cameras
  42120. */
  42121. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42122. /**
  42123. * Creates a new StereoscopicArcRotateCamera
  42124. * @param name defines camera name
  42125. * @param alpha defines alpha angle (in radians)
  42126. * @param beta defines beta angle (in radians)
  42127. * @param radius defines radius
  42128. * @param target defines camera target
  42129. * @param interaxialDistance defines distance between each color axis
  42130. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42131. * @param scene defines the hosting scene
  42132. */
  42133. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42134. /**
  42135. * Gets camera class name
  42136. * @returns StereoscopicArcRotateCamera
  42137. */
  42138. getClassName(): string;
  42139. }
  42140. }
  42141. declare module BABYLON {
  42142. /**
  42143. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42144. * @see http://doc.babylonjs.com/features/cameras
  42145. */
  42146. export class StereoscopicFreeCamera extends FreeCamera {
  42147. /**
  42148. * Creates a new StereoscopicFreeCamera
  42149. * @param name defines camera name
  42150. * @param position defines initial position
  42151. * @param interaxialDistance defines distance between each color axis
  42152. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42153. * @param scene defines the hosting scene
  42154. */
  42155. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42156. /**
  42157. * Gets camera class name
  42158. * @returns StereoscopicFreeCamera
  42159. */
  42160. getClassName(): string;
  42161. }
  42162. }
  42163. declare module BABYLON {
  42164. /**
  42165. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42166. * @see http://doc.babylonjs.com/features/cameras
  42167. */
  42168. export class StereoscopicGamepadCamera extends GamepadCamera {
  42169. /**
  42170. * Creates a new StereoscopicGamepadCamera
  42171. * @param name defines camera name
  42172. * @param position defines initial position
  42173. * @param interaxialDistance defines distance between each color axis
  42174. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42175. * @param scene defines the hosting scene
  42176. */
  42177. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42178. /**
  42179. * Gets camera class name
  42180. * @returns StereoscopicGamepadCamera
  42181. */
  42182. getClassName(): string;
  42183. }
  42184. }
  42185. declare module BABYLON {
  42186. /**
  42187. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42188. * @see http://doc.babylonjs.com/features/cameras
  42189. */
  42190. export class StereoscopicUniversalCamera extends UniversalCamera {
  42191. /**
  42192. * Creates a new StereoscopicUniversalCamera
  42193. * @param name defines camera name
  42194. * @param position defines initial position
  42195. * @param interaxialDistance defines distance between each color axis
  42196. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42197. * @param scene defines the hosting scene
  42198. */
  42199. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42200. /**
  42201. * Gets camera class name
  42202. * @returns StereoscopicUniversalCamera
  42203. */
  42204. getClassName(): string;
  42205. }
  42206. }
  42207. declare module BABYLON {
  42208. /**
  42209. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42210. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42211. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42212. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42213. */
  42214. export class VirtualJoysticksCamera extends FreeCamera {
  42215. /**
  42216. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42217. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42218. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42219. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42220. * @param name Define the name of the camera in the scene
  42221. * @param position Define the start position of the camera in the scene
  42222. * @param scene Define the scene the camera belongs to
  42223. */
  42224. constructor(name: string, position: Vector3, scene: Scene);
  42225. /**
  42226. * Gets the current object class name.
  42227. * @return the class name
  42228. */
  42229. getClassName(): string;
  42230. }
  42231. }
  42232. declare module BABYLON {
  42233. /**
  42234. * This represents all the required metrics to create a VR camera.
  42235. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42236. */
  42237. export class VRCameraMetrics {
  42238. /**
  42239. * Define the horizontal resolution off the screen.
  42240. */
  42241. hResolution: number;
  42242. /**
  42243. * Define the vertical resolution off the screen.
  42244. */
  42245. vResolution: number;
  42246. /**
  42247. * Define the horizontal screen size.
  42248. */
  42249. hScreenSize: number;
  42250. /**
  42251. * Define the vertical screen size.
  42252. */
  42253. vScreenSize: number;
  42254. /**
  42255. * Define the vertical screen center position.
  42256. */
  42257. vScreenCenter: number;
  42258. /**
  42259. * Define the distance of the eyes to the screen.
  42260. */
  42261. eyeToScreenDistance: number;
  42262. /**
  42263. * Define the distance between both lenses
  42264. */
  42265. lensSeparationDistance: number;
  42266. /**
  42267. * Define the distance between both viewer's eyes.
  42268. */
  42269. interpupillaryDistance: number;
  42270. /**
  42271. * Define the distortion factor of the VR postprocess.
  42272. * Please, touch with care.
  42273. */
  42274. distortionK: number[];
  42275. /**
  42276. * Define the chromatic aberration correction factors for the VR post process.
  42277. */
  42278. chromaAbCorrection: number[];
  42279. /**
  42280. * Define the scale factor of the post process.
  42281. * The smaller the better but the slower.
  42282. */
  42283. postProcessScaleFactor: number;
  42284. /**
  42285. * Define an offset for the lens center.
  42286. */
  42287. lensCenterOffset: number;
  42288. /**
  42289. * Define if the current vr camera should compensate the distortion of the lense or not.
  42290. */
  42291. compensateDistortion: boolean;
  42292. /**
  42293. * Defines if multiview should be enabled when rendering (Default: false)
  42294. */
  42295. multiviewEnabled: boolean;
  42296. /**
  42297. * Gets the rendering aspect ratio based on the provided resolutions.
  42298. */
  42299. get aspectRatio(): number;
  42300. /**
  42301. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42302. */
  42303. get aspectRatioFov(): number;
  42304. /**
  42305. * @hidden
  42306. */
  42307. get leftHMatrix(): Matrix;
  42308. /**
  42309. * @hidden
  42310. */
  42311. get rightHMatrix(): Matrix;
  42312. /**
  42313. * @hidden
  42314. */
  42315. get leftPreViewMatrix(): Matrix;
  42316. /**
  42317. * @hidden
  42318. */
  42319. get rightPreViewMatrix(): Matrix;
  42320. /**
  42321. * Get the default VRMetrics based on the most generic setup.
  42322. * @returns the default vr metrics
  42323. */
  42324. static GetDefault(): VRCameraMetrics;
  42325. }
  42326. }
  42327. declare module BABYLON {
  42328. /** @hidden */
  42329. export var vrDistortionCorrectionPixelShader: {
  42330. name: string;
  42331. shader: string;
  42332. };
  42333. }
  42334. declare module BABYLON {
  42335. /**
  42336. * VRDistortionCorrectionPostProcess used for mobile VR
  42337. */
  42338. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42339. private _isRightEye;
  42340. private _distortionFactors;
  42341. private _postProcessScaleFactor;
  42342. private _lensCenterOffset;
  42343. private _scaleIn;
  42344. private _scaleFactor;
  42345. private _lensCenter;
  42346. /**
  42347. * Initializes the VRDistortionCorrectionPostProcess
  42348. * @param name The name of the effect.
  42349. * @param camera The camera to apply the render pass to.
  42350. * @param isRightEye If this is for the right eye distortion
  42351. * @param vrMetrics All the required metrics for the VR camera
  42352. */
  42353. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42354. }
  42355. }
  42356. declare module BABYLON {
  42357. /**
  42358. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42359. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42360. */
  42361. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42362. /**
  42363. * Creates a new VRDeviceOrientationArcRotateCamera
  42364. * @param name defines camera name
  42365. * @param alpha defines the camera rotation along the logitudinal axis
  42366. * @param beta defines the camera rotation along the latitudinal axis
  42367. * @param radius defines the camera distance from its target
  42368. * @param target defines the camera target
  42369. * @param scene defines the scene the camera belongs to
  42370. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42371. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42372. */
  42373. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42374. /**
  42375. * Gets camera class name
  42376. * @returns VRDeviceOrientationArcRotateCamera
  42377. */
  42378. getClassName(): string;
  42379. }
  42380. }
  42381. declare module BABYLON {
  42382. /**
  42383. * Camera used to simulate VR rendering (based on FreeCamera)
  42384. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42385. */
  42386. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42387. /**
  42388. * Creates a new VRDeviceOrientationFreeCamera
  42389. * @param name defines camera name
  42390. * @param position defines the start position of the camera
  42391. * @param scene defines the scene the camera belongs to
  42392. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42393. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42394. */
  42395. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42396. /**
  42397. * Gets camera class name
  42398. * @returns VRDeviceOrientationFreeCamera
  42399. */
  42400. getClassName(): string;
  42401. }
  42402. }
  42403. declare module BABYLON {
  42404. /**
  42405. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42406. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42407. */
  42408. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42409. /**
  42410. * Creates a new VRDeviceOrientationGamepadCamera
  42411. * @param name defines camera name
  42412. * @param position defines the start position of the camera
  42413. * @param scene defines the scene the camera belongs to
  42414. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42415. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42416. */
  42417. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42418. /**
  42419. * Gets camera class name
  42420. * @returns VRDeviceOrientationGamepadCamera
  42421. */
  42422. getClassName(): string;
  42423. }
  42424. }
  42425. declare module BABYLON {
  42426. /** @hidden */
  42427. export var imageProcessingPixelShader: {
  42428. name: string;
  42429. shader: string;
  42430. };
  42431. }
  42432. declare module BABYLON {
  42433. /**
  42434. * ImageProcessingPostProcess
  42435. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42436. */
  42437. export class ImageProcessingPostProcess extends PostProcess {
  42438. /**
  42439. * Default configuration related to image processing available in the PBR Material.
  42440. */
  42441. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42442. /**
  42443. * Gets the image processing configuration used either in this material.
  42444. */
  42445. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42446. /**
  42447. * Sets the Default image processing configuration used either in the this material.
  42448. *
  42449. * If sets to null, the scene one is in use.
  42450. */
  42451. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42452. /**
  42453. * Keep track of the image processing observer to allow dispose and replace.
  42454. */
  42455. private _imageProcessingObserver;
  42456. /**
  42457. * Attaches a new image processing configuration to the PBR Material.
  42458. * @param configuration
  42459. */
  42460. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42461. /**
  42462. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42463. */
  42464. get colorCurves(): Nullable<ColorCurves>;
  42465. /**
  42466. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42467. */
  42468. set colorCurves(value: Nullable<ColorCurves>);
  42469. /**
  42470. * Gets wether the color curves effect is enabled.
  42471. */
  42472. get colorCurvesEnabled(): boolean;
  42473. /**
  42474. * Sets wether the color curves effect is enabled.
  42475. */
  42476. set colorCurvesEnabled(value: boolean);
  42477. /**
  42478. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42479. */
  42480. get colorGradingTexture(): Nullable<BaseTexture>;
  42481. /**
  42482. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42483. */
  42484. set colorGradingTexture(value: Nullable<BaseTexture>);
  42485. /**
  42486. * Gets wether the color grading effect is enabled.
  42487. */
  42488. get colorGradingEnabled(): boolean;
  42489. /**
  42490. * Gets wether the color grading effect is enabled.
  42491. */
  42492. set colorGradingEnabled(value: boolean);
  42493. /**
  42494. * Gets exposure used in the effect.
  42495. */
  42496. get exposure(): number;
  42497. /**
  42498. * Sets exposure used in the effect.
  42499. */
  42500. set exposure(value: number);
  42501. /**
  42502. * Gets wether tonemapping is enabled or not.
  42503. */
  42504. get toneMappingEnabled(): boolean;
  42505. /**
  42506. * Sets wether tonemapping is enabled or not
  42507. */
  42508. set toneMappingEnabled(value: boolean);
  42509. /**
  42510. * Gets the type of tone mapping effect.
  42511. */
  42512. get toneMappingType(): number;
  42513. /**
  42514. * Sets the type of tone mapping effect.
  42515. */
  42516. set toneMappingType(value: number);
  42517. /**
  42518. * Gets contrast used in the effect.
  42519. */
  42520. get contrast(): number;
  42521. /**
  42522. * Sets contrast used in the effect.
  42523. */
  42524. set contrast(value: number);
  42525. /**
  42526. * Gets Vignette stretch size.
  42527. */
  42528. get vignetteStretch(): number;
  42529. /**
  42530. * Sets Vignette stretch size.
  42531. */
  42532. set vignetteStretch(value: number);
  42533. /**
  42534. * Gets Vignette centre X Offset.
  42535. */
  42536. get vignetteCentreX(): number;
  42537. /**
  42538. * Sets Vignette centre X Offset.
  42539. */
  42540. set vignetteCentreX(value: number);
  42541. /**
  42542. * Gets Vignette centre Y Offset.
  42543. */
  42544. get vignetteCentreY(): number;
  42545. /**
  42546. * Sets Vignette centre Y Offset.
  42547. */
  42548. set vignetteCentreY(value: number);
  42549. /**
  42550. * Gets Vignette weight or intensity of the vignette effect.
  42551. */
  42552. get vignetteWeight(): number;
  42553. /**
  42554. * Sets Vignette weight or intensity of the vignette effect.
  42555. */
  42556. set vignetteWeight(value: number);
  42557. /**
  42558. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42559. * if vignetteEnabled is set to true.
  42560. */
  42561. get vignetteColor(): Color4;
  42562. /**
  42563. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42564. * if vignetteEnabled is set to true.
  42565. */
  42566. set vignetteColor(value: Color4);
  42567. /**
  42568. * Gets Camera field of view used by the Vignette effect.
  42569. */
  42570. get vignetteCameraFov(): number;
  42571. /**
  42572. * Sets Camera field of view used by the Vignette effect.
  42573. */
  42574. set vignetteCameraFov(value: number);
  42575. /**
  42576. * Gets the vignette blend mode allowing different kind of effect.
  42577. */
  42578. get vignetteBlendMode(): number;
  42579. /**
  42580. * Sets the vignette blend mode allowing different kind of effect.
  42581. */
  42582. set vignetteBlendMode(value: number);
  42583. /**
  42584. * Gets wether the vignette effect is enabled.
  42585. */
  42586. get vignetteEnabled(): boolean;
  42587. /**
  42588. * Sets wether the vignette effect is enabled.
  42589. */
  42590. set vignetteEnabled(value: boolean);
  42591. private _fromLinearSpace;
  42592. /**
  42593. * Gets wether the input of the processing is in Gamma or Linear Space.
  42594. */
  42595. get fromLinearSpace(): boolean;
  42596. /**
  42597. * Sets wether the input of the processing is in Gamma or Linear Space.
  42598. */
  42599. set fromLinearSpace(value: boolean);
  42600. /**
  42601. * Defines cache preventing GC.
  42602. */
  42603. private _defines;
  42604. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42605. /**
  42606. * "ImageProcessingPostProcess"
  42607. * @returns "ImageProcessingPostProcess"
  42608. */
  42609. getClassName(): string;
  42610. protected _updateParameters(): void;
  42611. dispose(camera?: Camera): void;
  42612. }
  42613. }
  42614. declare module BABYLON {
  42615. /**
  42616. * Class containing static functions to help procedurally build meshes
  42617. */
  42618. export class GroundBuilder {
  42619. /**
  42620. * Creates a ground mesh
  42621. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42622. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42624. * @param name defines the name of the mesh
  42625. * @param options defines the options used to create the mesh
  42626. * @param scene defines the hosting scene
  42627. * @returns the ground mesh
  42628. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42629. */
  42630. static CreateGround(name: string, options: {
  42631. width?: number;
  42632. height?: number;
  42633. subdivisions?: number;
  42634. subdivisionsX?: number;
  42635. subdivisionsY?: number;
  42636. updatable?: boolean;
  42637. }, scene: any): Mesh;
  42638. /**
  42639. * Creates a tiled ground mesh
  42640. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42641. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42642. * * 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
  42643. * * 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
  42644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42645. * @param name defines the name of the mesh
  42646. * @param options defines the options used to create the mesh
  42647. * @param scene defines the hosting scene
  42648. * @returns the tiled ground mesh
  42649. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42650. */
  42651. static CreateTiledGround(name: string, options: {
  42652. xmin: number;
  42653. zmin: number;
  42654. xmax: number;
  42655. zmax: number;
  42656. subdivisions?: {
  42657. w: number;
  42658. h: number;
  42659. };
  42660. precision?: {
  42661. w: number;
  42662. h: number;
  42663. };
  42664. updatable?: boolean;
  42665. }, scene?: Nullable<Scene>): Mesh;
  42666. /**
  42667. * Creates a ground mesh from a height map
  42668. * * The parameter `url` sets the URL of the height map image resource.
  42669. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42670. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42671. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42672. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42673. * * 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.
  42674. * * 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).
  42675. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42677. * @param name defines the name of the mesh
  42678. * @param url defines the url to the height map
  42679. * @param options defines the options used to create the mesh
  42680. * @param scene defines the hosting scene
  42681. * @returns the ground mesh
  42682. * @see https://doc.babylonjs.com/babylon101/height_map
  42683. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42684. */
  42685. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42686. width?: number;
  42687. height?: number;
  42688. subdivisions?: number;
  42689. minHeight?: number;
  42690. maxHeight?: number;
  42691. colorFilter?: Color3;
  42692. alphaFilter?: number;
  42693. updatable?: boolean;
  42694. onReady?: (mesh: GroundMesh) => void;
  42695. }, scene?: Nullable<Scene>): GroundMesh;
  42696. }
  42697. }
  42698. declare module BABYLON {
  42699. /**
  42700. * Class containing static functions to help procedurally build meshes
  42701. */
  42702. export class TorusBuilder {
  42703. /**
  42704. * Creates a torus mesh
  42705. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42706. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42707. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42709. * * 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
  42710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42711. * @param name defines the name of the mesh
  42712. * @param options defines the options used to create the mesh
  42713. * @param scene defines the hosting scene
  42714. * @returns the torus mesh
  42715. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42716. */
  42717. static CreateTorus(name: string, options: {
  42718. diameter?: number;
  42719. thickness?: number;
  42720. tessellation?: number;
  42721. updatable?: boolean;
  42722. sideOrientation?: number;
  42723. frontUVs?: Vector4;
  42724. backUVs?: Vector4;
  42725. }, scene: any): Mesh;
  42726. }
  42727. }
  42728. declare module BABYLON {
  42729. /**
  42730. * Class containing static functions to help procedurally build meshes
  42731. */
  42732. export class CylinderBuilder {
  42733. /**
  42734. * Creates a cylinder or a cone mesh
  42735. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42736. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42737. * * 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.
  42738. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42739. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42740. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42741. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42742. * * 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).
  42743. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42744. * * 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).
  42745. * * 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
  42746. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42747. * * 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
  42748. * * 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.
  42749. * * If `enclose` is false, a ring surface is one element.
  42750. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42751. * * 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
  42752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42753. * * 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
  42754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42755. * @param name defines the name of the mesh
  42756. * @param options defines the options used to create the mesh
  42757. * @param scene defines the hosting scene
  42758. * @returns the cylinder mesh
  42759. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42760. */
  42761. static CreateCylinder(name: string, options: {
  42762. height?: number;
  42763. diameterTop?: number;
  42764. diameterBottom?: number;
  42765. diameter?: number;
  42766. tessellation?: number;
  42767. subdivisions?: number;
  42768. arc?: number;
  42769. faceColors?: Color4[];
  42770. faceUV?: Vector4[];
  42771. updatable?: boolean;
  42772. hasRings?: boolean;
  42773. enclose?: boolean;
  42774. cap?: number;
  42775. sideOrientation?: number;
  42776. frontUVs?: Vector4;
  42777. backUVs?: Vector4;
  42778. }, scene: any): Mesh;
  42779. }
  42780. }
  42781. declare module BABYLON {
  42782. /**
  42783. * States of the webXR experience
  42784. */
  42785. export enum WebXRState {
  42786. /**
  42787. * Transitioning to being in XR mode
  42788. */
  42789. ENTERING_XR = 0,
  42790. /**
  42791. * Transitioning to non XR mode
  42792. */
  42793. EXITING_XR = 1,
  42794. /**
  42795. * In XR mode and presenting
  42796. */
  42797. IN_XR = 2,
  42798. /**
  42799. * Not entered XR mode
  42800. */
  42801. NOT_IN_XR = 3
  42802. }
  42803. /**
  42804. * Abstraction of the XR render target
  42805. */
  42806. export interface WebXRRenderTarget extends IDisposable {
  42807. /**
  42808. * xrpresent context of the canvas which can be used to display/mirror xr content
  42809. */
  42810. canvasContext: WebGLRenderingContext;
  42811. /**
  42812. * xr layer for the canvas
  42813. */
  42814. xrLayer: Nullable<XRWebGLLayer>;
  42815. /**
  42816. * Initializes the xr layer for the session
  42817. * @param xrSession xr session
  42818. * @returns a promise that will resolve once the XR Layer has been created
  42819. */
  42820. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42821. }
  42822. }
  42823. declare module BABYLON {
  42824. /**
  42825. * COnfiguration object for WebXR output canvas
  42826. */
  42827. export class WebXRManagedOutputCanvasOptions {
  42828. /**
  42829. * An optional canvas in case you wish to create it yourself and provide it here.
  42830. * If not provided, a new canvas will be created
  42831. */
  42832. canvasElement?: HTMLCanvasElement;
  42833. /**
  42834. * Options for this XR Layer output
  42835. */
  42836. canvasOptions?: XRWebGLLayerOptions;
  42837. /**
  42838. * CSS styling for a newly created canvas (if not provided)
  42839. */
  42840. newCanvasCssStyle?: string;
  42841. /**
  42842. * Get the default values of the configuration object
  42843. * @returns default values of this configuration object
  42844. */
  42845. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42846. }
  42847. /**
  42848. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42849. */
  42850. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42851. private _options;
  42852. private _canvas;
  42853. private _engine;
  42854. /**
  42855. * Rendering context of the canvas which can be used to display/mirror xr content
  42856. */
  42857. canvasContext: WebGLRenderingContext;
  42858. /**
  42859. * xr layer for the canvas
  42860. */
  42861. xrLayer: Nullable<XRWebGLLayer>;
  42862. /**
  42863. * Initializes the canvas to be added/removed upon entering/exiting xr
  42864. * @param _xrSessionManager The XR Session manager
  42865. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42866. */
  42867. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42868. /**
  42869. * Disposes of the object
  42870. */
  42871. dispose(): void;
  42872. /**
  42873. * Initializes the xr layer for the session
  42874. * @param xrSession xr session
  42875. * @returns a promise that will resolve once the XR Layer has been created
  42876. */
  42877. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42878. private _addCanvas;
  42879. private _removeCanvas;
  42880. private _setManagedOutputCanvas;
  42881. }
  42882. }
  42883. declare module BABYLON {
  42884. /**
  42885. * Manages an XRSession to work with Babylon's engine
  42886. * @see https://doc.babylonjs.com/how_to/webxr
  42887. */
  42888. export class WebXRSessionManager implements IDisposable {
  42889. /** The scene which the session should be created for */
  42890. scene: Scene;
  42891. private _referenceSpace;
  42892. private _rttProvider;
  42893. private _sessionEnded;
  42894. private _xrNavigator;
  42895. private baseLayer;
  42896. /**
  42897. * The base reference space from which the session started. good if you want to reset your
  42898. * reference space
  42899. */
  42900. baseReferenceSpace: XRReferenceSpace;
  42901. /**
  42902. * Current XR frame
  42903. */
  42904. currentFrame: Nullable<XRFrame>;
  42905. /** WebXR timestamp updated every frame */
  42906. currentTimestamp: number;
  42907. /**
  42908. * Used just in case of a failure to initialize an immersive session.
  42909. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42910. */
  42911. defaultHeightCompensation: number;
  42912. /**
  42913. * Fires every time a new xrFrame arrives which can be used to update the camera
  42914. */
  42915. onXRFrameObservable: Observable<XRFrame>;
  42916. /**
  42917. * Fires when the reference space changed
  42918. */
  42919. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42920. /**
  42921. * Fires when the xr session is ended either by the device or manually done
  42922. */
  42923. onXRSessionEnded: Observable<any>;
  42924. /**
  42925. * Fires when the xr session is ended either by the device or manually done
  42926. */
  42927. onXRSessionInit: Observable<XRSession>;
  42928. /**
  42929. * Underlying xr session
  42930. */
  42931. session: XRSession;
  42932. /**
  42933. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42934. * or get the offset the player is currently at.
  42935. */
  42936. viewerReferenceSpace: XRReferenceSpace;
  42937. /**
  42938. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42939. * @param scene The scene which the session should be created for
  42940. */
  42941. constructor(
  42942. /** The scene which the session should be created for */
  42943. scene: Scene);
  42944. /**
  42945. * The current reference space used in this session. This reference space can constantly change!
  42946. * It is mainly used to offset the camera's position.
  42947. */
  42948. get referenceSpace(): XRReferenceSpace;
  42949. /**
  42950. * Set a new reference space and triggers the observable
  42951. */
  42952. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42953. /**
  42954. * Disposes of the session manager
  42955. */
  42956. dispose(): void;
  42957. /**
  42958. * Stops the xrSession and restores the render loop
  42959. * @returns Promise which resolves after it exits XR
  42960. */
  42961. exitXRAsync(): Promise<void>;
  42962. /**
  42963. * Gets the correct render target texture to be rendered this frame for this eye
  42964. * @param eye the eye for which to get the render target
  42965. * @returns the render target for the specified eye
  42966. */
  42967. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42968. /**
  42969. * Creates a WebXRRenderTarget object for the XR session
  42970. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42971. * @param options optional options to provide when creating a new render target
  42972. * @returns a WebXR render target to which the session can render
  42973. */
  42974. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42975. /**
  42976. * Initializes the manager
  42977. * After initialization enterXR can be called to start an XR session
  42978. * @returns Promise which resolves after it is initialized
  42979. */
  42980. initializeAsync(): Promise<void>;
  42981. /**
  42982. * Initializes an xr session
  42983. * @param xrSessionMode mode to initialize
  42984. * @param xrSessionInit defines optional and required values to pass to the session builder
  42985. * @returns a promise which will resolve once the session has been initialized
  42986. */
  42987. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42988. /**
  42989. * Checks if a session would be supported for the creation options specified
  42990. * @param sessionMode session mode to check if supported eg. immersive-vr
  42991. * @returns A Promise that resolves to true if supported and false if not
  42992. */
  42993. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42994. /**
  42995. * Resets the reference space to the one started the session
  42996. */
  42997. resetReferenceSpace(): void;
  42998. /**
  42999. * Starts rendering to the xr layer
  43000. */
  43001. runXRRenderLoop(): void;
  43002. /**
  43003. * Sets the reference space on the xr session
  43004. * @param referenceSpaceType space to set
  43005. * @returns a promise that will resolve once the reference space has been set
  43006. */
  43007. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43008. /**
  43009. * Updates the render state of the session
  43010. * @param state state to set
  43011. * @returns a promise that resolves once the render state has been updated
  43012. */
  43013. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43014. /**
  43015. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43016. * @param sessionMode defines the session to test
  43017. * @returns a promise with boolean as final value
  43018. */
  43019. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43020. private _createRenderTargetTexture;
  43021. }
  43022. }
  43023. declare module BABYLON {
  43024. /**
  43025. * WebXR Camera which holds the views for the xrSession
  43026. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43027. */
  43028. export class WebXRCamera extends FreeCamera {
  43029. private _xrSessionManager;
  43030. private _firstFrame;
  43031. private _referenceQuaternion;
  43032. private _referencedPosition;
  43033. private _xrInvPositionCache;
  43034. private _xrInvQuaternionCache;
  43035. /**
  43036. * Should position compensation execute on first frame.
  43037. * This is used when copying the position from a native (non XR) camera
  43038. */
  43039. compensateOnFirstFrame: boolean;
  43040. /**
  43041. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43042. * @param name the name of the camera
  43043. * @param scene the scene to add the camera to
  43044. * @param _xrSessionManager a constructed xr session manager
  43045. */
  43046. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43047. /**
  43048. * Return the user's height, unrelated to the current ground.
  43049. * This will be the y position of this camera, when ground level is 0.
  43050. */
  43051. get realWorldHeight(): number;
  43052. /** @hidden */
  43053. _updateForDualEyeDebugging(): void;
  43054. /**
  43055. * Sets this camera's transformation based on a non-vr camera
  43056. * @param otherCamera the non-vr camera to copy the transformation from
  43057. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43058. */
  43059. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43060. /**
  43061. * Gets the current instance class name ("WebXRCamera").
  43062. * @returns the class name
  43063. */
  43064. getClassName(): string;
  43065. private _updateFromXRSession;
  43066. private _updateNumberOfRigCameras;
  43067. private _updateReferenceSpace;
  43068. private _updateReferenceSpaceOffset;
  43069. }
  43070. }
  43071. declare module BABYLON {
  43072. /**
  43073. * Defining the interface required for a (webxr) feature
  43074. */
  43075. export interface IWebXRFeature extends IDisposable {
  43076. /**
  43077. * Is this feature attached
  43078. */
  43079. attached: boolean;
  43080. /**
  43081. * Should auto-attach be disabled?
  43082. */
  43083. disableAutoAttach: boolean;
  43084. /**
  43085. * Attach the feature to the session
  43086. * Will usually be called by the features manager
  43087. *
  43088. * @param force should attachment be forced (even when already attached)
  43089. * @returns true if successful.
  43090. */
  43091. attach(force?: boolean): boolean;
  43092. /**
  43093. * Detach the feature from the session
  43094. * Will usually be called by the features manager
  43095. *
  43096. * @returns true if successful.
  43097. */
  43098. detach(): boolean;
  43099. }
  43100. /**
  43101. * A list of the currently available features without referencing them
  43102. */
  43103. export class WebXRFeatureName {
  43104. /**
  43105. * The name of the anchor system feature
  43106. */
  43107. static ANCHOR_SYSTEM: string;
  43108. /**
  43109. * The name of the background remover feature
  43110. */
  43111. static BACKGROUND_REMOVER: string;
  43112. /**
  43113. * The name of the hit test feature
  43114. */
  43115. static HIT_TEST: string;
  43116. /**
  43117. * physics impostors for xr controllers feature
  43118. */
  43119. static PHYSICS_CONTROLLERS: string;
  43120. /**
  43121. * The name of the plane detection feature
  43122. */
  43123. static PLANE_DETECTION: string;
  43124. /**
  43125. * The name of the pointer selection feature
  43126. */
  43127. static POINTER_SELECTION: string;
  43128. /**
  43129. * The name of the teleportation feature
  43130. */
  43131. static TELEPORTATION: string;
  43132. }
  43133. /**
  43134. * Defining the constructor of a feature. Used to register the modules.
  43135. */
  43136. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43137. /**
  43138. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43139. * It is mainly used in AR sessions.
  43140. *
  43141. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43142. */
  43143. export class WebXRFeaturesManager implements IDisposable {
  43144. private _xrSessionManager;
  43145. private static readonly _AvailableFeatures;
  43146. private _features;
  43147. /**
  43148. * constructs a new features manages.
  43149. *
  43150. * @param _xrSessionManager an instance of WebXRSessionManager
  43151. */
  43152. constructor(_xrSessionManager: WebXRSessionManager);
  43153. /**
  43154. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43155. * Mainly used internally.
  43156. *
  43157. * @param featureName the name of the feature to register
  43158. * @param constructorFunction the function used to construct the module
  43159. * @param version the (babylon) version of the module
  43160. * @param stable is that a stable version of this module
  43161. */
  43162. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43163. /**
  43164. * Returns a constructor of a specific feature.
  43165. *
  43166. * @param featureName the name of the feature to construct
  43167. * @param version the version of the feature to load
  43168. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43169. * @param options optional options provided to the module.
  43170. * @returns a function that, when called, will return a new instance of this feature
  43171. */
  43172. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43173. /**
  43174. * Can be used to return the list of features currently registered
  43175. *
  43176. * @returns an Array of available features
  43177. */
  43178. static GetAvailableFeatures(): string[];
  43179. /**
  43180. * Gets the versions available for a specific feature
  43181. * @param featureName the name of the feature
  43182. * @returns an array with the available versions
  43183. */
  43184. static GetAvailableVersions(featureName: string): string[];
  43185. /**
  43186. * Return the latest unstable version of this feature
  43187. * @param featureName the name of the feature to search
  43188. * @returns the version number. if not found will return -1
  43189. */
  43190. static GetLatestVersionOfFeature(featureName: string): number;
  43191. /**
  43192. * Return the latest stable version of this feature
  43193. * @param featureName the name of the feature to search
  43194. * @returns the version number. if not found will return -1
  43195. */
  43196. static GetStableVersionOfFeature(featureName: string): number;
  43197. /**
  43198. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43199. * Can be used during a session to start a feature
  43200. * @param featureName the name of feature to attach
  43201. */
  43202. attachFeature(featureName: string): void;
  43203. /**
  43204. * Can be used inside a session or when the session ends to detach a specific feature
  43205. * @param featureName the name of the feature to detach
  43206. */
  43207. detachFeature(featureName: string): void;
  43208. /**
  43209. * Used to disable an already-enabled feature
  43210. * The feature will be disposed and will be recreated once enabled.
  43211. * @param featureName the feature to disable
  43212. * @returns true if disable was successful
  43213. */
  43214. disableFeature(featureName: string | {
  43215. Name: string;
  43216. }): boolean;
  43217. /**
  43218. * dispose this features manager
  43219. */
  43220. dispose(): void;
  43221. /**
  43222. * 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.
  43223. * 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.
  43224. *
  43225. * @param featureName the name of the feature to load or the class of the feature
  43226. * @param version optional version to load. if not provided the latest version will be enabled
  43227. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43228. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43229. * @returns a new constructed feature or throws an error if feature not found.
  43230. */
  43231. enableFeature(featureName: string | {
  43232. Name: string;
  43233. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43234. /**
  43235. * get the implementation of an enabled feature.
  43236. * @param featureName the name of the feature to load
  43237. * @returns the feature class, if found
  43238. */
  43239. getEnabledFeature(featureName: string): IWebXRFeature;
  43240. /**
  43241. * Get the list of enabled features
  43242. * @returns an array of enabled features
  43243. */
  43244. getEnabledFeatures(): string[];
  43245. }
  43246. }
  43247. declare module BABYLON {
  43248. /**
  43249. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43250. * @see https://doc.babylonjs.com/how_to/webxr
  43251. */
  43252. export class WebXRExperienceHelper implements IDisposable {
  43253. private scene;
  43254. private _nonVRCamera;
  43255. private _originalSceneAutoClear;
  43256. private _supported;
  43257. /**
  43258. * Camera used to render xr content
  43259. */
  43260. camera: WebXRCamera;
  43261. /** A features manager for this xr session */
  43262. featuresManager: WebXRFeaturesManager;
  43263. /**
  43264. * Observers registered here will be triggered after the camera's initial transformation is set
  43265. * This can be used to set a different ground level or an extra rotation.
  43266. *
  43267. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43268. * to the position set after this observable is done executing.
  43269. */
  43270. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43271. /**
  43272. * Fires when the state of the experience helper has changed
  43273. */
  43274. onStateChangedObservable: Observable<WebXRState>;
  43275. /** Session manager used to keep track of xr session */
  43276. sessionManager: WebXRSessionManager;
  43277. /**
  43278. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43279. */
  43280. state: WebXRState;
  43281. /**
  43282. * Creates a WebXRExperienceHelper
  43283. * @param scene The scene the helper should be created in
  43284. */
  43285. private constructor();
  43286. /**
  43287. * Creates the experience helper
  43288. * @param scene the scene to attach the experience helper to
  43289. * @returns a promise for the experience helper
  43290. */
  43291. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43292. /**
  43293. * Disposes of the experience helper
  43294. */
  43295. dispose(): void;
  43296. /**
  43297. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43298. * @param sessionMode options for the XR session
  43299. * @param referenceSpaceType frame of reference of the XR session
  43300. * @param renderTarget the output canvas that will be used to enter XR mode
  43301. * @returns promise that resolves after xr mode has entered
  43302. */
  43303. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43304. /**
  43305. * Exits XR mode and returns the scene to its original state
  43306. * @returns promise that resolves after xr mode has exited
  43307. */
  43308. exitXRAsync(): Promise<void>;
  43309. private _nonXRToXRCamera;
  43310. private _setState;
  43311. }
  43312. }
  43313. declare module BABYLON {
  43314. /**
  43315. * X-Y values for axes in WebXR
  43316. */
  43317. export interface IWebXRMotionControllerAxesValue {
  43318. /**
  43319. * The value of the x axis
  43320. */
  43321. x: number;
  43322. /**
  43323. * The value of the y-axis
  43324. */
  43325. y: number;
  43326. }
  43327. /**
  43328. * changed / previous values for the values of this component
  43329. */
  43330. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43331. /**
  43332. * current (this frame) value
  43333. */
  43334. current: T;
  43335. /**
  43336. * previous (last change) value
  43337. */
  43338. previous: T;
  43339. }
  43340. /**
  43341. * Represents changes in the component between current frame and last values recorded
  43342. */
  43343. export interface IWebXRMotionControllerComponentChanges {
  43344. /**
  43345. * will be populated with previous and current values if axes changed
  43346. */
  43347. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43348. /**
  43349. * will be populated with previous and current values if pressed changed
  43350. */
  43351. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43352. /**
  43353. * will be populated with previous and current values if touched changed
  43354. */
  43355. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43356. /**
  43357. * will be populated with previous and current values if value changed
  43358. */
  43359. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43360. }
  43361. /**
  43362. * This class represents a single component (for example button or thumbstick) of a motion controller
  43363. */
  43364. export class WebXRControllerComponent implements IDisposable {
  43365. /**
  43366. * the id of this component
  43367. */
  43368. id: string;
  43369. /**
  43370. * the type of the component
  43371. */
  43372. type: MotionControllerComponentType;
  43373. private _buttonIndex;
  43374. private _axesIndices;
  43375. private _axes;
  43376. private _changes;
  43377. private _currentValue;
  43378. private _hasChanges;
  43379. private _pressed;
  43380. private _touched;
  43381. /**
  43382. * button component type
  43383. */
  43384. static BUTTON_TYPE: MotionControllerComponentType;
  43385. /**
  43386. * squeeze component type
  43387. */
  43388. static SQUEEZE_TYPE: MotionControllerComponentType;
  43389. /**
  43390. * Thumbstick component type
  43391. */
  43392. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43393. /**
  43394. * Touchpad component type
  43395. */
  43396. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43397. /**
  43398. * trigger component type
  43399. */
  43400. static TRIGGER_TYPE: MotionControllerComponentType;
  43401. /**
  43402. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43403. * the axes data changes
  43404. */
  43405. onAxisValueChangedObservable: Observable<{
  43406. x: number;
  43407. y: number;
  43408. }>;
  43409. /**
  43410. * Observers registered here will be triggered when the state of a button changes
  43411. * State change is either pressed / touched / value
  43412. */
  43413. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43414. /**
  43415. * Creates a new component for a motion controller.
  43416. * It is created by the motion controller itself
  43417. *
  43418. * @param id the id of this component
  43419. * @param type the type of the component
  43420. * @param _buttonIndex index in the buttons array of the gamepad
  43421. * @param _axesIndices indices of the values in the axes array of the gamepad
  43422. */
  43423. constructor(
  43424. /**
  43425. * the id of this component
  43426. */
  43427. id: string,
  43428. /**
  43429. * the type of the component
  43430. */
  43431. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43432. /**
  43433. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43434. */
  43435. get axes(): IWebXRMotionControllerAxesValue;
  43436. /**
  43437. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43438. */
  43439. get changes(): IWebXRMotionControllerComponentChanges;
  43440. /**
  43441. * Return whether or not the component changed the last frame
  43442. */
  43443. get hasChanges(): boolean;
  43444. /**
  43445. * is the button currently pressed
  43446. */
  43447. get pressed(): boolean;
  43448. /**
  43449. * is the button currently touched
  43450. */
  43451. get touched(): boolean;
  43452. /**
  43453. * Get the current value of this component
  43454. */
  43455. get value(): number;
  43456. /**
  43457. * Dispose this component
  43458. */
  43459. dispose(): void;
  43460. /**
  43461. * Are there axes correlating to this component
  43462. * @return true is axes data is available
  43463. */
  43464. isAxes(): boolean;
  43465. /**
  43466. * Is this component a button (hence - pressable)
  43467. * @returns true if can be pressed
  43468. */
  43469. isButton(): boolean;
  43470. /**
  43471. * update this component using the gamepad object it is in. Called on every frame
  43472. * @param nativeController the native gamepad controller object
  43473. */
  43474. update(nativeController: IMinimalMotionControllerObject): void;
  43475. }
  43476. }
  43477. declare module BABYLON {
  43478. /**
  43479. * Class used to represent data loading progression
  43480. */
  43481. export class SceneLoaderProgressEvent {
  43482. /** defines if data length to load can be evaluated */
  43483. readonly lengthComputable: boolean;
  43484. /** defines the loaded data length */
  43485. readonly loaded: number;
  43486. /** defines the data length to load */
  43487. readonly total: number;
  43488. /**
  43489. * Create a new progress event
  43490. * @param lengthComputable defines if data length to load can be evaluated
  43491. * @param loaded defines the loaded data length
  43492. * @param total defines the data length to load
  43493. */
  43494. constructor(
  43495. /** defines if data length to load can be evaluated */
  43496. lengthComputable: boolean,
  43497. /** defines the loaded data length */
  43498. loaded: number,
  43499. /** defines the data length to load */
  43500. total: number);
  43501. /**
  43502. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43503. * @param event defines the source event
  43504. * @returns a new SceneLoaderProgressEvent
  43505. */
  43506. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43507. }
  43508. /**
  43509. * Interface used by SceneLoader plugins to define supported file extensions
  43510. */
  43511. export interface ISceneLoaderPluginExtensions {
  43512. /**
  43513. * Defines the list of supported extensions
  43514. */
  43515. [extension: string]: {
  43516. isBinary: boolean;
  43517. };
  43518. }
  43519. /**
  43520. * Interface used by SceneLoader plugin factory
  43521. */
  43522. export interface ISceneLoaderPluginFactory {
  43523. /**
  43524. * Defines the name of the factory
  43525. */
  43526. name: string;
  43527. /**
  43528. * Function called to create a new plugin
  43529. * @return the new plugin
  43530. */
  43531. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43532. /**
  43533. * The callback that returns true if the data can be directly loaded.
  43534. * @param data string containing the file data
  43535. * @returns if the data can be loaded directly
  43536. */
  43537. canDirectLoad?(data: string): boolean;
  43538. }
  43539. /**
  43540. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43541. */
  43542. export interface ISceneLoaderPluginBase {
  43543. /**
  43544. * The friendly name of this plugin.
  43545. */
  43546. name: string;
  43547. /**
  43548. * The file extensions supported by this plugin.
  43549. */
  43550. extensions: string | ISceneLoaderPluginExtensions;
  43551. /**
  43552. * The callback called when loading from a url.
  43553. * @param scene scene loading this url
  43554. * @param url url to load
  43555. * @param onSuccess callback called when the file successfully loads
  43556. * @param onProgress callback called while file is loading (if the server supports this mode)
  43557. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43558. * @param onError callback called when the file fails to load
  43559. * @returns a file request object
  43560. */
  43561. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43562. /**
  43563. * The callback called when loading from a file object.
  43564. * @param scene scene loading this file
  43565. * @param file defines the file to load
  43566. * @param onSuccess defines the callback to call when data is loaded
  43567. * @param onProgress defines the callback to call during loading process
  43568. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43569. * @param onError defines the callback to call when an error occurs
  43570. * @returns a file request object
  43571. */
  43572. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43573. /**
  43574. * The callback that returns true if the data can be directly loaded.
  43575. * @param data string containing the file data
  43576. * @returns if the data can be loaded directly
  43577. */
  43578. canDirectLoad?(data: string): boolean;
  43579. /**
  43580. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43581. * @param scene scene loading this data
  43582. * @param data string containing the data
  43583. * @returns data to pass to the plugin
  43584. */
  43585. directLoad?(scene: Scene, data: string): any;
  43586. /**
  43587. * The callback that allows custom handling of the root url based on the response url.
  43588. * @param rootUrl the original root url
  43589. * @param responseURL the response url if available
  43590. * @returns the new root url
  43591. */
  43592. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43593. }
  43594. /**
  43595. * Interface used to define a SceneLoader plugin
  43596. */
  43597. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43598. /**
  43599. * Import meshes into a scene.
  43600. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43601. * @param scene The scene to import into
  43602. * @param data The data to import
  43603. * @param rootUrl The root url for scene and resources
  43604. * @param meshes The meshes array to import into
  43605. * @param particleSystems The particle systems array to import into
  43606. * @param skeletons The skeletons array to import into
  43607. * @param onError The callback when import fails
  43608. * @returns True if successful or false otherwise
  43609. */
  43610. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43611. /**
  43612. * Load into a scene.
  43613. * @param scene The scene to load into
  43614. * @param data The data to import
  43615. * @param rootUrl The root url for scene and resources
  43616. * @param onError The callback when import fails
  43617. * @returns True if successful or false otherwise
  43618. */
  43619. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43620. /**
  43621. * Load into an asset container.
  43622. * @param scene The scene to load into
  43623. * @param data The data to import
  43624. * @param rootUrl The root url for scene and resources
  43625. * @param onError The callback when import fails
  43626. * @returns The loaded asset container
  43627. */
  43628. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43629. }
  43630. /**
  43631. * Interface used to define an async SceneLoader plugin
  43632. */
  43633. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43634. /**
  43635. * Import meshes into a scene.
  43636. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43637. * @param scene The scene to import into
  43638. * @param data The data to import
  43639. * @param rootUrl The root url for scene and resources
  43640. * @param onProgress The callback when the load progresses
  43641. * @param fileName Defines the name of the file to load
  43642. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43643. */
  43644. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43645. meshes: AbstractMesh[];
  43646. particleSystems: IParticleSystem[];
  43647. skeletons: Skeleton[];
  43648. animationGroups: AnimationGroup[];
  43649. }>;
  43650. /**
  43651. * Load into a scene.
  43652. * @param scene The scene to load into
  43653. * @param data The data to import
  43654. * @param rootUrl The root url for scene and resources
  43655. * @param onProgress The callback when the load progresses
  43656. * @param fileName Defines the name of the file to load
  43657. * @returns Nothing
  43658. */
  43659. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43660. /**
  43661. * Load into an asset container.
  43662. * @param scene The scene to load into
  43663. * @param data The data to import
  43664. * @param rootUrl The root url for scene and resources
  43665. * @param onProgress The callback when the load progresses
  43666. * @param fileName Defines the name of the file to load
  43667. * @returns The loaded asset container
  43668. */
  43669. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43670. }
  43671. /**
  43672. * Mode that determines how to handle old animation groups before loading new ones.
  43673. */
  43674. export enum SceneLoaderAnimationGroupLoadingMode {
  43675. /**
  43676. * Reset all old animations to initial state then dispose them.
  43677. */
  43678. Clean = 0,
  43679. /**
  43680. * Stop all old animations.
  43681. */
  43682. Stop = 1,
  43683. /**
  43684. * Restart old animations from first frame.
  43685. */
  43686. Sync = 2,
  43687. /**
  43688. * Old animations remains untouched.
  43689. */
  43690. NoSync = 3
  43691. }
  43692. /**
  43693. * Class used to load scene from various file formats using registered plugins
  43694. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43695. */
  43696. export class SceneLoader {
  43697. /**
  43698. * No logging while loading
  43699. */
  43700. static readonly NO_LOGGING: number;
  43701. /**
  43702. * Minimal logging while loading
  43703. */
  43704. static readonly MINIMAL_LOGGING: number;
  43705. /**
  43706. * Summary logging while loading
  43707. */
  43708. static readonly SUMMARY_LOGGING: number;
  43709. /**
  43710. * Detailled logging while loading
  43711. */
  43712. static readonly DETAILED_LOGGING: number;
  43713. /**
  43714. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43715. */
  43716. static get ForceFullSceneLoadingForIncremental(): boolean;
  43717. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43718. /**
  43719. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43720. */
  43721. static get ShowLoadingScreen(): boolean;
  43722. static set ShowLoadingScreen(value: boolean);
  43723. /**
  43724. * Defines the current logging level (while loading the scene)
  43725. * @ignorenaming
  43726. */
  43727. static get loggingLevel(): number;
  43728. static set loggingLevel(value: number);
  43729. /**
  43730. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43731. */
  43732. static get CleanBoneMatrixWeights(): boolean;
  43733. static set CleanBoneMatrixWeights(value: boolean);
  43734. /**
  43735. * Event raised when a plugin is used to load a scene
  43736. */
  43737. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43738. private static _registeredPlugins;
  43739. private static _getDefaultPlugin;
  43740. private static _getPluginForExtension;
  43741. private static _getPluginForDirectLoad;
  43742. private static _getPluginForFilename;
  43743. private static _getDirectLoad;
  43744. private static _loadData;
  43745. private static _getFileInfo;
  43746. /**
  43747. * Gets a plugin that can load the given extension
  43748. * @param extension defines the extension to load
  43749. * @returns a plugin or null if none works
  43750. */
  43751. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43752. /**
  43753. * Gets a boolean indicating that the given extension can be loaded
  43754. * @param extension defines the extension to load
  43755. * @returns true if the extension is supported
  43756. */
  43757. static IsPluginForExtensionAvailable(extension: string): boolean;
  43758. /**
  43759. * Adds a new plugin to the list of registered plugins
  43760. * @param plugin defines the plugin to add
  43761. */
  43762. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43763. /**
  43764. * Import meshes into a scene
  43765. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43766. * @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)
  43767. * @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)
  43768. * @param scene the instance of BABYLON.Scene to append to
  43769. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43770. * @param onProgress a callback with a progress event for each file being loaded
  43771. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43772. * @param pluginExtension the extension used to determine the plugin
  43773. * @returns The loaded plugin
  43774. */
  43775. 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>;
  43776. /**
  43777. * Import meshes into a scene
  43778. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43779. * @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)
  43780. * @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)
  43781. * @param scene the instance of BABYLON.Scene to append to
  43782. * @param onProgress a callback with a progress event for each file being loaded
  43783. * @param pluginExtension the extension used to determine the plugin
  43784. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43785. */
  43786. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43787. meshes: AbstractMesh[];
  43788. particleSystems: IParticleSystem[];
  43789. skeletons: Skeleton[];
  43790. animationGroups: AnimationGroup[];
  43791. }>;
  43792. /**
  43793. * Load a scene
  43794. * @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)
  43795. * @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)
  43796. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43797. * @param onSuccess a callback with the scene when import succeeds
  43798. * @param onProgress a callback with a progress event for each file being loaded
  43799. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43800. * @param pluginExtension the extension used to determine the plugin
  43801. * @returns The loaded plugin
  43802. */
  43803. 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>;
  43804. /**
  43805. * Load a scene
  43806. * @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)
  43807. * @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)
  43808. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43809. * @param onProgress a callback with a progress event for each file being loaded
  43810. * @param pluginExtension the extension used to determine the plugin
  43811. * @returns The loaded scene
  43812. */
  43813. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43814. /**
  43815. * Append a scene
  43816. * @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)
  43817. * @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)
  43818. * @param scene is the instance of BABYLON.Scene to append to
  43819. * @param onSuccess a callback with the scene when import succeeds
  43820. * @param onProgress a callback with a progress event for each file being loaded
  43821. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43822. * @param pluginExtension the extension used to determine the plugin
  43823. * @returns The loaded plugin
  43824. */
  43825. 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>;
  43826. /**
  43827. * Append a scene
  43828. * @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)
  43829. * @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)
  43830. * @param scene is the instance of BABYLON.Scene to append to
  43831. * @param onProgress a callback with a progress event for each file being loaded
  43832. * @param pluginExtension the extension used to determine the plugin
  43833. * @returns The given scene
  43834. */
  43835. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43836. /**
  43837. * Load a scene into an asset container
  43838. * @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)
  43839. * @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)
  43840. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43841. * @param onSuccess a callback with the scene when import succeeds
  43842. * @param onProgress a callback with a progress event for each file being loaded
  43843. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43844. * @param pluginExtension the extension used to determine the plugin
  43845. * @returns The loaded plugin
  43846. */
  43847. 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>;
  43848. /**
  43849. * Load a scene into an asset container
  43850. * @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)
  43851. * @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)
  43852. * @param scene is the instance of Scene to append to
  43853. * @param onProgress a callback with a progress event for each file being loaded
  43854. * @param pluginExtension the extension used to determine the plugin
  43855. * @returns The loaded asset container
  43856. */
  43857. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43858. /**
  43859. * Import animations from a file into a scene
  43860. * @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)
  43861. * @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)
  43862. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43863. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43864. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43865. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43866. * @param onSuccess a callback with the scene when import succeeds
  43867. * @param onProgress a callback with a progress event for each file being loaded
  43868. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43869. */
  43870. 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;
  43871. /**
  43872. * Import animations from a file into a scene
  43873. * @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)
  43874. * @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)
  43875. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43876. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43877. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43878. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43879. * @param onSuccess a callback with the scene when import succeeds
  43880. * @param onProgress a callback with a progress event for each file being loaded
  43881. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43882. * @returns the updated scene with imported animations
  43883. */
  43884. 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>;
  43885. }
  43886. }
  43887. declare module BABYLON {
  43888. /**
  43889. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43890. */
  43891. export type MotionControllerHandness = "none" | "left" | "right";
  43892. /**
  43893. * The type of components available in motion controllers.
  43894. * This is not the name of the component.
  43895. */
  43896. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43897. /**
  43898. * The state of a controller component
  43899. */
  43900. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43901. /**
  43902. * The schema of motion controller layout.
  43903. * No object will be initialized using this interface
  43904. * This is used just to define the profile.
  43905. */
  43906. export interface IMotionControllerLayout {
  43907. /**
  43908. * Path to load the assets. Usually relative to the base path
  43909. */
  43910. assetPath: string;
  43911. /**
  43912. * Available components (unsorted)
  43913. */
  43914. components: {
  43915. /**
  43916. * A map of component Ids
  43917. */
  43918. [componentId: string]: {
  43919. /**
  43920. * The type of input the component outputs
  43921. */
  43922. type: MotionControllerComponentType;
  43923. /**
  43924. * The indices of this component in the gamepad object
  43925. */
  43926. gamepadIndices: {
  43927. /**
  43928. * Index of button
  43929. */
  43930. button?: number;
  43931. /**
  43932. * If available, index of x-axis
  43933. */
  43934. xAxis?: number;
  43935. /**
  43936. * If available, index of y-axis
  43937. */
  43938. yAxis?: number;
  43939. };
  43940. /**
  43941. * The mesh's root node name
  43942. */
  43943. rootNodeName: string;
  43944. /**
  43945. * Animation definitions for this model
  43946. */
  43947. visualResponses: {
  43948. [stateKey: string]: {
  43949. /**
  43950. * What property will be animated
  43951. */
  43952. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43953. /**
  43954. * What states influence this visual response
  43955. */
  43956. states: MotionControllerComponentStateType[];
  43957. /**
  43958. * Type of animation - movement or visibility
  43959. */
  43960. valueNodeProperty: "transform" | "visibility";
  43961. /**
  43962. * Base node name to move. Its position will be calculated according to the min and max nodes
  43963. */
  43964. valueNodeName?: string;
  43965. /**
  43966. * Minimum movement node
  43967. */
  43968. minNodeName?: string;
  43969. /**
  43970. * Max movement node
  43971. */
  43972. maxNodeName?: string;
  43973. };
  43974. };
  43975. /**
  43976. * If touch enabled, what is the name of node to display user feedback
  43977. */
  43978. touchPointNodeName?: string;
  43979. };
  43980. };
  43981. /**
  43982. * Is it xr standard mapping or not
  43983. */
  43984. gamepadMapping: "" | "xr-standard";
  43985. /**
  43986. * Base root node of this entire model
  43987. */
  43988. rootNodeName: string;
  43989. /**
  43990. * Defines the main button component id
  43991. */
  43992. selectComponentId: string;
  43993. }
  43994. /**
  43995. * A definition for the layout map in the input profile
  43996. */
  43997. export interface IMotionControllerLayoutMap {
  43998. /**
  43999. * Layouts with handness type as a key
  44000. */
  44001. [handness: string]: IMotionControllerLayout;
  44002. }
  44003. /**
  44004. * The XR Input profile schema
  44005. * Profiles can be found here:
  44006. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44007. */
  44008. export interface IMotionControllerProfile {
  44009. /**
  44010. * fallback profiles for this profileId
  44011. */
  44012. fallbackProfileIds: string[];
  44013. /**
  44014. * The layout map, with handness as key
  44015. */
  44016. layouts: IMotionControllerLayoutMap;
  44017. /**
  44018. * The id of this profile
  44019. * correlates to the profile(s) in the xrInput.profiles array
  44020. */
  44021. profileId: string;
  44022. }
  44023. /**
  44024. * A helper-interface for the 3 meshes needed for controller button animation
  44025. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44026. */
  44027. export interface IMotionControllerButtonMeshMap {
  44028. /**
  44029. * the mesh that defines the pressed value mesh position.
  44030. * This is used to find the max-position of this button
  44031. */
  44032. pressedMesh: AbstractMesh;
  44033. /**
  44034. * the mesh that defines the unpressed value mesh position.
  44035. * This is used to find the min (or initial) position of this button
  44036. */
  44037. unpressedMesh: AbstractMesh;
  44038. /**
  44039. * The mesh that will be changed when value changes
  44040. */
  44041. valueMesh: AbstractMesh;
  44042. }
  44043. /**
  44044. * A helper-interface for the 3 meshes needed for controller axis animation.
  44045. * This will be expanded when touchpad animations are fully supported
  44046. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44047. */
  44048. export interface IMotionControllerMeshMap {
  44049. /**
  44050. * the mesh that defines the maximum value mesh position.
  44051. */
  44052. maxMesh?: AbstractMesh;
  44053. /**
  44054. * the mesh that defines the minimum value mesh position.
  44055. */
  44056. minMesh?: AbstractMesh;
  44057. /**
  44058. * The mesh that will be changed when axis value changes
  44059. */
  44060. valueMesh: AbstractMesh;
  44061. }
  44062. /**
  44063. * The elements needed for change-detection of the gamepad objects in motion controllers
  44064. */
  44065. export interface IMinimalMotionControllerObject {
  44066. /**
  44067. * Available axes of this controller
  44068. */
  44069. axes: number[];
  44070. /**
  44071. * An array of available buttons
  44072. */
  44073. buttons: Array<{
  44074. /**
  44075. * Value of the button/trigger
  44076. */
  44077. value: number;
  44078. /**
  44079. * If the button/trigger is currently touched
  44080. */
  44081. touched: boolean;
  44082. /**
  44083. * If the button/trigger is currently pressed
  44084. */
  44085. pressed: boolean;
  44086. }>;
  44087. }
  44088. /**
  44089. * An Abstract Motion controller
  44090. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44091. * Each component has an observable to check for changes in value and state
  44092. */
  44093. export abstract class WebXRAbstractMotionController implements IDisposable {
  44094. protected scene: Scene;
  44095. protected layout: IMotionControllerLayout;
  44096. /**
  44097. * The gamepad object correlating to this controller
  44098. */
  44099. gamepadObject: IMinimalMotionControllerObject;
  44100. /**
  44101. * handness (left/right/none) of this controller
  44102. */
  44103. handness: MotionControllerHandness;
  44104. private _initComponent;
  44105. private _modelReady;
  44106. /**
  44107. * A map of components (WebXRControllerComponent) in this motion controller
  44108. * Components have a ComponentType and can also have both button and axis definitions
  44109. */
  44110. readonly components: {
  44111. [id: string]: WebXRControllerComponent;
  44112. };
  44113. /**
  44114. * Disable the model's animation. Can be set at any time.
  44115. */
  44116. disableAnimation: boolean;
  44117. /**
  44118. * Observers registered here will be triggered when the model of this controller is done loading
  44119. */
  44120. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44121. /**
  44122. * The profile id of this motion controller
  44123. */
  44124. abstract profileId: string;
  44125. /**
  44126. * The root mesh of the model. It is null if the model was not yet initialized
  44127. */
  44128. rootMesh: Nullable<AbstractMesh>;
  44129. /**
  44130. * constructs a new abstract motion controller
  44131. * @param scene the scene to which the model of the controller will be added
  44132. * @param layout The profile layout to load
  44133. * @param gamepadObject The gamepad object correlating to this controller
  44134. * @param handness handness (left/right/none) of this controller
  44135. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44136. */
  44137. constructor(scene: Scene, layout: IMotionControllerLayout,
  44138. /**
  44139. * The gamepad object correlating to this controller
  44140. */
  44141. gamepadObject: IMinimalMotionControllerObject,
  44142. /**
  44143. * handness (left/right/none) of this controller
  44144. */
  44145. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44146. /**
  44147. * Dispose this controller, the model mesh and all its components
  44148. */
  44149. dispose(): void;
  44150. /**
  44151. * Returns all components of specific type
  44152. * @param type the type to search for
  44153. * @return an array of components with this type
  44154. */
  44155. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44156. /**
  44157. * get a component based an its component id as defined in layout.components
  44158. * @param id the id of the component
  44159. * @returns the component correlates to the id or undefined if not found
  44160. */
  44161. getComponent(id: string): WebXRControllerComponent;
  44162. /**
  44163. * Get the list of components available in this motion controller
  44164. * @returns an array of strings correlating to available components
  44165. */
  44166. getComponentIds(): string[];
  44167. /**
  44168. * Get the first component of specific type
  44169. * @param type type of component to find
  44170. * @return a controller component or null if not found
  44171. */
  44172. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44173. /**
  44174. * Get the main (Select) component of this controller as defined in the layout
  44175. * @returns the main component of this controller
  44176. */
  44177. getMainComponent(): WebXRControllerComponent;
  44178. /**
  44179. * Loads the model correlating to this controller
  44180. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44181. * @returns A promise fulfilled with the result of the model loading
  44182. */
  44183. loadModel(): Promise<boolean>;
  44184. /**
  44185. * Update this model using the current XRFrame
  44186. * @param xrFrame the current xr frame to use and update the model
  44187. */
  44188. updateFromXRFrame(xrFrame: XRFrame): void;
  44189. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44190. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44191. /**
  44192. * Moves the axis on the controller mesh based on its current state
  44193. * @param axis the index of the axis
  44194. * @param axisValue the value of the axis which determines the meshes new position
  44195. * @hidden
  44196. */
  44197. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44198. /**
  44199. * Update the model itself with the current frame data
  44200. * @param xrFrame the frame to use for updating the model mesh
  44201. */
  44202. protected updateModel(xrFrame: XRFrame): void;
  44203. /**
  44204. * Get the filename and path for this controller's model
  44205. * @returns a map of filename and path
  44206. */
  44207. protected abstract _getFilenameAndPath(): {
  44208. filename: string;
  44209. path: string;
  44210. };
  44211. /**
  44212. * This function is called before the mesh is loaded. It checks for loading constraints.
  44213. * For example, this function can check if the GLB loader is available
  44214. * If this function returns false, the generic controller will be loaded instead
  44215. * @returns Is the client ready to load the mesh
  44216. */
  44217. protected abstract _getModelLoadingConstraints(): boolean;
  44218. /**
  44219. * This function will be called after the model was successfully loaded and can be used
  44220. * for mesh transformations before it is available for the user
  44221. * @param meshes the loaded meshes
  44222. */
  44223. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44224. /**
  44225. * Set the root mesh for this controller. Important for the WebXR controller class
  44226. * @param meshes the loaded meshes
  44227. */
  44228. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44229. /**
  44230. * A function executed each frame that updates the mesh (if needed)
  44231. * @param xrFrame the current xrFrame
  44232. */
  44233. protected abstract _updateModel(xrFrame: XRFrame): void;
  44234. private _getGenericFilenameAndPath;
  44235. private _getGenericParentMesh;
  44236. }
  44237. }
  44238. declare module BABYLON {
  44239. /**
  44240. * A generic trigger-only motion controller for WebXR
  44241. */
  44242. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44243. /**
  44244. * Static version of the profile id of this controller
  44245. */
  44246. static ProfileId: string;
  44247. profileId: string;
  44248. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44249. protected _getFilenameAndPath(): {
  44250. filename: string;
  44251. path: string;
  44252. };
  44253. protected _getModelLoadingConstraints(): boolean;
  44254. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44255. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44256. protected _updateModel(): void;
  44257. }
  44258. }
  44259. declare module BABYLON {
  44260. /**
  44261. * Class containing static functions to help procedurally build meshes
  44262. */
  44263. export class SphereBuilder {
  44264. /**
  44265. * Creates a sphere mesh
  44266. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44267. * * 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`)
  44268. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44269. * * 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
  44270. * * 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)
  44271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44272. * * 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
  44273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44274. * @param name defines the name of the mesh
  44275. * @param options defines the options used to create the mesh
  44276. * @param scene defines the hosting scene
  44277. * @returns the sphere mesh
  44278. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44279. */
  44280. static CreateSphere(name: string, options: {
  44281. segments?: number;
  44282. diameter?: number;
  44283. diameterX?: number;
  44284. diameterY?: number;
  44285. diameterZ?: number;
  44286. arc?: number;
  44287. slice?: number;
  44288. sideOrientation?: number;
  44289. frontUVs?: Vector4;
  44290. backUVs?: Vector4;
  44291. updatable?: boolean;
  44292. }, scene?: Nullable<Scene>): Mesh;
  44293. }
  44294. }
  44295. declare module BABYLON {
  44296. /**
  44297. * A profiled motion controller has its profile loaded from an online repository.
  44298. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44299. */
  44300. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44301. private _repositoryUrl;
  44302. private _buttonMeshMapping;
  44303. private _touchDots;
  44304. /**
  44305. * The profile ID of this controller. Will be populated when the controller initializes.
  44306. */
  44307. profileId: string;
  44308. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44309. dispose(): void;
  44310. protected _getFilenameAndPath(): {
  44311. filename: string;
  44312. path: string;
  44313. };
  44314. protected _getModelLoadingConstraints(): boolean;
  44315. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44316. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44317. protected _updateModel(_xrFrame: XRFrame): void;
  44318. }
  44319. }
  44320. declare module BABYLON {
  44321. /**
  44322. * A construction function type to create a new controller based on an xrInput object
  44323. */
  44324. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44325. /**
  44326. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44327. *
  44328. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44329. * it should be replaced with auto-loaded controllers.
  44330. *
  44331. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44332. */
  44333. export class WebXRMotionControllerManager {
  44334. private static _AvailableControllers;
  44335. private static _Fallbacks;
  44336. private static _ProfileLoadingPromises;
  44337. private static _ProfilesList;
  44338. /**
  44339. * The base URL of the online controller repository. Can be changed at any time.
  44340. */
  44341. static BaseRepositoryUrl: string;
  44342. /**
  44343. * Which repository gets priority - local or online
  44344. */
  44345. static PrioritizeOnlineRepository: boolean;
  44346. /**
  44347. * Use the online repository, or use only locally-defined controllers
  44348. */
  44349. static UseOnlineRepository: boolean;
  44350. /**
  44351. * Clear the cache used for profile loading and reload when requested again
  44352. */
  44353. static ClearProfilesCache(): void;
  44354. /**
  44355. * Register the default fallbacks.
  44356. * This function is called automatically when this file is imported.
  44357. */
  44358. static DefaultFallbacks(): void;
  44359. /**
  44360. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44361. * @param profileId the profile to which a fallback needs to be found
  44362. * @return an array with corresponding fallback profiles
  44363. */
  44364. static FindFallbackWithProfileId(profileId: string): string[];
  44365. /**
  44366. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44367. * The order of search:
  44368. *
  44369. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44370. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44371. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44372. * 4) return the generic trigger controller if none were found
  44373. *
  44374. * @param xrInput the xrInput to which a new controller is initialized
  44375. * @param scene the scene to which the model will be added
  44376. * @param forceProfile force a certain profile for this controller
  44377. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44378. */
  44379. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44380. /**
  44381. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44382. *
  44383. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44384. *
  44385. * @param type the profile type to register
  44386. * @param constructFunction the function to be called when loading this profile
  44387. */
  44388. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44389. /**
  44390. * Register a fallback to a specific profile.
  44391. * @param profileId the profileId that will receive the fallbacks
  44392. * @param fallbacks A list of fallback profiles
  44393. */
  44394. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44395. /**
  44396. * Will update the list of profiles available in the repository
  44397. * @return a promise that resolves to a map of profiles available online
  44398. */
  44399. static UpdateProfilesList(): Promise<{
  44400. [profile: string]: string;
  44401. }>;
  44402. private static _LoadProfileFromRepository;
  44403. private static _LoadProfilesFromAvailableControllers;
  44404. }
  44405. }
  44406. declare module BABYLON {
  44407. /**
  44408. * Configuration options for the WebXR controller creation
  44409. */
  44410. export interface IWebXRControllerOptions {
  44411. /**
  44412. * Should the controller mesh be animated when a user interacts with it
  44413. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44414. */
  44415. disableMotionControllerAnimation?: boolean;
  44416. /**
  44417. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44418. */
  44419. doNotLoadControllerMesh?: boolean;
  44420. /**
  44421. * Force a specific controller type for this controller.
  44422. * This can be used when creating your own profile or when testing different controllers
  44423. */
  44424. forceControllerProfile?: string;
  44425. }
  44426. /**
  44427. * Represents an XR controller
  44428. */
  44429. export class WebXRInputSource {
  44430. private _scene;
  44431. /** The underlying input source for the controller */
  44432. inputSource: XRInputSource;
  44433. private _options;
  44434. private _tmpQuaternion;
  44435. private _tmpVector;
  44436. private _uniqueId;
  44437. /**
  44438. * 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
  44439. */
  44440. grip?: AbstractMesh;
  44441. /**
  44442. * If available, this is the gamepad object related to this controller.
  44443. * Using this object it is possible to get click events and trackpad changes of the
  44444. * webxr controller that is currently being used.
  44445. */
  44446. motionController?: WebXRAbstractMotionController;
  44447. /**
  44448. * Event that fires when the controller is removed/disposed.
  44449. * The object provided as event data is this controller, after associated assets were disposed.
  44450. * uniqueId is still available.
  44451. */
  44452. onDisposeObservable: Observable<WebXRInputSource>;
  44453. /**
  44454. * Will be triggered when the mesh associated with the motion controller is done loading.
  44455. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44456. * A shortened version of controller -> motion controller -> on mesh loaded.
  44457. */
  44458. onMeshLoadedObservable: Observable<AbstractMesh>;
  44459. /**
  44460. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44461. */
  44462. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44463. /**
  44464. * Pointer which can be used to select objects or attach a visible laser to
  44465. */
  44466. pointer: AbstractMesh;
  44467. /**
  44468. * Creates the controller
  44469. * @see https://doc.babylonjs.com/how_to/webxr
  44470. * @param _scene the scene which the controller should be associated to
  44471. * @param inputSource the underlying input source for the controller
  44472. * @param _options options for this controller creation
  44473. */
  44474. constructor(_scene: Scene,
  44475. /** The underlying input source for the controller */
  44476. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44477. /**
  44478. * Get this controllers unique id
  44479. */
  44480. get uniqueId(): string;
  44481. /**
  44482. * Disposes of the object
  44483. */
  44484. dispose(): void;
  44485. /**
  44486. * Gets a world space ray coming from the pointer or grip
  44487. * @param result the resulting ray
  44488. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44489. */
  44490. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44491. /**
  44492. * Updates the controller pose based on the given XRFrame
  44493. * @param xrFrame xr frame to update the pose with
  44494. * @param referenceSpace reference space to use
  44495. */
  44496. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44497. }
  44498. }
  44499. declare module BABYLON {
  44500. /**
  44501. * The schema for initialization options of the XR Input class
  44502. */
  44503. export interface IWebXRInputOptions {
  44504. /**
  44505. * If set to true no model will be automatically loaded
  44506. */
  44507. doNotLoadControllerMeshes?: boolean;
  44508. /**
  44509. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44510. * If not found, the xr input profile data will be used.
  44511. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44512. */
  44513. forceInputProfile?: string;
  44514. /**
  44515. * Do not send a request to the controller repository to load the profile.
  44516. *
  44517. * Instead, use the controllers available in babylon itself.
  44518. */
  44519. disableOnlineControllerRepository?: boolean;
  44520. /**
  44521. * A custom URL for the controllers repository
  44522. */
  44523. customControllersRepositoryURL?: string;
  44524. /**
  44525. * Should the controller model's components not move according to the user input
  44526. */
  44527. disableControllerAnimation?: boolean;
  44528. }
  44529. /**
  44530. * XR input used to track XR inputs such as controllers/rays
  44531. */
  44532. export class WebXRInput implements IDisposable {
  44533. /**
  44534. * the xr session manager for this session
  44535. */
  44536. xrSessionManager: WebXRSessionManager;
  44537. /**
  44538. * the WebXR camera for this session. Mainly used for teleportation
  44539. */
  44540. xrCamera: WebXRCamera;
  44541. private readonly options;
  44542. /**
  44543. * XR controllers being tracked
  44544. */
  44545. controllers: Array<WebXRInputSource>;
  44546. private _frameObserver;
  44547. private _sessionEndedObserver;
  44548. private _sessionInitObserver;
  44549. /**
  44550. * Event when a controller has been connected/added
  44551. */
  44552. onControllerAddedObservable: Observable<WebXRInputSource>;
  44553. /**
  44554. * Event when a controller has been removed/disconnected
  44555. */
  44556. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44557. /**
  44558. * Initializes the WebXRInput
  44559. * @param xrSessionManager the xr session manager for this session
  44560. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44561. * @param options = initialization options for this xr input
  44562. */
  44563. constructor(
  44564. /**
  44565. * the xr session manager for this session
  44566. */
  44567. xrSessionManager: WebXRSessionManager,
  44568. /**
  44569. * the WebXR camera for this session. Mainly used for teleportation
  44570. */
  44571. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44572. private _onInputSourcesChange;
  44573. private _addAndRemoveControllers;
  44574. /**
  44575. * Disposes of the object
  44576. */
  44577. dispose(): void;
  44578. }
  44579. }
  44580. declare module BABYLON {
  44581. /**
  44582. * This is the base class for all WebXR features.
  44583. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44584. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44585. */
  44586. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44587. protected _xrSessionManager: WebXRSessionManager;
  44588. private _attached;
  44589. private _removeOnDetach;
  44590. /**
  44591. * Should auto-attach be disabled?
  44592. */
  44593. disableAutoAttach: boolean;
  44594. /**
  44595. * Construct a new (abstract) WebXR feature
  44596. * @param _xrSessionManager the xr session manager for this feature
  44597. */
  44598. constructor(_xrSessionManager: WebXRSessionManager);
  44599. /**
  44600. * Is this feature attached
  44601. */
  44602. get attached(): boolean;
  44603. /**
  44604. * attach this feature
  44605. *
  44606. * @param force should attachment be forced (even when already attached)
  44607. * @returns true if successful, false is failed or already attached
  44608. */
  44609. attach(force?: boolean): boolean;
  44610. /**
  44611. * detach this feature.
  44612. *
  44613. * @returns true if successful, false if failed or already detached
  44614. */
  44615. detach(): boolean;
  44616. /**
  44617. * Dispose this feature and all of the resources attached
  44618. */
  44619. dispose(): void;
  44620. /**
  44621. * This is used to register callbacks that will automatically be removed when detach is called.
  44622. * @param observable the observable to which the observer will be attached
  44623. * @param callback the callback to register
  44624. */
  44625. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44626. /**
  44627. * Code in this function will be executed on each xrFrame received from the browser.
  44628. * This function will not execute after the feature is detached.
  44629. * @param _xrFrame the current frame
  44630. */
  44631. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44632. }
  44633. }
  44634. declare module BABYLON {
  44635. /**
  44636. * Renders a layer on top of an existing scene
  44637. */
  44638. export class UtilityLayerRenderer implements IDisposable {
  44639. /** the original scene that will be rendered on top of */
  44640. originalScene: Scene;
  44641. private _pointerCaptures;
  44642. private _lastPointerEvents;
  44643. private static _DefaultUtilityLayer;
  44644. private static _DefaultKeepDepthUtilityLayer;
  44645. private _sharedGizmoLight;
  44646. private _renderCamera;
  44647. /**
  44648. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44649. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44650. * @returns the camera that is used when rendering the utility layer
  44651. */
  44652. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44653. /**
  44654. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44655. * @param cam the camera that should be used when rendering the utility layer
  44656. */
  44657. setRenderCamera(cam: Nullable<Camera>): void;
  44658. /**
  44659. * @hidden
  44660. * Light which used by gizmos to get light shading
  44661. */
  44662. _getSharedGizmoLight(): HemisphericLight;
  44663. /**
  44664. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44665. */
  44666. pickUtilitySceneFirst: boolean;
  44667. /**
  44668. * 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)
  44669. */
  44670. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44671. /**
  44672. * 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)
  44673. */
  44674. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44675. /**
  44676. * The scene that is rendered on top of the original scene
  44677. */
  44678. utilityLayerScene: Scene;
  44679. /**
  44680. * If the utility layer should automatically be rendered on top of existing scene
  44681. */
  44682. shouldRender: boolean;
  44683. /**
  44684. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44685. */
  44686. onlyCheckPointerDownEvents: boolean;
  44687. /**
  44688. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44689. */
  44690. processAllEvents: boolean;
  44691. /**
  44692. * Observable raised when the pointer move from the utility layer scene to the main scene
  44693. */
  44694. onPointerOutObservable: Observable<number>;
  44695. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44696. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44697. private _afterRenderObserver;
  44698. private _sceneDisposeObserver;
  44699. private _originalPointerObserver;
  44700. /**
  44701. * Instantiates a UtilityLayerRenderer
  44702. * @param originalScene the original scene that will be rendered on top of
  44703. * @param handleEvents boolean indicating if the utility layer should handle events
  44704. */
  44705. constructor(
  44706. /** the original scene that will be rendered on top of */
  44707. originalScene: Scene, handleEvents?: boolean);
  44708. private _notifyObservers;
  44709. /**
  44710. * Renders the utility layers scene on top of the original scene
  44711. */
  44712. render(): void;
  44713. /**
  44714. * Disposes of the renderer
  44715. */
  44716. dispose(): void;
  44717. private _updateCamera;
  44718. }
  44719. }
  44720. declare module BABYLON {
  44721. /**
  44722. * Options interface for the pointer selection module
  44723. */
  44724. export interface IWebXRControllerPointerSelectionOptions {
  44725. /**
  44726. * if provided, this scene will be used to render meshes.
  44727. */
  44728. customUtilityLayerScene?: Scene;
  44729. /**
  44730. * 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)
  44731. * If not disabled, the last picked point will be used to execute a pointer up event
  44732. * If disabled, pointer up event will be triggered right after the pointer down event.
  44733. * Used in screen and gaze target ray mode only
  44734. */
  44735. disablePointerUpOnTouchOut: boolean;
  44736. /**
  44737. * For gaze mode (time to select instead of press)
  44738. */
  44739. forceGazeMode: boolean;
  44740. /**
  44741. * 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
  44742. * to start a new countdown to the pointer down event.
  44743. * Defaults to 1.
  44744. */
  44745. gazeModePointerMovedFactor?: number;
  44746. /**
  44747. * Different button type to use instead of the main component
  44748. */
  44749. overrideButtonId?: string;
  44750. /**
  44751. * use this rendering group id for the meshes (optional)
  44752. */
  44753. renderingGroupId?: number;
  44754. /**
  44755. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44756. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44757. * 3000 means 3 seconds between pointing at something and selecting it
  44758. */
  44759. timeToSelect?: number;
  44760. /**
  44761. * Should meshes created here be added to a utility layer or the main scene
  44762. */
  44763. useUtilityLayer?: boolean;
  44764. /**
  44765. * the xr input to use with this pointer selection
  44766. */
  44767. xrInput: WebXRInput;
  44768. }
  44769. /**
  44770. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44771. */
  44772. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44773. private readonly _options;
  44774. private static _idCounter;
  44775. private _attachController;
  44776. private _controllers;
  44777. private _scene;
  44778. private _tmpVectorForPickCompare;
  44779. /**
  44780. * The module's name
  44781. */
  44782. static readonly Name: string;
  44783. /**
  44784. * The (Babylon) version of this module.
  44785. * This is an integer representing the implementation version.
  44786. * This number does not correspond to the WebXR specs version
  44787. */
  44788. static readonly Version: number;
  44789. /**
  44790. * Disable lighting on the laser pointer (so it will always be visible)
  44791. */
  44792. disablePointerLighting: boolean;
  44793. /**
  44794. * Disable lighting on the selection mesh (so it will always be visible)
  44795. */
  44796. disableSelectionMeshLighting: boolean;
  44797. /**
  44798. * Should the laser pointer be displayed
  44799. */
  44800. displayLaserPointer: boolean;
  44801. /**
  44802. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44803. */
  44804. displaySelectionMesh: boolean;
  44805. /**
  44806. * This color will be set to the laser pointer when selection is triggered
  44807. */
  44808. laserPointerPickedColor: Color3;
  44809. /**
  44810. * Default color of the laser pointer
  44811. */
  44812. lasterPointerDefaultColor: Color3;
  44813. /**
  44814. * default color of the selection ring
  44815. */
  44816. selectionMeshDefaultColor: Color3;
  44817. /**
  44818. * This color will be applied to the selection ring when selection is triggered
  44819. */
  44820. selectionMeshPickedColor: Color3;
  44821. /**
  44822. * Optional filter to be used for ray selection. This predicate shares behavior with
  44823. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44824. */
  44825. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44826. /**
  44827. * constructs a new background remover module
  44828. * @param _xrSessionManager the session manager for this module
  44829. * @param _options read-only options to be used in this module
  44830. */
  44831. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44832. /**
  44833. * attach this feature
  44834. * Will usually be called by the features manager
  44835. *
  44836. * @returns true if successful.
  44837. */
  44838. attach(): boolean;
  44839. /**
  44840. * detach this feature.
  44841. * Will usually be called by the features manager
  44842. *
  44843. * @returns true if successful.
  44844. */
  44845. detach(): boolean;
  44846. /**
  44847. * Will get the mesh under a specific pointer.
  44848. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44849. * @param controllerId the controllerId to check
  44850. * @returns The mesh under pointer or null if no mesh is under the pointer
  44851. */
  44852. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44853. /**
  44854. * Get the xr controller that correlates to the pointer id in the pointer event
  44855. *
  44856. * @param id the pointer id to search for
  44857. * @returns the controller that correlates to this id or null if not found
  44858. */
  44859. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44860. protected _onXRFrame(_xrFrame: XRFrame): void;
  44861. private _attachGazeMode;
  44862. private _attachScreenRayMode;
  44863. private _attachTrackedPointerRayMode;
  44864. private _convertNormalToDirectionOfRay;
  44865. private _detachController;
  44866. private _generateNewMeshPair;
  44867. private _pickingMoved;
  44868. private _updatePointerDistance;
  44869. }
  44870. }
  44871. declare module BABYLON {
  44872. /**
  44873. * Button which can be used to enter a different mode of XR
  44874. */
  44875. export class WebXREnterExitUIButton {
  44876. /** button element */
  44877. element: HTMLElement;
  44878. /** XR initialization options for the button */
  44879. sessionMode: XRSessionMode;
  44880. /** Reference space type */
  44881. referenceSpaceType: XRReferenceSpaceType;
  44882. /**
  44883. * Creates a WebXREnterExitUIButton
  44884. * @param element button element
  44885. * @param sessionMode XR initialization session mode
  44886. * @param referenceSpaceType the type of reference space to be used
  44887. */
  44888. constructor(
  44889. /** button element */
  44890. element: HTMLElement,
  44891. /** XR initialization options for the button */
  44892. sessionMode: XRSessionMode,
  44893. /** Reference space type */
  44894. referenceSpaceType: XRReferenceSpaceType);
  44895. /**
  44896. * Extendable function which can be used to update the button's visuals when the state changes
  44897. * @param activeButton the current active button in the UI
  44898. */
  44899. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44900. }
  44901. /**
  44902. * Options to create the webXR UI
  44903. */
  44904. export class WebXREnterExitUIOptions {
  44905. /**
  44906. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44907. */
  44908. customButtons?: Array<WebXREnterExitUIButton>;
  44909. /**
  44910. * A reference space type to use when creating the default button.
  44911. * Default is local-floor
  44912. */
  44913. referenceSpaceType?: XRReferenceSpaceType;
  44914. /**
  44915. * Context to enter xr with
  44916. */
  44917. renderTarget?: Nullable<WebXRRenderTarget>;
  44918. /**
  44919. * A session mode to use when creating the default button.
  44920. * Default is immersive-vr
  44921. */
  44922. sessionMode?: XRSessionMode;
  44923. }
  44924. /**
  44925. * UI to allow the user to enter/exit XR mode
  44926. */
  44927. export class WebXREnterExitUI implements IDisposable {
  44928. private scene;
  44929. /** version of the options passed to this UI */
  44930. options: WebXREnterExitUIOptions;
  44931. private _activeButton;
  44932. private _buttons;
  44933. private _overlay;
  44934. /**
  44935. * Fired every time the active button is changed.
  44936. *
  44937. * When xr is entered via a button that launches xr that button will be the callback parameter
  44938. *
  44939. * When exiting xr the callback parameter will be null)
  44940. */
  44941. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44942. /**
  44943. *
  44944. * @param scene babylon scene object to use
  44945. * @param options (read-only) version of the options passed to this UI
  44946. */
  44947. private constructor();
  44948. /**
  44949. * Creates UI to allow the user to enter/exit XR mode
  44950. * @param scene the scene to add the ui to
  44951. * @param helper the xr experience helper to enter/exit xr with
  44952. * @param options options to configure the UI
  44953. * @returns the created ui
  44954. */
  44955. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44956. /**
  44957. * Disposes of the XR UI component
  44958. */
  44959. dispose(): void;
  44960. private _updateButtons;
  44961. }
  44962. }
  44963. declare module BABYLON {
  44964. /**
  44965. * Class containing static functions to help procedurally build meshes
  44966. */
  44967. export class LinesBuilder {
  44968. /**
  44969. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44970. * * 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
  44971. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44972. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44973. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44974. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44975. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44976. * * 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
  44977. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44980. * @param name defines the name of the new line system
  44981. * @param options defines the options used to create the line system
  44982. * @param scene defines the hosting scene
  44983. * @returns a new line system mesh
  44984. */
  44985. static CreateLineSystem(name: string, options: {
  44986. lines: Vector3[][];
  44987. updatable?: boolean;
  44988. instance?: Nullable<LinesMesh>;
  44989. colors?: Nullable<Color4[][]>;
  44990. useVertexAlpha?: boolean;
  44991. }, scene: Nullable<Scene>): LinesMesh;
  44992. /**
  44993. * Creates a line mesh
  44994. * 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
  44995. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44996. * * The parameter `points` is an array successive Vector3
  44997. * * 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
  44998. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44999. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45000. * * When updating an instance, remember that only point positions can change, not the number of points
  45001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45003. * @param name defines the name of the new line system
  45004. * @param options defines the options used to create the line system
  45005. * @param scene defines the hosting scene
  45006. * @returns a new line mesh
  45007. */
  45008. static CreateLines(name: string, options: {
  45009. points: Vector3[];
  45010. updatable?: boolean;
  45011. instance?: Nullable<LinesMesh>;
  45012. colors?: Color4[];
  45013. useVertexAlpha?: boolean;
  45014. }, scene?: Nullable<Scene>): LinesMesh;
  45015. /**
  45016. * Creates a dashed line mesh
  45017. * * 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
  45018. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45019. * * The parameter `points` is an array successive Vector3
  45020. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45021. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45022. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45023. * * 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
  45024. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45025. * * When updating an instance, remember that only point positions can change, not the number of points
  45026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45027. * @param name defines the name of the mesh
  45028. * @param options defines the options used to create the mesh
  45029. * @param scene defines the hosting scene
  45030. * @returns the dashed line mesh
  45031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45032. */
  45033. static CreateDashedLines(name: string, options: {
  45034. points: Vector3[];
  45035. dashSize?: number;
  45036. gapSize?: number;
  45037. dashNb?: number;
  45038. updatable?: boolean;
  45039. instance?: LinesMesh;
  45040. useVertexAlpha?: boolean;
  45041. }, scene?: Nullable<Scene>): LinesMesh;
  45042. }
  45043. }
  45044. declare module BABYLON {
  45045. /**
  45046. * The options container for the teleportation module
  45047. */
  45048. export interface IWebXRTeleportationOptions {
  45049. /**
  45050. * if provided, this scene will be used to render meshes.
  45051. */
  45052. customUtilityLayerScene?: Scene;
  45053. /**
  45054. * Values to configure the default target mesh
  45055. */
  45056. defaultTargetMeshOptions?: {
  45057. /**
  45058. * Fill color of the teleportation area
  45059. */
  45060. teleportationFillColor?: string;
  45061. /**
  45062. * Border color for the teleportation area
  45063. */
  45064. teleportationBorderColor?: string;
  45065. /**
  45066. * Disable the mesh's animation sequence
  45067. */
  45068. disableAnimation?: boolean;
  45069. /**
  45070. * Disable lighting on the material or the ring and arrow
  45071. */
  45072. disableLighting?: boolean;
  45073. /**
  45074. * Override the default material of the torus and arrow
  45075. */
  45076. torusArrowMaterial?: Material;
  45077. };
  45078. /**
  45079. * A list of meshes to use as floor meshes.
  45080. * Meshes can be added and removed after initializing the feature using the
  45081. * addFloorMesh and removeFloorMesh functions
  45082. * If empty, rotation will still work
  45083. */
  45084. floorMeshes?: AbstractMesh[];
  45085. /**
  45086. * use this rendering group id for the meshes (optional)
  45087. */
  45088. renderingGroupId?: number;
  45089. /**
  45090. * Should teleportation move only to snap points
  45091. */
  45092. snapPointsOnly?: boolean;
  45093. /**
  45094. * An array of points to which the teleportation will snap to.
  45095. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45096. */
  45097. snapPositions?: Vector3[];
  45098. /**
  45099. * How close should the teleportation ray be in order to snap to position.
  45100. * Default to 0.8 units (meters)
  45101. */
  45102. snapToPositionRadius?: number;
  45103. /**
  45104. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45105. * If you want to support rotation, make sure your mesh has a direction indicator.
  45106. *
  45107. * When left untouched, the default mesh will be initialized.
  45108. */
  45109. teleportationTargetMesh?: AbstractMesh;
  45110. /**
  45111. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45112. */
  45113. timeToTeleport?: number;
  45114. /**
  45115. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45116. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45117. */
  45118. useMainComponentOnly?: boolean;
  45119. /**
  45120. * Should meshes created here be added to a utility layer or the main scene
  45121. */
  45122. useUtilityLayer?: boolean;
  45123. /**
  45124. * Babylon XR Input class for controller
  45125. */
  45126. xrInput: WebXRInput;
  45127. }
  45128. /**
  45129. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45130. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45131. * the input of the attached controllers.
  45132. */
  45133. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45134. private _options;
  45135. private _controllers;
  45136. private _currentTeleportationControllerId;
  45137. private _floorMeshes;
  45138. private _quadraticBezierCurve;
  45139. private _selectionFeature;
  45140. private _snapToPositions;
  45141. private _snappedToPoint;
  45142. private _teleportationRingMaterial?;
  45143. private _tmpRay;
  45144. private _tmpVector;
  45145. /**
  45146. * The module's name
  45147. */
  45148. static readonly Name: string;
  45149. /**
  45150. * The (Babylon) version of this module.
  45151. * This is an integer representing the implementation version.
  45152. * This number does not correspond to the webxr specs version
  45153. */
  45154. static readonly Version: number;
  45155. /**
  45156. * Is movement backwards enabled
  45157. */
  45158. backwardsMovementEnabled: boolean;
  45159. /**
  45160. * Distance to travel when moving backwards
  45161. */
  45162. backwardsTeleportationDistance: number;
  45163. /**
  45164. * The distance from the user to the inspection point in the direction of the controller
  45165. * A higher number will allow the user to move further
  45166. * defaults to 5 (meters, in xr units)
  45167. */
  45168. parabolicCheckRadius: number;
  45169. /**
  45170. * Should the module support parabolic ray on top of direct ray
  45171. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45172. * Very helpful when moving between floors / different heights
  45173. */
  45174. parabolicRayEnabled: boolean;
  45175. /**
  45176. * How much rotation should be applied when rotating right and left
  45177. */
  45178. rotationAngle: number;
  45179. /**
  45180. * Is rotation enabled when moving forward?
  45181. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45182. */
  45183. rotationEnabled: boolean;
  45184. /**
  45185. * constructs a new anchor system
  45186. * @param _xrSessionManager an instance of WebXRSessionManager
  45187. * @param _options configuration object for this feature
  45188. */
  45189. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45190. /**
  45191. * Get the snapPointsOnly flag
  45192. */
  45193. get snapPointsOnly(): boolean;
  45194. /**
  45195. * Sets the snapPointsOnly flag
  45196. * @param snapToPoints should teleportation be exclusively to snap points
  45197. */
  45198. set snapPointsOnly(snapToPoints: boolean);
  45199. /**
  45200. * Add a new mesh to the floor meshes array
  45201. * @param mesh the mesh to use as floor mesh
  45202. */
  45203. addFloorMesh(mesh: AbstractMesh): void;
  45204. /**
  45205. * Add a new snap-to point to fix teleportation to this position
  45206. * @param newSnapPoint The new Snap-To point
  45207. */
  45208. addSnapPoint(newSnapPoint: Vector3): void;
  45209. attach(): boolean;
  45210. detach(): boolean;
  45211. dispose(): void;
  45212. /**
  45213. * Remove a mesh from the floor meshes array
  45214. * @param mesh the mesh to remove
  45215. */
  45216. removeFloorMesh(mesh: AbstractMesh): void;
  45217. /**
  45218. * Remove a mesh from the floor meshes array using its name
  45219. * @param name the mesh name to remove
  45220. */
  45221. removeFloorMeshByName(name: string): void;
  45222. /**
  45223. * 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
  45224. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45225. * @returns was the point found and removed or not
  45226. */
  45227. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45228. /**
  45229. * This function sets a selection feature that will be disabled when
  45230. * the forward ray is shown and will be reattached when hidden.
  45231. * This is used to remove the selection rays when moving.
  45232. * @param selectionFeature the feature to disable when forward movement is enabled
  45233. */
  45234. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45235. protected _onXRFrame(_xrFrame: XRFrame): void;
  45236. private _attachController;
  45237. private _createDefaultTargetMesh;
  45238. private _detachController;
  45239. private _findClosestSnapPointWithRadius;
  45240. private _setTargetMeshPosition;
  45241. private _setTargetMeshVisibility;
  45242. private _showParabolicPath;
  45243. private _teleportForward;
  45244. }
  45245. }
  45246. declare module BABYLON {
  45247. /**
  45248. * Options for the default xr helper
  45249. */
  45250. export class WebXRDefaultExperienceOptions {
  45251. /**
  45252. * Enable or disable default UI to enter XR
  45253. */
  45254. disableDefaultUI?: boolean;
  45255. /**
  45256. * Should teleportation not initialize. defaults to false.
  45257. */
  45258. disableTeleportation?: boolean;
  45259. /**
  45260. * Floor meshes that will be used for teleport
  45261. */
  45262. floorMeshes?: Array<AbstractMesh>;
  45263. /**
  45264. * If set to true, the first frame will not be used to reset position
  45265. * The first frame is mainly used when copying transformation from the old camera
  45266. * Mainly used in AR
  45267. */
  45268. ignoreNativeCameraTransformation?: boolean;
  45269. /**
  45270. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45271. */
  45272. inputOptions?: IWebXRInputOptions;
  45273. /**
  45274. * optional configuration for the output canvas
  45275. */
  45276. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45277. /**
  45278. * optional UI options. This can be used among other to change session mode and reference space type
  45279. */
  45280. uiOptions?: WebXREnterExitUIOptions;
  45281. /**
  45282. * When loading teleportation and pointer select, use stable versions instead of latest.
  45283. */
  45284. useStablePlugins?: boolean;
  45285. }
  45286. /**
  45287. * Default experience which provides a similar setup to the previous webVRExperience
  45288. */
  45289. export class WebXRDefaultExperience {
  45290. /**
  45291. * Base experience
  45292. */
  45293. baseExperience: WebXRExperienceHelper;
  45294. /**
  45295. * Enables ui for entering/exiting xr
  45296. */
  45297. enterExitUI: WebXREnterExitUI;
  45298. /**
  45299. * Input experience extension
  45300. */
  45301. input: WebXRInput;
  45302. /**
  45303. * Enables laser pointer and selection
  45304. */
  45305. pointerSelection: WebXRControllerPointerSelection;
  45306. /**
  45307. * Default target xr should render to
  45308. */
  45309. renderTarget: WebXRRenderTarget;
  45310. /**
  45311. * Enables teleportation
  45312. */
  45313. teleportation: WebXRMotionControllerTeleportation;
  45314. private constructor();
  45315. /**
  45316. * Creates the default xr experience
  45317. * @param scene scene
  45318. * @param options options for basic configuration
  45319. * @returns resulting WebXRDefaultExperience
  45320. */
  45321. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45322. /**
  45323. * DIsposes of the experience helper
  45324. */
  45325. dispose(): void;
  45326. }
  45327. }
  45328. declare module BABYLON {
  45329. /**
  45330. * Options to modify the vr teleportation behavior.
  45331. */
  45332. export interface VRTeleportationOptions {
  45333. /**
  45334. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45335. */
  45336. floorMeshName?: string;
  45337. /**
  45338. * A list of meshes to be used as the teleportation floor. (default: empty)
  45339. */
  45340. floorMeshes?: Mesh[];
  45341. /**
  45342. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45343. */
  45344. teleportationMode?: number;
  45345. /**
  45346. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45347. */
  45348. teleportationTime?: number;
  45349. /**
  45350. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45351. */
  45352. teleportationSpeed?: number;
  45353. /**
  45354. * The easing function used in the animation or null for Linear. (default CircleEase)
  45355. */
  45356. easingFunction?: EasingFunction;
  45357. }
  45358. /**
  45359. * Options to modify the vr experience helper's behavior.
  45360. */
  45361. export interface VRExperienceHelperOptions extends WebVROptions {
  45362. /**
  45363. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45364. */
  45365. createDeviceOrientationCamera?: boolean;
  45366. /**
  45367. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45368. */
  45369. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45370. /**
  45371. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45372. */
  45373. laserToggle?: boolean;
  45374. /**
  45375. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45376. */
  45377. floorMeshes?: Mesh[];
  45378. /**
  45379. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45380. */
  45381. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45382. /**
  45383. * Defines if WebXR should be used instead of WebVR (if available)
  45384. */
  45385. useXR?: boolean;
  45386. }
  45387. /**
  45388. * Event containing information after VR has been entered
  45389. */
  45390. export class OnAfterEnteringVRObservableEvent {
  45391. /**
  45392. * If entering vr was successful
  45393. */
  45394. success: boolean;
  45395. }
  45396. /**
  45397. * Helps to quickly add VR support to an existing scene.
  45398. * See http://doc.babylonjs.com/how_to/webvr_helper
  45399. */
  45400. export class VRExperienceHelper {
  45401. /** Options to modify the vr experience helper's behavior. */
  45402. webVROptions: VRExperienceHelperOptions;
  45403. private _scene;
  45404. private _position;
  45405. private _btnVR;
  45406. private _btnVRDisplayed;
  45407. private _webVRsupported;
  45408. private _webVRready;
  45409. private _webVRrequesting;
  45410. private _webVRpresenting;
  45411. private _hasEnteredVR;
  45412. private _fullscreenVRpresenting;
  45413. private _inputElement;
  45414. private _webVRCamera;
  45415. private _vrDeviceOrientationCamera;
  45416. private _deviceOrientationCamera;
  45417. private _existingCamera;
  45418. private _onKeyDown;
  45419. private _onVrDisplayPresentChange;
  45420. private _onVRDisplayChanged;
  45421. private _onVRRequestPresentStart;
  45422. private _onVRRequestPresentComplete;
  45423. /**
  45424. * 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)
  45425. */
  45426. enableGazeEvenWhenNoPointerLock: boolean;
  45427. /**
  45428. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45429. */
  45430. exitVROnDoubleTap: boolean;
  45431. /**
  45432. * Observable raised right before entering VR.
  45433. */
  45434. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45435. /**
  45436. * Observable raised when entering VR has completed.
  45437. */
  45438. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45439. /**
  45440. * Observable raised when exiting VR.
  45441. */
  45442. onExitingVRObservable: Observable<VRExperienceHelper>;
  45443. /**
  45444. * Observable raised when controller mesh is loaded.
  45445. */
  45446. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45447. /** Return this.onEnteringVRObservable
  45448. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45449. */
  45450. get onEnteringVR(): Observable<VRExperienceHelper>;
  45451. /** Return this.onExitingVRObservable
  45452. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45453. */
  45454. get onExitingVR(): Observable<VRExperienceHelper>;
  45455. /** Return this.onControllerMeshLoadedObservable
  45456. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45457. */
  45458. get onControllerMeshLoaded(): Observable<WebVRController>;
  45459. private _rayLength;
  45460. private _useCustomVRButton;
  45461. private _teleportationRequested;
  45462. private _teleportActive;
  45463. private _floorMeshName;
  45464. private _floorMeshesCollection;
  45465. private _teleportationMode;
  45466. private _teleportationTime;
  45467. private _teleportationSpeed;
  45468. private _teleportationEasing;
  45469. private _rotationAllowed;
  45470. private _teleportBackwardsVector;
  45471. private _teleportationTarget;
  45472. private _isDefaultTeleportationTarget;
  45473. private _postProcessMove;
  45474. private _teleportationFillColor;
  45475. private _teleportationBorderColor;
  45476. private _rotationAngle;
  45477. private _haloCenter;
  45478. private _cameraGazer;
  45479. private _padSensibilityUp;
  45480. private _padSensibilityDown;
  45481. private _leftController;
  45482. private _rightController;
  45483. private _gazeColor;
  45484. private _laserColor;
  45485. private _pickedLaserColor;
  45486. private _pickedGazeColor;
  45487. /**
  45488. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45489. */
  45490. onNewMeshSelected: Observable<AbstractMesh>;
  45491. /**
  45492. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45493. * This observable will provide the mesh and the controller used to select the mesh
  45494. */
  45495. onMeshSelectedWithController: Observable<{
  45496. mesh: AbstractMesh;
  45497. controller: WebVRController;
  45498. }>;
  45499. /**
  45500. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45501. */
  45502. onNewMeshPicked: Observable<PickingInfo>;
  45503. private _circleEase;
  45504. /**
  45505. * Observable raised before camera teleportation
  45506. */
  45507. onBeforeCameraTeleport: Observable<Vector3>;
  45508. /**
  45509. * Observable raised after camera teleportation
  45510. */
  45511. onAfterCameraTeleport: Observable<Vector3>;
  45512. /**
  45513. * Observable raised when current selected mesh gets unselected
  45514. */
  45515. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45516. private _raySelectionPredicate;
  45517. /**
  45518. * To be optionaly changed by user to define custom ray selection
  45519. */
  45520. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45521. /**
  45522. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45523. */
  45524. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45525. /**
  45526. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45527. */
  45528. teleportationEnabled: boolean;
  45529. private _defaultHeight;
  45530. private _teleportationInitialized;
  45531. private _interactionsEnabled;
  45532. private _interactionsRequested;
  45533. private _displayGaze;
  45534. private _displayLaserPointer;
  45535. /**
  45536. * The mesh used to display where the user is going to teleport.
  45537. */
  45538. get teleportationTarget(): Mesh;
  45539. /**
  45540. * Sets the mesh to be used to display where the user is going to teleport.
  45541. */
  45542. set teleportationTarget(value: Mesh);
  45543. /**
  45544. * 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
  45545. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45546. * See http://doc.babylonjs.com/resources/baking_transformations
  45547. */
  45548. get gazeTrackerMesh(): Mesh;
  45549. set gazeTrackerMesh(value: Mesh);
  45550. /**
  45551. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45552. */
  45553. updateGazeTrackerScale: boolean;
  45554. /**
  45555. * If the gaze trackers color should be updated when selecting meshes
  45556. */
  45557. updateGazeTrackerColor: boolean;
  45558. /**
  45559. * If the controller laser color should be updated when selecting meshes
  45560. */
  45561. updateControllerLaserColor: boolean;
  45562. /**
  45563. * The gaze tracking mesh corresponding to the left controller
  45564. */
  45565. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45566. /**
  45567. * The gaze tracking mesh corresponding to the right controller
  45568. */
  45569. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45570. /**
  45571. * If the ray of the gaze should be displayed.
  45572. */
  45573. get displayGaze(): boolean;
  45574. /**
  45575. * Sets if the ray of the gaze should be displayed.
  45576. */
  45577. set displayGaze(value: boolean);
  45578. /**
  45579. * If the ray of the LaserPointer should be displayed.
  45580. */
  45581. get displayLaserPointer(): boolean;
  45582. /**
  45583. * Sets if the ray of the LaserPointer should be displayed.
  45584. */
  45585. set displayLaserPointer(value: boolean);
  45586. /**
  45587. * The deviceOrientationCamera used as the camera when not in VR.
  45588. */
  45589. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45590. /**
  45591. * Based on the current WebVR support, returns the current VR camera used.
  45592. */
  45593. get currentVRCamera(): Nullable<Camera>;
  45594. /**
  45595. * The webVRCamera which is used when in VR.
  45596. */
  45597. get webVRCamera(): WebVRFreeCamera;
  45598. /**
  45599. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45600. */
  45601. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45602. /**
  45603. * The html button that is used to trigger entering into VR.
  45604. */
  45605. get vrButton(): Nullable<HTMLButtonElement>;
  45606. private get _teleportationRequestInitiated();
  45607. /**
  45608. * Defines whether or not Pointer lock should be requested when switching to
  45609. * full screen.
  45610. */
  45611. requestPointerLockOnFullScreen: boolean;
  45612. /**
  45613. * If asking to force XR, this will be populated with the default xr experience
  45614. */
  45615. xr: WebXRDefaultExperience;
  45616. /**
  45617. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45618. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45619. */
  45620. xrTestDone: boolean;
  45621. /**
  45622. * Instantiates a VRExperienceHelper.
  45623. * Helps to quickly add VR support to an existing scene.
  45624. * @param scene The scene the VRExperienceHelper belongs to.
  45625. * @param webVROptions Options to modify the vr experience helper's behavior.
  45626. */
  45627. constructor(scene: Scene,
  45628. /** Options to modify the vr experience helper's behavior. */
  45629. webVROptions?: VRExperienceHelperOptions);
  45630. private completeVRInit;
  45631. private _onDefaultMeshLoaded;
  45632. private _onResize;
  45633. private _onFullscreenChange;
  45634. /**
  45635. * Gets a value indicating if we are currently in VR mode.
  45636. */
  45637. get isInVRMode(): boolean;
  45638. private onVrDisplayPresentChange;
  45639. private onVRDisplayChanged;
  45640. private moveButtonToBottomRight;
  45641. private displayVRButton;
  45642. private updateButtonVisibility;
  45643. private _cachedAngularSensibility;
  45644. /**
  45645. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45646. * Otherwise, will use the fullscreen API.
  45647. */
  45648. enterVR(): void;
  45649. /**
  45650. * Attempt to exit VR, or fullscreen.
  45651. */
  45652. exitVR(): void;
  45653. /**
  45654. * The position of the vr experience helper.
  45655. */
  45656. get position(): Vector3;
  45657. /**
  45658. * Sets the position of the vr experience helper.
  45659. */
  45660. set position(value: Vector3);
  45661. /**
  45662. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45663. */
  45664. enableInteractions(): void;
  45665. private get _noControllerIsActive();
  45666. private beforeRender;
  45667. private _isTeleportationFloor;
  45668. /**
  45669. * Adds a floor mesh to be used for teleportation.
  45670. * @param floorMesh the mesh to be used for teleportation.
  45671. */
  45672. addFloorMesh(floorMesh: Mesh): void;
  45673. /**
  45674. * Removes a floor mesh from being used for teleportation.
  45675. * @param floorMesh the mesh to be removed.
  45676. */
  45677. removeFloorMesh(floorMesh: Mesh): void;
  45678. /**
  45679. * Enables interactions and teleportation using the VR controllers and gaze.
  45680. * @param vrTeleportationOptions options to modify teleportation behavior.
  45681. */
  45682. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45683. private _onNewGamepadConnected;
  45684. private _tryEnableInteractionOnController;
  45685. private _onNewGamepadDisconnected;
  45686. private _enableInteractionOnController;
  45687. private _checkTeleportWithRay;
  45688. private _checkRotate;
  45689. private _checkTeleportBackwards;
  45690. private _enableTeleportationOnController;
  45691. private _createTeleportationCircles;
  45692. private _displayTeleportationTarget;
  45693. private _hideTeleportationTarget;
  45694. private _rotateCamera;
  45695. private _moveTeleportationSelectorTo;
  45696. private _workingVector;
  45697. private _workingQuaternion;
  45698. private _workingMatrix;
  45699. /**
  45700. * Time Constant Teleportation Mode
  45701. */
  45702. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45703. /**
  45704. * Speed Constant Teleportation Mode
  45705. */
  45706. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45707. /**
  45708. * Teleports the users feet to the desired location
  45709. * @param location The location where the user's feet should be placed
  45710. */
  45711. teleportCamera(location: Vector3): void;
  45712. private _convertNormalToDirectionOfRay;
  45713. private _castRayAndSelectObject;
  45714. private _notifySelectedMeshUnselected;
  45715. /**
  45716. * Permanently set new colors for the laser pointer
  45717. * @param color the new laser color
  45718. * @param pickedColor the new laser color when picked mesh detected
  45719. */
  45720. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45721. /**
  45722. * Set lighting enabled / disabled on the laser pointer of both controllers
  45723. * @param enabled should the lighting be enabled on the laser pointer
  45724. */
  45725. setLaserLightingState(enabled?: boolean): void;
  45726. /**
  45727. * Permanently set new colors for the gaze pointer
  45728. * @param color the new gaze color
  45729. * @param pickedColor the new gaze color when picked mesh detected
  45730. */
  45731. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45732. /**
  45733. * Sets the color of the laser ray from the vr controllers.
  45734. * @param color new color for the ray.
  45735. */
  45736. changeLaserColor(color: Color3): void;
  45737. /**
  45738. * Sets the color of the ray from the vr headsets gaze.
  45739. * @param color new color for the ray.
  45740. */
  45741. changeGazeColor(color: Color3): void;
  45742. /**
  45743. * Exits VR and disposes of the vr experience helper
  45744. */
  45745. dispose(): void;
  45746. /**
  45747. * Gets the name of the VRExperienceHelper class
  45748. * @returns "VRExperienceHelper"
  45749. */
  45750. getClassName(): string;
  45751. }
  45752. }
  45753. declare module BABYLON {
  45754. /**
  45755. * Contains an array of blocks representing the octree
  45756. */
  45757. export interface IOctreeContainer<T> {
  45758. /**
  45759. * Blocks within the octree
  45760. */
  45761. blocks: Array<OctreeBlock<T>>;
  45762. }
  45763. /**
  45764. * Class used to store a cell in an octree
  45765. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45766. */
  45767. export class OctreeBlock<T> {
  45768. /**
  45769. * Gets the content of the current block
  45770. */
  45771. entries: T[];
  45772. /**
  45773. * Gets the list of block children
  45774. */
  45775. blocks: Array<OctreeBlock<T>>;
  45776. private _depth;
  45777. private _maxDepth;
  45778. private _capacity;
  45779. private _minPoint;
  45780. private _maxPoint;
  45781. private _boundingVectors;
  45782. private _creationFunc;
  45783. /**
  45784. * Creates a new block
  45785. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45786. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45787. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45788. * @param depth defines the current depth of this block in the octree
  45789. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45790. * @param creationFunc defines a callback to call when an element is added to the block
  45791. */
  45792. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45793. /**
  45794. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45795. */
  45796. get capacity(): number;
  45797. /**
  45798. * Gets the minimum vector (in world space) of the block's bounding box
  45799. */
  45800. get minPoint(): Vector3;
  45801. /**
  45802. * Gets the maximum vector (in world space) of the block's bounding box
  45803. */
  45804. get maxPoint(): Vector3;
  45805. /**
  45806. * Add a new element to this block
  45807. * @param entry defines the element to add
  45808. */
  45809. addEntry(entry: T): void;
  45810. /**
  45811. * Remove an element from this block
  45812. * @param entry defines the element to remove
  45813. */
  45814. removeEntry(entry: T): void;
  45815. /**
  45816. * Add an array of elements to this block
  45817. * @param entries defines the array of elements to add
  45818. */
  45819. addEntries(entries: T[]): void;
  45820. /**
  45821. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45822. * @param frustumPlanes defines the frustum planes to test
  45823. * @param selection defines the array to store current content if selection is positive
  45824. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45825. */
  45826. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45827. /**
  45828. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45829. * @param sphereCenter defines the bounding sphere center
  45830. * @param sphereRadius defines the bounding sphere radius
  45831. * @param selection defines the array to store current content if selection is positive
  45832. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45833. */
  45834. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45835. /**
  45836. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45837. * @param ray defines the ray to test with
  45838. * @param selection defines the array to store current content if selection is positive
  45839. */
  45840. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45841. /**
  45842. * Subdivide the content into child blocks (this block will then be empty)
  45843. */
  45844. createInnerBlocks(): void;
  45845. /**
  45846. * @hidden
  45847. */
  45848. 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;
  45849. }
  45850. }
  45851. declare module BABYLON {
  45852. /**
  45853. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45854. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45855. */
  45856. export class Octree<T> {
  45857. /** 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.) */
  45858. maxDepth: number;
  45859. /**
  45860. * Blocks within the octree containing objects
  45861. */
  45862. blocks: Array<OctreeBlock<T>>;
  45863. /**
  45864. * Content stored in the octree
  45865. */
  45866. dynamicContent: T[];
  45867. private _maxBlockCapacity;
  45868. private _selectionContent;
  45869. private _creationFunc;
  45870. /**
  45871. * Creates a octree
  45872. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45873. * @param creationFunc function to be used to instatiate the octree
  45874. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45875. * @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.)
  45876. */
  45877. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45878. /** 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.) */
  45879. maxDepth?: number);
  45880. /**
  45881. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45882. * @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);
  45883. * @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);
  45884. * @param entries meshes to be added to the octree blocks
  45885. */
  45886. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45887. /**
  45888. * Adds a mesh to the octree
  45889. * @param entry Mesh to add to the octree
  45890. */
  45891. addMesh(entry: T): void;
  45892. /**
  45893. * Remove an element from the octree
  45894. * @param entry defines the element to remove
  45895. */
  45896. removeMesh(entry: T): void;
  45897. /**
  45898. * Selects an array of meshes within the frustum
  45899. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45900. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45901. * @returns array of meshes within the frustum
  45902. */
  45903. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45904. /**
  45905. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45906. * @param sphereCenter defines the bounding sphere center
  45907. * @param sphereRadius defines the bounding sphere radius
  45908. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45909. * @returns an array of objects that intersect the sphere
  45910. */
  45911. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45912. /**
  45913. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45914. * @param ray defines the ray to test with
  45915. * @returns array of intersected objects
  45916. */
  45917. intersectsRay(ray: Ray): SmartArray<T>;
  45918. /**
  45919. * Adds a mesh into the octree block if it intersects the block
  45920. */
  45921. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45922. /**
  45923. * Adds a submesh into the octree block if it intersects the block
  45924. */
  45925. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45926. }
  45927. }
  45928. declare module BABYLON {
  45929. interface Scene {
  45930. /**
  45931. * @hidden
  45932. * Backing Filed
  45933. */
  45934. _selectionOctree: Octree<AbstractMesh>;
  45935. /**
  45936. * Gets the octree used to boost mesh selection (picking)
  45937. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45938. */
  45939. selectionOctree: Octree<AbstractMesh>;
  45940. /**
  45941. * Creates or updates the octree used to boost selection (picking)
  45942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45943. * @param maxCapacity defines the maximum capacity per leaf
  45944. * @param maxDepth defines the maximum depth of the octree
  45945. * @returns an octree of AbstractMesh
  45946. */
  45947. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45948. }
  45949. interface AbstractMesh {
  45950. /**
  45951. * @hidden
  45952. * Backing Field
  45953. */
  45954. _submeshesOctree: Octree<SubMesh>;
  45955. /**
  45956. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45957. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45958. * @param maxCapacity defines the maximum size of each block (64 by default)
  45959. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45960. * @returns the new octree
  45961. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45963. */
  45964. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45965. }
  45966. /**
  45967. * Defines the octree scene component responsible to manage any octrees
  45968. * in a given scene.
  45969. */
  45970. export class OctreeSceneComponent {
  45971. /**
  45972. * The component name help to identify the component in the list of scene components.
  45973. */
  45974. readonly name: string;
  45975. /**
  45976. * The scene the component belongs to.
  45977. */
  45978. scene: Scene;
  45979. /**
  45980. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45981. */
  45982. readonly checksIsEnabled: boolean;
  45983. /**
  45984. * Creates a new instance of the component for the given scene
  45985. * @param scene Defines the scene to register the component in
  45986. */
  45987. constructor(scene: Scene);
  45988. /**
  45989. * Registers the component in a given scene
  45990. */
  45991. register(): void;
  45992. /**
  45993. * Return the list of active meshes
  45994. * @returns the list of active meshes
  45995. */
  45996. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45997. /**
  45998. * Return the list of active sub meshes
  45999. * @param mesh The mesh to get the candidates sub meshes from
  46000. * @returns the list of active sub meshes
  46001. */
  46002. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46003. private _tempRay;
  46004. /**
  46005. * Return the list of sub meshes intersecting with a given local ray
  46006. * @param mesh defines the mesh to find the submesh for
  46007. * @param localRay defines the ray in local space
  46008. * @returns the list of intersecting sub meshes
  46009. */
  46010. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46011. /**
  46012. * Return the list of sub meshes colliding with a collider
  46013. * @param mesh defines the mesh to find the submesh for
  46014. * @param collider defines the collider to evaluate the collision against
  46015. * @returns the list of colliding sub meshes
  46016. */
  46017. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46018. /**
  46019. * Rebuilds the elements related to this component in case of
  46020. * context lost for instance.
  46021. */
  46022. rebuild(): void;
  46023. /**
  46024. * Disposes the component and the associated ressources.
  46025. */
  46026. dispose(): void;
  46027. }
  46028. }
  46029. declare module BABYLON {
  46030. /**
  46031. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46032. */
  46033. export class Gizmo implements IDisposable {
  46034. /** The utility layer the gizmo will be added to */
  46035. gizmoLayer: UtilityLayerRenderer;
  46036. /**
  46037. * The root mesh of the gizmo
  46038. */
  46039. _rootMesh: Mesh;
  46040. private _attachedMesh;
  46041. /**
  46042. * Ratio for the scale of the gizmo (Default: 1)
  46043. */
  46044. scaleRatio: number;
  46045. /**
  46046. * If a custom mesh has been set (Default: false)
  46047. */
  46048. protected _customMeshSet: boolean;
  46049. /**
  46050. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46051. * * When set, interactions will be enabled
  46052. */
  46053. get attachedMesh(): Nullable<AbstractMesh>;
  46054. set attachedMesh(value: Nullable<AbstractMesh>);
  46055. /**
  46056. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46057. * @param mesh The mesh to replace the default mesh of the gizmo
  46058. */
  46059. setCustomMesh(mesh: Mesh): void;
  46060. /**
  46061. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46062. */
  46063. updateGizmoRotationToMatchAttachedMesh: boolean;
  46064. /**
  46065. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46066. */
  46067. updateGizmoPositionToMatchAttachedMesh: boolean;
  46068. /**
  46069. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46070. */
  46071. updateScale: boolean;
  46072. protected _interactionsEnabled: boolean;
  46073. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46074. private _beforeRenderObserver;
  46075. private _tempVector;
  46076. /**
  46077. * Creates a gizmo
  46078. * @param gizmoLayer The utility layer the gizmo will be added to
  46079. */
  46080. constructor(
  46081. /** The utility layer the gizmo will be added to */
  46082. gizmoLayer?: UtilityLayerRenderer);
  46083. /**
  46084. * Updates the gizmo to match the attached mesh's position/rotation
  46085. */
  46086. protected _update(): void;
  46087. /**
  46088. * Disposes of the gizmo
  46089. */
  46090. dispose(): void;
  46091. }
  46092. }
  46093. declare module BABYLON {
  46094. /**
  46095. * Single plane drag gizmo
  46096. */
  46097. export class PlaneDragGizmo extends Gizmo {
  46098. /**
  46099. * Drag behavior responsible for the gizmos dragging interactions
  46100. */
  46101. dragBehavior: PointerDragBehavior;
  46102. private _pointerObserver;
  46103. /**
  46104. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46105. */
  46106. snapDistance: number;
  46107. /**
  46108. * Event that fires each time the gizmo snaps to a new location.
  46109. * * snapDistance is the the change in distance
  46110. */
  46111. onSnapObservable: Observable<{
  46112. snapDistance: number;
  46113. }>;
  46114. private _plane;
  46115. private _coloredMaterial;
  46116. private _hoverMaterial;
  46117. private _isEnabled;
  46118. private _parent;
  46119. /** @hidden */
  46120. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46121. /** @hidden */
  46122. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46123. /**
  46124. * Creates a PlaneDragGizmo
  46125. * @param gizmoLayer The utility layer the gizmo will be added to
  46126. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46127. * @param color The color of the gizmo
  46128. */
  46129. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46130. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46131. /**
  46132. * If the gizmo is enabled
  46133. */
  46134. set isEnabled(value: boolean);
  46135. get isEnabled(): boolean;
  46136. /**
  46137. * Disposes of the gizmo
  46138. */
  46139. dispose(): void;
  46140. }
  46141. }
  46142. declare module BABYLON {
  46143. /**
  46144. * Gizmo that enables dragging a mesh along 3 axis
  46145. */
  46146. export class PositionGizmo extends Gizmo {
  46147. /**
  46148. * Internal gizmo used for interactions on the x axis
  46149. */
  46150. xGizmo: AxisDragGizmo;
  46151. /**
  46152. * Internal gizmo used for interactions on the y axis
  46153. */
  46154. yGizmo: AxisDragGizmo;
  46155. /**
  46156. * Internal gizmo used for interactions on the z axis
  46157. */
  46158. zGizmo: AxisDragGizmo;
  46159. /**
  46160. * Internal gizmo used for interactions on the yz plane
  46161. */
  46162. xPlaneGizmo: PlaneDragGizmo;
  46163. /**
  46164. * Internal gizmo used for interactions on the xz plane
  46165. */
  46166. yPlaneGizmo: PlaneDragGizmo;
  46167. /**
  46168. * Internal gizmo used for interactions on the xy plane
  46169. */
  46170. zPlaneGizmo: PlaneDragGizmo;
  46171. /**
  46172. * private variables
  46173. */
  46174. private _meshAttached;
  46175. private _updateGizmoRotationToMatchAttachedMesh;
  46176. private _snapDistance;
  46177. private _scaleRatio;
  46178. /** Fires an event when any of it's sub gizmos are dragged */
  46179. onDragStartObservable: Observable<unknown>;
  46180. /** Fires an event when any of it's sub gizmos are released from dragging */
  46181. onDragEndObservable: Observable<unknown>;
  46182. /**
  46183. * If set to true, planar drag is enabled
  46184. */
  46185. private _planarGizmoEnabled;
  46186. get attachedMesh(): Nullable<AbstractMesh>;
  46187. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46188. /**
  46189. * Creates a PositionGizmo
  46190. * @param gizmoLayer The utility layer the gizmo will be added to
  46191. */
  46192. constructor(gizmoLayer?: UtilityLayerRenderer);
  46193. /**
  46194. * If the planar drag gizmo is enabled
  46195. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46196. */
  46197. set planarGizmoEnabled(value: boolean);
  46198. get planarGizmoEnabled(): boolean;
  46199. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46200. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46201. /**
  46202. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46203. */
  46204. set snapDistance(value: number);
  46205. get snapDistance(): number;
  46206. /**
  46207. * Ratio for the scale of the gizmo (Default: 1)
  46208. */
  46209. set scaleRatio(value: number);
  46210. get scaleRatio(): number;
  46211. /**
  46212. * Disposes of the gizmo
  46213. */
  46214. dispose(): void;
  46215. /**
  46216. * CustomMeshes are not supported by this gizmo
  46217. * @param mesh The mesh to replace the default mesh of the gizmo
  46218. */
  46219. setCustomMesh(mesh: Mesh): void;
  46220. }
  46221. }
  46222. declare module BABYLON {
  46223. /**
  46224. * Single axis drag gizmo
  46225. */
  46226. export class AxisDragGizmo extends Gizmo {
  46227. /**
  46228. * Drag behavior responsible for the gizmos dragging interactions
  46229. */
  46230. dragBehavior: PointerDragBehavior;
  46231. private _pointerObserver;
  46232. /**
  46233. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46234. */
  46235. snapDistance: number;
  46236. /**
  46237. * Event that fires each time the gizmo snaps to a new location.
  46238. * * snapDistance is the the change in distance
  46239. */
  46240. onSnapObservable: Observable<{
  46241. snapDistance: number;
  46242. }>;
  46243. private _isEnabled;
  46244. private _parent;
  46245. private _arrow;
  46246. private _coloredMaterial;
  46247. private _hoverMaterial;
  46248. /** @hidden */
  46249. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46250. /** @hidden */
  46251. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46252. /**
  46253. * Creates an AxisDragGizmo
  46254. * @param gizmoLayer The utility layer the gizmo will be added to
  46255. * @param dragAxis The axis which the gizmo will be able to drag on
  46256. * @param color The color of the gizmo
  46257. */
  46258. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46259. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46260. /**
  46261. * If the gizmo is enabled
  46262. */
  46263. set isEnabled(value: boolean);
  46264. get isEnabled(): boolean;
  46265. /**
  46266. * Disposes of the gizmo
  46267. */
  46268. dispose(): void;
  46269. }
  46270. }
  46271. declare module BABYLON.Debug {
  46272. /**
  46273. * The Axes viewer will show 3 axes in a specific point in space
  46274. */
  46275. export class AxesViewer {
  46276. private _xAxis;
  46277. private _yAxis;
  46278. private _zAxis;
  46279. private _scaleLinesFactor;
  46280. private _instanced;
  46281. /**
  46282. * Gets the hosting scene
  46283. */
  46284. scene: Scene;
  46285. /**
  46286. * Gets or sets a number used to scale line length
  46287. */
  46288. scaleLines: number;
  46289. /** Gets the node hierarchy used to render x-axis */
  46290. get xAxis(): TransformNode;
  46291. /** Gets the node hierarchy used to render y-axis */
  46292. get yAxis(): TransformNode;
  46293. /** Gets the node hierarchy used to render z-axis */
  46294. get zAxis(): TransformNode;
  46295. /**
  46296. * Creates a new AxesViewer
  46297. * @param scene defines the hosting scene
  46298. * @param scaleLines defines a number used to scale line length (1 by default)
  46299. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46300. * @param xAxis defines the node hierarchy used to render the x-axis
  46301. * @param yAxis defines the node hierarchy used to render the y-axis
  46302. * @param zAxis defines the node hierarchy used to render the z-axis
  46303. */
  46304. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46305. /**
  46306. * Force the viewer to update
  46307. * @param position defines the position of the viewer
  46308. * @param xaxis defines the x axis of the viewer
  46309. * @param yaxis defines the y axis of the viewer
  46310. * @param zaxis defines the z axis of the viewer
  46311. */
  46312. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46313. /**
  46314. * Creates an instance of this axes viewer.
  46315. * @returns a new axes viewer with instanced meshes
  46316. */
  46317. createInstance(): AxesViewer;
  46318. /** Releases resources */
  46319. dispose(): void;
  46320. private static _SetRenderingGroupId;
  46321. }
  46322. }
  46323. declare module BABYLON.Debug {
  46324. /**
  46325. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46326. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46327. */
  46328. export class BoneAxesViewer extends AxesViewer {
  46329. /**
  46330. * Gets or sets the target mesh where to display the axes viewer
  46331. */
  46332. mesh: Nullable<Mesh>;
  46333. /**
  46334. * Gets or sets the target bone where to display the axes viewer
  46335. */
  46336. bone: Nullable<Bone>;
  46337. /** Gets current position */
  46338. pos: Vector3;
  46339. /** Gets direction of X axis */
  46340. xaxis: Vector3;
  46341. /** Gets direction of Y axis */
  46342. yaxis: Vector3;
  46343. /** Gets direction of Z axis */
  46344. zaxis: Vector3;
  46345. /**
  46346. * Creates a new BoneAxesViewer
  46347. * @param scene defines the hosting scene
  46348. * @param bone defines the target bone
  46349. * @param mesh defines the target mesh
  46350. * @param scaleLines defines a scaling factor for line length (1 by default)
  46351. */
  46352. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46353. /**
  46354. * Force the viewer to update
  46355. */
  46356. update(): void;
  46357. /** Releases resources */
  46358. dispose(): void;
  46359. }
  46360. }
  46361. declare module BABYLON {
  46362. /**
  46363. * Interface used to define scene explorer extensibility option
  46364. */
  46365. export interface IExplorerExtensibilityOption {
  46366. /**
  46367. * Define the option label
  46368. */
  46369. label: string;
  46370. /**
  46371. * Defines the action to execute on click
  46372. */
  46373. action: (entity: any) => void;
  46374. }
  46375. /**
  46376. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46377. */
  46378. export interface IExplorerExtensibilityGroup {
  46379. /**
  46380. * Defines a predicate to test if a given type mut be extended
  46381. */
  46382. predicate: (entity: any) => boolean;
  46383. /**
  46384. * Gets the list of options added to a type
  46385. */
  46386. entries: IExplorerExtensibilityOption[];
  46387. }
  46388. /**
  46389. * Interface used to define the options to use to create the Inspector
  46390. */
  46391. export interface IInspectorOptions {
  46392. /**
  46393. * Display in overlay mode (default: false)
  46394. */
  46395. overlay?: boolean;
  46396. /**
  46397. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46398. */
  46399. globalRoot?: HTMLElement;
  46400. /**
  46401. * Display the Scene explorer
  46402. */
  46403. showExplorer?: boolean;
  46404. /**
  46405. * Display the property inspector
  46406. */
  46407. showInspector?: boolean;
  46408. /**
  46409. * Display in embed mode (both panes on the right)
  46410. */
  46411. embedMode?: boolean;
  46412. /**
  46413. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46414. */
  46415. handleResize?: boolean;
  46416. /**
  46417. * Allow the panes to popup (default: true)
  46418. */
  46419. enablePopup?: boolean;
  46420. /**
  46421. * Allow the panes to be closed by users (default: true)
  46422. */
  46423. enableClose?: boolean;
  46424. /**
  46425. * Optional list of extensibility entries
  46426. */
  46427. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46428. /**
  46429. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46430. */
  46431. inspectorURL?: string;
  46432. /**
  46433. * Optional initial tab (default to DebugLayerTab.Properties)
  46434. */
  46435. initialTab?: DebugLayerTab;
  46436. }
  46437. interface Scene {
  46438. /**
  46439. * @hidden
  46440. * Backing field
  46441. */
  46442. _debugLayer: DebugLayer;
  46443. /**
  46444. * Gets the debug layer (aka Inspector) associated with the scene
  46445. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46446. */
  46447. debugLayer: DebugLayer;
  46448. }
  46449. /**
  46450. * Enum of inspector action tab
  46451. */
  46452. export enum DebugLayerTab {
  46453. /**
  46454. * Properties tag (default)
  46455. */
  46456. Properties = 0,
  46457. /**
  46458. * Debug tab
  46459. */
  46460. Debug = 1,
  46461. /**
  46462. * Statistics tab
  46463. */
  46464. Statistics = 2,
  46465. /**
  46466. * Tools tab
  46467. */
  46468. Tools = 3,
  46469. /**
  46470. * Settings tab
  46471. */
  46472. Settings = 4
  46473. }
  46474. /**
  46475. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46476. * what is happening in your scene
  46477. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46478. */
  46479. export class DebugLayer {
  46480. /**
  46481. * Define the url to get the inspector script from.
  46482. * By default it uses the babylonjs CDN.
  46483. * @ignoreNaming
  46484. */
  46485. static InspectorURL: string;
  46486. private _scene;
  46487. private BJSINSPECTOR;
  46488. private _onPropertyChangedObservable?;
  46489. /**
  46490. * Observable triggered when a property is changed through the inspector.
  46491. */
  46492. get onPropertyChangedObservable(): any;
  46493. /**
  46494. * Instantiates a new debug layer.
  46495. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46496. * what is happening in your scene
  46497. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46498. * @param scene Defines the scene to inspect
  46499. */
  46500. constructor(scene: Scene);
  46501. /** Creates the inspector window. */
  46502. private _createInspector;
  46503. /**
  46504. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46505. * @param entity defines the entity to select
  46506. * @param lineContainerTitle defines the specific block to highlight
  46507. */
  46508. select(entity: any, lineContainerTitle?: string): void;
  46509. /** Get the inspector from bundle or global */
  46510. private _getGlobalInspector;
  46511. /**
  46512. * Get if the inspector is visible or not.
  46513. * @returns true if visible otherwise, false
  46514. */
  46515. isVisible(): boolean;
  46516. /**
  46517. * Hide the inspector and close its window.
  46518. */
  46519. hide(): void;
  46520. /**
  46521. * Launch the debugLayer.
  46522. * @param config Define the configuration of the inspector
  46523. * @return a promise fulfilled when the debug layer is visible
  46524. */
  46525. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46526. }
  46527. }
  46528. declare module BABYLON {
  46529. /**
  46530. * Class containing static functions to help procedurally build meshes
  46531. */
  46532. export class BoxBuilder {
  46533. /**
  46534. * Creates a box mesh
  46535. * * The parameter `size` sets the size (float) of each box side (default 1)
  46536. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46537. * * 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)
  46538. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46540. * * 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
  46541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46542. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46543. * @param name defines the name of the mesh
  46544. * @param options defines the options used to create the mesh
  46545. * @param scene defines the hosting scene
  46546. * @returns the box mesh
  46547. */
  46548. static CreateBox(name: string, options: {
  46549. size?: number;
  46550. width?: number;
  46551. height?: number;
  46552. depth?: number;
  46553. faceUV?: Vector4[];
  46554. faceColors?: Color4[];
  46555. sideOrientation?: number;
  46556. frontUVs?: Vector4;
  46557. backUVs?: Vector4;
  46558. wrap?: boolean;
  46559. topBaseAt?: number;
  46560. bottomBaseAt?: number;
  46561. updatable?: boolean;
  46562. }, scene?: Nullable<Scene>): Mesh;
  46563. }
  46564. }
  46565. declare module BABYLON.Debug {
  46566. /**
  46567. * Used to show the physics impostor around the specific mesh
  46568. */
  46569. export class PhysicsViewer {
  46570. /** @hidden */
  46571. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46572. /** @hidden */
  46573. protected _meshes: Array<Nullable<AbstractMesh>>;
  46574. /** @hidden */
  46575. protected _scene: Nullable<Scene>;
  46576. /** @hidden */
  46577. protected _numMeshes: number;
  46578. /** @hidden */
  46579. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46580. private _renderFunction;
  46581. private _utilityLayer;
  46582. private _debugBoxMesh;
  46583. private _debugSphereMesh;
  46584. private _debugCylinderMesh;
  46585. private _debugMaterial;
  46586. private _debugMeshMeshes;
  46587. /**
  46588. * Creates a new PhysicsViewer
  46589. * @param scene defines the hosting scene
  46590. */
  46591. constructor(scene: Scene);
  46592. /** @hidden */
  46593. protected _updateDebugMeshes(): void;
  46594. /**
  46595. * Renders a specified physic impostor
  46596. * @param impostor defines the impostor to render
  46597. * @param targetMesh defines the mesh represented by the impostor
  46598. * @returns the new debug mesh used to render the impostor
  46599. */
  46600. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46601. /**
  46602. * Hides a specified physic impostor
  46603. * @param impostor defines the impostor to hide
  46604. */
  46605. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46606. private _getDebugMaterial;
  46607. private _getDebugBoxMesh;
  46608. private _getDebugSphereMesh;
  46609. private _getDebugCylinderMesh;
  46610. private _getDebugMeshMesh;
  46611. private _getDebugMesh;
  46612. /** Releases all resources */
  46613. dispose(): void;
  46614. }
  46615. }
  46616. declare module BABYLON {
  46617. /**
  46618. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46619. * in order to better appreciate the issue one might have.
  46620. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46621. */
  46622. export class RayHelper {
  46623. /**
  46624. * Defines the ray we are currently tryin to visualize.
  46625. */
  46626. ray: Nullable<Ray>;
  46627. private _renderPoints;
  46628. private _renderLine;
  46629. private _renderFunction;
  46630. private _scene;
  46631. private _updateToMeshFunction;
  46632. private _attachedToMesh;
  46633. private _meshSpaceDirection;
  46634. private _meshSpaceOrigin;
  46635. /**
  46636. * Helper function to create a colored helper in a scene in one line.
  46637. * @param ray Defines the ray we are currently tryin to visualize
  46638. * @param scene Defines the scene the ray is used in
  46639. * @param color Defines the color we want to see the ray in
  46640. * @returns The newly created ray helper.
  46641. */
  46642. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46643. /**
  46644. * Instantiate a new ray helper.
  46645. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46646. * in order to better appreciate the issue one might have.
  46647. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46648. * @param ray Defines the ray we are currently tryin to visualize
  46649. */
  46650. constructor(ray: Ray);
  46651. /**
  46652. * Shows the ray we are willing to debug.
  46653. * @param scene Defines the scene the ray needs to be rendered in
  46654. * @param color Defines the color the ray needs to be rendered in
  46655. */
  46656. show(scene: Scene, color?: Color3): void;
  46657. /**
  46658. * Hides the ray we are debugging.
  46659. */
  46660. hide(): void;
  46661. private _render;
  46662. /**
  46663. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46664. * @param mesh Defines the mesh we want the helper attached to
  46665. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46666. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46667. * @param length Defines the length of the ray
  46668. */
  46669. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46670. /**
  46671. * Detach the ray helper from the mesh it has previously been attached to.
  46672. */
  46673. detachFromMesh(): void;
  46674. private _updateToMesh;
  46675. /**
  46676. * Dispose the helper and release its associated resources.
  46677. */
  46678. dispose(): void;
  46679. }
  46680. }
  46681. declare module BABYLON.Debug {
  46682. /**
  46683. * Class used to render a debug view of a given skeleton
  46684. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46685. */
  46686. export class SkeletonViewer {
  46687. /** defines the skeleton to render */
  46688. skeleton: Skeleton;
  46689. /** defines the mesh attached to the skeleton */
  46690. mesh: AbstractMesh;
  46691. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46692. autoUpdateBonesMatrices: boolean;
  46693. /** defines the rendering group id to use with the viewer */
  46694. renderingGroupId: number;
  46695. /** Gets or sets the color used to render the skeleton */
  46696. color: Color3;
  46697. private _scene;
  46698. private _debugLines;
  46699. private _debugMesh;
  46700. private _isEnabled;
  46701. private _renderFunction;
  46702. private _utilityLayer;
  46703. /**
  46704. * Returns the mesh used to render the bones
  46705. */
  46706. get debugMesh(): Nullable<LinesMesh>;
  46707. /**
  46708. * Creates a new SkeletonViewer
  46709. * @param skeleton defines the skeleton to render
  46710. * @param mesh defines the mesh attached to the skeleton
  46711. * @param scene defines the hosting scene
  46712. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46713. * @param renderingGroupId defines the rendering group id to use with the viewer
  46714. */
  46715. constructor(
  46716. /** defines the skeleton to render */
  46717. skeleton: Skeleton,
  46718. /** defines the mesh attached to the skeleton */
  46719. mesh: AbstractMesh, scene: Scene,
  46720. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46721. autoUpdateBonesMatrices?: boolean,
  46722. /** defines the rendering group id to use with the viewer */
  46723. renderingGroupId?: number);
  46724. /** Gets or sets a boolean indicating if the viewer is enabled */
  46725. set isEnabled(value: boolean);
  46726. get isEnabled(): boolean;
  46727. private _getBonePosition;
  46728. private _getLinesForBonesWithLength;
  46729. private _getLinesForBonesNoLength;
  46730. /** Update the viewer to sync with current skeleton state */
  46731. update(): void;
  46732. /** Release associated resources */
  46733. dispose(): void;
  46734. }
  46735. }
  46736. declare module BABYLON {
  46737. /**
  46738. * Options to create the null engine
  46739. */
  46740. export class NullEngineOptions {
  46741. /**
  46742. * Render width (Default: 512)
  46743. */
  46744. renderWidth: number;
  46745. /**
  46746. * Render height (Default: 256)
  46747. */
  46748. renderHeight: number;
  46749. /**
  46750. * Texture size (Default: 512)
  46751. */
  46752. textureSize: number;
  46753. /**
  46754. * If delta time between frames should be constant
  46755. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46756. */
  46757. deterministicLockstep: boolean;
  46758. /**
  46759. * Maximum about of steps between frames (Default: 4)
  46760. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46761. */
  46762. lockstepMaxSteps: number;
  46763. }
  46764. /**
  46765. * The null engine class provides support for headless version of babylon.js.
  46766. * This can be used in server side scenario or for testing purposes
  46767. */
  46768. export class NullEngine extends Engine {
  46769. private _options;
  46770. /**
  46771. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46772. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46773. * @returns true if engine is in deterministic lock step mode
  46774. */
  46775. isDeterministicLockStep(): boolean;
  46776. /**
  46777. * Gets the max steps when engine is running in deterministic lock step
  46778. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46779. * @returns the max steps
  46780. */
  46781. getLockstepMaxSteps(): number;
  46782. /**
  46783. * Gets the current hardware scaling level.
  46784. * By default the hardware scaling level is computed from the window device ratio.
  46785. * 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.
  46786. * @returns a number indicating the current hardware scaling level
  46787. */
  46788. getHardwareScalingLevel(): number;
  46789. constructor(options?: NullEngineOptions);
  46790. /**
  46791. * Creates a vertex buffer
  46792. * @param vertices the data for the vertex buffer
  46793. * @returns the new WebGL static buffer
  46794. */
  46795. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46796. /**
  46797. * Creates a new index buffer
  46798. * @param indices defines the content of the index buffer
  46799. * @param updatable defines if the index buffer must be updatable
  46800. * @returns a new webGL buffer
  46801. */
  46802. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46803. /**
  46804. * Clear the current render buffer or the current render target (if any is set up)
  46805. * @param color defines the color to use
  46806. * @param backBuffer defines if the back buffer must be cleared
  46807. * @param depth defines if the depth buffer must be cleared
  46808. * @param stencil defines if the stencil buffer must be cleared
  46809. */
  46810. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46811. /**
  46812. * Gets the current render width
  46813. * @param useScreen defines if screen size must be used (or the current render target if any)
  46814. * @returns a number defining the current render width
  46815. */
  46816. getRenderWidth(useScreen?: boolean): number;
  46817. /**
  46818. * Gets the current render height
  46819. * @param useScreen defines if screen size must be used (or the current render target if any)
  46820. * @returns a number defining the current render height
  46821. */
  46822. getRenderHeight(useScreen?: boolean): number;
  46823. /**
  46824. * Set the WebGL's viewport
  46825. * @param viewport defines the viewport element to be used
  46826. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46827. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46828. */
  46829. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46830. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46831. /**
  46832. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46833. * @param pipelineContext defines the pipeline context to use
  46834. * @param uniformsNames defines the list of uniform names
  46835. * @returns an array of webGL uniform locations
  46836. */
  46837. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46838. /**
  46839. * Gets the lsit of active attributes for a given webGL program
  46840. * @param pipelineContext defines the pipeline context to use
  46841. * @param attributesNames defines the list of attribute names to get
  46842. * @returns an array of indices indicating the offset of each attribute
  46843. */
  46844. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46845. /**
  46846. * Binds an effect to the webGL context
  46847. * @param effect defines the effect to bind
  46848. */
  46849. bindSamplers(effect: Effect): void;
  46850. /**
  46851. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46852. * @param effect defines the effect to activate
  46853. */
  46854. enableEffect(effect: Effect): void;
  46855. /**
  46856. * Set various states to the webGL context
  46857. * @param culling defines backface culling state
  46858. * @param zOffset defines the value to apply to zOffset (0 by default)
  46859. * @param force defines if states must be applied even if cache is up to date
  46860. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46861. */
  46862. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46863. /**
  46864. * Set the value of an uniform to an array of int32
  46865. * @param uniform defines the webGL uniform location where to store the value
  46866. * @param array defines the array of int32 to store
  46867. */
  46868. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46869. /**
  46870. * Set the value of an uniform to an array of int32 (stored as vec2)
  46871. * @param uniform defines the webGL uniform location where to store the value
  46872. * @param array defines the array of int32 to store
  46873. */
  46874. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46875. /**
  46876. * Set the value of an uniform to an array of int32 (stored as vec3)
  46877. * @param uniform defines the webGL uniform location where to store the value
  46878. * @param array defines the array of int32 to store
  46879. */
  46880. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46881. /**
  46882. * Set the value of an uniform to an array of int32 (stored as vec4)
  46883. * @param uniform defines the webGL uniform location where to store the value
  46884. * @param array defines the array of int32 to store
  46885. */
  46886. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46887. /**
  46888. * Set the value of an uniform to an array of float32
  46889. * @param uniform defines the webGL uniform location where to store the value
  46890. * @param array defines the array of float32 to store
  46891. */
  46892. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46893. /**
  46894. * Set the value of an uniform to an array of float32 (stored as vec2)
  46895. * @param uniform defines the webGL uniform location where to store the value
  46896. * @param array defines the array of float32 to store
  46897. */
  46898. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46899. /**
  46900. * Set the value of an uniform to an array of float32 (stored as vec3)
  46901. * @param uniform defines the webGL uniform location where to store the value
  46902. * @param array defines the array of float32 to store
  46903. */
  46904. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46905. /**
  46906. * Set the value of an uniform to an array of float32 (stored as vec4)
  46907. * @param uniform defines the webGL uniform location where to store the value
  46908. * @param array defines the array of float32 to store
  46909. */
  46910. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46911. /**
  46912. * Set the value of an uniform to an array of number
  46913. * @param uniform defines the webGL uniform location where to store the value
  46914. * @param array defines the array of number to store
  46915. */
  46916. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46917. /**
  46918. * Set the value of an uniform to an array of number (stored as vec2)
  46919. * @param uniform defines the webGL uniform location where to store the value
  46920. * @param array defines the array of number to store
  46921. */
  46922. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46923. /**
  46924. * Set the value of an uniform to an array of number (stored as vec3)
  46925. * @param uniform defines the webGL uniform location where to store the value
  46926. * @param array defines the array of number to store
  46927. */
  46928. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46929. /**
  46930. * Set the value of an uniform to an array of number (stored as vec4)
  46931. * @param uniform defines the webGL uniform location where to store the value
  46932. * @param array defines the array of number to store
  46933. */
  46934. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46935. /**
  46936. * Set the value of an uniform to an array of float32 (stored as matrices)
  46937. * @param uniform defines the webGL uniform location where to store the value
  46938. * @param matrices defines the array of float32 to store
  46939. */
  46940. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46941. /**
  46942. * Set the value of an uniform to a matrix (3x3)
  46943. * @param uniform defines the webGL uniform location where to store the value
  46944. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46945. */
  46946. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46947. /**
  46948. * Set the value of an uniform to a matrix (2x2)
  46949. * @param uniform defines the webGL uniform location where to store the value
  46950. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46951. */
  46952. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46953. /**
  46954. * Set the value of an uniform to a number (float)
  46955. * @param uniform defines the webGL uniform location where to store the value
  46956. * @param value defines the float number to store
  46957. */
  46958. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46959. /**
  46960. * Set the value of an uniform to a vec2
  46961. * @param uniform defines the webGL uniform location where to store the value
  46962. * @param x defines the 1st component of the value
  46963. * @param y defines the 2nd component of the value
  46964. */
  46965. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46966. /**
  46967. * Set the value of an uniform to a vec3
  46968. * @param uniform defines the webGL uniform location where to store the value
  46969. * @param x defines the 1st component of the value
  46970. * @param y defines the 2nd component of the value
  46971. * @param z defines the 3rd component of the value
  46972. */
  46973. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46974. /**
  46975. * Set the value of an uniform to a boolean
  46976. * @param uniform defines the webGL uniform location where to store the value
  46977. * @param bool defines the boolean to store
  46978. */
  46979. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46980. /**
  46981. * Set the value of an uniform to a vec4
  46982. * @param uniform defines the webGL uniform location where to store the value
  46983. * @param x defines the 1st component of the value
  46984. * @param y defines the 2nd component of the value
  46985. * @param z defines the 3rd component of the value
  46986. * @param w defines the 4th component of the value
  46987. */
  46988. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46989. /**
  46990. * Sets the current alpha mode
  46991. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46992. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46993. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46994. */
  46995. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46996. /**
  46997. * Bind webGl buffers directly to the webGL context
  46998. * @param vertexBuffers defines the vertex buffer to bind
  46999. * @param indexBuffer defines the index buffer to bind
  47000. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47001. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47002. * @param effect defines the effect associated with the vertex buffer
  47003. */
  47004. bindBuffers(vertexBuffers: {
  47005. [key: string]: VertexBuffer;
  47006. }, indexBuffer: DataBuffer, effect: Effect): void;
  47007. /**
  47008. * Force the entire cache to be cleared
  47009. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47010. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47011. */
  47012. wipeCaches(bruteForce?: boolean): void;
  47013. /**
  47014. * Send a draw order
  47015. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47016. * @param indexStart defines the starting index
  47017. * @param indexCount defines the number of index to draw
  47018. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47019. */
  47020. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47021. /**
  47022. * Draw a list of indexed primitives
  47023. * @param fillMode defines the primitive to use
  47024. * @param indexStart defines the starting index
  47025. * @param indexCount defines the number of index to draw
  47026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47027. */
  47028. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47029. /**
  47030. * Draw a list of unindexed primitives
  47031. * @param fillMode defines the primitive to use
  47032. * @param verticesStart defines the index of first vertex to draw
  47033. * @param verticesCount defines the count of vertices to draw
  47034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47035. */
  47036. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47037. /** @hidden */
  47038. _createTexture(): WebGLTexture;
  47039. /** @hidden */
  47040. _releaseTexture(texture: InternalTexture): void;
  47041. /**
  47042. * Usually called from Texture.ts.
  47043. * Passed information to create a WebGLTexture
  47044. * @param urlArg defines a value which contains one of the following:
  47045. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47046. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47047. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47048. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47049. * @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)
  47050. * @param scene needed for loading to the correct scene
  47051. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47052. * @param onLoad optional callback to be called upon successful completion
  47053. * @param onError optional callback to be called upon failure
  47054. * @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
  47055. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47056. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47057. * @param forcedExtension defines the extension to use to pick the right loader
  47058. * @param mimeType defines an optional mime type
  47059. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47060. */
  47061. 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;
  47062. /**
  47063. * Creates a new render target texture
  47064. * @param size defines the size of the texture
  47065. * @param options defines the options used to create the texture
  47066. * @returns a new render target texture stored in an InternalTexture
  47067. */
  47068. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47069. /**
  47070. * Update the sampling mode of a given texture
  47071. * @param samplingMode defines the required sampling mode
  47072. * @param texture defines the texture to update
  47073. */
  47074. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47075. /**
  47076. * Binds the frame buffer to the specified texture.
  47077. * @param texture The texture to render to or null for the default canvas
  47078. * @param faceIndex The face of the texture to render to in case of cube texture
  47079. * @param requiredWidth The width of the target to render to
  47080. * @param requiredHeight The height of the target to render to
  47081. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47082. * @param lodLevel defines le lod level to bind to the frame buffer
  47083. */
  47084. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47085. /**
  47086. * Unbind the current render target texture from the webGL context
  47087. * @param texture defines the render target texture to unbind
  47088. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47089. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47090. */
  47091. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47092. /**
  47093. * Creates a dynamic vertex buffer
  47094. * @param vertices the data for the dynamic vertex buffer
  47095. * @returns the new WebGL dynamic buffer
  47096. */
  47097. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47098. /**
  47099. * Update the content of a dynamic texture
  47100. * @param texture defines the texture to update
  47101. * @param canvas defines the canvas containing the source
  47102. * @param invertY defines if data must be stored with Y axis inverted
  47103. * @param premulAlpha defines if alpha is stored as premultiplied
  47104. * @param format defines the format of the data
  47105. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47106. */
  47107. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47108. /**
  47109. * Gets a boolean indicating if all created effects are ready
  47110. * @returns true if all effects are ready
  47111. */
  47112. areAllEffectsReady(): boolean;
  47113. /**
  47114. * @hidden
  47115. * Get the current error code of the webGL context
  47116. * @returns the error code
  47117. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47118. */
  47119. getError(): number;
  47120. /** @hidden */
  47121. _getUnpackAlignement(): number;
  47122. /** @hidden */
  47123. _unpackFlipY(value: boolean): void;
  47124. /**
  47125. * Update a dynamic index buffer
  47126. * @param indexBuffer defines the target index buffer
  47127. * @param indices defines the data to update
  47128. * @param offset defines the offset in the target index buffer where update should start
  47129. */
  47130. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47131. /**
  47132. * Updates a dynamic vertex buffer.
  47133. * @param vertexBuffer the vertex buffer to update
  47134. * @param vertices the data used to update the vertex buffer
  47135. * @param byteOffset the byte offset of the data (optional)
  47136. * @param byteLength the byte length of the data (optional)
  47137. */
  47138. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47139. /** @hidden */
  47140. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47141. /** @hidden */
  47142. _bindTexture(channel: number, texture: InternalTexture): void;
  47143. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47144. /**
  47145. * 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
  47146. */
  47147. releaseEffects(): void;
  47148. displayLoadingUI(): void;
  47149. hideLoadingUI(): void;
  47150. /** @hidden */
  47151. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47152. /** @hidden */
  47153. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47154. /** @hidden */
  47155. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47156. /** @hidden */
  47157. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47158. }
  47159. }
  47160. declare module BABYLON {
  47161. /**
  47162. * @hidden
  47163. **/
  47164. export class _TimeToken {
  47165. _startTimeQuery: Nullable<WebGLQuery>;
  47166. _endTimeQuery: Nullable<WebGLQuery>;
  47167. _timeElapsedQuery: Nullable<WebGLQuery>;
  47168. _timeElapsedQueryEnded: boolean;
  47169. }
  47170. }
  47171. declare module BABYLON {
  47172. /** @hidden */
  47173. export class _OcclusionDataStorage {
  47174. /** @hidden */
  47175. occlusionInternalRetryCounter: number;
  47176. /** @hidden */
  47177. isOcclusionQueryInProgress: boolean;
  47178. /** @hidden */
  47179. isOccluded: boolean;
  47180. /** @hidden */
  47181. occlusionRetryCount: number;
  47182. /** @hidden */
  47183. occlusionType: number;
  47184. /** @hidden */
  47185. occlusionQueryAlgorithmType: number;
  47186. }
  47187. interface Engine {
  47188. /**
  47189. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47190. * @return the new query
  47191. */
  47192. createQuery(): WebGLQuery;
  47193. /**
  47194. * Delete and release a webGL query
  47195. * @param query defines the query to delete
  47196. * @return the current engine
  47197. */
  47198. deleteQuery(query: WebGLQuery): Engine;
  47199. /**
  47200. * Check if a given query has resolved and got its value
  47201. * @param query defines the query to check
  47202. * @returns true if the query got its value
  47203. */
  47204. isQueryResultAvailable(query: WebGLQuery): boolean;
  47205. /**
  47206. * Gets the value of a given query
  47207. * @param query defines the query to check
  47208. * @returns the value of the query
  47209. */
  47210. getQueryResult(query: WebGLQuery): number;
  47211. /**
  47212. * Initiates an occlusion query
  47213. * @param algorithmType defines the algorithm to use
  47214. * @param query defines the query to use
  47215. * @returns the current engine
  47216. * @see http://doc.babylonjs.com/features/occlusionquery
  47217. */
  47218. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47219. /**
  47220. * Ends an occlusion query
  47221. * @see http://doc.babylonjs.com/features/occlusionquery
  47222. * @param algorithmType defines the algorithm to use
  47223. * @returns the current engine
  47224. */
  47225. endOcclusionQuery(algorithmType: number): Engine;
  47226. /**
  47227. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47228. * Please note that only one query can be issued at a time
  47229. * @returns a time token used to track the time span
  47230. */
  47231. startTimeQuery(): Nullable<_TimeToken>;
  47232. /**
  47233. * Ends a time query
  47234. * @param token defines the token used to measure the time span
  47235. * @returns the time spent (in ns)
  47236. */
  47237. endTimeQuery(token: _TimeToken): int;
  47238. /** @hidden */
  47239. _currentNonTimestampToken: Nullable<_TimeToken>;
  47240. /** @hidden */
  47241. _createTimeQuery(): WebGLQuery;
  47242. /** @hidden */
  47243. _deleteTimeQuery(query: WebGLQuery): void;
  47244. /** @hidden */
  47245. _getGlAlgorithmType(algorithmType: number): number;
  47246. /** @hidden */
  47247. _getTimeQueryResult(query: WebGLQuery): any;
  47248. /** @hidden */
  47249. _getTimeQueryAvailability(query: WebGLQuery): any;
  47250. }
  47251. interface AbstractMesh {
  47252. /**
  47253. * Backing filed
  47254. * @hidden
  47255. */
  47256. __occlusionDataStorage: _OcclusionDataStorage;
  47257. /**
  47258. * Access property
  47259. * @hidden
  47260. */
  47261. _occlusionDataStorage: _OcclusionDataStorage;
  47262. /**
  47263. * 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.
  47264. * The default value is -1 which means don't break the query and wait till the result
  47265. * @see http://doc.babylonjs.com/features/occlusionquery
  47266. */
  47267. occlusionRetryCount: number;
  47268. /**
  47269. * 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:
  47270. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47271. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47272. * * 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.
  47273. * @see http://doc.babylonjs.com/features/occlusionquery
  47274. */
  47275. occlusionType: number;
  47276. /**
  47277. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47278. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47279. * * 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.
  47280. * @see http://doc.babylonjs.com/features/occlusionquery
  47281. */
  47282. occlusionQueryAlgorithmType: number;
  47283. /**
  47284. * 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
  47285. * @see http://doc.babylonjs.com/features/occlusionquery
  47286. */
  47287. isOccluded: boolean;
  47288. /**
  47289. * Flag to check the progress status of the query
  47290. * @see http://doc.babylonjs.com/features/occlusionquery
  47291. */
  47292. isOcclusionQueryInProgress: boolean;
  47293. }
  47294. }
  47295. declare module BABYLON {
  47296. /** @hidden */
  47297. export var _forceTransformFeedbackToBundle: boolean;
  47298. interface Engine {
  47299. /**
  47300. * Creates a webGL transform feedback object
  47301. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47302. * @returns the webGL transform feedback object
  47303. */
  47304. createTransformFeedback(): WebGLTransformFeedback;
  47305. /**
  47306. * Delete a webGL transform feedback object
  47307. * @param value defines the webGL transform feedback object to delete
  47308. */
  47309. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47310. /**
  47311. * Bind a webGL transform feedback object to the webgl context
  47312. * @param value defines the webGL transform feedback object to bind
  47313. */
  47314. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47315. /**
  47316. * Begins a transform feedback operation
  47317. * @param usePoints defines if points or triangles must be used
  47318. */
  47319. beginTransformFeedback(usePoints: boolean): void;
  47320. /**
  47321. * Ends a transform feedback operation
  47322. */
  47323. endTransformFeedback(): void;
  47324. /**
  47325. * Specify the varyings to use with transform feedback
  47326. * @param program defines the associated webGL program
  47327. * @param value defines the list of strings representing the varying names
  47328. */
  47329. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47330. /**
  47331. * Bind a webGL buffer for a transform feedback operation
  47332. * @param value defines the webGL buffer to bind
  47333. */
  47334. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47335. }
  47336. }
  47337. declare module BABYLON {
  47338. /**
  47339. * Creation options of the multi render target texture.
  47340. */
  47341. export interface IMultiRenderTargetOptions {
  47342. /**
  47343. * Define if the texture needs to create mip maps after render.
  47344. */
  47345. generateMipMaps?: boolean;
  47346. /**
  47347. * Define the types of all the draw buffers we want to create
  47348. */
  47349. types?: number[];
  47350. /**
  47351. * Define the sampling modes of all the draw buffers we want to create
  47352. */
  47353. samplingModes?: number[];
  47354. /**
  47355. * Define if a depth buffer is required
  47356. */
  47357. generateDepthBuffer?: boolean;
  47358. /**
  47359. * Define if a stencil buffer is required
  47360. */
  47361. generateStencilBuffer?: boolean;
  47362. /**
  47363. * Define if a depth texture is required instead of a depth buffer
  47364. */
  47365. generateDepthTexture?: boolean;
  47366. /**
  47367. * Define the number of desired draw buffers
  47368. */
  47369. textureCount?: number;
  47370. /**
  47371. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47372. */
  47373. doNotChangeAspectRatio?: boolean;
  47374. /**
  47375. * Define the default type of the buffers we are creating
  47376. */
  47377. defaultType?: number;
  47378. }
  47379. /**
  47380. * A multi render target, like a render target provides the ability to render to a texture.
  47381. * Unlike the render target, it can render to several draw buffers in one draw.
  47382. * This is specially interesting in deferred rendering or for any effects requiring more than
  47383. * just one color from a single pass.
  47384. */
  47385. export class MultiRenderTarget extends RenderTargetTexture {
  47386. private _internalTextures;
  47387. private _textures;
  47388. private _multiRenderTargetOptions;
  47389. /**
  47390. * Get if draw buffers are currently supported by the used hardware and browser.
  47391. */
  47392. get isSupported(): boolean;
  47393. /**
  47394. * Get the list of textures generated by the multi render target.
  47395. */
  47396. get textures(): Texture[];
  47397. /**
  47398. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47399. */
  47400. get depthTexture(): Texture;
  47401. /**
  47402. * Set the wrapping mode on U of all the textures we are rendering to.
  47403. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47404. */
  47405. set wrapU(wrap: number);
  47406. /**
  47407. * Set the wrapping mode on V of all the textures we are rendering to.
  47408. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47409. */
  47410. set wrapV(wrap: number);
  47411. /**
  47412. * Instantiate a new multi render target texture.
  47413. * A multi render target, like a render target provides the ability to render to a texture.
  47414. * Unlike the render target, it can render to several draw buffers in one draw.
  47415. * This is specially interesting in deferred rendering or for any effects requiring more than
  47416. * just one color from a single pass.
  47417. * @param name Define the name of the texture
  47418. * @param size Define the size of the buffers to render to
  47419. * @param count Define the number of target we are rendering into
  47420. * @param scene Define the scene the texture belongs to
  47421. * @param options Define the options used to create the multi render target
  47422. */
  47423. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47424. /** @hidden */
  47425. _rebuild(): void;
  47426. private _createInternalTextures;
  47427. private _createTextures;
  47428. /**
  47429. * Define the number of samples used if MSAA is enabled.
  47430. */
  47431. get samples(): number;
  47432. set samples(value: number);
  47433. /**
  47434. * Resize all the textures in the multi render target.
  47435. * Be carrefull as it will recreate all the data in the new texture.
  47436. * @param size Define the new size
  47437. */
  47438. resize(size: any): void;
  47439. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47440. /**
  47441. * Dispose the render targets and their associated resources
  47442. */
  47443. dispose(): void;
  47444. /**
  47445. * Release all the underlying texture used as draw buffers.
  47446. */
  47447. releaseInternalTextures(): void;
  47448. }
  47449. }
  47450. declare module BABYLON {
  47451. interface ThinEngine {
  47452. /**
  47453. * Unbind a list of render target textures from the webGL context
  47454. * This is used only when drawBuffer extension or webGL2 are active
  47455. * @param textures defines the render target textures to unbind
  47456. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47457. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47458. */
  47459. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47460. /**
  47461. * Create a multi render target texture
  47462. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47463. * @param size defines the size of the texture
  47464. * @param options defines the creation options
  47465. * @returns the cube texture as an InternalTexture
  47466. */
  47467. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47468. /**
  47469. * Update the sample count for a given multiple render target texture
  47470. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47471. * @param textures defines the textures to update
  47472. * @param samples defines the sample count to set
  47473. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47474. */
  47475. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47476. }
  47477. }
  47478. declare module BABYLON {
  47479. /**
  47480. * Class used to define an additional view for the engine
  47481. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47482. */
  47483. export class EngineView {
  47484. /** Defines the canvas where to render the view */
  47485. target: HTMLCanvasElement;
  47486. /** Defines an optional camera used to render the view (will use active camera else) */
  47487. camera?: Camera;
  47488. }
  47489. interface Engine {
  47490. /**
  47491. * Gets or sets the HTML element to use for attaching events
  47492. */
  47493. inputElement: Nullable<HTMLElement>;
  47494. /**
  47495. * Gets the current engine view
  47496. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47497. */
  47498. activeView: Nullable<EngineView>;
  47499. /** Gets or sets the list of views */
  47500. views: EngineView[];
  47501. /**
  47502. * Register a new child canvas
  47503. * @param canvas defines the canvas to register
  47504. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47505. * @returns the associated view
  47506. */
  47507. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47508. /**
  47509. * Remove a registered child canvas
  47510. * @param canvas defines the canvas to remove
  47511. * @returns the current engine
  47512. */
  47513. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47514. }
  47515. }
  47516. declare module BABYLON {
  47517. interface Engine {
  47518. /** @hidden */
  47519. _excludedCompressedTextures: string[];
  47520. /** @hidden */
  47521. _textureFormatInUse: string;
  47522. /**
  47523. * Gets the list of texture formats supported
  47524. */
  47525. readonly texturesSupported: Array<string>;
  47526. /**
  47527. * Gets the texture format in use
  47528. */
  47529. readonly textureFormatInUse: Nullable<string>;
  47530. /**
  47531. * Set the compressed texture extensions or file names to skip.
  47532. *
  47533. * @param skippedFiles defines the list of those texture files you want to skip
  47534. * Example: [".dds", ".env", "myfile.png"]
  47535. */
  47536. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47537. /**
  47538. * Set the compressed texture format to use, based on the formats you have, and the formats
  47539. * supported by the hardware / browser.
  47540. *
  47541. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47542. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47543. * to API arguments needed to compressed textures. This puts the burden on the container
  47544. * generator to house the arcane code for determining these for current & future formats.
  47545. *
  47546. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47547. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47548. *
  47549. * Note: The result of this call is not taken into account when a texture is base64.
  47550. *
  47551. * @param formatsAvailable defines the list of those format families you have created
  47552. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47553. *
  47554. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47555. * @returns The extension selected.
  47556. */
  47557. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47558. }
  47559. }
  47560. declare module BABYLON {
  47561. /**
  47562. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47563. */
  47564. export interface CubeMapInfo {
  47565. /**
  47566. * The pixel array for the front face.
  47567. * This is stored in format, left to right, up to down format.
  47568. */
  47569. front: Nullable<ArrayBufferView>;
  47570. /**
  47571. * The pixel array for the back face.
  47572. * This is stored in format, left to right, up to down format.
  47573. */
  47574. back: Nullable<ArrayBufferView>;
  47575. /**
  47576. * The pixel array for the left face.
  47577. * This is stored in format, left to right, up to down format.
  47578. */
  47579. left: Nullable<ArrayBufferView>;
  47580. /**
  47581. * The pixel array for the right face.
  47582. * This is stored in format, left to right, up to down format.
  47583. */
  47584. right: Nullable<ArrayBufferView>;
  47585. /**
  47586. * The pixel array for the up face.
  47587. * This is stored in format, left to right, up to down format.
  47588. */
  47589. up: Nullable<ArrayBufferView>;
  47590. /**
  47591. * The pixel array for the down face.
  47592. * This is stored in format, left to right, up to down format.
  47593. */
  47594. down: Nullable<ArrayBufferView>;
  47595. /**
  47596. * The size of the cubemap stored.
  47597. *
  47598. * Each faces will be size * size pixels.
  47599. */
  47600. size: number;
  47601. /**
  47602. * The format of the texture.
  47603. *
  47604. * RGBA, RGB.
  47605. */
  47606. format: number;
  47607. /**
  47608. * The type of the texture data.
  47609. *
  47610. * UNSIGNED_INT, FLOAT.
  47611. */
  47612. type: number;
  47613. /**
  47614. * Specifies whether the texture is in gamma space.
  47615. */
  47616. gammaSpace: boolean;
  47617. }
  47618. /**
  47619. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47620. */
  47621. export class PanoramaToCubeMapTools {
  47622. private static FACE_FRONT;
  47623. private static FACE_BACK;
  47624. private static FACE_RIGHT;
  47625. private static FACE_LEFT;
  47626. private static FACE_DOWN;
  47627. private static FACE_UP;
  47628. /**
  47629. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47630. *
  47631. * @param float32Array The source data.
  47632. * @param inputWidth The width of the input panorama.
  47633. * @param inputHeight The height of the input panorama.
  47634. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47635. * @return The cubemap data
  47636. */
  47637. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47638. private static CreateCubemapTexture;
  47639. private static CalcProjectionSpherical;
  47640. }
  47641. }
  47642. declare module BABYLON {
  47643. /**
  47644. * Helper class dealing with the extraction of spherical polynomial dataArray
  47645. * from a cube map.
  47646. */
  47647. export class CubeMapToSphericalPolynomialTools {
  47648. private static FileFaces;
  47649. /**
  47650. * Converts a texture to the according Spherical Polynomial data.
  47651. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47652. *
  47653. * @param texture The texture to extract the information from.
  47654. * @return The Spherical Polynomial data.
  47655. */
  47656. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47657. /**
  47658. * Converts a cubemap to the according Spherical Polynomial data.
  47659. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47660. *
  47661. * @param cubeInfo The Cube map to extract the information from.
  47662. * @return The Spherical Polynomial data.
  47663. */
  47664. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47665. }
  47666. }
  47667. declare module BABYLON {
  47668. interface BaseTexture {
  47669. /**
  47670. * Get the polynomial representation of the texture data.
  47671. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47672. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47673. */
  47674. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47675. }
  47676. }
  47677. declare module BABYLON {
  47678. /** @hidden */
  47679. export var rgbdEncodePixelShader: {
  47680. name: string;
  47681. shader: string;
  47682. };
  47683. }
  47684. declare module BABYLON {
  47685. /** @hidden */
  47686. export var rgbdDecodePixelShader: {
  47687. name: string;
  47688. shader: string;
  47689. };
  47690. }
  47691. declare module BABYLON {
  47692. /**
  47693. * Raw texture data and descriptor sufficient for WebGL texture upload
  47694. */
  47695. export interface EnvironmentTextureInfo {
  47696. /**
  47697. * Version of the environment map
  47698. */
  47699. version: number;
  47700. /**
  47701. * Width of image
  47702. */
  47703. width: number;
  47704. /**
  47705. * Irradiance information stored in the file.
  47706. */
  47707. irradiance: any;
  47708. /**
  47709. * Specular information stored in the file.
  47710. */
  47711. specular: any;
  47712. }
  47713. /**
  47714. * Defines One Image in the file. It requires only the position in the file
  47715. * as well as the length.
  47716. */
  47717. interface BufferImageData {
  47718. /**
  47719. * Length of the image data.
  47720. */
  47721. length: number;
  47722. /**
  47723. * Position of the data from the null terminator delimiting the end of the JSON.
  47724. */
  47725. position: number;
  47726. }
  47727. /**
  47728. * Defines the specular data enclosed in the file.
  47729. * This corresponds to the version 1 of the data.
  47730. */
  47731. export interface EnvironmentTextureSpecularInfoV1 {
  47732. /**
  47733. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47734. */
  47735. specularDataPosition?: number;
  47736. /**
  47737. * This contains all the images data needed to reconstruct the cubemap.
  47738. */
  47739. mipmaps: Array<BufferImageData>;
  47740. /**
  47741. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47742. */
  47743. lodGenerationScale: number;
  47744. }
  47745. /**
  47746. * Sets of helpers addressing the serialization and deserialization of environment texture
  47747. * stored in a BabylonJS env file.
  47748. * Those files are usually stored as .env files.
  47749. */
  47750. export class EnvironmentTextureTools {
  47751. /**
  47752. * Magic number identifying the env file.
  47753. */
  47754. private static _MagicBytes;
  47755. /**
  47756. * Gets the environment info from an env file.
  47757. * @param data The array buffer containing the .env bytes.
  47758. * @returns the environment file info (the json header) if successfully parsed.
  47759. */
  47760. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47761. /**
  47762. * Creates an environment texture from a loaded cube texture.
  47763. * @param texture defines the cube texture to convert in env file
  47764. * @return a promise containing the environment data if succesfull.
  47765. */
  47766. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47767. /**
  47768. * Creates a JSON representation of the spherical data.
  47769. * @param texture defines the texture containing the polynomials
  47770. * @return the JSON representation of the spherical info
  47771. */
  47772. private static _CreateEnvTextureIrradiance;
  47773. /**
  47774. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47775. * @param data the image data
  47776. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47777. * @return the views described by info providing access to the underlying buffer
  47778. */
  47779. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47780. /**
  47781. * Uploads the texture info contained in the env file to the GPU.
  47782. * @param texture defines the internal texture to upload to
  47783. * @param data defines the data to load
  47784. * @param info defines the texture info retrieved through the GetEnvInfo method
  47785. * @returns a promise
  47786. */
  47787. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47788. private static _OnImageReadyAsync;
  47789. /**
  47790. * Uploads the levels of image data to the GPU.
  47791. * @param texture defines the internal texture to upload to
  47792. * @param imageData defines the array buffer views of image data [mipmap][face]
  47793. * @returns a promise
  47794. */
  47795. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47796. /**
  47797. * Uploads spherical polynomials information to the texture.
  47798. * @param texture defines the texture we are trying to upload the information to
  47799. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47800. */
  47801. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47802. /** @hidden */
  47803. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47804. }
  47805. }
  47806. declare module BABYLON {
  47807. /**
  47808. * Contains position and normal vectors for a vertex
  47809. */
  47810. export class PositionNormalVertex {
  47811. /** the position of the vertex (defaut: 0,0,0) */
  47812. position: Vector3;
  47813. /** the normal of the vertex (defaut: 0,1,0) */
  47814. normal: Vector3;
  47815. /**
  47816. * Creates a PositionNormalVertex
  47817. * @param position the position of the vertex (defaut: 0,0,0)
  47818. * @param normal the normal of the vertex (defaut: 0,1,0)
  47819. */
  47820. constructor(
  47821. /** the position of the vertex (defaut: 0,0,0) */
  47822. position?: Vector3,
  47823. /** the normal of the vertex (defaut: 0,1,0) */
  47824. normal?: Vector3);
  47825. /**
  47826. * Clones the PositionNormalVertex
  47827. * @returns the cloned PositionNormalVertex
  47828. */
  47829. clone(): PositionNormalVertex;
  47830. }
  47831. /**
  47832. * Contains position, normal and uv vectors for a vertex
  47833. */
  47834. export class PositionNormalTextureVertex {
  47835. /** the position of the vertex (defaut: 0,0,0) */
  47836. position: Vector3;
  47837. /** the normal of the vertex (defaut: 0,1,0) */
  47838. normal: Vector3;
  47839. /** the uv of the vertex (default: 0,0) */
  47840. uv: Vector2;
  47841. /**
  47842. * Creates a PositionNormalTextureVertex
  47843. * @param position the position of the vertex (defaut: 0,0,0)
  47844. * @param normal the normal of the vertex (defaut: 0,1,0)
  47845. * @param uv the uv of the vertex (default: 0,0)
  47846. */
  47847. constructor(
  47848. /** the position of the vertex (defaut: 0,0,0) */
  47849. position?: Vector3,
  47850. /** the normal of the vertex (defaut: 0,1,0) */
  47851. normal?: Vector3,
  47852. /** the uv of the vertex (default: 0,0) */
  47853. uv?: Vector2);
  47854. /**
  47855. * Clones the PositionNormalTextureVertex
  47856. * @returns the cloned PositionNormalTextureVertex
  47857. */
  47858. clone(): PositionNormalTextureVertex;
  47859. }
  47860. }
  47861. declare module BABYLON {
  47862. /** @hidden */
  47863. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47864. private _genericAttributeLocation;
  47865. private _varyingLocationCount;
  47866. private _varyingLocationMap;
  47867. private _replacements;
  47868. private _textureCount;
  47869. private _uniforms;
  47870. lineProcessor(line: string): string;
  47871. attributeProcessor(attribute: string): string;
  47872. varyingProcessor(varying: string, isFragment: boolean): string;
  47873. uniformProcessor(uniform: string): string;
  47874. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47875. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47876. }
  47877. }
  47878. declare module BABYLON {
  47879. /**
  47880. * Container for accessors for natively-stored mesh data buffers.
  47881. */
  47882. class NativeDataBuffer extends DataBuffer {
  47883. /**
  47884. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47885. */
  47886. nativeIndexBuffer?: any;
  47887. /**
  47888. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47889. */
  47890. nativeVertexBuffer?: any;
  47891. }
  47892. /** @hidden */
  47893. class NativeTexture extends InternalTexture {
  47894. getInternalTexture(): InternalTexture;
  47895. getViewCount(): number;
  47896. }
  47897. /** @hidden */
  47898. export class NativeEngine extends Engine {
  47899. private readonly _native;
  47900. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47901. private readonly INVALID_HANDLE;
  47902. getHardwareScalingLevel(): number;
  47903. constructor();
  47904. /**
  47905. * Can be used to override the current requestAnimationFrame requester.
  47906. * @hidden
  47907. */
  47908. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47909. /**
  47910. * Override default engine behavior.
  47911. * @param color
  47912. * @param backBuffer
  47913. * @param depth
  47914. * @param stencil
  47915. */
  47916. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47917. /**
  47918. * Gets host document
  47919. * @returns the host document object
  47920. */
  47921. getHostDocument(): Nullable<Document>;
  47922. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47923. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47924. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47925. recordVertexArrayObject(vertexBuffers: {
  47926. [key: string]: VertexBuffer;
  47927. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47928. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47929. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47930. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47931. /**
  47932. * Draw a list of indexed primitives
  47933. * @param fillMode defines the primitive to use
  47934. * @param indexStart defines the starting index
  47935. * @param indexCount defines the number of index to draw
  47936. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47937. */
  47938. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47939. /**
  47940. * Draw a list of unindexed primitives
  47941. * @param fillMode defines the primitive to use
  47942. * @param verticesStart defines the index of first vertex to draw
  47943. * @param verticesCount defines the count of vertices to draw
  47944. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47945. */
  47946. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47947. createPipelineContext(): IPipelineContext;
  47948. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47949. /** @hidden */
  47950. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47951. /** @hidden */
  47952. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47953. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47954. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47955. protected _setProgram(program: WebGLProgram): void;
  47956. _releaseEffect(effect: Effect): void;
  47957. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47958. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47959. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47960. bindSamplers(effect: Effect): void;
  47961. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47962. getRenderWidth(useScreen?: boolean): number;
  47963. getRenderHeight(useScreen?: boolean): number;
  47964. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47965. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47966. /**
  47967. * Set the z offset to apply to current rendering
  47968. * @param value defines the offset to apply
  47969. */
  47970. setZOffset(value: number): void;
  47971. /**
  47972. * Gets the current value of the zOffset
  47973. * @returns the current zOffset state
  47974. */
  47975. getZOffset(): number;
  47976. /**
  47977. * Enable or disable depth buffering
  47978. * @param enable defines the state to set
  47979. */
  47980. setDepthBuffer(enable: boolean): void;
  47981. /**
  47982. * Gets a boolean indicating if depth writing is enabled
  47983. * @returns the current depth writing state
  47984. */
  47985. getDepthWrite(): boolean;
  47986. /**
  47987. * Enable or disable depth writing
  47988. * @param enable defines the state to set
  47989. */
  47990. setDepthWrite(enable: boolean): void;
  47991. /**
  47992. * Enable or disable color writing
  47993. * @param enable defines the state to set
  47994. */
  47995. setColorWrite(enable: boolean): void;
  47996. /**
  47997. * Gets a boolean indicating if color writing is enabled
  47998. * @returns the current color writing state
  47999. */
  48000. getColorWrite(): boolean;
  48001. /**
  48002. * Sets alpha constants used by some alpha blending modes
  48003. * @param r defines the red component
  48004. * @param g defines the green component
  48005. * @param b defines the blue component
  48006. * @param a defines the alpha component
  48007. */
  48008. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48009. /**
  48010. * Sets the current alpha mode
  48011. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48012. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48013. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48014. */
  48015. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48016. /**
  48017. * Gets the current alpha mode
  48018. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48019. * @returns the current alpha mode
  48020. */
  48021. getAlphaMode(): number;
  48022. setInt(uniform: WebGLUniformLocation, int: number): void;
  48023. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48024. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48025. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48026. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48027. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48028. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48029. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48030. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48031. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48032. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48033. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48034. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48035. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48036. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48037. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48038. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48039. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48040. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48041. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48042. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48043. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48044. wipeCaches(bruteForce?: boolean): void;
  48045. _createTexture(): WebGLTexture;
  48046. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48047. /**
  48048. * Usually called from Texture.ts.
  48049. * Passed information to create a WebGLTexture
  48050. * @param urlArg defines a value which contains one of the following:
  48051. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48052. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48053. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48054. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48055. * @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)
  48056. * @param scene needed for loading to the correct scene
  48057. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48058. * @param onLoad optional callback to be called upon successful completion
  48059. * @param onError optional callback to be called upon failure
  48060. * @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
  48061. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48062. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48063. * @param forcedExtension defines the extension to use to pick the right loader
  48064. * @param mimeType defines an optional mime type
  48065. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48066. */
  48067. 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;
  48068. /**
  48069. * Creates a cube texture
  48070. * @param rootUrl defines the url where the files to load is located
  48071. * @param scene defines the current scene
  48072. * @param files defines the list of files to load (1 per face)
  48073. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48074. * @param onLoad defines an optional callback raised when the texture is loaded
  48075. * @param onError defines an optional callback raised if there is an issue to load the texture
  48076. * @param format defines the format of the data
  48077. * @param forcedExtension defines the extension to use to pick the right loader
  48078. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48079. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48080. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48081. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48082. * @returns the cube texture as an InternalTexture
  48083. */
  48084. 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;
  48085. private _getSamplingFilter;
  48086. private static _GetNativeTextureFormat;
  48087. createRenderTargetTexture(size: number | {
  48088. width: number;
  48089. height: number;
  48090. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48091. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48092. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48093. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48094. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48095. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48096. /**
  48097. * Updates a dynamic vertex buffer.
  48098. * @param vertexBuffer the vertex buffer to update
  48099. * @param data the data used to update the vertex buffer
  48100. * @param byteOffset the byte offset of the data (optional)
  48101. * @param byteLength the byte length of the data (optional)
  48102. */
  48103. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48104. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48105. private _updateAnisotropicLevel;
  48106. private _getAddressMode;
  48107. /** @hidden */
  48108. _bindTexture(channel: number, texture: InternalTexture): void;
  48109. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48110. releaseEffects(): void;
  48111. /** @hidden */
  48112. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48113. /** @hidden */
  48114. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48115. /** @hidden */
  48116. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48117. /** @hidden */
  48118. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48119. }
  48120. }
  48121. declare module BABYLON {
  48122. /**
  48123. * Gather the list of clipboard event types as constants.
  48124. */
  48125. export class ClipboardEventTypes {
  48126. /**
  48127. * The clipboard event is fired when a copy command is active (pressed).
  48128. */
  48129. static readonly COPY: number;
  48130. /**
  48131. * The clipboard event is fired when a cut command is active (pressed).
  48132. */
  48133. static readonly CUT: number;
  48134. /**
  48135. * The clipboard event is fired when a paste command is active (pressed).
  48136. */
  48137. static readonly PASTE: number;
  48138. }
  48139. /**
  48140. * This class is used to store clipboard related info for the onClipboardObservable event.
  48141. */
  48142. export class ClipboardInfo {
  48143. /**
  48144. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48145. */
  48146. type: number;
  48147. /**
  48148. * Defines the related dom event
  48149. */
  48150. event: ClipboardEvent;
  48151. /**
  48152. *Creates an instance of ClipboardInfo.
  48153. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48154. * @param event Defines the related dom event
  48155. */
  48156. constructor(
  48157. /**
  48158. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48159. */
  48160. type: number,
  48161. /**
  48162. * Defines the related dom event
  48163. */
  48164. event: ClipboardEvent);
  48165. /**
  48166. * Get the clipboard event's type from the keycode.
  48167. * @param keyCode Defines the keyCode for the current keyboard event.
  48168. * @return {number}
  48169. */
  48170. static GetTypeFromCharacter(keyCode: number): number;
  48171. }
  48172. }
  48173. declare module BABYLON {
  48174. /**
  48175. * Google Daydream controller
  48176. */
  48177. export class DaydreamController extends WebVRController {
  48178. /**
  48179. * Base Url for the controller model.
  48180. */
  48181. static MODEL_BASE_URL: string;
  48182. /**
  48183. * File name for the controller model.
  48184. */
  48185. static MODEL_FILENAME: string;
  48186. /**
  48187. * Gamepad Id prefix used to identify Daydream Controller.
  48188. */
  48189. static readonly GAMEPAD_ID_PREFIX: string;
  48190. /**
  48191. * Creates a new DaydreamController from a gamepad
  48192. * @param vrGamepad the gamepad that the controller should be created from
  48193. */
  48194. constructor(vrGamepad: any);
  48195. /**
  48196. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48197. * @param scene scene in which to add meshes
  48198. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48199. */
  48200. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48201. /**
  48202. * Called once for each button that changed state since the last frame
  48203. * @param buttonIdx Which button index changed
  48204. * @param state New state of the button
  48205. * @param changes Which properties on the state changed since last frame
  48206. */
  48207. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48208. }
  48209. }
  48210. declare module BABYLON {
  48211. /**
  48212. * Gear VR Controller
  48213. */
  48214. export class GearVRController extends WebVRController {
  48215. /**
  48216. * Base Url for the controller model.
  48217. */
  48218. static MODEL_BASE_URL: string;
  48219. /**
  48220. * File name for the controller model.
  48221. */
  48222. static MODEL_FILENAME: string;
  48223. /**
  48224. * Gamepad Id prefix used to identify this controller.
  48225. */
  48226. static readonly GAMEPAD_ID_PREFIX: string;
  48227. private readonly _buttonIndexToObservableNameMap;
  48228. /**
  48229. * Creates a new GearVRController from a gamepad
  48230. * @param vrGamepad the gamepad that the controller should be created from
  48231. */
  48232. constructor(vrGamepad: any);
  48233. /**
  48234. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48235. * @param scene scene in which to add meshes
  48236. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48237. */
  48238. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48239. /**
  48240. * Called once for each button that changed state since the last frame
  48241. * @param buttonIdx Which button index changed
  48242. * @param state New state of the button
  48243. * @param changes Which properties on the state changed since last frame
  48244. */
  48245. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48246. }
  48247. }
  48248. declare module BABYLON {
  48249. /**
  48250. * Generic Controller
  48251. */
  48252. export class GenericController extends WebVRController {
  48253. /**
  48254. * Base Url for the controller model.
  48255. */
  48256. static readonly MODEL_BASE_URL: string;
  48257. /**
  48258. * File name for the controller model.
  48259. */
  48260. static readonly MODEL_FILENAME: string;
  48261. /**
  48262. * Creates a new GenericController from a gamepad
  48263. * @param vrGamepad the gamepad that the controller should be created from
  48264. */
  48265. constructor(vrGamepad: any);
  48266. /**
  48267. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48268. * @param scene scene in which to add meshes
  48269. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48270. */
  48271. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48272. /**
  48273. * Called once for each button that changed state since the last frame
  48274. * @param buttonIdx Which button index changed
  48275. * @param state New state of the button
  48276. * @param changes Which properties on the state changed since last frame
  48277. */
  48278. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48279. }
  48280. }
  48281. declare module BABYLON {
  48282. /**
  48283. * Oculus Touch Controller
  48284. */
  48285. export class OculusTouchController extends WebVRController {
  48286. /**
  48287. * Base Url for the controller model.
  48288. */
  48289. static MODEL_BASE_URL: string;
  48290. /**
  48291. * File name for the left controller model.
  48292. */
  48293. static MODEL_LEFT_FILENAME: string;
  48294. /**
  48295. * File name for the right controller model.
  48296. */
  48297. static MODEL_RIGHT_FILENAME: string;
  48298. /**
  48299. * Base Url for the Quest controller model.
  48300. */
  48301. static QUEST_MODEL_BASE_URL: string;
  48302. /**
  48303. * @hidden
  48304. * If the controllers are running on a device that needs the updated Quest controller models
  48305. */
  48306. static _IsQuest: boolean;
  48307. /**
  48308. * Fired when the secondary trigger on this controller is modified
  48309. */
  48310. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48311. /**
  48312. * Fired when the thumb rest on this controller is modified
  48313. */
  48314. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48315. /**
  48316. * Creates a new OculusTouchController from a gamepad
  48317. * @param vrGamepad the gamepad that the controller should be created from
  48318. */
  48319. constructor(vrGamepad: any);
  48320. /**
  48321. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48322. * @param scene scene in which to add meshes
  48323. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48324. */
  48325. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48326. /**
  48327. * Fired when the A button on this controller is modified
  48328. */
  48329. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48330. /**
  48331. * Fired when the B button on this controller is modified
  48332. */
  48333. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48334. /**
  48335. * Fired when the X button on this controller is modified
  48336. */
  48337. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48338. /**
  48339. * Fired when the Y button on this controller is modified
  48340. */
  48341. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48342. /**
  48343. * Called once for each button that changed state since the last frame
  48344. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48345. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48346. * 2) secondary trigger (same)
  48347. * 3) A (right) X (left), touch, pressed = value
  48348. * 4) B / Y
  48349. * 5) thumb rest
  48350. * @param buttonIdx Which button index changed
  48351. * @param state New state of the button
  48352. * @param changes Which properties on the state changed since last frame
  48353. */
  48354. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48355. }
  48356. }
  48357. declare module BABYLON {
  48358. /**
  48359. * Vive Controller
  48360. */
  48361. export class ViveController extends WebVRController {
  48362. /**
  48363. * Base Url for the controller model.
  48364. */
  48365. static MODEL_BASE_URL: string;
  48366. /**
  48367. * File name for the controller model.
  48368. */
  48369. static MODEL_FILENAME: string;
  48370. /**
  48371. * Creates a new ViveController from a gamepad
  48372. * @param vrGamepad the gamepad that the controller should be created from
  48373. */
  48374. constructor(vrGamepad: any);
  48375. /**
  48376. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48377. * @param scene scene in which to add meshes
  48378. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48379. */
  48380. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48381. /**
  48382. * Fired when the left button on this controller is modified
  48383. */
  48384. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48385. /**
  48386. * Fired when the right button on this controller is modified
  48387. */
  48388. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48389. /**
  48390. * Fired when the menu button on this controller is modified
  48391. */
  48392. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48393. /**
  48394. * Called once for each button that changed state since the last frame
  48395. * Vive mapping:
  48396. * 0: touchpad
  48397. * 1: trigger
  48398. * 2: left AND right buttons
  48399. * 3: menu button
  48400. * @param buttonIdx Which button index changed
  48401. * @param state New state of the button
  48402. * @param changes Which properties on the state changed since last frame
  48403. */
  48404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48405. }
  48406. }
  48407. declare module BABYLON {
  48408. /**
  48409. * Defines the WindowsMotionController object that the state of the windows motion controller
  48410. */
  48411. export class WindowsMotionController extends WebVRController {
  48412. /**
  48413. * The base url used to load the left and right controller models
  48414. */
  48415. static MODEL_BASE_URL: string;
  48416. /**
  48417. * The name of the left controller model file
  48418. */
  48419. static MODEL_LEFT_FILENAME: string;
  48420. /**
  48421. * The name of the right controller model file
  48422. */
  48423. static MODEL_RIGHT_FILENAME: string;
  48424. /**
  48425. * The controller name prefix for this controller type
  48426. */
  48427. static readonly GAMEPAD_ID_PREFIX: string;
  48428. /**
  48429. * The controller id pattern for this controller type
  48430. */
  48431. private static readonly GAMEPAD_ID_PATTERN;
  48432. private _loadedMeshInfo;
  48433. protected readonly _mapping: {
  48434. buttons: string[];
  48435. buttonMeshNames: {
  48436. 'trigger': string;
  48437. 'menu': string;
  48438. 'grip': string;
  48439. 'thumbstick': string;
  48440. 'trackpad': string;
  48441. };
  48442. buttonObservableNames: {
  48443. 'trigger': string;
  48444. 'menu': string;
  48445. 'grip': string;
  48446. 'thumbstick': string;
  48447. 'trackpad': string;
  48448. };
  48449. axisMeshNames: string[];
  48450. pointingPoseMeshName: string;
  48451. };
  48452. /**
  48453. * Fired when the trackpad on this controller is clicked
  48454. */
  48455. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48456. /**
  48457. * Fired when the trackpad on this controller is modified
  48458. */
  48459. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48460. /**
  48461. * The current x and y values of this controller's trackpad
  48462. */
  48463. trackpad: StickValues;
  48464. /**
  48465. * Creates a new WindowsMotionController from a gamepad
  48466. * @param vrGamepad the gamepad that the controller should be created from
  48467. */
  48468. constructor(vrGamepad: any);
  48469. /**
  48470. * Fired when the trigger on this controller is modified
  48471. */
  48472. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48473. /**
  48474. * Fired when the menu button on this controller is modified
  48475. */
  48476. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48477. /**
  48478. * Fired when the grip button on this controller is modified
  48479. */
  48480. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48481. /**
  48482. * Fired when the thumbstick button on this controller is modified
  48483. */
  48484. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48485. /**
  48486. * Fired when the touchpad button on this controller is modified
  48487. */
  48488. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48489. /**
  48490. * Fired when the touchpad values on this controller are modified
  48491. */
  48492. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48493. protected _updateTrackpad(): void;
  48494. /**
  48495. * Called once per frame by the engine.
  48496. */
  48497. update(): void;
  48498. /**
  48499. * Called once for each button that changed state since the last frame
  48500. * @param buttonIdx Which button index changed
  48501. * @param state New state of the button
  48502. * @param changes Which properties on the state changed since last frame
  48503. */
  48504. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48505. /**
  48506. * Moves the buttons on the controller mesh based on their current state
  48507. * @param buttonName the name of the button to move
  48508. * @param buttonValue the value of the button which determines the buttons new position
  48509. */
  48510. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48511. /**
  48512. * Moves the axis on the controller mesh based on its current state
  48513. * @param axis the index of the axis
  48514. * @param axisValue the value of the axis which determines the meshes new position
  48515. * @hidden
  48516. */
  48517. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48518. /**
  48519. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48520. * @param scene scene in which to add meshes
  48521. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48522. */
  48523. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48524. /**
  48525. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48526. * can be transformed by button presses and axes values, based on this._mapping.
  48527. *
  48528. * @param scene scene in which the meshes exist
  48529. * @param meshes list of meshes that make up the controller model to process
  48530. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48531. */
  48532. private processModel;
  48533. private createMeshInfo;
  48534. /**
  48535. * Gets the ray of the controller in the direction the controller is pointing
  48536. * @param length the length the resulting ray should be
  48537. * @returns a ray in the direction the controller is pointing
  48538. */
  48539. getForwardRay(length?: number): Ray;
  48540. /**
  48541. * Disposes of the controller
  48542. */
  48543. dispose(): void;
  48544. }
  48545. /**
  48546. * This class represents a new windows motion controller in XR.
  48547. */
  48548. export class XRWindowsMotionController extends WindowsMotionController {
  48549. /**
  48550. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48551. */
  48552. protected readonly _mapping: {
  48553. buttons: string[];
  48554. buttonMeshNames: {
  48555. 'trigger': string;
  48556. 'menu': string;
  48557. 'grip': string;
  48558. 'thumbstick': string;
  48559. 'trackpad': string;
  48560. };
  48561. buttonObservableNames: {
  48562. 'trigger': string;
  48563. 'menu': string;
  48564. 'grip': string;
  48565. 'thumbstick': string;
  48566. 'trackpad': string;
  48567. };
  48568. axisMeshNames: string[];
  48569. pointingPoseMeshName: string;
  48570. };
  48571. /**
  48572. * Construct a new XR-Based windows motion controller
  48573. *
  48574. * @param gamepadInfo the gamepad object from the browser
  48575. */
  48576. constructor(gamepadInfo: any);
  48577. /**
  48578. * holds the thumbstick values (X,Y)
  48579. */
  48580. thumbstickValues: StickValues;
  48581. /**
  48582. * Fired when the thumbstick on this controller is clicked
  48583. */
  48584. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48585. /**
  48586. * Fired when the thumbstick on this controller is modified
  48587. */
  48588. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48589. /**
  48590. * Fired when the touchpad button on this controller is modified
  48591. */
  48592. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48593. /**
  48594. * Fired when the touchpad values on this controller are modified
  48595. */
  48596. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48597. /**
  48598. * Fired when the thumbstick button on this controller is modified
  48599. * here to prevent breaking changes
  48600. */
  48601. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48602. /**
  48603. * updating the thumbstick(!) and not the trackpad.
  48604. * This is named this way due to the difference between WebVR and XR and to avoid
  48605. * changing the parent class.
  48606. */
  48607. protected _updateTrackpad(): void;
  48608. /**
  48609. * Disposes the class with joy
  48610. */
  48611. dispose(): void;
  48612. }
  48613. }
  48614. declare module BABYLON {
  48615. /**
  48616. * Class containing static functions to help procedurally build meshes
  48617. */
  48618. export class PolyhedronBuilder {
  48619. /**
  48620. * Creates a polyhedron mesh
  48621. * * 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
  48622. * * The parameter `size` (positive float, default 1) sets the polygon size
  48623. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48624. * * 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`
  48625. * * 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
  48626. * * 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)`)
  48627. * * 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
  48628. * * 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
  48629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48630. * * 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
  48631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48632. * @param name defines the name of the mesh
  48633. * @param options defines the options used to create the mesh
  48634. * @param scene defines the hosting scene
  48635. * @returns the polyhedron mesh
  48636. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48637. */
  48638. static CreatePolyhedron(name: string, options: {
  48639. type?: number;
  48640. size?: number;
  48641. sizeX?: number;
  48642. sizeY?: number;
  48643. sizeZ?: number;
  48644. custom?: any;
  48645. faceUV?: Vector4[];
  48646. faceColors?: Color4[];
  48647. flat?: boolean;
  48648. updatable?: boolean;
  48649. sideOrientation?: number;
  48650. frontUVs?: Vector4;
  48651. backUVs?: Vector4;
  48652. }, scene?: Nullable<Scene>): Mesh;
  48653. }
  48654. }
  48655. declare module BABYLON {
  48656. /**
  48657. * Gizmo that enables scaling a mesh along 3 axis
  48658. */
  48659. export class ScaleGizmo extends Gizmo {
  48660. /**
  48661. * Internal gizmo used for interactions on the x axis
  48662. */
  48663. xGizmo: AxisScaleGizmo;
  48664. /**
  48665. * Internal gizmo used for interactions on the y axis
  48666. */
  48667. yGizmo: AxisScaleGizmo;
  48668. /**
  48669. * Internal gizmo used for interactions on the z axis
  48670. */
  48671. zGizmo: AxisScaleGizmo;
  48672. /**
  48673. * Internal gizmo used to scale all axis equally
  48674. */
  48675. uniformScaleGizmo: AxisScaleGizmo;
  48676. private _meshAttached;
  48677. private _updateGizmoRotationToMatchAttachedMesh;
  48678. private _snapDistance;
  48679. private _scaleRatio;
  48680. private _uniformScalingMesh;
  48681. private _octahedron;
  48682. private _sensitivity;
  48683. /** Fires an event when any of it's sub gizmos are dragged */
  48684. onDragStartObservable: Observable<unknown>;
  48685. /** Fires an event when any of it's sub gizmos are released from dragging */
  48686. onDragEndObservable: Observable<unknown>;
  48687. get attachedMesh(): Nullable<AbstractMesh>;
  48688. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48689. /**
  48690. * Creates a ScaleGizmo
  48691. * @param gizmoLayer The utility layer the gizmo will be added to
  48692. */
  48693. constructor(gizmoLayer?: UtilityLayerRenderer);
  48694. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48695. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48696. /**
  48697. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48698. */
  48699. set snapDistance(value: number);
  48700. get snapDistance(): number;
  48701. /**
  48702. * Ratio for the scale of the gizmo (Default: 1)
  48703. */
  48704. set scaleRatio(value: number);
  48705. get scaleRatio(): number;
  48706. /**
  48707. * Sensitivity factor for dragging (Default: 1)
  48708. */
  48709. set sensitivity(value: number);
  48710. get sensitivity(): number;
  48711. /**
  48712. * Disposes of the gizmo
  48713. */
  48714. dispose(): void;
  48715. }
  48716. }
  48717. declare module BABYLON {
  48718. /**
  48719. * Single axis scale gizmo
  48720. */
  48721. export class AxisScaleGizmo extends Gizmo {
  48722. /**
  48723. * Drag behavior responsible for the gizmos dragging interactions
  48724. */
  48725. dragBehavior: PointerDragBehavior;
  48726. private _pointerObserver;
  48727. /**
  48728. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48729. */
  48730. snapDistance: number;
  48731. /**
  48732. * Event that fires each time the gizmo snaps to a new location.
  48733. * * snapDistance is the the change in distance
  48734. */
  48735. onSnapObservable: Observable<{
  48736. snapDistance: number;
  48737. }>;
  48738. /**
  48739. * If the scaling operation should be done on all axis (default: false)
  48740. */
  48741. uniformScaling: boolean;
  48742. /**
  48743. * Custom sensitivity value for the drag strength
  48744. */
  48745. sensitivity: number;
  48746. private _isEnabled;
  48747. private _parent;
  48748. private _arrow;
  48749. private _coloredMaterial;
  48750. private _hoverMaterial;
  48751. /**
  48752. * Creates an AxisScaleGizmo
  48753. * @param gizmoLayer The utility layer the gizmo will be added to
  48754. * @param dragAxis The axis which the gizmo will be able to scale on
  48755. * @param color The color of the gizmo
  48756. */
  48757. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48758. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48759. /**
  48760. * If the gizmo is enabled
  48761. */
  48762. set isEnabled(value: boolean);
  48763. get isEnabled(): boolean;
  48764. /**
  48765. * Disposes of the gizmo
  48766. */
  48767. dispose(): void;
  48768. /**
  48769. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48770. * @param mesh The mesh to replace the default mesh of the gizmo
  48771. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48772. */
  48773. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48774. }
  48775. }
  48776. declare module BABYLON {
  48777. /**
  48778. * Bounding box gizmo
  48779. */
  48780. export class BoundingBoxGizmo extends Gizmo {
  48781. private _lineBoundingBox;
  48782. private _rotateSpheresParent;
  48783. private _scaleBoxesParent;
  48784. private _boundingDimensions;
  48785. private _renderObserver;
  48786. private _pointerObserver;
  48787. private _scaleDragSpeed;
  48788. private _tmpQuaternion;
  48789. private _tmpVector;
  48790. private _tmpRotationMatrix;
  48791. /**
  48792. * 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)
  48793. */
  48794. ignoreChildren: boolean;
  48795. /**
  48796. * 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)
  48797. */
  48798. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48799. /**
  48800. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48801. */
  48802. rotationSphereSize: number;
  48803. /**
  48804. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48805. */
  48806. scaleBoxSize: number;
  48807. /**
  48808. * 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)
  48809. */
  48810. fixedDragMeshScreenSize: boolean;
  48811. /**
  48812. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48813. */
  48814. fixedDragMeshScreenSizeDistanceFactor: number;
  48815. /**
  48816. * Fired when a rotation sphere or scale box is dragged
  48817. */
  48818. onDragStartObservable: Observable<{}>;
  48819. /**
  48820. * Fired when a scale box is dragged
  48821. */
  48822. onScaleBoxDragObservable: Observable<{}>;
  48823. /**
  48824. * Fired when a scale box drag is ended
  48825. */
  48826. onScaleBoxDragEndObservable: Observable<{}>;
  48827. /**
  48828. * Fired when a rotation sphere is dragged
  48829. */
  48830. onRotationSphereDragObservable: Observable<{}>;
  48831. /**
  48832. * Fired when a rotation sphere drag is ended
  48833. */
  48834. onRotationSphereDragEndObservable: Observable<{}>;
  48835. /**
  48836. * 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)
  48837. */
  48838. scalePivot: Nullable<Vector3>;
  48839. /**
  48840. * Mesh used as a pivot to rotate the attached mesh
  48841. */
  48842. private _anchorMesh;
  48843. private _existingMeshScale;
  48844. private _dragMesh;
  48845. private pointerDragBehavior;
  48846. private coloredMaterial;
  48847. private hoverColoredMaterial;
  48848. /**
  48849. * Sets the color of the bounding box gizmo
  48850. * @param color the color to set
  48851. */
  48852. setColor(color: Color3): void;
  48853. /**
  48854. * Creates an BoundingBoxGizmo
  48855. * @param gizmoLayer The utility layer the gizmo will be added to
  48856. * @param color The color of the gizmo
  48857. */
  48858. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48859. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48860. private _selectNode;
  48861. /**
  48862. * Updates the bounding box information for the Gizmo
  48863. */
  48864. updateBoundingBox(): void;
  48865. private _updateRotationSpheres;
  48866. private _updateScaleBoxes;
  48867. /**
  48868. * Enables rotation on the specified axis and disables rotation on the others
  48869. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48870. */
  48871. setEnabledRotationAxis(axis: string): void;
  48872. /**
  48873. * Enables/disables scaling
  48874. * @param enable if scaling should be enabled
  48875. * @param homogeneousScaling defines if scaling should only be homogeneous
  48876. */
  48877. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  48878. private _updateDummy;
  48879. /**
  48880. * Enables a pointer drag behavior on the bounding box of the gizmo
  48881. */
  48882. enableDragBehavior(): void;
  48883. /**
  48884. * Disposes of the gizmo
  48885. */
  48886. dispose(): void;
  48887. /**
  48888. * 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)
  48889. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48890. * @returns the bounding box mesh with the passed in mesh as a child
  48891. */
  48892. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48893. /**
  48894. * CustomMeshes are not supported by this gizmo
  48895. * @param mesh The mesh to replace the default mesh of the gizmo
  48896. */
  48897. setCustomMesh(mesh: Mesh): void;
  48898. }
  48899. }
  48900. declare module BABYLON {
  48901. /**
  48902. * Single plane rotation gizmo
  48903. */
  48904. export class PlaneRotationGizmo extends Gizmo {
  48905. /**
  48906. * Drag behavior responsible for the gizmos dragging interactions
  48907. */
  48908. dragBehavior: PointerDragBehavior;
  48909. private _pointerObserver;
  48910. /**
  48911. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48912. */
  48913. snapDistance: number;
  48914. /**
  48915. * Event that fires each time the gizmo snaps to a new location.
  48916. * * snapDistance is the the change in distance
  48917. */
  48918. onSnapObservable: Observable<{
  48919. snapDistance: number;
  48920. }>;
  48921. private _isEnabled;
  48922. private _parent;
  48923. /**
  48924. * Creates a PlaneRotationGizmo
  48925. * @param gizmoLayer The utility layer the gizmo will be added to
  48926. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48927. * @param color The color of the gizmo
  48928. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48929. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48930. */
  48931. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48932. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48933. /**
  48934. * If the gizmo is enabled
  48935. */
  48936. set isEnabled(value: boolean);
  48937. get isEnabled(): boolean;
  48938. /**
  48939. * Disposes of the gizmo
  48940. */
  48941. dispose(): void;
  48942. }
  48943. }
  48944. declare module BABYLON {
  48945. /**
  48946. * Gizmo that enables rotating a mesh along 3 axis
  48947. */
  48948. export class RotationGizmo extends Gizmo {
  48949. /**
  48950. * Internal gizmo used for interactions on the x axis
  48951. */
  48952. xGizmo: PlaneRotationGizmo;
  48953. /**
  48954. * Internal gizmo used for interactions on the y axis
  48955. */
  48956. yGizmo: PlaneRotationGizmo;
  48957. /**
  48958. * Internal gizmo used for interactions on the z axis
  48959. */
  48960. zGizmo: PlaneRotationGizmo;
  48961. /** Fires an event when any of it's sub gizmos are dragged */
  48962. onDragStartObservable: Observable<unknown>;
  48963. /** Fires an event when any of it's sub gizmos are released from dragging */
  48964. onDragEndObservable: Observable<unknown>;
  48965. private _meshAttached;
  48966. get attachedMesh(): Nullable<AbstractMesh>;
  48967. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48968. /**
  48969. * Creates a RotationGizmo
  48970. * @param gizmoLayer The utility layer the gizmo will be added to
  48971. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48972. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48973. */
  48974. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48975. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48976. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48977. /**
  48978. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48979. */
  48980. set snapDistance(value: number);
  48981. get snapDistance(): number;
  48982. /**
  48983. * Ratio for the scale of the gizmo (Default: 1)
  48984. */
  48985. set scaleRatio(value: number);
  48986. get scaleRatio(): number;
  48987. /**
  48988. * Disposes of the gizmo
  48989. */
  48990. dispose(): void;
  48991. /**
  48992. * CustomMeshes are not supported by this gizmo
  48993. * @param mesh The mesh to replace the default mesh of the gizmo
  48994. */
  48995. setCustomMesh(mesh: Mesh): void;
  48996. }
  48997. }
  48998. declare module BABYLON {
  48999. /**
  49000. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49001. */
  49002. export class GizmoManager implements IDisposable {
  49003. private scene;
  49004. /**
  49005. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49006. */
  49007. gizmos: {
  49008. positionGizmo: Nullable<PositionGizmo>;
  49009. rotationGizmo: Nullable<RotationGizmo>;
  49010. scaleGizmo: Nullable<ScaleGizmo>;
  49011. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49012. };
  49013. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49014. clearGizmoOnEmptyPointerEvent: boolean;
  49015. /** Fires an event when the manager is attached to a mesh */
  49016. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49017. private _gizmosEnabled;
  49018. private _pointerObserver;
  49019. private _attachedMesh;
  49020. private _boundingBoxColor;
  49021. private _defaultUtilityLayer;
  49022. private _defaultKeepDepthUtilityLayer;
  49023. /**
  49024. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49025. */
  49026. boundingBoxDragBehavior: SixDofDragBehavior;
  49027. /**
  49028. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49029. */
  49030. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49031. /**
  49032. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49033. */
  49034. usePointerToAttachGizmos: boolean;
  49035. /**
  49036. * Utility layer that the bounding box gizmo belongs to
  49037. */
  49038. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49039. /**
  49040. * Utility layer that all gizmos besides bounding box belong to
  49041. */
  49042. get utilityLayer(): UtilityLayerRenderer;
  49043. /**
  49044. * Instatiates a gizmo manager
  49045. * @param scene the scene to overlay the gizmos on top of
  49046. */
  49047. constructor(scene: Scene);
  49048. /**
  49049. * Attaches a set of gizmos to the specified mesh
  49050. * @param mesh The mesh the gizmo's should be attached to
  49051. */
  49052. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49053. /**
  49054. * If the position gizmo is enabled
  49055. */
  49056. set positionGizmoEnabled(value: boolean);
  49057. get positionGizmoEnabled(): boolean;
  49058. /**
  49059. * If the rotation gizmo is enabled
  49060. */
  49061. set rotationGizmoEnabled(value: boolean);
  49062. get rotationGizmoEnabled(): boolean;
  49063. /**
  49064. * If the scale gizmo is enabled
  49065. */
  49066. set scaleGizmoEnabled(value: boolean);
  49067. get scaleGizmoEnabled(): boolean;
  49068. /**
  49069. * If the boundingBox gizmo is enabled
  49070. */
  49071. set boundingBoxGizmoEnabled(value: boolean);
  49072. get boundingBoxGizmoEnabled(): boolean;
  49073. /**
  49074. * Disposes of the gizmo manager
  49075. */
  49076. dispose(): void;
  49077. }
  49078. }
  49079. declare module BABYLON {
  49080. /**
  49081. * A directional light is defined by a direction (what a surprise!).
  49082. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49083. * 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.
  49084. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49085. */
  49086. export class DirectionalLight extends ShadowLight {
  49087. private _shadowFrustumSize;
  49088. /**
  49089. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49090. */
  49091. get shadowFrustumSize(): number;
  49092. /**
  49093. * Specifies a fix frustum size for the shadow generation.
  49094. */
  49095. set shadowFrustumSize(value: number);
  49096. private _shadowOrthoScale;
  49097. /**
  49098. * Gets the shadow projection scale against the optimal computed one.
  49099. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49100. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49101. */
  49102. get shadowOrthoScale(): number;
  49103. /**
  49104. * Sets the shadow projection scale against the optimal computed one.
  49105. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49106. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49107. */
  49108. set shadowOrthoScale(value: number);
  49109. /**
  49110. * Automatically compute the projection matrix to best fit (including all the casters)
  49111. * on each frame.
  49112. */
  49113. autoUpdateExtends: boolean;
  49114. /**
  49115. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49116. * on each frame. autoUpdateExtends must be set to true for this to work
  49117. */
  49118. autoCalcShadowZBounds: boolean;
  49119. private _orthoLeft;
  49120. private _orthoRight;
  49121. private _orthoTop;
  49122. private _orthoBottom;
  49123. /**
  49124. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49125. * The directional light is emitted from everywhere in the given direction.
  49126. * It can cast shadows.
  49127. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49128. * @param name The friendly name of the light
  49129. * @param direction The direction of the light
  49130. * @param scene The scene the light belongs to
  49131. */
  49132. constructor(name: string, direction: Vector3, scene: Scene);
  49133. /**
  49134. * Returns the string "DirectionalLight".
  49135. * @return The class name
  49136. */
  49137. getClassName(): string;
  49138. /**
  49139. * Returns the integer 1.
  49140. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49141. */
  49142. getTypeID(): number;
  49143. /**
  49144. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49145. * Returns the DirectionalLight Shadow projection matrix.
  49146. */
  49147. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49148. /**
  49149. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49150. * Returns the DirectionalLight Shadow projection matrix.
  49151. */
  49152. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49153. /**
  49154. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49155. * Returns the DirectionalLight Shadow projection matrix.
  49156. */
  49157. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49158. protected _buildUniformLayout(): void;
  49159. /**
  49160. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49161. * @param effect The effect to update
  49162. * @param lightIndex The index of the light in the effect to update
  49163. * @returns The directional light
  49164. */
  49165. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49166. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49167. /**
  49168. * Gets the minZ used for shadow according to both the scene and the light.
  49169. *
  49170. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49171. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49172. * @param activeCamera The camera we are returning the min for
  49173. * @returns the depth min z
  49174. */
  49175. getDepthMinZ(activeCamera: Camera): number;
  49176. /**
  49177. * Gets the maxZ used for shadow according to both the scene and the light.
  49178. *
  49179. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49180. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49181. * @param activeCamera The camera we are returning the max for
  49182. * @returns the depth max z
  49183. */
  49184. getDepthMaxZ(activeCamera: Camera): number;
  49185. /**
  49186. * Prepares the list of defines specific to the light type.
  49187. * @param defines the list of defines
  49188. * @param lightIndex defines the index of the light for the effect
  49189. */
  49190. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49191. }
  49192. }
  49193. declare module BABYLON {
  49194. /**
  49195. * Class containing static functions to help procedurally build meshes
  49196. */
  49197. export class HemisphereBuilder {
  49198. /**
  49199. * Creates a hemisphere mesh
  49200. * @param name defines the name of the mesh
  49201. * @param options defines the options used to create the mesh
  49202. * @param scene defines the hosting scene
  49203. * @returns the hemisphere mesh
  49204. */
  49205. static CreateHemisphere(name: string, options: {
  49206. segments?: number;
  49207. diameter?: number;
  49208. sideOrientation?: number;
  49209. }, scene: any): Mesh;
  49210. }
  49211. }
  49212. declare module BABYLON {
  49213. /**
  49214. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49215. * These values define a cone of light starting from the position, emitting toward the direction.
  49216. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49217. * and the exponent defines the speed of the decay of the light with distance (reach).
  49218. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49219. */
  49220. export class SpotLight extends ShadowLight {
  49221. private _angle;
  49222. private _innerAngle;
  49223. private _cosHalfAngle;
  49224. private _lightAngleScale;
  49225. private _lightAngleOffset;
  49226. /**
  49227. * Gets the cone angle of the spot light in Radians.
  49228. */
  49229. get angle(): number;
  49230. /**
  49231. * Sets the cone angle of the spot light in Radians.
  49232. */
  49233. set angle(value: number);
  49234. /**
  49235. * Only used in gltf falloff mode, this defines the angle where
  49236. * the directional falloff will start before cutting at angle which could be seen
  49237. * as outer angle.
  49238. */
  49239. get innerAngle(): number;
  49240. /**
  49241. * Only used in gltf falloff mode, this defines the angle where
  49242. * the directional falloff will start before cutting at angle which could be seen
  49243. * as outer angle.
  49244. */
  49245. set innerAngle(value: number);
  49246. private _shadowAngleScale;
  49247. /**
  49248. * Allows scaling the angle of the light for shadow generation only.
  49249. */
  49250. get shadowAngleScale(): number;
  49251. /**
  49252. * Allows scaling the angle of the light for shadow generation only.
  49253. */
  49254. set shadowAngleScale(value: number);
  49255. /**
  49256. * The light decay speed with the distance from the emission spot.
  49257. */
  49258. exponent: number;
  49259. private _projectionTextureMatrix;
  49260. /**
  49261. * Allows reading the projecton texture
  49262. */
  49263. get projectionTextureMatrix(): Matrix;
  49264. protected _projectionTextureLightNear: number;
  49265. /**
  49266. * Gets the near clip of the Spotlight for texture projection.
  49267. */
  49268. get projectionTextureLightNear(): number;
  49269. /**
  49270. * Sets the near clip of the Spotlight for texture projection.
  49271. */
  49272. set projectionTextureLightNear(value: number);
  49273. protected _projectionTextureLightFar: number;
  49274. /**
  49275. * Gets the far clip of the Spotlight for texture projection.
  49276. */
  49277. get projectionTextureLightFar(): number;
  49278. /**
  49279. * Sets the far clip of the Spotlight for texture projection.
  49280. */
  49281. set projectionTextureLightFar(value: number);
  49282. protected _projectionTextureUpDirection: Vector3;
  49283. /**
  49284. * Gets the Up vector of the Spotlight for texture projection.
  49285. */
  49286. get projectionTextureUpDirection(): Vector3;
  49287. /**
  49288. * Sets the Up vector of the Spotlight for texture projection.
  49289. */
  49290. set projectionTextureUpDirection(value: Vector3);
  49291. private _projectionTexture;
  49292. /**
  49293. * Gets the projection texture of the light.
  49294. */
  49295. get projectionTexture(): Nullable<BaseTexture>;
  49296. /**
  49297. * Sets the projection texture of the light.
  49298. */
  49299. set projectionTexture(value: Nullable<BaseTexture>);
  49300. private _projectionTextureViewLightDirty;
  49301. private _projectionTextureProjectionLightDirty;
  49302. private _projectionTextureDirty;
  49303. private _projectionTextureViewTargetVector;
  49304. private _projectionTextureViewLightMatrix;
  49305. private _projectionTextureProjectionLightMatrix;
  49306. private _projectionTextureScalingMatrix;
  49307. /**
  49308. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49309. * It can cast shadows.
  49310. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49311. * @param name The light friendly name
  49312. * @param position The position of the spot light in the scene
  49313. * @param direction The direction of the light in the scene
  49314. * @param angle The cone angle of the light in Radians
  49315. * @param exponent The light decay speed with the distance from the emission spot
  49316. * @param scene The scene the lights belongs to
  49317. */
  49318. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49319. /**
  49320. * Returns the string "SpotLight".
  49321. * @returns the class name
  49322. */
  49323. getClassName(): string;
  49324. /**
  49325. * Returns the integer 2.
  49326. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49327. */
  49328. getTypeID(): number;
  49329. /**
  49330. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49331. */
  49332. protected _setDirection(value: Vector3): void;
  49333. /**
  49334. * Overrides the position setter to recompute the projection texture view light Matrix.
  49335. */
  49336. protected _setPosition(value: Vector3): void;
  49337. /**
  49338. * 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.
  49339. * Returns the SpotLight.
  49340. */
  49341. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49342. protected _computeProjectionTextureViewLightMatrix(): void;
  49343. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49344. /**
  49345. * Main function for light texture projection matrix computing.
  49346. */
  49347. protected _computeProjectionTextureMatrix(): void;
  49348. protected _buildUniformLayout(): void;
  49349. private _computeAngleValues;
  49350. /**
  49351. * Sets the passed Effect "effect" with the Light textures.
  49352. * @param effect The effect to update
  49353. * @param lightIndex The index of the light in the effect to update
  49354. * @returns The light
  49355. */
  49356. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49357. /**
  49358. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49359. * @param effect The effect to update
  49360. * @param lightIndex The index of the light in the effect to update
  49361. * @returns The spot light
  49362. */
  49363. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49364. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49365. /**
  49366. * Disposes the light and the associated resources.
  49367. */
  49368. dispose(): void;
  49369. /**
  49370. * Prepares the list of defines specific to the light type.
  49371. * @param defines the list of defines
  49372. * @param lightIndex defines the index of the light for the effect
  49373. */
  49374. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49375. }
  49376. }
  49377. declare module BABYLON {
  49378. /**
  49379. * Gizmo that enables viewing a light
  49380. */
  49381. export class LightGizmo extends Gizmo {
  49382. private _lightMesh;
  49383. private _material;
  49384. private _cachedPosition;
  49385. private _cachedForward;
  49386. private _attachedMeshParent;
  49387. /**
  49388. * Creates a LightGizmo
  49389. * @param gizmoLayer The utility layer the gizmo will be added to
  49390. */
  49391. constructor(gizmoLayer?: UtilityLayerRenderer);
  49392. private _light;
  49393. /**
  49394. * The light that the gizmo is attached to
  49395. */
  49396. set light(light: Nullable<Light>);
  49397. get light(): Nullable<Light>;
  49398. /**
  49399. * Gets the material used to render the light gizmo
  49400. */
  49401. get material(): StandardMaterial;
  49402. /**
  49403. * @hidden
  49404. * Updates the gizmo to match the attached mesh's position/rotation
  49405. */
  49406. protected _update(): void;
  49407. private static _Scale;
  49408. /**
  49409. * Creates the lines for a light mesh
  49410. */
  49411. private static _CreateLightLines;
  49412. /**
  49413. * Disposes of the light gizmo
  49414. */
  49415. dispose(): void;
  49416. private static _CreateHemisphericLightMesh;
  49417. private static _CreatePointLightMesh;
  49418. private static _CreateSpotLightMesh;
  49419. private static _CreateDirectionalLightMesh;
  49420. }
  49421. }
  49422. declare module BABYLON {
  49423. /** @hidden */
  49424. export var backgroundFragmentDeclaration: {
  49425. name: string;
  49426. shader: string;
  49427. };
  49428. }
  49429. declare module BABYLON {
  49430. /** @hidden */
  49431. export var backgroundUboDeclaration: {
  49432. name: string;
  49433. shader: string;
  49434. };
  49435. }
  49436. declare module BABYLON {
  49437. /** @hidden */
  49438. export var backgroundPixelShader: {
  49439. name: string;
  49440. shader: string;
  49441. };
  49442. }
  49443. declare module BABYLON {
  49444. /** @hidden */
  49445. export var backgroundVertexDeclaration: {
  49446. name: string;
  49447. shader: string;
  49448. };
  49449. }
  49450. declare module BABYLON {
  49451. /** @hidden */
  49452. export var backgroundVertexShader: {
  49453. name: string;
  49454. shader: string;
  49455. };
  49456. }
  49457. declare module BABYLON {
  49458. /**
  49459. * Background material used to create an efficient environement around your scene.
  49460. */
  49461. export class BackgroundMaterial extends PushMaterial {
  49462. /**
  49463. * Standard reflectance value at parallel view angle.
  49464. */
  49465. static StandardReflectance0: number;
  49466. /**
  49467. * Standard reflectance value at grazing angle.
  49468. */
  49469. static StandardReflectance90: number;
  49470. protected _primaryColor: Color3;
  49471. /**
  49472. * Key light Color (multiply against the environement texture)
  49473. */
  49474. primaryColor: Color3;
  49475. protected __perceptualColor: Nullable<Color3>;
  49476. /**
  49477. * Experimental Internal Use Only.
  49478. *
  49479. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49480. * This acts as a helper to set the primary color to a more "human friendly" value.
  49481. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49482. * output color as close as possible from the chosen value.
  49483. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49484. * part of lighting setup.)
  49485. */
  49486. get _perceptualColor(): Nullable<Color3>;
  49487. set _perceptualColor(value: Nullable<Color3>);
  49488. protected _primaryColorShadowLevel: float;
  49489. /**
  49490. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49491. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49492. */
  49493. get primaryColorShadowLevel(): float;
  49494. set primaryColorShadowLevel(value: float);
  49495. protected _primaryColorHighlightLevel: float;
  49496. /**
  49497. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49498. * The primary color is used at the level chosen to define what the white area would look.
  49499. */
  49500. get primaryColorHighlightLevel(): float;
  49501. set primaryColorHighlightLevel(value: float);
  49502. protected _reflectionTexture: Nullable<BaseTexture>;
  49503. /**
  49504. * Reflection Texture used in the material.
  49505. * Should be author in a specific way for the best result (refer to the documentation).
  49506. */
  49507. reflectionTexture: Nullable<BaseTexture>;
  49508. protected _reflectionBlur: float;
  49509. /**
  49510. * Reflection Texture level of blur.
  49511. *
  49512. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49513. * texture twice.
  49514. */
  49515. reflectionBlur: float;
  49516. protected _diffuseTexture: Nullable<BaseTexture>;
  49517. /**
  49518. * Diffuse Texture used in the material.
  49519. * Should be author in a specific way for the best result (refer to the documentation).
  49520. */
  49521. diffuseTexture: Nullable<BaseTexture>;
  49522. protected _shadowLights: Nullable<IShadowLight[]>;
  49523. /**
  49524. * Specify the list of lights casting shadow on the material.
  49525. * All scene shadow lights will be included if null.
  49526. */
  49527. shadowLights: Nullable<IShadowLight[]>;
  49528. protected _shadowLevel: float;
  49529. /**
  49530. * Helps adjusting the shadow to a softer level if required.
  49531. * 0 means black shadows and 1 means no shadows.
  49532. */
  49533. shadowLevel: float;
  49534. protected _sceneCenter: Vector3;
  49535. /**
  49536. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49537. * It is usually zero but might be interesting to modify according to your setup.
  49538. */
  49539. sceneCenter: Vector3;
  49540. protected _opacityFresnel: boolean;
  49541. /**
  49542. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49543. * This helps ensuring a nice transition when the camera goes under the ground.
  49544. */
  49545. opacityFresnel: boolean;
  49546. protected _reflectionFresnel: boolean;
  49547. /**
  49548. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49549. * This helps adding a mirror texture on the ground.
  49550. */
  49551. reflectionFresnel: boolean;
  49552. protected _reflectionFalloffDistance: number;
  49553. /**
  49554. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49555. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49556. */
  49557. reflectionFalloffDistance: number;
  49558. protected _reflectionAmount: number;
  49559. /**
  49560. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49561. */
  49562. reflectionAmount: number;
  49563. protected _reflectionReflectance0: number;
  49564. /**
  49565. * This specifies the weight of the reflection at grazing angle.
  49566. */
  49567. reflectionReflectance0: number;
  49568. protected _reflectionReflectance90: number;
  49569. /**
  49570. * This specifies the weight of the reflection at a perpendicular point of view.
  49571. */
  49572. reflectionReflectance90: number;
  49573. /**
  49574. * Sets the reflection reflectance fresnel values according to the default standard
  49575. * empirically know to work well :-)
  49576. */
  49577. set reflectionStandardFresnelWeight(value: number);
  49578. protected _useRGBColor: boolean;
  49579. /**
  49580. * Helps to directly use the maps channels instead of their level.
  49581. */
  49582. useRGBColor: boolean;
  49583. protected _enableNoise: boolean;
  49584. /**
  49585. * This helps reducing the banding effect that could occur on the background.
  49586. */
  49587. enableNoise: boolean;
  49588. /**
  49589. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49590. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49591. * Recommended to be keep at 1.0 except for special cases.
  49592. */
  49593. get fovMultiplier(): number;
  49594. set fovMultiplier(value: number);
  49595. private _fovMultiplier;
  49596. /**
  49597. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49598. */
  49599. useEquirectangularFOV: boolean;
  49600. private _maxSimultaneousLights;
  49601. /**
  49602. * Number of Simultaneous lights allowed on the material.
  49603. */
  49604. maxSimultaneousLights: int;
  49605. /**
  49606. * Default configuration related to image processing available in the Background Material.
  49607. */
  49608. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49609. /**
  49610. * Keep track of the image processing observer to allow dispose and replace.
  49611. */
  49612. private _imageProcessingObserver;
  49613. /**
  49614. * Attaches a new image processing configuration to the PBR Material.
  49615. * @param configuration (if null the scene configuration will be use)
  49616. */
  49617. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49618. /**
  49619. * Gets the image processing configuration used either in this material.
  49620. */
  49621. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49622. /**
  49623. * Sets the Default image processing configuration used either in the this material.
  49624. *
  49625. * If sets to null, the scene one is in use.
  49626. */
  49627. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49628. /**
  49629. * Gets wether the color curves effect is enabled.
  49630. */
  49631. get cameraColorCurvesEnabled(): boolean;
  49632. /**
  49633. * Sets wether the color curves effect is enabled.
  49634. */
  49635. set cameraColorCurvesEnabled(value: boolean);
  49636. /**
  49637. * Gets wether the color grading effect is enabled.
  49638. */
  49639. get cameraColorGradingEnabled(): boolean;
  49640. /**
  49641. * Gets wether the color grading effect is enabled.
  49642. */
  49643. set cameraColorGradingEnabled(value: boolean);
  49644. /**
  49645. * Gets wether tonemapping is enabled or not.
  49646. */
  49647. get cameraToneMappingEnabled(): boolean;
  49648. /**
  49649. * Sets wether tonemapping is enabled or not
  49650. */
  49651. set cameraToneMappingEnabled(value: boolean);
  49652. /**
  49653. * The camera exposure used on this material.
  49654. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49655. * This corresponds to a photographic exposure.
  49656. */
  49657. get cameraExposure(): float;
  49658. /**
  49659. * The camera exposure used on this material.
  49660. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49661. * This corresponds to a photographic exposure.
  49662. */
  49663. set cameraExposure(value: float);
  49664. /**
  49665. * Gets The camera contrast used on this material.
  49666. */
  49667. get cameraContrast(): float;
  49668. /**
  49669. * Sets The camera contrast used on this material.
  49670. */
  49671. set cameraContrast(value: float);
  49672. /**
  49673. * Gets the Color Grading 2D Lookup Texture.
  49674. */
  49675. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49676. /**
  49677. * Sets the Color Grading 2D Lookup Texture.
  49678. */
  49679. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49680. /**
  49681. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49682. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49683. * 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;
  49684. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49685. */
  49686. get cameraColorCurves(): Nullable<ColorCurves>;
  49687. /**
  49688. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49689. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49690. * 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;
  49691. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49692. */
  49693. set cameraColorCurves(value: Nullable<ColorCurves>);
  49694. /**
  49695. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49696. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49697. */
  49698. switchToBGR: boolean;
  49699. private _renderTargets;
  49700. private _reflectionControls;
  49701. private _white;
  49702. private _primaryShadowColor;
  49703. private _primaryHighlightColor;
  49704. /**
  49705. * Instantiates a Background Material in the given scene
  49706. * @param name The friendly name of the material
  49707. * @param scene The scene to add the material to
  49708. */
  49709. constructor(name: string, scene: Scene);
  49710. /**
  49711. * Gets a boolean indicating that current material needs to register RTT
  49712. */
  49713. get hasRenderTargetTextures(): boolean;
  49714. /**
  49715. * The entire material has been created in order to prevent overdraw.
  49716. * @returns false
  49717. */
  49718. needAlphaTesting(): boolean;
  49719. /**
  49720. * The entire material has been created in order to prevent overdraw.
  49721. * @returns true if blending is enable
  49722. */
  49723. needAlphaBlending(): boolean;
  49724. /**
  49725. * Checks wether the material is ready to be rendered for a given mesh.
  49726. * @param mesh The mesh to render
  49727. * @param subMesh The submesh to check against
  49728. * @param useInstances Specify wether or not the material is used with instances
  49729. * @returns true if all the dependencies are ready (Textures, Effects...)
  49730. */
  49731. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49732. /**
  49733. * Compute the primary color according to the chosen perceptual color.
  49734. */
  49735. private _computePrimaryColorFromPerceptualColor;
  49736. /**
  49737. * Compute the highlights and shadow colors according to their chosen levels.
  49738. */
  49739. private _computePrimaryColors;
  49740. /**
  49741. * Build the uniform buffer used in the material.
  49742. */
  49743. buildUniformLayout(): void;
  49744. /**
  49745. * Unbind the material.
  49746. */
  49747. unbind(): void;
  49748. /**
  49749. * Bind only the world matrix to the material.
  49750. * @param world The world matrix to bind.
  49751. */
  49752. bindOnlyWorldMatrix(world: Matrix): void;
  49753. /**
  49754. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49755. * @param world The world matrix to bind.
  49756. * @param subMesh The submesh to bind for.
  49757. */
  49758. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49759. /**
  49760. * Checks to see if a texture is used in the material.
  49761. * @param texture - Base texture to use.
  49762. * @returns - Boolean specifying if a texture is used in the material.
  49763. */
  49764. hasTexture(texture: BaseTexture): boolean;
  49765. /**
  49766. * Dispose the material.
  49767. * @param forceDisposeEffect Force disposal of the associated effect.
  49768. * @param forceDisposeTextures Force disposal of the associated textures.
  49769. */
  49770. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49771. /**
  49772. * Clones the material.
  49773. * @param name The cloned name.
  49774. * @returns The cloned material.
  49775. */
  49776. clone(name: string): BackgroundMaterial;
  49777. /**
  49778. * Serializes the current material to its JSON representation.
  49779. * @returns The JSON representation.
  49780. */
  49781. serialize(): any;
  49782. /**
  49783. * Gets the class name of the material
  49784. * @returns "BackgroundMaterial"
  49785. */
  49786. getClassName(): string;
  49787. /**
  49788. * Parse a JSON input to create back a background material.
  49789. * @param source The JSON data to parse
  49790. * @param scene The scene to create the parsed material in
  49791. * @param rootUrl The root url of the assets the material depends upon
  49792. * @returns the instantiated BackgroundMaterial.
  49793. */
  49794. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49795. }
  49796. }
  49797. declare module BABYLON {
  49798. /**
  49799. * Represents the different options available during the creation of
  49800. * a Environment helper.
  49801. *
  49802. * This can control the default ground, skybox and image processing setup of your scene.
  49803. */
  49804. export interface IEnvironmentHelperOptions {
  49805. /**
  49806. * Specifies whether or not to create a ground.
  49807. * True by default.
  49808. */
  49809. createGround: boolean;
  49810. /**
  49811. * Specifies the ground size.
  49812. * 15 by default.
  49813. */
  49814. groundSize: number;
  49815. /**
  49816. * The texture used on the ground for the main color.
  49817. * Comes from the BabylonJS CDN by default.
  49818. *
  49819. * Remarks: Can be either a texture or a url.
  49820. */
  49821. groundTexture: string | BaseTexture;
  49822. /**
  49823. * The color mixed in the ground texture by default.
  49824. * BabylonJS clearColor by default.
  49825. */
  49826. groundColor: Color3;
  49827. /**
  49828. * Specifies the ground opacity.
  49829. * 1 by default.
  49830. */
  49831. groundOpacity: number;
  49832. /**
  49833. * Enables the ground to receive shadows.
  49834. * True by default.
  49835. */
  49836. enableGroundShadow: boolean;
  49837. /**
  49838. * Helps preventing the shadow to be fully black on the ground.
  49839. * 0.5 by default.
  49840. */
  49841. groundShadowLevel: number;
  49842. /**
  49843. * Creates a mirror texture attach to the ground.
  49844. * false by default.
  49845. */
  49846. enableGroundMirror: boolean;
  49847. /**
  49848. * Specifies the ground mirror size ratio.
  49849. * 0.3 by default as the default kernel is 64.
  49850. */
  49851. groundMirrorSizeRatio: number;
  49852. /**
  49853. * Specifies the ground mirror blur kernel size.
  49854. * 64 by default.
  49855. */
  49856. groundMirrorBlurKernel: number;
  49857. /**
  49858. * Specifies the ground mirror visibility amount.
  49859. * 1 by default
  49860. */
  49861. groundMirrorAmount: number;
  49862. /**
  49863. * Specifies the ground mirror reflectance weight.
  49864. * This uses the standard weight of the background material to setup the fresnel effect
  49865. * of the mirror.
  49866. * 1 by default.
  49867. */
  49868. groundMirrorFresnelWeight: number;
  49869. /**
  49870. * Specifies the ground mirror Falloff distance.
  49871. * This can helps reducing the size of the reflection.
  49872. * 0 by Default.
  49873. */
  49874. groundMirrorFallOffDistance: number;
  49875. /**
  49876. * Specifies the ground mirror texture type.
  49877. * Unsigned Int by Default.
  49878. */
  49879. groundMirrorTextureType: number;
  49880. /**
  49881. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49882. * the shown objects.
  49883. */
  49884. groundYBias: number;
  49885. /**
  49886. * Specifies whether or not to create a skybox.
  49887. * True by default.
  49888. */
  49889. createSkybox: boolean;
  49890. /**
  49891. * Specifies the skybox size.
  49892. * 20 by default.
  49893. */
  49894. skyboxSize: number;
  49895. /**
  49896. * The texture used on the skybox for the main color.
  49897. * Comes from the BabylonJS CDN by default.
  49898. *
  49899. * Remarks: Can be either a texture or a url.
  49900. */
  49901. skyboxTexture: string | BaseTexture;
  49902. /**
  49903. * The color mixed in the skybox texture by default.
  49904. * BabylonJS clearColor by default.
  49905. */
  49906. skyboxColor: Color3;
  49907. /**
  49908. * The background rotation around the Y axis of the scene.
  49909. * This helps aligning the key lights of your scene with the background.
  49910. * 0 by default.
  49911. */
  49912. backgroundYRotation: number;
  49913. /**
  49914. * Compute automatically the size of the elements to best fit with the scene.
  49915. */
  49916. sizeAuto: boolean;
  49917. /**
  49918. * Default position of the rootMesh if autoSize is not true.
  49919. */
  49920. rootPosition: Vector3;
  49921. /**
  49922. * Sets up the image processing in the scene.
  49923. * true by default.
  49924. */
  49925. setupImageProcessing: boolean;
  49926. /**
  49927. * The texture used as your environment texture in the scene.
  49928. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49929. *
  49930. * Remarks: Can be either a texture or a url.
  49931. */
  49932. environmentTexture: string | BaseTexture;
  49933. /**
  49934. * The value of the exposure to apply to the scene.
  49935. * 0.6 by default if setupImageProcessing is true.
  49936. */
  49937. cameraExposure: number;
  49938. /**
  49939. * The value of the contrast to apply to the scene.
  49940. * 1.6 by default if setupImageProcessing is true.
  49941. */
  49942. cameraContrast: number;
  49943. /**
  49944. * Specifies whether or not tonemapping should be enabled in the scene.
  49945. * true by default if setupImageProcessing is true.
  49946. */
  49947. toneMappingEnabled: boolean;
  49948. }
  49949. /**
  49950. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49951. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49952. * It also helps with the default setup of your imageProcessing configuration.
  49953. */
  49954. export class EnvironmentHelper {
  49955. /**
  49956. * Default ground texture URL.
  49957. */
  49958. private static _groundTextureCDNUrl;
  49959. /**
  49960. * Default skybox texture URL.
  49961. */
  49962. private static _skyboxTextureCDNUrl;
  49963. /**
  49964. * Default environment texture URL.
  49965. */
  49966. private static _environmentTextureCDNUrl;
  49967. /**
  49968. * Creates the default options for the helper.
  49969. */
  49970. private static _getDefaultOptions;
  49971. private _rootMesh;
  49972. /**
  49973. * Gets the root mesh created by the helper.
  49974. */
  49975. get rootMesh(): Mesh;
  49976. private _skybox;
  49977. /**
  49978. * Gets the skybox created by the helper.
  49979. */
  49980. get skybox(): Nullable<Mesh>;
  49981. private _skyboxTexture;
  49982. /**
  49983. * Gets the skybox texture created by the helper.
  49984. */
  49985. get skyboxTexture(): Nullable<BaseTexture>;
  49986. private _skyboxMaterial;
  49987. /**
  49988. * Gets the skybox material created by the helper.
  49989. */
  49990. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49991. private _ground;
  49992. /**
  49993. * Gets the ground mesh created by the helper.
  49994. */
  49995. get ground(): Nullable<Mesh>;
  49996. private _groundTexture;
  49997. /**
  49998. * Gets the ground texture created by the helper.
  49999. */
  50000. get groundTexture(): Nullable<BaseTexture>;
  50001. private _groundMirror;
  50002. /**
  50003. * Gets the ground mirror created by the helper.
  50004. */
  50005. get groundMirror(): Nullable<MirrorTexture>;
  50006. /**
  50007. * Gets the ground mirror render list to helps pushing the meshes
  50008. * you wish in the ground reflection.
  50009. */
  50010. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50011. private _groundMaterial;
  50012. /**
  50013. * Gets the ground material created by the helper.
  50014. */
  50015. get groundMaterial(): Nullable<BackgroundMaterial>;
  50016. /**
  50017. * Stores the creation options.
  50018. */
  50019. private readonly _scene;
  50020. private _options;
  50021. /**
  50022. * This observable will be notified with any error during the creation of the environment,
  50023. * mainly texture creation errors.
  50024. */
  50025. onErrorObservable: Observable<{
  50026. message?: string;
  50027. exception?: any;
  50028. }>;
  50029. /**
  50030. * constructor
  50031. * @param options Defines the options we want to customize the helper
  50032. * @param scene The scene to add the material to
  50033. */
  50034. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50035. /**
  50036. * Updates the background according to the new options
  50037. * @param options
  50038. */
  50039. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50040. /**
  50041. * Sets the primary color of all the available elements.
  50042. * @param color the main color to affect to the ground and the background
  50043. */
  50044. setMainColor(color: Color3): void;
  50045. /**
  50046. * Setup the image processing according to the specified options.
  50047. */
  50048. private _setupImageProcessing;
  50049. /**
  50050. * Setup the environment texture according to the specified options.
  50051. */
  50052. private _setupEnvironmentTexture;
  50053. /**
  50054. * Setup the background according to the specified options.
  50055. */
  50056. private _setupBackground;
  50057. /**
  50058. * Get the scene sizes according to the setup.
  50059. */
  50060. private _getSceneSize;
  50061. /**
  50062. * Setup the ground according to the specified options.
  50063. */
  50064. private _setupGround;
  50065. /**
  50066. * Setup the ground material according to the specified options.
  50067. */
  50068. private _setupGroundMaterial;
  50069. /**
  50070. * Setup the ground diffuse texture according to the specified options.
  50071. */
  50072. private _setupGroundDiffuseTexture;
  50073. /**
  50074. * Setup the ground mirror texture according to the specified options.
  50075. */
  50076. private _setupGroundMirrorTexture;
  50077. /**
  50078. * Setup the ground to receive the mirror texture.
  50079. */
  50080. private _setupMirrorInGroundMaterial;
  50081. /**
  50082. * Setup the skybox according to the specified options.
  50083. */
  50084. private _setupSkybox;
  50085. /**
  50086. * Setup the skybox material according to the specified options.
  50087. */
  50088. private _setupSkyboxMaterial;
  50089. /**
  50090. * Setup the skybox reflection texture according to the specified options.
  50091. */
  50092. private _setupSkyboxReflectionTexture;
  50093. private _errorHandler;
  50094. /**
  50095. * Dispose all the elements created by the Helper.
  50096. */
  50097. dispose(): void;
  50098. }
  50099. }
  50100. declare module BABYLON {
  50101. /**
  50102. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50103. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50104. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50105. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50106. */
  50107. export class PhotoDome extends TransformNode {
  50108. /**
  50109. * Define the image as a Monoscopic panoramic 360 image.
  50110. */
  50111. static readonly MODE_MONOSCOPIC: number;
  50112. /**
  50113. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50114. */
  50115. static readonly MODE_TOPBOTTOM: number;
  50116. /**
  50117. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50118. */
  50119. static readonly MODE_SIDEBYSIDE: number;
  50120. private _useDirectMapping;
  50121. /**
  50122. * The texture being displayed on the sphere
  50123. */
  50124. protected _photoTexture: Texture;
  50125. /**
  50126. * Gets or sets the texture being displayed on the sphere
  50127. */
  50128. get photoTexture(): Texture;
  50129. set photoTexture(value: Texture);
  50130. /**
  50131. * Observable raised when an error occured while loading the 360 image
  50132. */
  50133. onLoadErrorObservable: Observable<string>;
  50134. /**
  50135. * The skybox material
  50136. */
  50137. protected _material: BackgroundMaterial;
  50138. /**
  50139. * The surface used for the skybox
  50140. */
  50141. protected _mesh: Mesh;
  50142. /**
  50143. * Gets the mesh used for the skybox.
  50144. */
  50145. get mesh(): Mesh;
  50146. /**
  50147. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50148. * Also see the options.resolution property.
  50149. */
  50150. get fovMultiplier(): number;
  50151. set fovMultiplier(value: number);
  50152. private _imageMode;
  50153. /**
  50154. * Gets or set the current video mode for the video. It can be:
  50155. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50156. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50157. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50158. */
  50159. get imageMode(): number;
  50160. set imageMode(value: number);
  50161. /**
  50162. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50163. * @param name Element's name, child elements will append suffixes for their own names.
  50164. * @param urlsOfPhoto defines the url of the photo to display
  50165. * @param options defines an object containing optional or exposed sub element properties
  50166. * @param onError defines a callback called when an error occured while loading the texture
  50167. */
  50168. constructor(name: string, urlOfPhoto: string, options: {
  50169. resolution?: number;
  50170. size?: number;
  50171. useDirectMapping?: boolean;
  50172. faceForward?: boolean;
  50173. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50174. private _onBeforeCameraRenderObserver;
  50175. private _changeImageMode;
  50176. /**
  50177. * Releases resources associated with this node.
  50178. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50179. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50180. */
  50181. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50182. }
  50183. }
  50184. declare module BABYLON {
  50185. /**
  50186. * Class used to host RGBD texture specific utilities
  50187. */
  50188. export class RGBDTextureTools {
  50189. /**
  50190. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50191. * @param texture the texture to expand.
  50192. */
  50193. static ExpandRGBDTexture(texture: Texture): void;
  50194. }
  50195. }
  50196. declare module BABYLON {
  50197. /**
  50198. * Class used to host texture specific utilities
  50199. */
  50200. export class BRDFTextureTools {
  50201. /**
  50202. * Prevents texture cache collision
  50203. */
  50204. private static _instanceNumber;
  50205. /**
  50206. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50207. * @param scene defines the hosting scene
  50208. * @returns the environment BRDF texture
  50209. */
  50210. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50211. private static _environmentBRDFBase64Texture;
  50212. }
  50213. }
  50214. declare module BABYLON {
  50215. /**
  50216. * @hidden
  50217. */
  50218. export interface IMaterialClearCoatDefines {
  50219. CLEARCOAT: boolean;
  50220. CLEARCOAT_DEFAULTIOR: boolean;
  50221. CLEARCOAT_TEXTURE: boolean;
  50222. CLEARCOAT_TEXTUREDIRECTUV: number;
  50223. CLEARCOAT_BUMP: boolean;
  50224. CLEARCOAT_BUMPDIRECTUV: number;
  50225. CLEARCOAT_TINT: boolean;
  50226. CLEARCOAT_TINT_TEXTURE: boolean;
  50227. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50228. /** @hidden */
  50229. _areTexturesDirty: boolean;
  50230. }
  50231. /**
  50232. * Define the code related to the clear coat parameters of the pbr material.
  50233. */
  50234. export class PBRClearCoatConfiguration {
  50235. /**
  50236. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50237. * The default fits with a polyurethane material.
  50238. */
  50239. private static readonly _DefaultIndexOfRefraction;
  50240. private _isEnabled;
  50241. /**
  50242. * Defines if the clear coat is enabled in the material.
  50243. */
  50244. isEnabled: boolean;
  50245. /**
  50246. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50247. */
  50248. intensity: number;
  50249. /**
  50250. * Defines the clear coat layer roughness.
  50251. */
  50252. roughness: number;
  50253. private _indexOfRefraction;
  50254. /**
  50255. * Defines the index of refraction of the clear coat.
  50256. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50257. * The default fits with a polyurethane material.
  50258. * Changing the default value is more performance intensive.
  50259. */
  50260. indexOfRefraction: number;
  50261. private _texture;
  50262. /**
  50263. * Stores the clear coat values in a texture.
  50264. */
  50265. texture: Nullable<BaseTexture>;
  50266. private _bumpTexture;
  50267. /**
  50268. * Define the clear coat specific bump texture.
  50269. */
  50270. bumpTexture: Nullable<BaseTexture>;
  50271. private _isTintEnabled;
  50272. /**
  50273. * Defines if the clear coat tint is enabled in the material.
  50274. */
  50275. isTintEnabled: boolean;
  50276. /**
  50277. * Defines the clear coat tint of the material.
  50278. * This is only use if tint is enabled
  50279. */
  50280. tintColor: Color3;
  50281. /**
  50282. * Defines the distance at which the tint color should be found in the
  50283. * clear coat media.
  50284. * This is only use if tint is enabled
  50285. */
  50286. tintColorAtDistance: number;
  50287. /**
  50288. * Defines the clear coat layer thickness.
  50289. * This is only use if tint is enabled
  50290. */
  50291. tintThickness: number;
  50292. private _tintTexture;
  50293. /**
  50294. * Stores the clear tint values in a texture.
  50295. * rgb is tint
  50296. * a is a thickness factor
  50297. */
  50298. tintTexture: Nullable<BaseTexture>;
  50299. /** @hidden */
  50300. private _internalMarkAllSubMeshesAsTexturesDirty;
  50301. /** @hidden */
  50302. _markAllSubMeshesAsTexturesDirty(): void;
  50303. /**
  50304. * Instantiate a new istance of clear coat configuration.
  50305. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50306. */
  50307. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50308. /**
  50309. * Gets wehter the submesh is ready to be used or not.
  50310. * @param defines the list of "defines" to update.
  50311. * @param scene defines the scene the material belongs to.
  50312. * @param engine defines the engine the material belongs to.
  50313. * @param disableBumpMap defines wether the material disables bump or not.
  50314. * @returns - boolean indicating that the submesh is ready or not.
  50315. */
  50316. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50317. /**
  50318. * Checks to see if a texture is used in the material.
  50319. * @param defines the list of "defines" to update.
  50320. * @param scene defines the scene to the material belongs to.
  50321. */
  50322. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50323. /**
  50324. * Binds the material data.
  50325. * @param uniformBuffer defines the Uniform buffer to fill in.
  50326. * @param scene defines the scene the material belongs to.
  50327. * @param engine defines the engine the material belongs to.
  50328. * @param disableBumpMap defines wether the material disables bump or not.
  50329. * @param isFrozen defines wether the material is frozen or not.
  50330. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50331. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50332. */
  50333. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50334. /**
  50335. * Checks to see if a texture is used in the material.
  50336. * @param texture - Base texture to use.
  50337. * @returns - Boolean specifying if a texture is used in the material.
  50338. */
  50339. hasTexture(texture: BaseTexture): boolean;
  50340. /**
  50341. * Returns an array of the actively used textures.
  50342. * @param activeTextures Array of BaseTextures
  50343. */
  50344. getActiveTextures(activeTextures: BaseTexture[]): void;
  50345. /**
  50346. * Returns the animatable textures.
  50347. * @param animatables Array of animatable textures.
  50348. */
  50349. getAnimatables(animatables: IAnimatable[]): void;
  50350. /**
  50351. * Disposes the resources of the material.
  50352. * @param forceDisposeTextures - Forces the disposal of all textures.
  50353. */
  50354. dispose(forceDisposeTextures?: boolean): void;
  50355. /**
  50356. * Get the current class name of the texture useful for serialization or dynamic coding.
  50357. * @returns "PBRClearCoatConfiguration"
  50358. */
  50359. getClassName(): string;
  50360. /**
  50361. * Add fallbacks to the effect fallbacks list.
  50362. * @param defines defines the Base texture to use.
  50363. * @param fallbacks defines the current fallback list.
  50364. * @param currentRank defines the current fallback rank.
  50365. * @returns the new fallback rank.
  50366. */
  50367. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50368. /**
  50369. * Add the required uniforms to the current list.
  50370. * @param uniforms defines the current uniform list.
  50371. */
  50372. static AddUniforms(uniforms: string[]): void;
  50373. /**
  50374. * Add the required samplers to the current list.
  50375. * @param samplers defines the current sampler list.
  50376. */
  50377. static AddSamplers(samplers: string[]): void;
  50378. /**
  50379. * Add the required uniforms to the current buffer.
  50380. * @param uniformBuffer defines the current uniform buffer.
  50381. */
  50382. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50383. /**
  50384. * Makes a duplicate of the current configuration into another one.
  50385. * @param clearCoatConfiguration define the config where to copy the info
  50386. */
  50387. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50388. /**
  50389. * Serializes this clear coat configuration.
  50390. * @returns - An object with the serialized config.
  50391. */
  50392. serialize(): any;
  50393. /**
  50394. * Parses a anisotropy Configuration from a serialized object.
  50395. * @param source - Serialized object.
  50396. * @param scene Defines the scene we are parsing for
  50397. * @param rootUrl Defines the rootUrl to load from
  50398. */
  50399. parse(source: any, scene: Scene, rootUrl: string): void;
  50400. }
  50401. }
  50402. declare module BABYLON {
  50403. /**
  50404. * @hidden
  50405. */
  50406. export interface IMaterialAnisotropicDefines {
  50407. ANISOTROPIC: boolean;
  50408. ANISOTROPIC_TEXTURE: boolean;
  50409. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50410. MAINUV1: boolean;
  50411. _areTexturesDirty: boolean;
  50412. _needUVs: boolean;
  50413. }
  50414. /**
  50415. * Define the code related to the anisotropic parameters of the pbr material.
  50416. */
  50417. export class PBRAnisotropicConfiguration {
  50418. private _isEnabled;
  50419. /**
  50420. * Defines if the anisotropy is enabled in the material.
  50421. */
  50422. isEnabled: boolean;
  50423. /**
  50424. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50425. */
  50426. intensity: number;
  50427. /**
  50428. * Defines if the effect is along the tangents, bitangents or in between.
  50429. * By default, the effect is "strectching" the highlights along the tangents.
  50430. */
  50431. direction: Vector2;
  50432. private _texture;
  50433. /**
  50434. * Stores the anisotropy values in a texture.
  50435. * rg is direction (like normal from -1 to 1)
  50436. * b is a intensity
  50437. */
  50438. texture: Nullable<BaseTexture>;
  50439. /** @hidden */
  50440. private _internalMarkAllSubMeshesAsTexturesDirty;
  50441. /** @hidden */
  50442. _markAllSubMeshesAsTexturesDirty(): void;
  50443. /**
  50444. * Instantiate a new istance of anisotropy configuration.
  50445. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50446. */
  50447. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50448. /**
  50449. * Specifies that the submesh is ready to be used.
  50450. * @param defines the list of "defines" to update.
  50451. * @param scene defines the scene the material belongs to.
  50452. * @returns - boolean indicating that the submesh is ready or not.
  50453. */
  50454. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50455. /**
  50456. * Checks to see if a texture is used in the material.
  50457. * @param defines the list of "defines" to update.
  50458. * @param mesh the mesh we are preparing the defines for.
  50459. * @param scene defines the scene the material belongs to.
  50460. */
  50461. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50462. /**
  50463. * Binds the material data.
  50464. * @param uniformBuffer defines the Uniform buffer to fill in.
  50465. * @param scene defines the scene the material belongs to.
  50466. * @param isFrozen defines wether the material is frozen or not.
  50467. */
  50468. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50469. /**
  50470. * Checks to see if a texture is used in the material.
  50471. * @param texture - Base texture to use.
  50472. * @returns - Boolean specifying if a texture is used in the material.
  50473. */
  50474. hasTexture(texture: BaseTexture): boolean;
  50475. /**
  50476. * Returns an array of the actively used textures.
  50477. * @param activeTextures Array of BaseTextures
  50478. */
  50479. getActiveTextures(activeTextures: BaseTexture[]): void;
  50480. /**
  50481. * Returns the animatable textures.
  50482. * @param animatables Array of animatable textures.
  50483. */
  50484. getAnimatables(animatables: IAnimatable[]): void;
  50485. /**
  50486. * Disposes the resources of the material.
  50487. * @param forceDisposeTextures - Forces the disposal of all textures.
  50488. */
  50489. dispose(forceDisposeTextures?: boolean): void;
  50490. /**
  50491. * Get the current class name of the texture useful for serialization or dynamic coding.
  50492. * @returns "PBRAnisotropicConfiguration"
  50493. */
  50494. getClassName(): string;
  50495. /**
  50496. * Add fallbacks to the effect fallbacks list.
  50497. * @param defines defines the Base texture to use.
  50498. * @param fallbacks defines the current fallback list.
  50499. * @param currentRank defines the current fallback rank.
  50500. * @returns the new fallback rank.
  50501. */
  50502. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50503. /**
  50504. * Add the required uniforms to the current list.
  50505. * @param uniforms defines the current uniform list.
  50506. */
  50507. static AddUniforms(uniforms: string[]): void;
  50508. /**
  50509. * Add the required uniforms to the current buffer.
  50510. * @param uniformBuffer defines the current uniform buffer.
  50511. */
  50512. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50513. /**
  50514. * Add the required samplers to the current list.
  50515. * @param samplers defines the current sampler list.
  50516. */
  50517. static AddSamplers(samplers: string[]): void;
  50518. /**
  50519. * Makes a duplicate of the current configuration into another one.
  50520. * @param anisotropicConfiguration define the config where to copy the info
  50521. */
  50522. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50523. /**
  50524. * Serializes this anisotropy configuration.
  50525. * @returns - An object with the serialized config.
  50526. */
  50527. serialize(): any;
  50528. /**
  50529. * Parses a anisotropy Configuration from a serialized object.
  50530. * @param source - Serialized object.
  50531. * @param scene Defines the scene we are parsing for
  50532. * @param rootUrl Defines the rootUrl to load from
  50533. */
  50534. parse(source: any, scene: Scene, rootUrl: string): void;
  50535. }
  50536. }
  50537. declare module BABYLON {
  50538. /**
  50539. * @hidden
  50540. */
  50541. export interface IMaterialBRDFDefines {
  50542. BRDF_V_HEIGHT_CORRELATED: boolean;
  50543. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50544. SPHERICAL_HARMONICS: boolean;
  50545. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50546. /** @hidden */
  50547. _areMiscDirty: boolean;
  50548. }
  50549. /**
  50550. * Define the code related to the BRDF parameters of the pbr material.
  50551. */
  50552. export class PBRBRDFConfiguration {
  50553. /**
  50554. * Default value used for the energy conservation.
  50555. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50556. */
  50557. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50558. /**
  50559. * Default value used for the Smith Visibility Height Correlated mode.
  50560. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50561. */
  50562. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50563. /**
  50564. * Default value used for the IBL diffuse part.
  50565. * This can help switching back to the polynomials mode globally which is a tiny bit
  50566. * less GPU intensive at the drawback of a lower quality.
  50567. */
  50568. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50569. /**
  50570. * Default value used for activating energy conservation for the specular workflow.
  50571. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50572. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50573. */
  50574. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50575. private _useEnergyConservation;
  50576. /**
  50577. * Defines if the material uses energy conservation.
  50578. */
  50579. useEnergyConservation: boolean;
  50580. private _useSmithVisibilityHeightCorrelated;
  50581. /**
  50582. * LEGACY Mode set to false
  50583. * Defines if the material uses height smith correlated visibility term.
  50584. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50585. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50586. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50587. * Not relying on height correlated will also disable energy conservation.
  50588. */
  50589. useSmithVisibilityHeightCorrelated: boolean;
  50590. private _useSphericalHarmonics;
  50591. /**
  50592. * LEGACY Mode set to false
  50593. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50594. * diffuse part of the IBL.
  50595. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50596. * to the ground truth.
  50597. */
  50598. useSphericalHarmonics: boolean;
  50599. private _useSpecularGlossinessInputEnergyConservation;
  50600. /**
  50601. * Defines if the material uses energy conservation, when the specular workflow is active.
  50602. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50603. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50604. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50605. */
  50606. useSpecularGlossinessInputEnergyConservation: boolean;
  50607. /** @hidden */
  50608. private _internalMarkAllSubMeshesAsMiscDirty;
  50609. /** @hidden */
  50610. _markAllSubMeshesAsMiscDirty(): void;
  50611. /**
  50612. * Instantiate a new istance of clear coat configuration.
  50613. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50614. */
  50615. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50616. /**
  50617. * Checks to see if a texture is used in the material.
  50618. * @param defines the list of "defines" to update.
  50619. */
  50620. prepareDefines(defines: IMaterialBRDFDefines): void;
  50621. /**
  50622. * Get the current class name of the texture useful for serialization or dynamic coding.
  50623. * @returns "PBRClearCoatConfiguration"
  50624. */
  50625. getClassName(): string;
  50626. /**
  50627. * Makes a duplicate of the current configuration into another one.
  50628. * @param brdfConfiguration define the config where to copy the info
  50629. */
  50630. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50631. /**
  50632. * Serializes this BRDF configuration.
  50633. * @returns - An object with the serialized config.
  50634. */
  50635. serialize(): any;
  50636. /**
  50637. * Parses a anisotropy Configuration from a serialized object.
  50638. * @param source - Serialized object.
  50639. * @param scene Defines the scene we are parsing for
  50640. * @param rootUrl Defines the rootUrl to load from
  50641. */
  50642. parse(source: any, scene: Scene, rootUrl: string): void;
  50643. }
  50644. }
  50645. declare module BABYLON {
  50646. /**
  50647. * @hidden
  50648. */
  50649. export interface IMaterialSheenDefines {
  50650. SHEEN: boolean;
  50651. SHEEN_TEXTURE: boolean;
  50652. SHEEN_TEXTUREDIRECTUV: number;
  50653. SHEEN_LINKWITHALBEDO: boolean;
  50654. SHEEN_ROUGHNESS: boolean;
  50655. SHEEN_ALBEDOSCALING: boolean;
  50656. /** @hidden */
  50657. _areTexturesDirty: boolean;
  50658. }
  50659. /**
  50660. * Define the code related to the Sheen parameters of the pbr material.
  50661. */
  50662. export class PBRSheenConfiguration {
  50663. private _isEnabled;
  50664. /**
  50665. * Defines if the material uses sheen.
  50666. */
  50667. isEnabled: boolean;
  50668. private _linkSheenWithAlbedo;
  50669. /**
  50670. * Defines if the sheen is linked to the sheen color.
  50671. */
  50672. linkSheenWithAlbedo: boolean;
  50673. /**
  50674. * Defines the sheen intensity.
  50675. */
  50676. intensity: number;
  50677. /**
  50678. * Defines the sheen color.
  50679. */
  50680. color: Color3;
  50681. private _texture;
  50682. /**
  50683. * Stores the sheen tint values in a texture.
  50684. * rgb is tint
  50685. * a is a intensity
  50686. */
  50687. texture: Nullable<BaseTexture>;
  50688. private _roughness;
  50689. /**
  50690. * Defines the sheen roughness.
  50691. * It is not taken into account if linkSheenWithAlbedo is true.
  50692. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50693. */
  50694. roughness: Nullable<number>;
  50695. private _albedoScaling;
  50696. /**
  50697. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50698. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50699. * making it easier to setup and tweak the effect
  50700. */
  50701. albedoScaling: boolean;
  50702. /** @hidden */
  50703. private _internalMarkAllSubMeshesAsTexturesDirty;
  50704. /** @hidden */
  50705. _markAllSubMeshesAsTexturesDirty(): void;
  50706. /**
  50707. * Instantiate a new istance of clear coat configuration.
  50708. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50709. */
  50710. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50711. /**
  50712. * Specifies that the submesh is ready to be used.
  50713. * @param defines the list of "defines" to update.
  50714. * @param scene defines the scene the material belongs to.
  50715. * @returns - boolean indicating that the submesh is ready or not.
  50716. */
  50717. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50718. /**
  50719. * Checks to see if a texture is used in the material.
  50720. * @param defines the list of "defines" to update.
  50721. * @param scene defines the scene the material belongs to.
  50722. */
  50723. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50724. /**
  50725. * Binds the material data.
  50726. * @param uniformBuffer defines the Uniform buffer to fill in.
  50727. * @param scene defines the scene the material belongs to.
  50728. * @param isFrozen defines wether the material is frozen or not.
  50729. */
  50730. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50731. /**
  50732. * Checks to see if a texture is used in the material.
  50733. * @param texture - Base texture to use.
  50734. * @returns - Boolean specifying if a texture is used in the material.
  50735. */
  50736. hasTexture(texture: BaseTexture): boolean;
  50737. /**
  50738. * Returns an array of the actively used textures.
  50739. * @param activeTextures Array of BaseTextures
  50740. */
  50741. getActiveTextures(activeTextures: BaseTexture[]): void;
  50742. /**
  50743. * Returns the animatable textures.
  50744. * @param animatables Array of animatable textures.
  50745. */
  50746. getAnimatables(animatables: IAnimatable[]): void;
  50747. /**
  50748. * Disposes the resources of the material.
  50749. * @param forceDisposeTextures - Forces the disposal of all textures.
  50750. */
  50751. dispose(forceDisposeTextures?: boolean): void;
  50752. /**
  50753. * Get the current class name of the texture useful for serialization or dynamic coding.
  50754. * @returns "PBRSheenConfiguration"
  50755. */
  50756. getClassName(): string;
  50757. /**
  50758. * Add fallbacks to the effect fallbacks list.
  50759. * @param defines defines the Base texture to use.
  50760. * @param fallbacks defines the current fallback list.
  50761. * @param currentRank defines the current fallback rank.
  50762. * @returns the new fallback rank.
  50763. */
  50764. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50765. /**
  50766. * Add the required uniforms to the current list.
  50767. * @param uniforms defines the current uniform list.
  50768. */
  50769. static AddUniforms(uniforms: string[]): void;
  50770. /**
  50771. * Add the required uniforms to the current buffer.
  50772. * @param uniformBuffer defines the current uniform buffer.
  50773. */
  50774. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50775. /**
  50776. * Add the required samplers to the current list.
  50777. * @param samplers defines the current sampler list.
  50778. */
  50779. static AddSamplers(samplers: string[]): void;
  50780. /**
  50781. * Makes a duplicate of the current configuration into another one.
  50782. * @param sheenConfiguration define the config where to copy the info
  50783. */
  50784. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50785. /**
  50786. * Serializes this BRDF configuration.
  50787. * @returns - An object with the serialized config.
  50788. */
  50789. serialize(): any;
  50790. /**
  50791. * Parses a anisotropy Configuration from a serialized object.
  50792. * @param source - Serialized object.
  50793. * @param scene Defines the scene we are parsing for
  50794. * @param rootUrl Defines the rootUrl to load from
  50795. */
  50796. parse(source: any, scene: Scene, rootUrl: string): void;
  50797. }
  50798. }
  50799. declare module BABYLON {
  50800. /**
  50801. * @hidden
  50802. */
  50803. export interface IMaterialSubSurfaceDefines {
  50804. SUBSURFACE: boolean;
  50805. SS_REFRACTION: boolean;
  50806. SS_TRANSLUCENCY: boolean;
  50807. SS_SCATERRING: boolean;
  50808. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50809. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50810. SS_REFRACTIONMAP_3D: boolean;
  50811. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50812. SS_LODINREFRACTIONALPHA: boolean;
  50813. SS_GAMMAREFRACTION: boolean;
  50814. SS_RGBDREFRACTION: boolean;
  50815. SS_LINEARSPECULARREFRACTION: boolean;
  50816. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50817. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50818. /** @hidden */
  50819. _areTexturesDirty: boolean;
  50820. }
  50821. /**
  50822. * Define the code related to the sub surface parameters of the pbr material.
  50823. */
  50824. export class PBRSubSurfaceConfiguration {
  50825. private _isRefractionEnabled;
  50826. /**
  50827. * Defines if the refraction is enabled in the material.
  50828. */
  50829. isRefractionEnabled: boolean;
  50830. private _isTranslucencyEnabled;
  50831. /**
  50832. * Defines if the translucency is enabled in the material.
  50833. */
  50834. isTranslucencyEnabled: boolean;
  50835. private _isScatteringEnabled;
  50836. /**
  50837. * Defines the refraction intensity of the material.
  50838. * The refraction when enabled replaces the Diffuse part of the material.
  50839. * The intensity helps transitionning between diffuse and refraction.
  50840. */
  50841. refractionIntensity: number;
  50842. /**
  50843. * Defines the translucency intensity of the material.
  50844. * When translucency has been enabled, this defines how much of the "translucency"
  50845. * is addded to the diffuse part of the material.
  50846. */
  50847. translucencyIntensity: number;
  50848. /**
  50849. * Defines the scattering intensity of the material.
  50850. * When scattering has been enabled, this defines how much of the "scattered light"
  50851. * is addded to the diffuse part of the material.
  50852. */
  50853. scatteringIntensity: number;
  50854. private _thicknessTexture;
  50855. /**
  50856. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50857. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50858. * 0 would mean minimumThickness
  50859. * 1 would mean maximumThickness
  50860. * The other channels might be use as a mask to vary the different effects intensity.
  50861. */
  50862. thicknessTexture: Nullable<BaseTexture>;
  50863. private _refractionTexture;
  50864. /**
  50865. * Defines the texture to use for refraction.
  50866. */
  50867. refractionTexture: Nullable<BaseTexture>;
  50868. private _indexOfRefraction;
  50869. /**
  50870. * Defines the index of refraction used in the material.
  50871. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50872. */
  50873. indexOfRefraction: number;
  50874. private _invertRefractionY;
  50875. /**
  50876. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50877. */
  50878. invertRefractionY: boolean;
  50879. private _linkRefractionWithTransparency;
  50880. /**
  50881. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50882. * Materials half opaque for instance using refraction could benefit from this control.
  50883. */
  50884. linkRefractionWithTransparency: boolean;
  50885. /**
  50886. * Defines the minimum thickness stored in the thickness map.
  50887. * If no thickness map is defined, this value will be used to simulate thickness.
  50888. */
  50889. minimumThickness: number;
  50890. /**
  50891. * Defines the maximum thickness stored in the thickness map.
  50892. */
  50893. maximumThickness: number;
  50894. /**
  50895. * Defines the volume tint of the material.
  50896. * This is used for both translucency and scattering.
  50897. */
  50898. tintColor: Color3;
  50899. /**
  50900. * Defines the distance at which the tint color should be found in the media.
  50901. * This is used for refraction only.
  50902. */
  50903. tintColorAtDistance: number;
  50904. /**
  50905. * Defines how far each channel transmit through the media.
  50906. * It is defined as a color to simplify it selection.
  50907. */
  50908. diffusionDistance: Color3;
  50909. private _useMaskFromThicknessTexture;
  50910. /**
  50911. * Stores the intensity of the different subsurface effects in the thickness texture.
  50912. * * the green channel is the translucency intensity.
  50913. * * the blue channel is the scattering intensity.
  50914. * * the alpha channel is the refraction intensity.
  50915. */
  50916. useMaskFromThicknessTexture: boolean;
  50917. /** @hidden */
  50918. private _internalMarkAllSubMeshesAsTexturesDirty;
  50919. /** @hidden */
  50920. _markAllSubMeshesAsTexturesDirty(): void;
  50921. /**
  50922. * Instantiate a new istance of sub surface configuration.
  50923. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50924. */
  50925. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50926. /**
  50927. * Gets wehter the submesh is ready to be used or not.
  50928. * @param defines the list of "defines" to update.
  50929. * @param scene defines the scene the material belongs to.
  50930. * @returns - boolean indicating that the submesh is ready or not.
  50931. */
  50932. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50933. /**
  50934. * Checks to see if a texture is used in the material.
  50935. * @param defines the list of "defines" to update.
  50936. * @param scene defines the scene to the material belongs to.
  50937. */
  50938. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50939. /**
  50940. * Binds the material data.
  50941. * @param uniformBuffer defines the Uniform buffer to fill in.
  50942. * @param scene defines the scene the material belongs to.
  50943. * @param engine defines the engine the material belongs to.
  50944. * @param isFrozen defines wether the material is frozen or not.
  50945. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50946. */
  50947. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50948. /**
  50949. * Unbinds the material from the mesh.
  50950. * @param activeEffect defines the effect that should be unbound from.
  50951. * @returns true if unbound, otherwise false
  50952. */
  50953. unbind(activeEffect: Effect): boolean;
  50954. /**
  50955. * Returns the texture used for refraction or null if none is used.
  50956. * @param scene defines the scene the material belongs to.
  50957. * @returns - Refraction texture if present. If no refraction texture and refraction
  50958. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50959. */
  50960. private _getRefractionTexture;
  50961. /**
  50962. * Returns true if alpha blending should be disabled.
  50963. */
  50964. get disableAlphaBlending(): boolean;
  50965. /**
  50966. * Fills the list of render target textures.
  50967. * @param renderTargets the list of render targets to update
  50968. */
  50969. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50970. /**
  50971. * Checks to see if a texture is used in the material.
  50972. * @param texture - Base texture to use.
  50973. * @returns - Boolean specifying if a texture is used in the material.
  50974. */
  50975. hasTexture(texture: BaseTexture): boolean;
  50976. /**
  50977. * Gets a boolean indicating that current material needs to register RTT
  50978. * @returns true if this uses a render target otherwise false.
  50979. */
  50980. hasRenderTargetTextures(): boolean;
  50981. /**
  50982. * Returns an array of the actively used textures.
  50983. * @param activeTextures Array of BaseTextures
  50984. */
  50985. getActiveTextures(activeTextures: BaseTexture[]): void;
  50986. /**
  50987. * Returns the animatable textures.
  50988. * @param animatables Array of animatable textures.
  50989. */
  50990. getAnimatables(animatables: IAnimatable[]): void;
  50991. /**
  50992. * Disposes the resources of the material.
  50993. * @param forceDisposeTextures - Forces the disposal of all textures.
  50994. */
  50995. dispose(forceDisposeTextures?: boolean): void;
  50996. /**
  50997. * Get the current class name of the texture useful for serialization or dynamic coding.
  50998. * @returns "PBRSubSurfaceConfiguration"
  50999. */
  51000. getClassName(): string;
  51001. /**
  51002. * Add fallbacks to the effect fallbacks list.
  51003. * @param defines defines the Base texture to use.
  51004. * @param fallbacks defines the current fallback list.
  51005. * @param currentRank defines the current fallback rank.
  51006. * @returns the new fallback rank.
  51007. */
  51008. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51009. /**
  51010. * Add the required uniforms to the current list.
  51011. * @param uniforms defines the current uniform list.
  51012. */
  51013. static AddUniforms(uniforms: string[]): void;
  51014. /**
  51015. * Add the required samplers to the current list.
  51016. * @param samplers defines the current sampler list.
  51017. */
  51018. static AddSamplers(samplers: string[]): void;
  51019. /**
  51020. * Add the required uniforms to the current buffer.
  51021. * @param uniformBuffer defines the current uniform buffer.
  51022. */
  51023. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51024. /**
  51025. * Makes a duplicate of the current configuration into another one.
  51026. * @param configuration define the config where to copy the info
  51027. */
  51028. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51029. /**
  51030. * Serializes this Sub Surface configuration.
  51031. * @returns - An object with the serialized config.
  51032. */
  51033. serialize(): any;
  51034. /**
  51035. * Parses a anisotropy Configuration from a serialized object.
  51036. * @param source - Serialized object.
  51037. * @param scene Defines the scene we are parsing for
  51038. * @param rootUrl Defines the rootUrl to load from
  51039. */
  51040. parse(source: any, scene: Scene, rootUrl: string): void;
  51041. }
  51042. }
  51043. declare module BABYLON {
  51044. /** @hidden */
  51045. export var pbrFragmentDeclaration: {
  51046. name: string;
  51047. shader: string;
  51048. };
  51049. }
  51050. declare module BABYLON {
  51051. /** @hidden */
  51052. export var pbrUboDeclaration: {
  51053. name: string;
  51054. shader: string;
  51055. };
  51056. }
  51057. declare module BABYLON {
  51058. /** @hidden */
  51059. export var pbrFragmentExtraDeclaration: {
  51060. name: string;
  51061. shader: string;
  51062. };
  51063. }
  51064. declare module BABYLON {
  51065. /** @hidden */
  51066. export var pbrFragmentSamplersDeclaration: {
  51067. name: string;
  51068. shader: string;
  51069. };
  51070. }
  51071. declare module BABYLON {
  51072. /** @hidden */
  51073. export var pbrHelperFunctions: {
  51074. name: string;
  51075. shader: string;
  51076. };
  51077. }
  51078. declare module BABYLON {
  51079. /** @hidden */
  51080. export var harmonicsFunctions: {
  51081. name: string;
  51082. shader: string;
  51083. };
  51084. }
  51085. declare module BABYLON {
  51086. /** @hidden */
  51087. export var pbrDirectLightingSetupFunctions: {
  51088. name: string;
  51089. shader: string;
  51090. };
  51091. }
  51092. declare module BABYLON {
  51093. /** @hidden */
  51094. export var pbrDirectLightingFalloffFunctions: {
  51095. name: string;
  51096. shader: string;
  51097. };
  51098. }
  51099. declare module BABYLON {
  51100. /** @hidden */
  51101. export var pbrBRDFFunctions: {
  51102. name: string;
  51103. shader: string;
  51104. };
  51105. }
  51106. declare module BABYLON {
  51107. /** @hidden */
  51108. export var pbrDirectLightingFunctions: {
  51109. name: string;
  51110. shader: string;
  51111. };
  51112. }
  51113. declare module BABYLON {
  51114. /** @hidden */
  51115. export var pbrIBLFunctions: {
  51116. name: string;
  51117. shader: string;
  51118. };
  51119. }
  51120. declare module BABYLON {
  51121. /** @hidden */
  51122. export var pbrDebug: {
  51123. name: string;
  51124. shader: string;
  51125. };
  51126. }
  51127. declare module BABYLON {
  51128. /** @hidden */
  51129. export var pbrPixelShader: {
  51130. name: string;
  51131. shader: string;
  51132. };
  51133. }
  51134. declare module BABYLON {
  51135. /** @hidden */
  51136. export var pbrVertexDeclaration: {
  51137. name: string;
  51138. shader: string;
  51139. };
  51140. }
  51141. declare module BABYLON {
  51142. /** @hidden */
  51143. export var pbrVertexShader: {
  51144. name: string;
  51145. shader: string;
  51146. };
  51147. }
  51148. declare module BABYLON {
  51149. /**
  51150. * Manages the defines for the PBR Material.
  51151. * @hidden
  51152. */
  51153. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51154. PBR: boolean;
  51155. MAINUV1: boolean;
  51156. MAINUV2: boolean;
  51157. UV1: boolean;
  51158. UV2: boolean;
  51159. ALBEDO: boolean;
  51160. GAMMAALBEDO: boolean;
  51161. ALBEDODIRECTUV: number;
  51162. VERTEXCOLOR: boolean;
  51163. AMBIENT: boolean;
  51164. AMBIENTDIRECTUV: number;
  51165. AMBIENTINGRAYSCALE: boolean;
  51166. OPACITY: boolean;
  51167. VERTEXALPHA: boolean;
  51168. OPACITYDIRECTUV: number;
  51169. OPACITYRGB: boolean;
  51170. ALPHATEST: boolean;
  51171. DEPTHPREPASS: boolean;
  51172. ALPHABLEND: boolean;
  51173. ALPHAFROMALBEDO: boolean;
  51174. ALPHATESTVALUE: string;
  51175. SPECULAROVERALPHA: boolean;
  51176. RADIANCEOVERALPHA: boolean;
  51177. ALPHAFRESNEL: boolean;
  51178. LINEARALPHAFRESNEL: boolean;
  51179. PREMULTIPLYALPHA: boolean;
  51180. EMISSIVE: boolean;
  51181. EMISSIVEDIRECTUV: number;
  51182. REFLECTIVITY: boolean;
  51183. REFLECTIVITYDIRECTUV: number;
  51184. SPECULARTERM: boolean;
  51185. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51186. MICROSURFACEAUTOMATIC: boolean;
  51187. LODBASEDMICROSFURACE: boolean;
  51188. MICROSURFACEMAP: boolean;
  51189. MICROSURFACEMAPDIRECTUV: number;
  51190. METALLICWORKFLOW: boolean;
  51191. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51192. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51193. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51194. AOSTOREINMETALMAPRED: boolean;
  51195. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51196. ENVIRONMENTBRDF: boolean;
  51197. ENVIRONMENTBRDF_RGBD: boolean;
  51198. NORMAL: boolean;
  51199. TANGENT: boolean;
  51200. BUMP: boolean;
  51201. BUMPDIRECTUV: number;
  51202. OBJECTSPACE_NORMALMAP: boolean;
  51203. PARALLAX: boolean;
  51204. PARALLAXOCCLUSION: boolean;
  51205. NORMALXYSCALE: boolean;
  51206. LIGHTMAP: boolean;
  51207. LIGHTMAPDIRECTUV: number;
  51208. USELIGHTMAPASSHADOWMAP: boolean;
  51209. GAMMALIGHTMAP: boolean;
  51210. RGBDLIGHTMAP: boolean;
  51211. REFLECTION: boolean;
  51212. REFLECTIONMAP_3D: boolean;
  51213. REFLECTIONMAP_SPHERICAL: boolean;
  51214. REFLECTIONMAP_PLANAR: boolean;
  51215. REFLECTIONMAP_CUBIC: boolean;
  51216. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51217. REFLECTIONMAP_PROJECTION: boolean;
  51218. REFLECTIONMAP_SKYBOX: boolean;
  51219. REFLECTIONMAP_EXPLICIT: boolean;
  51220. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51221. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51222. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51223. INVERTCUBICMAP: boolean;
  51224. USESPHERICALFROMREFLECTIONMAP: boolean;
  51225. USEIRRADIANCEMAP: boolean;
  51226. SPHERICAL_HARMONICS: boolean;
  51227. USESPHERICALINVERTEX: boolean;
  51228. REFLECTIONMAP_OPPOSITEZ: boolean;
  51229. LODINREFLECTIONALPHA: boolean;
  51230. GAMMAREFLECTION: boolean;
  51231. RGBDREFLECTION: boolean;
  51232. LINEARSPECULARREFLECTION: boolean;
  51233. RADIANCEOCCLUSION: boolean;
  51234. HORIZONOCCLUSION: boolean;
  51235. INSTANCES: boolean;
  51236. NUM_BONE_INFLUENCERS: number;
  51237. BonesPerMesh: number;
  51238. BONETEXTURE: boolean;
  51239. NONUNIFORMSCALING: boolean;
  51240. MORPHTARGETS: boolean;
  51241. MORPHTARGETS_NORMAL: boolean;
  51242. MORPHTARGETS_TANGENT: boolean;
  51243. MORPHTARGETS_UV: boolean;
  51244. NUM_MORPH_INFLUENCERS: number;
  51245. IMAGEPROCESSING: boolean;
  51246. VIGNETTE: boolean;
  51247. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51248. VIGNETTEBLENDMODEOPAQUE: boolean;
  51249. TONEMAPPING: boolean;
  51250. TONEMAPPING_ACES: boolean;
  51251. CONTRAST: boolean;
  51252. COLORCURVES: boolean;
  51253. COLORGRADING: boolean;
  51254. COLORGRADING3D: boolean;
  51255. SAMPLER3DGREENDEPTH: boolean;
  51256. SAMPLER3DBGRMAP: boolean;
  51257. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51258. EXPOSURE: boolean;
  51259. MULTIVIEW: boolean;
  51260. USEPHYSICALLIGHTFALLOFF: boolean;
  51261. USEGLTFLIGHTFALLOFF: boolean;
  51262. TWOSIDEDLIGHTING: boolean;
  51263. SHADOWFLOAT: boolean;
  51264. CLIPPLANE: boolean;
  51265. CLIPPLANE2: boolean;
  51266. CLIPPLANE3: boolean;
  51267. CLIPPLANE4: boolean;
  51268. CLIPPLANE5: boolean;
  51269. CLIPPLANE6: boolean;
  51270. POINTSIZE: boolean;
  51271. FOG: boolean;
  51272. LOGARITHMICDEPTH: boolean;
  51273. FORCENORMALFORWARD: boolean;
  51274. SPECULARAA: boolean;
  51275. CLEARCOAT: boolean;
  51276. CLEARCOAT_DEFAULTIOR: boolean;
  51277. CLEARCOAT_TEXTURE: boolean;
  51278. CLEARCOAT_TEXTUREDIRECTUV: number;
  51279. CLEARCOAT_BUMP: boolean;
  51280. CLEARCOAT_BUMPDIRECTUV: number;
  51281. CLEARCOAT_TINT: boolean;
  51282. CLEARCOAT_TINT_TEXTURE: boolean;
  51283. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51284. ANISOTROPIC: boolean;
  51285. ANISOTROPIC_TEXTURE: boolean;
  51286. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51287. BRDF_V_HEIGHT_CORRELATED: boolean;
  51288. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51289. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51290. SHEEN: boolean;
  51291. SHEEN_TEXTURE: boolean;
  51292. SHEEN_TEXTUREDIRECTUV: number;
  51293. SHEEN_LINKWITHALBEDO: boolean;
  51294. SHEEN_ROUGHNESS: boolean;
  51295. SHEEN_ALBEDOSCALING: boolean;
  51296. SUBSURFACE: boolean;
  51297. SS_REFRACTION: boolean;
  51298. SS_TRANSLUCENCY: boolean;
  51299. SS_SCATERRING: boolean;
  51300. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51301. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51302. SS_REFRACTIONMAP_3D: boolean;
  51303. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51304. SS_LODINREFRACTIONALPHA: boolean;
  51305. SS_GAMMAREFRACTION: boolean;
  51306. SS_RGBDREFRACTION: boolean;
  51307. SS_LINEARSPECULARREFRACTION: boolean;
  51308. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51309. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51310. UNLIT: boolean;
  51311. DEBUGMODE: number;
  51312. /**
  51313. * Initializes the PBR Material defines.
  51314. */
  51315. constructor();
  51316. /**
  51317. * Resets the PBR Material defines.
  51318. */
  51319. reset(): void;
  51320. }
  51321. /**
  51322. * The Physically based material base class of BJS.
  51323. *
  51324. * This offers the main features of a standard PBR material.
  51325. * For more information, please refer to the documentation :
  51326. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51327. */
  51328. export abstract class PBRBaseMaterial extends PushMaterial {
  51329. /**
  51330. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51331. */
  51332. static readonly PBRMATERIAL_OPAQUE: number;
  51333. /**
  51334. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51335. */
  51336. static readonly PBRMATERIAL_ALPHATEST: number;
  51337. /**
  51338. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51339. */
  51340. static readonly PBRMATERIAL_ALPHABLEND: number;
  51341. /**
  51342. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51343. * They are also discarded below the alpha cutoff threshold to improve performances.
  51344. */
  51345. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51346. /**
  51347. * Defines the default value of how much AO map is occluding the analytical lights
  51348. * (point spot...).
  51349. */
  51350. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51351. /**
  51352. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51353. */
  51354. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51355. /**
  51356. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51357. * to enhance interoperability with other engines.
  51358. */
  51359. static readonly LIGHTFALLOFF_GLTF: number;
  51360. /**
  51361. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51362. * to enhance interoperability with other materials.
  51363. */
  51364. static readonly LIGHTFALLOFF_STANDARD: number;
  51365. /**
  51366. * Intensity of the direct lights e.g. the four lights available in your scene.
  51367. * This impacts both the direct diffuse and specular highlights.
  51368. */
  51369. protected _directIntensity: number;
  51370. /**
  51371. * Intensity of the emissive part of the material.
  51372. * This helps controlling the emissive effect without modifying the emissive color.
  51373. */
  51374. protected _emissiveIntensity: number;
  51375. /**
  51376. * Intensity of the environment e.g. how much the environment will light the object
  51377. * either through harmonics for rough material or through the refelction for shiny ones.
  51378. */
  51379. protected _environmentIntensity: number;
  51380. /**
  51381. * This is a special control allowing the reduction of the specular highlights coming from the
  51382. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51383. */
  51384. protected _specularIntensity: number;
  51385. /**
  51386. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51387. */
  51388. private _lightingInfos;
  51389. /**
  51390. * Debug Control allowing disabling the bump map on this material.
  51391. */
  51392. protected _disableBumpMap: boolean;
  51393. /**
  51394. * AKA Diffuse Texture in standard nomenclature.
  51395. */
  51396. protected _albedoTexture: Nullable<BaseTexture>;
  51397. /**
  51398. * AKA Occlusion Texture in other nomenclature.
  51399. */
  51400. protected _ambientTexture: Nullable<BaseTexture>;
  51401. /**
  51402. * AKA Occlusion Texture Intensity in other nomenclature.
  51403. */
  51404. protected _ambientTextureStrength: number;
  51405. /**
  51406. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51407. * 1 means it completely occludes it
  51408. * 0 mean it has no impact
  51409. */
  51410. protected _ambientTextureImpactOnAnalyticalLights: number;
  51411. /**
  51412. * Stores the alpha values in a texture.
  51413. */
  51414. protected _opacityTexture: Nullable<BaseTexture>;
  51415. /**
  51416. * Stores the reflection values in a texture.
  51417. */
  51418. protected _reflectionTexture: Nullable<BaseTexture>;
  51419. /**
  51420. * Stores the emissive values in a texture.
  51421. */
  51422. protected _emissiveTexture: Nullable<BaseTexture>;
  51423. /**
  51424. * AKA Specular texture in other nomenclature.
  51425. */
  51426. protected _reflectivityTexture: Nullable<BaseTexture>;
  51427. /**
  51428. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51429. */
  51430. protected _metallicTexture: Nullable<BaseTexture>;
  51431. /**
  51432. * Specifies the metallic scalar of the metallic/roughness workflow.
  51433. * Can also be used to scale the metalness values of the metallic texture.
  51434. */
  51435. protected _metallic: Nullable<number>;
  51436. /**
  51437. * Specifies the roughness scalar of the metallic/roughness workflow.
  51438. * Can also be used to scale the roughness values of the metallic texture.
  51439. */
  51440. protected _roughness: Nullable<number>;
  51441. /**
  51442. * Specifies the an F0 factor to help configuring the material F0.
  51443. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51444. * to 0.5 the previously hard coded value stays the same.
  51445. * Can also be used to scale the F0 values of the metallic texture.
  51446. */
  51447. protected _metallicF0Factor: number;
  51448. /**
  51449. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51450. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51451. * your expectation as it multiplies with the texture data.
  51452. */
  51453. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51454. /**
  51455. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51456. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51457. */
  51458. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51459. /**
  51460. * Stores surface normal data used to displace a mesh in a texture.
  51461. */
  51462. protected _bumpTexture: Nullable<BaseTexture>;
  51463. /**
  51464. * Stores the pre-calculated light information of a mesh in a texture.
  51465. */
  51466. protected _lightmapTexture: Nullable<BaseTexture>;
  51467. /**
  51468. * The color of a material in ambient lighting.
  51469. */
  51470. protected _ambientColor: Color3;
  51471. /**
  51472. * AKA Diffuse Color in other nomenclature.
  51473. */
  51474. protected _albedoColor: Color3;
  51475. /**
  51476. * AKA Specular Color in other nomenclature.
  51477. */
  51478. protected _reflectivityColor: Color3;
  51479. /**
  51480. * The color applied when light is reflected from a material.
  51481. */
  51482. protected _reflectionColor: Color3;
  51483. /**
  51484. * The color applied when light is emitted from a material.
  51485. */
  51486. protected _emissiveColor: Color3;
  51487. /**
  51488. * AKA Glossiness in other nomenclature.
  51489. */
  51490. protected _microSurface: number;
  51491. /**
  51492. * Specifies that the material will use the light map as a show map.
  51493. */
  51494. protected _useLightmapAsShadowmap: boolean;
  51495. /**
  51496. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51497. * makes the reflect vector face the model (under horizon).
  51498. */
  51499. protected _useHorizonOcclusion: boolean;
  51500. /**
  51501. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51502. * too much the area relying on ambient texture to define their ambient occlusion.
  51503. */
  51504. protected _useRadianceOcclusion: boolean;
  51505. /**
  51506. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51507. */
  51508. protected _useAlphaFromAlbedoTexture: boolean;
  51509. /**
  51510. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51511. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51512. */
  51513. protected _useSpecularOverAlpha: boolean;
  51514. /**
  51515. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51516. */
  51517. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51518. /**
  51519. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51520. */
  51521. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51522. /**
  51523. * Specifies if the metallic texture contains the roughness information in its green channel.
  51524. */
  51525. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51526. /**
  51527. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51528. */
  51529. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51530. /**
  51531. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51532. */
  51533. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51534. /**
  51535. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51536. */
  51537. protected _useAmbientInGrayScale: boolean;
  51538. /**
  51539. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51540. * The material will try to infer what glossiness each pixel should be.
  51541. */
  51542. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51543. /**
  51544. * Defines the falloff type used in this material.
  51545. * It by default is Physical.
  51546. */
  51547. protected _lightFalloff: number;
  51548. /**
  51549. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51550. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51551. */
  51552. protected _useRadianceOverAlpha: boolean;
  51553. /**
  51554. * Allows using an object space normal map (instead of tangent space).
  51555. */
  51556. protected _useObjectSpaceNormalMap: boolean;
  51557. /**
  51558. * Allows using the bump map in parallax mode.
  51559. */
  51560. protected _useParallax: boolean;
  51561. /**
  51562. * Allows using the bump map in parallax occlusion mode.
  51563. */
  51564. protected _useParallaxOcclusion: boolean;
  51565. /**
  51566. * Controls the scale bias of the parallax mode.
  51567. */
  51568. protected _parallaxScaleBias: number;
  51569. /**
  51570. * If sets to true, disables all the lights affecting the material.
  51571. */
  51572. protected _disableLighting: boolean;
  51573. /**
  51574. * Number of Simultaneous lights allowed on the material.
  51575. */
  51576. protected _maxSimultaneousLights: number;
  51577. /**
  51578. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51579. */
  51580. protected _invertNormalMapX: boolean;
  51581. /**
  51582. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51583. */
  51584. protected _invertNormalMapY: boolean;
  51585. /**
  51586. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51587. */
  51588. protected _twoSidedLighting: boolean;
  51589. /**
  51590. * Defines the alpha limits in alpha test mode.
  51591. */
  51592. protected _alphaCutOff: number;
  51593. /**
  51594. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51595. */
  51596. protected _forceAlphaTest: boolean;
  51597. /**
  51598. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51599. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51600. */
  51601. protected _useAlphaFresnel: boolean;
  51602. /**
  51603. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51604. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51605. */
  51606. protected _useLinearAlphaFresnel: boolean;
  51607. /**
  51608. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51609. * from cos thetav and roughness:
  51610. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51611. */
  51612. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51613. /**
  51614. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51615. */
  51616. protected _forceIrradianceInFragment: boolean;
  51617. /**
  51618. * Force normal to face away from face.
  51619. */
  51620. protected _forceNormalForward: boolean;
  51621. /**
  51622. * Enables specular anti aliasing in the PBR shader.
  51623. * It will both interacts on the Geometry for analytical and IBL lighting.
  51624. * It also prefilter the roughness map based on the bump values.
  51625. */
  51626. protected _enableSpecularAntiAliasing: boolean;
  51627. /**
  51628. * Default configuration related to image processing available in the PBR Material.
  51629. */
  51630. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51631. /**
  51632. * Keep track of the image processing observer to allow dispose and replace.
  51633. */
  51634. private _imageProcessingObserver;
  51635. /**
  51636. * Attaches a new image processing configuration to the PBR Material.
  51637. * @param configuration
  51638. */
  51639. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51640. /**
  51641. * Stores the available render targets.
  51642. */
  51643. private _renderTargets;
  51644. /**
  51645. * Sets the global ambient color for the material used in lighting calculations.
  51646. */
  51647. private _globalAmbientColor;
  51648. /**
  51649. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51650. */
  51651. private _useLogarithmicDepth;
  51652. /**
  51653. * If set to true, no lighting calculations will be applied.
  51654. */
  51655. private _unlit;
  51656. private _debugMode;
  51657. /**
  51658. * @hidden
  51659. * This is reserved for the inspector.
  51660. * Defines the material debug mode.
  51661. * It helps seeing only some components of the material while troubleshooting.
  51662. */
  51663. debugMode: number;
  51664. /**
  51665. * @hidden
  51666. * This is reserved for the inspector.
  51667. * Specify from where on screen the debug mode should start.
  51668. * The value goes from -1 (full screen) to 1 (not visible)
  51669. * It helps with side by side comparison against the final render
  51670. * This defaults to -1
  51671. */
  51672. private debugLimit;
  51673. /**
  51674. * @hidden
  51675. * This is reserved for the inspector.
  51676. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51677. * You can use the factor to better multiply the final value.
  51678. */
  51679. private debugFactor;
  51680. /**
  51681. * Defines the clear coat layer parameters for the material.
  51682. */
  51683. readonly clearCoat: PBRClearCoatConfiguration;
  51684. /**
  51685. * Defines the anisotropic parameters for the material.
  51686. */
  51687. readonly anisotropy: PBRAnisotropicConfiguration;
  51688. /**
  51689. * Defines the BRDF parameters for the material.
  51690. */
  51691. readonly brdf: PBRBRDFConfiguration;
  51692. /**
  51693. * Defines the Sheen parameters for the material.
  51694. */
  51695. readonly sheen: PBRSheenConfiguration;
  51696. /**
  51697. * Defines the SubSurface parameters for the material.
  51698. */
  51699. readonly subSurface: PBRSubSurfaceConfiguration;
  51700. /**
  51701. * Custom callback helping to override the default shader used in the material.
  51702. */
  51703. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51704. protected _rebuildInParallel: boolean;
  51705. /**
  51706. * Instantiates a new PBRMaterial instance.
  51707. *
  51708. * @param name The material name
  51709. * @param scene The scene the material will be use in.
  51710. */
  51711. constructor(name: string, scene: Scene);
  51712. /**
  51713. * Gets a boolean indicating that current material needs to register RTT
  51714. */
  51715. get hasRenderTargetTextures(): boolean;
  51716. /**
  51717. * Gets the name of the material class.
  51718. */
  51719. getClassName(): string;
  51720. /**
  51721. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51722. */
  51723. get useLogarithmicDepth(): boolean;
  51724. /**
  51725. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51726. */
  51727. set useLogarithmicDepth(value: boolean);
  51728. /**
  51729. * Returns true if alpha blending should be disabled.
  51730. */
  51731. protected get _disableAlphaBlending(): boolean;
  51732. /**
  51733. * Specifies whether or not this material should be rendered in alpha blend mode.
  51734. */
  51735. needAlphaBlending(): boolean;
  51736. /**
  51737. * Specifies whether or not this material should be rendered in alpha test mode.
  51738. */
  51739. needAlphaTesting(): boolean;
  51740. /**
  51741. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51742. */
  51743. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51744. /**
  51745. * Gets the texture used for the alpha test.
  51746. */
  51747. getAlphaTestTexture(): Nullable<BaseTexture>;
  51748. /**
  51749. * Specifies that the submesh is ready to be used.
  51750. * @param mesh - BJS mesh.
  51751. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51752. * @param useInstances - Specifies that instances should be used.
  51753. * @returns - boolean indicating that the submesh is ready or not.
  51754. */
  51755. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51756. /**
  51757. * Specifies if the material uses metallic roughness workflow.
  51758. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51759. */
  51760. isMetallicWorkflow(): boolean;
  51761. private _prepareEffect;
  51762. private _prepareDefines;
  51763. /**
  51764. * Force shader compilation
  51765. */
  51766. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51767. /**
  51768. * Initializes the uniform buffer layout for the shader.
  51769. */
  51770. buildUniformLayout(): void;
  51771. /**
  51772. * Unbinds the material from the mesh
  51773. */
  51774. unbind(): void;
  51775. /**
  51776. * Binds the submesh data.
  51777. * @param world - The world matrix.
  51778. * @param mesh - The BJS mesh.
  51779. * @param subMesh - A submesh of the BJS mesh.
  51780. */
  51781. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51782. /**
  51783. * Returns the animatable textures.
  51784. * @returns - Array of animatable textures.
  51785. */
  51786. getAnimatables(): IAnimatable[];
  51787. /**
  51788. * Returns the texture used for reflections.
  51789. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51790. */
  51791. private _getReflectionTexture;
  51792. /**
  51793. * Returns an array of the actively used textures.
  51794. * @returns - Array of BaseTextures
  51795. */
  51796. getActiveTextures(): BaseTexture[];
  51797. /**
  51798. * Checks to see if a texture is used in the material.
  51799. * @param texture - Base texture to use.
  51800. * @returns - Boolean specifying if a texture is used in the material.
  51801. */
  51802. hasTexture(texture: BaseTexture): boolean;
  51803. /**
  51804. * Disposes the resources of the material.
  51805. * @param forceDisposeEffect - Forces the disposal of effects.
  51806. * @param forceDisposeTextures - Forces the disposal of all textures.
  51807. */
  51808. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51809. }
  51810. }
  51811. declare module BABYLON {
  51812. /**
  51813. * The Physically based material of BJS.
  51814. *
  51815. * This offers the main features of a standard PBR material.
  51816. * For more information, please refer to the documentation :
  51817. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51818. */
  51819. export class PBRMaterial extends PBRBaseMaterial {
  51820. /**
  51821. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51822. */
  51823. static readonly PBRMATERIAL_OPAQUE: number;
  51824. /**
  51825. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51826. */
  51827. static readonly PBRMATERIAL_ALPHATEST: number;
  51828. /**
  51829. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51830. */
  51831. static readonly PBRMATERIAL_ALPHABLEND: number;
  51832. /**
  51833. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51834. * They are also discarded below the alpha cutoff threshold to improve performances.
  51835. */
  51836. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51837. /**
  51838. * Defines the default value of how much AO map is occluding the analytical lights
  51839. * (point spot...).
  51840. */
  51841. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51842. /**
  51843. * Intensity of the direct lights e.g. the four lights available in your scene.
  51844. * This impacts both the direct diffuse and specular highlights.
  51845. */
  51846. directIntensity: number;
  51847. /**
  51848. * Intensity of the emissive part of the material.
  51849. * This helps controlling the emissive effect without modifying the emissive color.
  51850. */
  51851. emissiveIntensity: number;
  51852. /**
  51853. * Intensity of the environment e.g. how much the environment will light the object
  51854. * either through harmonics for rough material or through the refelction for shiny ones.
  51855. */
  51856. environmentIntensity: number;
  51857. /**
  51858. * This is a special control allowing the reduction of the specular highlights coming from the
  51859. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51860. */
  51861. specularIntensity: number;
  51862. /**
  51863. * Debug Control allowing disabling the bump map on this material.
  51864. */
  51865. disableBumpMap: boolean;
  51866. /**
  51867. * AKA Diffuse Texture in standard nomenclature.
  51868. */
  51869. albedoTexture: BaseTexture;
  51870. /**
  51871. * AKA Occlusion Texture in other nomenclature.
  51872. */
  51873. ambientTexture: BaseTexture;
  51874. /**
  51875. * AKA Occlusion Texture Intensity in other nomenclature.
  51876. */
  51877. ambientTextureStrength: number;
  51878. /**
  51879. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51880. * 1 means it completely occludes it
  51881. * 0 mean it has no impact
  51882. */
  51883. ambientTextureImpactOnAnalyticalLights: number;
  51884. /**
  51885. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51886. */
  51887. opacityTexture: BaseTexture;
  51888. /**
  51889. * Stores the reflection values in a texture.
  51890. */
  51891. reflectionTexture: Nullable<BaseTexture>;
  51892. /**
  51893. * Stores the emissive values in a texture.
  51894. */
  51895. emissiveTexture: BaseTexture;
  51896. /**
  51897. * AKA Specular texture in other nomenclature.
  51898. */
  51899. reflectivityTexture: BaseTexture;
  51900. /**
  51901. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51902. */
  51903. metallicTexture: BaseTexture;
  51904. /**
  51905. * Specifies the metallic scalar of the metallic/roughness workflow.
  51906. * Can also be used to scale the metalness values of the metallic texture.
  51907. */
  51908. metallic: Nullable<number>;
  51909. /**
  51910. * Specifies the roughness scalar of the metallic/roughness workflow.
  51911. * Can also be used to scale the roughness values of the metallic texture.
  51912. */
  51913. roughness: Nullable<number>;
  51914. /**
  51915. * Specifies the an F0 factor to help configuring the material F0.
  51916. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51917. * to 0.5 the previously hard coded value stays the same.
  51918. * Can also be used to scale the F0 values of the metallic texture.
  51919. */
  51920. metallicF0Factor: number;
  51921. /**
  51922. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51923. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51924. * your expectation as it multiplies with the texture data.
  51925. */
  51926. useMetallicF0FactorFromMetallicTexture: boolean;
  51927. /**
  51928. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51929. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51930. */
  51931. microSurfaceTexture: BaseTexture;
  51932. /**
  51933. * Stores surface normal data used to displace a mesh in a texture.
  51934. */
  51935. bumpTexture: BaseTexture;
  51936. /**
  51937. * Stores the pre-calculated light information of a mesh in a texture.
  51938. */
  51939. lightmapTexture: BaseTexture;
  51940. /**
  51941. * Stores the refracted light information in a texture.
  51942. */
  51943. get refractionTexture(): Nullable<BaseTexture>;
  51944. set refractionTexture(value: Nullable<BaseTexture>);
  51945. /**
  51946. * The color of a material in ambient lighting.
  51947. */
  51948. ambientColor: Color3;
  51949. /**
  51950. * AKA Diffuse Color in other nomenclature.
  51951. */
  51952. albedoColor: Color3;
  51953. /**
  51954. * AKA Specular Color in other nomenclature.
  51955. */
  51956. reflectivityColor: Color3;
  51957. /**
  51958. * The color reflected from the material.
  51959. */
  51960. reflectionColor: Color3;
  51961. /**
  51962. * The color emitted from the material.
  51963. */
  51964. emissiveColor: Color3;
  51965. /**
  51966. * AKA Glossiness in other nomenclature.
  51967. */
  51968. microSurface: number;
  51969. /**
  51970. * source material index of refraction (IOR)' / 'destination material IOR.
  51971. */
  51972. get indexOfRefraction(): number;
  51973. set indexOfRefraction(value: number);
  51974. /**
  51975. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51976. */
  51977. get invertRefractionY(): boolean;
  51978. set invertRefractionY(value: boolean);
  51979. /**
  51980. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51981. * Materials half opaque for instance using refraction could benefit from this control.
  51982. */
  51983. get linkRefractionWithTransparency(): boolean;
  51984. set linkRefractionWithTransparency(value: boolean);
  51985. /**
  51986. * If true, the light map contains occlusion information instead of lighting info.
  51987. */
  51988. useLightmapAsShadowmap: boolean;
  51989. /**
  51990. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51991. */
  51992. useAlphaFromAlbedoTexture: boolean;
  51993. /**
  51994. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51995. */
  51996. forceAlphaTest: boolean;
  51997. /**
  51998. * Defines the alpha limits in alpha test mode.
  51999. */
  52000. alphaCutOff: number;
  52001. /**
  52002. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52003. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52004. */
  52005. useSpecularOverAlpha: boolean;
  52006. /**
  52007. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52008. */
  52009. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52010. /**
  52011. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52012. */
  52013. useRoughnessFromMetallicTextureAlpha: boolean;
  52014. /**
  52015. * Specifies if the metallic texture contains the roughness information in its green channel.
  52016. */
  52017. useRoughnessFromMetallicTextureGreen: boolean;
  52018. /**
  52019. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52020. */
  52021. useMetallnessFromMetallicTextureBlue: boolean;
  52022. /**
  52023. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52024. */
  52025. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52026. /**
  52027. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52028. */
  52029. useAmbientInGrayScale: boolean;
  52030. /**
  52031. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52032. * The material will try to infer what glossiness each pixel should be.
  52033. */
  52034. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52035. /**
  52036. * BJS is using an harcoded light falloff based on a manually sets up range.
  52037. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52038. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52039. */
  52040. get usePhysicalLightFalloff(): boolean;
  52041. /**
  52042. * BJS is using an harcoded light falloff based on a manually sets up range.
  52043. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52044. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52045. */
  52046. set usePhysicalLightFalloff(value: boolean);
  52047. /**
  52048. * In order to support the falloff compatibility with gltf, a special mode has been added
  52049. * to reproduce the gltf light falloff.
  52050. */
  52051. get useGLTFLightFalloff(): boolean;
  52052. /**
  52053. * In order to support the falloff compatibility with gltf, a special mode has been added
  52054. * to reproduce the gltf light falloff.
  52055. */
  52056. set useGLTFLightFalloff(value: boolean);
  52057. /**
  52058. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52059. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52060. */
  52061. useRadianceOverAlpha: boolean;
  52062. /**
  52063. * Allows using an object space normal map (instead of tangent space).
  52064. */
  52065. useObjectSpaceNormalMap: boolean;
  52066. /**
  52067. * Allows using the bump map in parallax mode.
  52068. */
  52069. useParallax: boolean;
  52070. /**
  52071. * Allows using the bump map in parallax occlusion mode.
  52072. */
  52073. useParallaxOcclusion: boolean;
  52074. /**
  52075. * Controls the scale bias of the parallax mode.
  52076. */
  52077. parallaxScaleBias: number;
  52078. /**
  52079. * If sets to true, disables all the lights affecting the material.
  52080. */
  52081. disableLighting: boolean;
  52082. /**
  52083. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52084. */
  52085. forceIrradianceInFragment: boolean;
  52086. /**
  52087. * Number of Simultaneous lights allowed on the material.
  52088. */
  52089. maxSimultaneousLights: number;
  52090. /**
  52091. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52092. */
  52093. invertNormalMapX: boolean;
  52094. /**
  52095. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52096. */
  52097. invertNormalMapY: boolean;
  52098. /**
  52099. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52100. */
  52101. twoSidedLighting: boolean;
  52102. /**
  52103. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52104. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52105. */
  52106. useAlphaFresnel: boolean;
  52107. /**
  52108. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52109. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52110. */
  52111. useLinearAlphaFresnel: boolean;
  52112. /**
  52113. * Let user defines the brdf lookup texture used for IBL.
  52114. * A default 8bit version is embedded but you could point at :
  52115. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52116. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52117. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52118. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52119. */
  52120. environmentBRDFTexture: Nullable<BaseTexture>;
  52121. /**
  52122. * Force normal to face away from face.
  52123. */
  52124. forceNormalForward: boolean;
  52125. /**
  52126. * Enables specular anti aliasing in the PBR shader.
  52127. * It will both interacts on the Geometry for analytical and IBL lighting.
  52128. * It also prefilter the roughness map based on the bump values.
  52129. */
  52130. enableSpecularAntiAliasing: boolean;
  52131. /**
  52132. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52133. * makes the reflect vector face the model (under horizon).
  52134. */
  52135. useHorizonOcclusion: boolean;
  52136. /**
  52137. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52138. * too much the area relying on ambient texture to define their ambient occlusion.
  52139. */
  52140. useRadianceOcclusion: boolean;
  52141. /**
  52142. * If set to true, no lighting calculations will be applied.
  52143. */
  52144. unlit: boolean;
  52145. /**
  52146. * Gets the image processing configuration used either in this material.
  52147. */
  52148. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52149. /**
  52150. * Sets the Default image processing configuration used either in the this material.
  52151. *
  52152. * If sets to null, the scene one is in use.
  52153. */
  52154. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52155. /**
  52156. * Gets wether the color curves effect is enabled.
  52157. */
  52158. get cameraColorCurvesEnabled(): boolean;
  52159. /**
  52160. * Sets wether the color curves effect is enabled.
  52161. */
  52162. set cameraColorCurvesEnabled(value: boolean);
  52163. /**
  52164. * Gets wether the color grading effect is enabled.
  52165. */
  52166. get cameraColorGradingEnabled(): boolean;
  52167. /**
  52168. * Gets wether the color grading effect is enabled.
  52169. */
  52170. set cameraColorGradingEnabled(value: boolean);
  52171. /**
  52172. * Gets wether tonemapping is enabled or not.
  52173. */
  52174. get cameraToneMappingEnabled(): boolean;
  52175. /**
  52176. * Sets wether tonemapping is enabled or not
  52177. */
  52178. set cameraToneMappingEnabled(value: boolean);
  52179. /**
  52180. * The camera exposure used on this material.
  52181. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52182. * This corresponds to a photographic exposure.
  52183. */
  52184. get cameraExposure(): number;
  52185. /**
  52186. * The camera exposure used on this material.
  52187. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52188. * This corresponds to a photographic exposure.
  52189. */
  52190. set cameraExposure(value: number);
  52191. /**
  52192. * Gets The camera contrast used on this material.
  52193. */
  52194. get cameraContrast(): number;
  52195. /**
  52196. * Sets The camera contrast used on this material.
  52197. */
  52198. set cameraContrast(value: number);
  52199. /**
  52200. * Gets the Color Grading 2D Lookup Texture.
  52201. */
  52202. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52203. /**
  52204. * Sets the Color Grading 2D Lookup Texture.
  52205. */
  52206. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52207. /**
  52208. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52209. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52210. * 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;
  52211. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52212. */
  52213. get cameraColorCurves(): Nullable<ColorCurves>;
  52214. /**
  52215. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52216. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52217. * 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;
  52218. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52219. */
  52220. set cameraColorCurves(value: Nullable<ColorCurves>);
  52221. /**
  52222. * Instantiates a new PBRMaterial instance.
  52223. *
  52224. * @param name The material name
  52225. * @param scene The scene the material will be use in.
  52226. */
  52227. constructor(name: string, scene: Scene);
  52228. /**
  52229. * Returns the name of this material class.
  52230. */
  52231. getClassName(): string;
  52232. /**
  52233. * Makes a duplicate of the current material.
  52234. * @param name - name to use for the new material.
  52235. */
  52236. clone(name: string): PBRMaterial;
  52237. /**
  52238. * Serializes this PBR Material.
  52239. * @returns - An object with the serialized material.
  52240. */
  52241. serialize(): any;
  52242. /**
  52243. * Parses a PBR Material from a serialized object.
  52244. * @param source - Serialized object.
  52245. * @param scene - BJS scene instance.
  52246. * @param rootUrl - url for the scene object
  52247. * @returns - PBRMaterial
  52248. */
  52249. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52250. }
  52251. }
  52252. declare module BABYLON {
  52253. /**
  52254. * Direct draw surface info
  52255. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52256. */
  52257. export interface DDSInfo {
  52258. /**
  52259. * Width of the texture
  52260. */
  52261. width: number;
  52262. /**
  52263. * Width of the texture
  52264. */
  52265. height: number;
  52266. /**
  52267. * Number of Mipmaps for the texture
  52268. * @see https://en.wikipedia.org/wiki/Mipmap
  52269. */
  52270. mipmapCount: number;
  52271. /**
  52272. * If the textures format is a known fourCC format
  52273. * @see https://www.fourcc.org/
  52274. */
  52275. isFourCC: boolean;
  52276. /**
  52277. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52278. */
  52279. isRGB: boolean;
  52280. /**
  52281. * If the texture is a lumincance format
  52282. */
  52283. isLuminance: boolean;
  52284. /**
  52285. * If this is a cube texture
  52286. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52287. */
  52288. isCube: boolean;
  52289. /**
  52290. * If the texture is a compressed format eg. FOURCC_DXT1
  52291. */
  52292. isCompressed: boolean;
  52293. /**
  52294. * The dxgiFormat of the texture
  52295. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52296. */
  52297. dxgiFormat: number;
  52298. /**
  52299. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52300. */
  52301. textureType: number;
  52302. /**
  52303. * Sphericle polynomial created for the dds texture
  52304. */
  52305. sphericalPolynomial?: SphericalPolynomial;
  52306. }
  52307. /**
  52308. * Class used to provide DDS decompression tools
  52309. */
  52310. export class DDSTools {
  52311. /**
  52312. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52313. */
  52314. static StoreLODInAlphaChannel: boolean;
  52315. /**
  52316. * Gets DDS information from an array buffer
  52317. * @param data defines the array buffer view to read data from
  52318. * @returns the DDS information
  52319. */
  52320. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52321. private static _FloatView;
  52322. private static _Int32View;
  52323. private static _ToHalfFloat;
  52324. private static _FromHalfFloat;
  52325. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52326. private static _GetHalfFloatRGBAArrayBuffer;
  52327. private static _GetFloatRGBAArrayBuffer;
  52328. private static _GetFloatAsUIntRGBAArrayBuffer;
  52329. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52330. private static _GetRGBAArrayBuffer;
  52331. private static _ExtractLongWordOrder;
  52332. private static _GetRGBArrayBuffer;
  52333. private static _GetLuminanceArrayBuffer;
  52334. /**
  52335. * Uploads DDS Levels to a Babylon Texture
  52336. * @hidden
  52337. */
  52338. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52339. }
  52340. interface ThinEngine {
  52341. /**
  52342. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52343. * @param rootUrl defines the url where the file to load is located
  52344. * @param scene defines the current scene
  52345. * @param lodScale defines scale to apply to the mip map selection
  52346. * @param lodOffset defines offset to apply to the mip map selection
  52347. * @param onLoad defines an optional callback raised when the texture is loaded
  52348. * @param onError defines an optional callback raised if there is an issue to load the texture
  52349. * @param format defines the format of the data
  52350. * @param forcedExtension defines the extension to use to pick the right loader
  52351. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52352. * @returns the cube texture as an InternalTexture
  52353. */
  52354. 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;
  52355. }
  52356. }
  52357. declare module BABYLON {
  52358. /**
  52359. * Implementation of the DDS Texture Loader.
  52360. * @hidden
  52361. */
  52362. export class _DDSTextureLoader implements IInternalTextureLoader {
  52363. /**
  52364. * Defines wether the loader supports cascade loading the different faces.
  52365. */
  52366. readonly supportCascades: boolean;
  52367. /**
  52368. * This returns if the loader support the current file information.
  52369. * @param extension defines the file extension of the file being loaded
  52370. * @returns true if the loader can load the specified file
  52371. */
  52372. canLoad(extension: string): boolean;
  52373. /**
  52374. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52375. * @param data contains the texture data
  52376. * @param texture defines the BabylonJS internal texture
  52377. * @param createPolynomials will be true if polynomials have been requested
  52378. * @param onLoad defines the callback to trigger once the texture is ready
  52379. * @param onError defines the callback to trigger in case of error
  52380. */
  52381. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52382. /**
  52383. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52384. * @param data contains the texture data
  52385. * @param texture defines the BabylonJS internal texture
  52386. * @param callback defines the method to call once ready to upload
  52387. */
  52388. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52389. }
  52390. }
  52391. declare module BABYLON {
  52392. /**
  52393. * Implementation of the ENV Texture Loader.
  52394. * @hidden
  52395. */
  52396. export class _ENVTextureLoader implements IInternalTextureLoader {
  52397. /**
  52398. * Defines wether the loader supports cascade loading the different faces.
  52399. */
  52400. readonly supportCascades: boolean;
  52401. /**
  52402. * This returns if the loader support the current file information.
  52403. * @param extension defines the file extension of the file being loaded
  52404. * @returns true if the loader can load the specified file
  52405. */
  52406. canLoad(extension: string): boolean;
  52407. /**
  52408. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52409. * @param data contains the texture data
  52410. * @param texture defines the BabylonJS internal texture
  52411. * @param createPolynomials will be true if polynomials have been requested
  52412. * @param onLoad defines the callback to trigger once the texture is ready
  52413. * @param onError defines the callback to trigger in case of error
  52414. */
  52415. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52416. /**
  52417. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52418. * @param data contains the texture data
  52419. * @param texture defines the BabylonJS internal texture
  52420. * @param callback defines the method to call once ready to upload
  52421. */
  52422. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52423. }
  52424. }
  52425. declare module BABYLON {
  52426. /**
  52427. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52428. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52429. */
  52430. export class KhronosTextureContainer {
  52431. /** contents of the KTX container file */
  52432. data: ArrayBufferView;
  52433. private static HEADER_LEN;
  52434. private static COMPRESSED_2D;
  52435. private static COMPRESSED_3D;
  52436. private static TEX_2D;
  52437. private static TEX_3D;
  52438. /**
  52439. * Gets the openGL type
  52440. */
  52441. glType: number;
  52442. /**
  52443. * Gets the openGL type size
  52444. */
  52445. glTypeSize: number;
  52446. /**
  52447. * Gets the openGL format
  52448. */
  52449. glFormat: number;
  52450. /**
  52451. * Gets the openGL internal format
  52452. */
  52453. glInternalFormat: number;
  52454. /**
  52455. * Gets the base internal format
  52456. */
  52457. glBaseInternalFormat: number;
  52458. /**
  52459. * Gets image width in pixel
  52460. */
  52461. pixelWidth: number;
  52462. /**
  52463. * Gets image height in pixel
  52464. */
  52465. pixelHeight: number;
  52466. /**
  52467. * Gets image depth in pixels
  52468. */
  52469. pixelDepth: number;
  52470. /**
  52471. * Gets the number of array elements
  52472. */
  52473. numberOfArrayElements: number;
  52474. /**
  52475. * Gets the number of faces
  52476. */
  52477. numberOfFaces: number;
  52478. /**
  52479. * Gets the number of mipmap levels
  52480. */
  52481. numberOfMipmapLevels: number;
  52482. /**
  52483. * Gets the bytes of key value data
  52484. */
  52485. bytesOfKeyValueData: number;
  52486. /**
  52487. * Gets the load type
  52488. */
  52489. loadType: number;
  52490. /**
  52491. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52492. */
  52493. isInvalid: boolean;
  52494. /**
  52495. * Creates a new KhronosTextureContainer
  52496. * @param data contents of the KTX container file
  52497. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52498. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52499. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52500. */
  52501. constructor(
  52502. /** contents of the KTX container file */
  52503. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52504. /**
  52505. * Uploads KTX content to a Babylon Texture.
  52506. * It is assumed that the texture has already been created & is currently bound
  52507. * @hidden
  52508. */
  52509. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52510. private _upload2DCompressedLevels;
  52511. /**
  52512. * Checks if the given data starts with a KTX file identifier.
  52513. * @param data the data to check
  52514. * @returns true if the data is a KTX file or false otherwise
  52515. */
  52516. static IsValid(data: ArrayBufferView): boolean;
  52517. }
  52518. }
  52519. declare module BABYLON {
  52520. /**
  52521. * Class for loading KTX2 files
  52522. * !!! Experimental Extension Subject to Changes !!!
  52523. * @hidden
  52524. */
  52525. export class KhronosTextureContainer2 {
  52526. private static _ModulePromise;
  52527. private static _TranscodeFormat;
  52528. constructor(engine: ThinEngine);
  52529. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52530. private _determineTranscodeFormat;
  52531. /**
  52532. * Checks if the given data starts with a KTX2 file identifier.
  52533. * @param data the data to check
  52534. * @returns true if the data is a KTX2 file or false otherwise
  52535. */
  52536. static IsValid(data: ArrayBufferView): boolean;
  52537. }
  52538. }
  52539. declare module BABYLON {
  52540. /**
  52541. * Implementation of the KTX Texture Loader.
  52542. * @hidden
  52543. */
  52544. export class _KTXTextureLoader implements IInternalTextureLoader {
  52545. /**
  52546. * Defines wether the loader supports cascade loading the different faces.
  52547. */
  52548. readonly supportCascades: boolean;
  52549. /**
  52550. * This returns if the loader support the current file information.
  52551. * @param extension defines the file extension of the file being loaded
  52552. * @returns true if the loader can load the specified file
  52553. */
  52554. canLoad(extension: string): boolean;
  52555. /**
  52556. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52557. * @param data contains the texture data
  52558. * @param texture defines the BabylonJS internal texture
  52559. * @param createPolynomials will be true if polynomials have been requested
  52560. * @param onLoad defines the callback to trigger once the texture is ready
  52561. * @param onError defines the callback to trigger in case of error
  52562. */
  52563. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52564. /**
  52565. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52566. * @param data contains the texture data
  52567. * @param texture defines the BabylonJS internal texture
  52568. * @param callback defines the method to call once ready to upload
  52569. */
  52570. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52571. }
  52572. }
  52573. declare module BABYLON {
  52574. /** @hidden */
  52575. export var _forceSceneHelpersToBundle: boolean;
  52576. interface Scene {
  52577. /**
  52578. * Creates a default light for the scene.
  52579. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52580. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52581. */
  52582. createDefaultLight(replace?: boolean): void;
  52583. /**
  52584. * Creates a default camera for the scene.
  52585. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52586. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52587. * @param replace has default false, when true replaces the active camera in the scene
  52588. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52589. */
  52590. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52591. /**
  52592. * Creates a default camera and a default light.
  52593. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52594. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52595. * @param replace has the default false, when true replaces the active camera/light in the scene
  52596. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52597. */
  52598. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52599. /**
  52600. * Creates a new sky box
  52601. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52602. * @param environmentTexture defines the texture to use as environment texture
  52603. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52604. * @param scale defines the overall scale of the skybox
  52605. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52606. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52607. * @returns a new mesh holding the sky box
  52608. */
  52609. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52610. /**
  52611. * Creates a new environment
  52612. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52613. * @param options defines the options you can use to configure the environment
  52614. * @returns the new EnvironmentHelper
  52615. */
  52616. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52617. /**
  52618. * Creates a new VREXperienceHelper
  52619. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52620. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52621. * @returns a new VREXperienceHelper
  52622. */
  52623. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52624. /**
  52625. * Creates a new WebXRDefaultExperience
  52626. * @see http://doc.babylonjs.com/how_to/webxr
  52627. * @param options experience options
  52628. * @returns a promise for a new WebXRDefaultExperience
  52629. */
  52630. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52631. }
  52632. }
  52633. declare module BABYLON {
  52634. /**
  52635. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52636. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52637. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52638. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52639. */
  52640. export class VideoDome extends TransformNode {
  52641. /**
  52642. * Define the video source as a Monoscopic panoramic 360 video.
  52643. */
  52644. static readonly MODE_MONOSCOPIC: number;
  52645. /**
  52646. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52647. */
  52648. static readonly MODE_TOPBOTTOM: number;
  52649. /**
  52650. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52651. */
  52652. static readonly MODE_SIDEBYSIDE: number;
  52653. private _halfDome;
  52654. private _useDirectMapping;
  52655. /**
  52656. * The video texture being displayed on the sphere
  52657. */
  52658. protected _videoTexture: VideoTexture;
  52659. /**
  52660. * Gets the video texture being displayed on the sphere
  52661. */
  52662. get videoTexture(): VideoTexture;
  52663. /**
  52664. * The skybox material
  52665. */
  52666. protected _material: BackgroundMaterial;
  52667. /**
  52668. * The surface used for the skybox
  52669. */
  52670. protected _mesh: Mesh;
  52671. /**
  52672. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52673. */
  52674. private _halfDomeMask;
  52675. /**
  52676. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52677. * Also see the options.resolution property.
  52678. */
  52679. get fovMultiplier(): number;
  52680. set fovMultiplier(value: number);
  52681. private _videoMode;
  52682. /**
  52683. * Gets or set the current video mode for the video. It can be:
  52684. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52685. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52686. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52687. */
  52688. get videoMode(): number;
  52689. set videoMode(value: number);
  52690. /**
  52691. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52692. *
  52693. */
  52694. get halfDome(): boolean;
  52695. /**
  52696. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52697. */
  52698. set halfDome(enabled: boolean);
  52699. /**
  52700. * Oberserver used in Stereoscopic VR Mode.
  52701. */
  52702. private _onBeforeCameraRenderObserver;
  52703. /**
  52704. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52705. * @param name Element's name, child elements will append suffixes for their own names.
  52706. * @param urlsOrVideo defines the url(s) or the video element to use
  52707. * @param options An object containing optional or exposed sub element properties
  52708. */
  52709. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52710. resolution?: number;
  52711. clickToPlay?: boolean;
  52712. autoPlay?: boolean;
  52713. loop?: boolean;
  52714. size?: number;
  52715. poster?: string;
  52716. faceForward?: boolean;
  52717. useDirectMapping?: boolean;
  52718. halfDomeMode?: boolean;
  52719. }, scene: Scene);
  52720. private _changeVideoMode;
  52721. /**
  52722. * Releases resources associated with this node.
  52723. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52724. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52725. */
  52726. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52727. }
  52728. }
  52729. declare module BABYLON {
  52730. /**
  52731. * This class can be used to get instrumentation data from a Babylon engine
  52732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52733. */
  52734. export class EngineInstrumentation implements IDisposable {
  52735. /**
  52736. * Define the instrumented engine.
  52737. */
  52738. engine: Engine;
  52739. private _captureGPUFrameTime;
  52740. private _gpuFrameTimeToken;
  52741. private _gpuFrameTime;
  52742. private _captureShaderCompilationTime;
  52743. private _shaderCompilationTime;
  52744. private _onBeginFrameObserver;
  52745. private _onEndFrameObserver;
  52746. private _onBeforeShaderCompilationObserver;
  52747. private _onAfterShaderCompilationObserver;
  52748. /**
  52749. * Gets the perf counter used for GPU frame time
  52750. */
  52751. get gpuFrameTimeCounter(): PerfCounter;
  52752. /**
  52753. * Gets the GPU frame time capture status
  52754. */
  52755. get captureGPUFrameTime(): boolean;
  52756. /**
  52757. * Enable or disable the GPU frame time capture
  52758. */
  52759. set captureGPUFrameTime(value: boolean);
  52760. /**
  52761. * Gets the perf counter used for shader compilation time
  52762. */
  52763. get shaderCompilationTimeCounter(): PerfCounter;
  52764. /**
  52765. * Gets the shader compilation time capture status
  52766. */
  52767. get captureShaderCompilationTime(): boolean;
  52768. /**
  52769. * Enable or disable the shader compilation time capture
  52770. */
  52771. set captureShaderCompilationTime(value: boolean);
  52772. /**
  52773. * Instantiates a new engine instrumentation.
  52774. * This class can be used to get instrumentation data from a Babylon engine
  52775. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52776. * @param engine Defines the engine to instrument
  52777. */
  52778. constructor(
  52779. /**
  52780. * Define the instrumented engine.
  52781. */
  52782. engine: Engine);
  52783. /**
  52784. * Dispose and release associated resources.
  52785. */
  52786. dispose(): void;
  52787. }
  52788. }
  52789. declare module BABYLON {
  52790. /**
  52791. * This class can be used to get instrumentation data from a Babylon engine
  52792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52793. */
  52794. export class SceneInstrumentation implements IDisposable {
  52795. /**
  52796. * Defines the scene to instrument
  52797. */
  52798. scene: Scene;
  52799. private _captureActiveMeshesEvaluationTime;
  52800. private _activeMeshesEvaluationTime;
  52801. private _captureRenderTargetsRenderTime;
  52802. private _renderTargetsRenderTime;
  52803. private _captureFrameTime;
  52804. private _frameTime;
  52805. private _captureRenderTime;
  52806. private _renderTime;
  52807. private _captureInterFrameTime;
  52808. private _interFrameTime;
  52809. private _captureParticlesRenderTime;
  52810. private _particlesRenderTime;
  52811. private _captureSpritesRenderTime;
  52812. private _spritesRenderTime;
  52813. private _capturePhysicsTime;
  52814. private _physicsTime;
  52815. private _captureAnimationsTime;
  52816. private _animationsTime;
  52817. private _captureCameraRenderTime;
  52818. private _cameraRenderTime;
  52819. private _onBeforeActiveMeshesEvaluationObserver;
  52820. private _onAfterActiveMeshesEvaluationObserver;
  52821. private _onBeforeRenderTargetsRenderObserver;
  52822. private _onAfterRenderTargetsRenderObserver;
  52823. private _onAfterRenderObserver;
  52824. private _onBeforeDrawPhaseObserver;
  52825. private _onAfterDrawPhaseObserver;
  52826. private _onBeforeAnimationsObserver;
  52827. private _onBeforeParticlesRenderingObserver;
  52828. private _onAfterParticlesRenderingObserver;
  52829. private _onBeforeSpritesRenderingObserver;
  52830. private _onAfterSpritesRenderingObserver;
  52831. private _onBeforePhysicsObserver;
  52832. private _onAfterPhysicsObserver;
  52833. private _onAfterAnimationsObserver;
  52834. private _onBeforeCameraRenderObserver;
  52835. private _onAfterCameraRenderObserver;
  52836. /**
  52837. * Gets the perf counter used for active meshes evaluation time
  52838. */
  52839. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52840. /**
  52841. * Gets the active meshes evaluation time capture status
  52842. */
  52843. get captureActiveMeshesEvaluationTime(): boolean;
  52844. /**
  52845. * Enable or disable the active meshes evaluation time capture
  52846. */
  52847. set captureActiveMeshesEvaluationTime(value: boolean);
  52848. /**
  52849. * Gets the perf counter used for render targets render time
  52850. */
  52851. get renderTargetsRenderTimeCounter(): PerfCounter;
  52852. /**
  52853. * Gets the render targets render time capture status
  52854. */
  52855. get captureRenderTargetsRenderTime(): boolean;
  52856. /**
  52857. * Enable or disable the render targets render time capture
  52858. */
  52859. set captureRenderTargetsRenderTime(value: boolean);
  52860. /**
  52861. * Gets the perf counter used for particles render time
  52862. */
  52863. get particlesRenderTimeCounter(): PerfCounter;
  52864. /**
  52865. * Gets the particles render time capture status
  52866. */
  52867. get captureParticlesRenderTime(): boolean;
  52868. /**
  52869. * Enable or disable the particles render time capture
  52870. */
  52871. set captureParticlesRenderTime(value: boolean);
  52872. /**
  52873. * Gets the perf counter used for sprites render time
  52874. */
  52875. get spritesRenderTimeCounter(): PerfCounter;
  52876. /**
  52877. * Gets the sprites render time capture status
  52878. */
  52879. get captureSpritesRenderTime(): boolean;
  52880. /**
  52881. * Enable or disable the sprites render time capture
  52882. */
  52883. set captureSpritesRenderTime(value: boolean);
  52884. /**
  52885. * Gets the perf counter used for physics time
  52886. */
  52887. get physicsTimeCounter(): PerfCounter;
  52888. /**
  52889. * Gets the physics time capture status
  52890. */
  52891. get capturePhysicsTime(): boolean;
  52892. /**
  52893. * Enable or disable the physics time capture
  52894. */
  52895. set capturePhysicsTime(value: boolean);
  52896. /**
  52897. * Gets the perf counter used for animations time
  52898. */
  52899. get animationsTimeCounter(): PerfCounter;
  52900. /**
  52901. * Gets the animations time capture status
  52902. */
  52903. get captureAnimationsTime(): boolean;
  52904. /**
  52905. * Enable or disable the animations time capture
  52906. */
  52907. set captureAnimationsTime(value: boolean);
  52908. /**
  52909. * Gets the perf counter used for frame time capture
  52910. */
  52911. get frameTimeCounter(): PerfCounter;
  52912. /**
  52913. * Gets the frame time capture status
  52914. */
  52915. get captureFrameTime(): boolean;
  52916. /**
  52917. * Enable or disable the frame time capture
  52918. */
  52919. set captureFrameTime(value: boolean);
  52920. /**
  52921. * Gets the perf counter used for inter-frames time capture
  52922. */
  52923. get interFrameTimeCounter(): PerfCounter;
  52924. /**
  52925. * Gets the inter-frames time capture status
  52926. */
  52927. get captureInterFrameTime(): boolean;
  52928. /**
  52929. * Enable or disable the inter-frames time capture
  52930. */
  52931. set captureInterFrameTime(value: boolean);
  52932. /**
  52933. * Gets the perf counter used for render time capture
  52934. */
  52935. get renderTimeCounter(): PerfCounter;
  52936. /**
  52937. * Gets the render time capture status
  52938. */
  52939. get captureRenderTime(): boolean;
  52940. /**
  52941. * Enable or disable the render time capture
  52942. */
  52943. set captureRenderTime(value: boolean);
  52944. /**
  52945. * Gets the perf counter used for camera render time capture
  52946. */
  52947. get cameraRenderTimeCounter(): PerfCounter;
  52948. /**
  52949. * Gets the camera render time capture status
  52950. */
  52951. get captureCameraRenderTime(): boolean;
  52952. /**
  52953. * Enable or disable the camera render time capture
  52954. */
  52955. set captureCameraRenderTime(value: boolean);
  52956. /**
  52957. * Gets the perf counter used for draw calls
  52958. */
  52959. get drawCallsCounter(): PerfCounter;
  52960. /**
  52961. * Instantiates a new scene instrumentation.
  52962. * This class can be used to get instrumentation data from a Babylon engine
  52963. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52964. * @param scene Defines the scene to instrument
  52965. */
  52966. constructor(
  52967. /**
  52968. * Defines the scene to instrument
  52969. */
  52970. scene: Scene);
  52971. /**
  52972. * Dispose and release associated resources.
  52973. */
  52974. dispose(): void;
  52975. }
  52976. }
  52977. declare module BABYLON {
  52978. /** @hidden */
  52979. export var glowMapGenerationPixelShader: {
  52980. name: string;
  52981. shader: string;
  52982. };
  52983. }
  52984. declare module BABYLON {
  52985. /** @hidden */
  52986. export var glowMapGenerationVertexShader: {
  52987. name: string;
  52988. shader: string;
  52989. };
  52990. }
  52991. declare module BABYLON {
  52992. /**
  52993. * Effect layer options. This helps customizing the behaviour
  52994. * of the effect layer.
  52995. */
  52996. export interface IEffectLayerOptions {
  52997. /**
  52998. * Multiplication factor apply to the canvas size to compute the render target size
  52999. * used to generated the objects (the smaller the faster).
  53000. */
  53001. mainTextureRatio: number;
  53002. /**
  53003. * Enforces a fixed size texture to ensure effect stability across devices.
  53004. */
  53005. mainTextureFixedSize?: number;
  53006. /**
  53007. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53008. */
  53009. alphaBlendingMode: number;
  53010. /**
  53011. * The camera attached to the layer.
  53012. */
  53013. camera: Nullable<Camera>;
  53014. /**
  53015. * The rendering group to draw the layer in.
  53016. */
  53017. renderingGroupId: number;
  53018. }
  53019. /**
  53020. * The effect layer Helps adding post process effect blended with the main pass.
  53021. *
  53022. * This can be for instance use to generate glow or higlight effects on the scene.
  53023. *
  53024. * The effect layer class can not be used directly and is intented to inherited from to be
  53025. * customized per effects.
  53026. */
  53027. export abstract class EffectLayer {
  53028. private _vertexBuffers;
  53029. private _indexBuffer;
  53030. private _cachedDefines;
  53031. private _effectLayerMapGenerationEffect;
  53032. private _effectLayerOptions;
  53033. private _mergeEffect;
  53034. protected _scene: Scene;
  53035. protected _engine: Engine;
  53036. protected _maxSize: number;
  53037. protected _mainTextureDesiredSize: ISize;
  53038. protected _mainTexture: RenderTargetTexture;
  53039. protected _shouldRender: boolean;
  53040. protected _postProcesses: PostProcess[];
  53041. protected _textures: BaseTexture[];
  53042. protected _emissiveTextureAndColor: {
  53043. texture: Nullable<BaseTexture>;
  53044. color: Color4;
  53045. };
  53046. /**
  53047. * The name of the layer
  53048. */
  53049. name: string;
  53050. /**
  53051. * The clear color of the texture used to generate the glow map.
  53052. */
  53053. neutralColor: Color4;
  53054. /**
  53055. * Specifies whether the highlight layer is enabled or not.
  53056. */
  53057. isEnabled: boolean;
  53058. /**
  53059. * Gets the camera attached to the layer.
  53060. */
  53061. get camera(): Nullable<Camera>;
  53062. /**
  53063. * Gets the rendering group id the layer should render in.
  53064. */
  53065. get renderingGroupId(): number;
  53066. set renderingGroupId(renderingGroupId: number);
  53067. /**
  53068. * An event triggered when the effect layer has been disposed.
  53069. */
  53070. onDisposeObservable: Observable<EffectLayer>;
  53071. /**
  53072. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53073. */
  53074. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53075. /**
  53076. * An event triggered when the generated texture is being merged in the scene.
  53077. */
  53078. onBeforeComposeObservable: Observable<EffectLayer>;
  53079. /**
  53080. * An event triggered when the mesh is rendered into the effect render target.
  53081. */
  53082. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53083. /**
  53084. * An event triggered after the mesh has been rendered into the effect render target.
  53085. */
  53086. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53087. /**
  53088. * An event triggered when the generated texture has been merged in the scene.
  53089. */
  53090. onAfterComposeObservable: Observable<EffectLayer>;
  53091. /**
  53092. * An event triggered when the efffect layer changes its size.
  53093. */
  53094. onSizeChangedObservable: Observable<EffectLayer>;
  53095. /** @hidden */
  53096. static _SceneComponentInitialization: (scene: Scene) => void;
  53097. /**
  53098. * Instantiates a new effect Layer and references it in the scene.
  53099. * @param name The name of the layer
  53100. * @param scene The scene to use the layer in
  53101. */
  53102. constructor(
  53103. /** The Friendly of the effect in the scene */
  53104. name: string, scene: Scene);
  53105. /**
  53106. * Get the effect name of the layer.
  53107. * @return The effect name
  53108. */
  53109. abstract getEffectName(): string;
  53110. /**
  53111. * Checks for the readiness of the element composing the layer.
  53112. * @param subMesh the mesh to check for
  53113. * @param useInstances specify whether or not to use instances to render the mesh
  53114. * @return true if ready otherwise, false
  53115. */
  53116. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53117. /**
  53118. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53119. * @returns true if the effect requires stencil during the main canvas render pass.
  53120. */
  53121. abstract needStencil(): boolean;
  53122. /**
  53123. * Create the merge effect. This is the shader use to blit the information back
  53124. * to the main canvas at the end of the scene rendering.
  53125. * @returns The effect containing the shader used to merge the effect on the main canvas
  53126. */
  53127. protected abstract _createMergeEffect(): Effect;
  53128. /**
  53129. * Creates the render target textures and post processes used in the effect layer.
  53130. */
  53131. protected abstract _createTextureAndPostProcesses(): void;
  53132. /**
  53133. * Implementation specific of rendering the generating effect on the main canvas.
  53134. * @param effect The effect used to render through
  53135. */
  53136. protected abstract _internalRender(effect: Effect): void;
  53137. /**
  53138. * Sets the required values for both the emissive texture and and the main color.
  53139. */
  53140. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53141. /**
  53142. * Free any resources and references associated to a mesh.
  53143. * Internal use
  53144. * @param mesh The mesh to free.
  53145. */
  53146. abstract _disposeMesh(mesh: Mesh): void;
  53147. /**
  53148. * Serializes this layer (Glow or Highlight for example)
  53149. * @returns a serialized layer object
  53150. */
  53151. abstract serialize?(): any;
  53152. /**
  53153. * Initializes the effect layer with the required options.
  53154. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53155. */
  53156. protected _init(options: Partial<IEffectLayerOptions>): void;
  53157. /**
  53158. * Generates the index buffer of the full screen quad blending to the main canvas.
  53159. */
  53160. private _generateIndexBuffer;
  53161. /**
  53162. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53163. */
  53164. private _generateVertexBuffer;
  53165. /**
  53166. * Sets the main texture desired size which is the closest power of two
  53167. * of the engine canvas size.
  53168. */
  53169. private _setMainTextureSize;
  53170. /**
  53171. * Creates the main texture for the effect layer.
  53172. */
  53173. protected _createMainTexture(): void;
  53174. /**
  53175. * Adds specific effects defines.
  53176. * @param defines The defines to add specifics to.
  53177. */
  53178. protected _addCustomEffectDefines(defines: string[]): void;
  53179. /**
  53180. * Checks for the readiness of the element composing the layer.
  53181. * @param subMesh the mesh to check for
  53182. * @param useInstances specify whether or not to use instances to render the mesh
  53183. * @param emissiveTexture the associated emissive texture used to generate the glow
  53184. * @return true if ready otherwise, false
  53185. */
  53186. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53187. /**
  53188. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53189. */
  53190. render(): void;
  53191. /**
  53192. * Determine if a given mesh will be used in the current effect.
  53193. * @param mesh mesh to test
  53194. * @returns true if the mesh will be used
  53195. */
  53196. hasMesh(mesh: AbstractMesh): boolean;
  53197. /**
  53198. * Returns true if the layer contains information to display, otherwise false.
  53199. * @returns true if the glow layer should be rendered
  53200. */
  53201. shouldRender(): boolean;
  53202. /**
  53203. * Returns true if the mesh should render, otherwise false.
  53204. * @param mesh The mesh to render
  53205. * @returns true if it should render otherwise false
  53206. */
  53207. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53208. /**
  53209. * Returns true if the mesh can be rendered, otherwise false.
  53210. * @param mesh The mesh to render
  53211. * @param material The material used on the mesh
  53212. * @returns true if it can be rendered otherwise false
  53213. */
  53214. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53215. /**
  53216. * Returns true if the mesh should render, otherwise false.
  53217. * @param mesh The mesh to render
  53218. * @returns true if it should render otherwise false
  53219. */
  53220. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53221. /**
  53222. * Renders the submesh passed in parameter to the generation map.
  53223. */
  53224. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53225. /**
  53226. * Defines whether the current material of the mesh should be use to render the effect.
  53227. * @param mesh defines the current mesh to render
  53228. */
  53229. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53230. /**
  53231. * Rebuild the required buffers.
  53232. * @hidden Internal use only.
  53233. */
  53234. _rebuild(): void;
  53235. /**
  53236. * Dispose only the render target textures and post process.
  53237. */
  53238. private _disposeTextureAndPostProcesses;
  53239. /**
  53240. * Dispose the highlight layer and free resources.
  53241. */
  53242. dispose(): void;
  53243. /**
  53244. * Gets the class name of the effect layer
  53245. * @returns the string with the class name of the effect layer
  53246. */
  53247. getClassName(): string;
  53248. /**
  53249. * Creates an effect layer from parsed effect layer data
  53250. * @param parsedEffectLayer defines effect layer data
  53251. * @param scene defines the current scene
  53252. * @param rootUrl defines the root URL containing the effect layer information
  53253. * @returns a parsed effect Layer
  53254. */
  53255. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53256. }
  53257. }
  53258. declare module BABYLON {
  53259. interface AbstractScene {
  53260. /**
  53261. * The list of effect layers (highlights/glow) added to the scene
  53262. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53263. * @see http://doc.babylonjs.com/how_to/glow_layer
  53264. */
  53265. effectLayers: Array<EffectLayer>;
  53266. /**
  53267. * Removes the given effect layer from this scene.
  53268. * @param toRemove defines the effect layer to remove
  53269. * @returns the index of the removed effect layer
  53270. */
  53271. removeEffectLayer(toRemove: EffectLayer): number;
  53272. /**
  53273. * Adds the given effect layer to this scene
  53274. * @param newEffectLayer defines the effect layer to add
  53275. */
  53276. addEffectLayer(newEffectLayer: EffectLayer): void;
  53277. }
  53278. /**
  53279. * Defines the layer scene component responsible to manage any effect layers
  53280. * in a given scene.
  53281. */
  53282. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53283. /**
  53284. * The component name helpfull to identify the component in the list of scene components.
  53285. */
  53286. readonly name: string;
  53287. /**
  53288. * The scene the component belongs to.
  53289. */
  53290. scene: Scene;
  53291. private _engine;
  53292. private _renderEffects;
  53293. private _needStencil;
  53294. private _previousStencilState;
  53295. /**
  53296. * Creates a new instance of the component for the given scene
  53297. * @param scene Defines the scene to register the component in
  53298. */
  53299. constructor(scene: Scene);
  53300. /**
  53301. * Registers the component in a given scene
  53302. */
  53303. register(): void;
  53304. /**
  53305. * Rebuilds the elements related to this component in case of
  53306. * context lost for instance.
  53307. */
  53308. rebuild(): void;
  53309. /**
  53310. * Serializes the component data to the specified json object
  53311. * @param serializationObject The object to serialize to
  53312. */
  53313. serialize(serializationObject: any): void;
  53314. /**
  53315. * Adds all the elements from the container to the scene
  53316. * @param container the container holding the elements
  53317. */
  53318. addFromContainer(container: AbstractScene): void;
  53319. /**
  53320. * Removes all the elements in the container from the scene
  53321. * @param container contains the elements to remove
  53322. * @param dispose if the removed element should be disposed (default: false)
  53323. */
  53324. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53325. /**
  53326. * Disposes the component and the associated ressources.
  53327. */
  53328. dispose(): void;
  53329. private _isReadyForMesh;
  53330. private _renderMainTexture;
  53331. private _setStencil;
  53332. private _setStencilBack;
  53333. private _draw;
  53334. private _drawCamera;
  53335. private _drawRenderingGroup;
  53336. }
  53337. }
  53338. declare module BABYLON {
  53339. /** @hidden */
  53340. export var glowMapMergePixelShader: {
  53341. name: string;
  53342. shader: string;
  53343. };
  53344. }
  53345. declare module BABYLON {
  53346. /** @hidden */
  53347. export var glowMapMergeVertexShader: {
  53348. name: string;
  53349. shader: string;
  53350. };
  53351. }
  53352. declare module BABYLON {
  53353. interface AbstractScene {
  53354. /**
  53355. * Return a the first highlight layer of the scene with a given name.
  53356. * @param name The name of the highlight layer to look for.
  53357. * @return The highlight layer if found otherwise null.
  53358. */
  53359. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53360. }
  53361. /**
  53362. * Glow layer options. This helps customizing the behaviour
  53363. * of the glow layer.
  53364. */
  53365. export interface IGlowLayerOptions {
  53366. /**
  53367. * Multiplication factor apply to the canvas size to compute the render target size
  53368. * used to generated the glowing objects (the smaller the faster).
  53369. */
  53370. mainTextureRatio: number;
  53371. /**
  53372. * Enforces a fixed size texture to ensure resize independant blur.
  53373. */
  53374. mainTextureFixedSize?: number;
  53375. /**
  53376. * How big is the kernel of the blur texture.
  53377. */
  53378. blurKernelSize: number;
  53379. /**
  53380. * The camera attached to the layer.
  53381. */
  53382. camera: Nullable<Camera>;
  53383. /**
  53384. * Enable MSAA by chosing the number of samples.
  53385. */
  53386. mainTextureSamples?: number;
  53387. /**
  53388. * The rendering group to draw the layer in.
  53389. */
  53390. renderingGroupId: number;
  53391. }
  53392. /**
  53393. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53394. *
  53395. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53396. *
  53397. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53398. */
  53399. export class GlowLayer extends EffectLayer {
  53400. /**
  53401. * Effect Name of the layer.
  53402. */
  53403. static readonly EffectName: string;
  53404. /**
  53405. * The default blur kernel size used for the glow.
  53406. */
  53407. static DefaultBlurKernelSize: number;
  53408. /**
  53409. * The default texture size ratio used for the glow.
  53410. */
  53411. static DefaultTextureRatio: number;
  53412. /**
  53413. * Sets the kernel size of the blur.
  53414. */
  53415. set blurKernelSize(value: number);
  53416. /**
  53417. * Gets the kernel size of the blur.
  53418. */
  53419. get blurKernelSize(): number;
  53420. /**
  53421. * Sets the glow intensity.
  53422. */
  53423. set intensity(value: number);
  53424. /**
  53425. * Gets the glow intensity.
  53426. */
  53427. get intensity(): number;
  53428. private _options;
  53429. private _intensity;
  53430. private _horizontalBlurPostprocess1;
  53431. private _verticalBlurPostprocess1;
  53432. private _horizontalBlurPostprocess2;
  53433. private _verticalBlurPostprocess2;
  53434. private _blurTexture1;
  53435. private _blurTexture2;
  53436. private _postProcesses1;
  53437. private _postProcesses2;
  53438. private _includedOnlyMeshes;
  53439. private _excludedMeshes;
  53440. private _meshesUsingTheirOwnMaterials;
  53441. /**
  53442. * Callback used to let the user override the color selection on a per mesh basis
  53443. */
  53444. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53445. /**
  53446. * Callback used to let the user override the texture selection on a per mesh basis
  53447. */
  53448. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53449. /**
  53450. * Instantiates a new glow Layer and references it to the scene.
  53451. * @param name The name of the layer
  53452. * @param scene The scene to use the layer in
  53453. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53454. */
  53455. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53456. /**
  53457. * Get the effect name of the layer.
  53458. * @return The effect name
  53459. */
  53460. getEffectName(): string;
  53461. /**
  53462. * Create the merge effect. This is the shader use to blit the information back
  53463. * to the main canvas at the end of the scene rendering.
  53464. */
  53465. protected _createMergeEffect(): Effect;
  53466. /**
  53467. * Creates the render target textures and post processes used in the glow layer.
  53468. */
  53469. protected _createTextureAndPostProcesses(): void;
  53470. /**
  53471. * Checks for the readiness of the element composing the layer.
  53472. * @param subMesh the mesh to check for
  53473. * @param useInstances specify wether or not to use instances to render the mesh
  53474. * @param emissiveTexture the associated emissive texture used to generate the glow
  53475. * @return true if ready otherwise, false
  53476. */
  53477. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53478. /**
  53479. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53480. */
  53481. needStencil(): boolean;
  53482. /**
  53483. * Returns true if the mesh can be rendered, otherwise false.
  53484. * @param mesh The mesh to render
  53485. * @param material The material used on the mesh
  53486. * @returns true if it can be rendered otherwise false
  53487. */
  53488. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53489. /**
  53490. * Implementation specific of rendering the generating effect on the main canvas.
  53491. * @param effect The effect used to render through
  53492. */
  53493. protected _internalRender(effect: Effect): void;
  53494. /**
  53495. * Sets the required values for both the emissive texture and and the main color.
  53496. */
  53497. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53498. /**
  53499. * Returns true if the mesh should render, otherwise false.
  53500. * @param mesh The mesh to render
  53501. * @returns true if it should render otherwise false
  53502. */
  53503. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53504. /**
  53505. * Adds specific effects defines.
  53506. * @param defines The defines to add specifics to.
  53507. */
  53508. protected _addCustomEffectDefines(defines: string[]): void;
  53509. /**
  53510. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53511. * @param mesh The mesh to exclude from the glow layer
  53512. */
  53513. addExcludedMesh(mesh: Mesh): void;
  53514. /**
  53515. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53516. * @param mesh The mesh to remove
  53517. */
  53518. removeExcludedMesh(mesh: Mesh): void;
  53519. /**
  53520. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53521. * @param mesh The mesh to include in the glow layer
  53522. */
  53523. addIncludedOnlyMesh(mesh: Mesh): void;
  53524. /**
  53525. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53526. * @param mesh The mesh to remove
  53527. */
  53528. removeIncludedOnlyMesh(mesh: Mesh): void;
  53529. /**
  53530. * Determine if a given mesh will be used in the glow layer
  53531. * @param mesh The mesh to test
  53532. * @returns true if the mesh will be highlighted by the current glow layer
  53533. */
  53534. hasMesh(mesh: AbstractMesh): boolean;
  53535. /**
  53536. * Defines whether the current material of the mesh should be use to render the effect.
  53537. * @param mesh defines the current mesh to render
  53538. */
  53539. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53540. /**
  53541. * Add a mesh to be rendered through its own material and not with emissive only.
  53542. * @param mesh The mesh for which we need to use its material
  53543. */
  53544. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53545. /**
  53546. * Remove a mesh from being rendered through its own material and not with emissive only.
  53547. * @param mesh The mesh for which we need to not use its material
  53548. */
  53549. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53550. /**
  53551. * Free any resources and references associated to a mesh.
  53552. * Internal use
  53553. * @param mesh The mesh to free.
  53554. * @hidden
  53555. */
  53556. _disposeMesh(mesh: Mesh): void;
  53557. /**
  53558. * Gets the class name of the effect layer
  53559. * @returns the string with the class name of the effect layer
  53560. */
  53561. getClassName(): string;
  53562. /**
  53563. * Serializes this glow layer
  53564. * @returns a serialized glow layer object
  53565. */
  53566. serialize(): any;
  53567. /**
  53568. * Creates a Glow Layer from parsed glow layer data
  53569. * @param parsedGlowLayer defines glow layer data
  53570. * @param scene defines the current scene
  53571. * @param rootUrl defines the root URL containing the glow layer information
  53572. * @returns a parsed Glow Layer
  53573. */
  53574. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53575. }
  53576. }
  53577. declare module BABYLON {
  53578. /** @hidden */
  53579. export var glowBlurPostProcessPixelShader: {
  53580. name: string;
  53581. shader: string;
  53582. };
  53583. }
  53584. declare module BABYLON {
  53585. interface AbstractScene {
  53586. /**
  53587. * Return a the first highlight layer of the scene with a given name.
  53588. * @param name The name of the highlight layer to look for.
  53589. * @return The highlight layer if found otherwise null.
  53590. */
  53591. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53592. }
  53593. /**
  53594. * Highlight layer options. This helps customizing the behaviour
  53595. * of the highlight layer.
  53596. */
  53597. export interface IHighlightLayerOptions {
  53598. /**
  53599. * Multiplication factor apply to the canvas size to compute the render target size
  53600. * used to generated the glowing objects (the smaller the faster).
  53601. */
  53602. mainTextureRatio: number;
  53603. /**
  53604. * Enforces a fixed size texture to ensure resize independant blur.
  53605. */
  53606. mainTextureFixedSize?: number;
  53607. /**
  53608. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53609. * of the picture to blur (the smaller the faster).
  53610. */
  53611. blurTextureSizeRatio: number;
  53612. /**
  53613. * How big in texel of the blur texture is the vertical blur.
  53614. */
  53615. blurVerticalSize: number;
  53616. /**
  53617. * How big in texel of the blur texture is the horizontal blur.
  53618. */
  53619. blurHorizontalSize: number;
  53620. /**
  53621. * Alpha blending mode used to apply the blur. Default is combine.
  53622. */
  53623. alphaBlendingMode: number;
  53624. /**
  53625. * The camera attached to the layer.
  53626. */
  53627. camera: Nullable<Camera>;
  53628. /**
  53629. * Should we display highlight as a solid stroke?
  53630. */
  53631. isStroke?: boolean;
  53632. /**
  53633. * The rendering group to draw the layer in.
  53634. */
  53635. renderingGroupId: number;
  53636. }
  53637. /**
  53638. * The highlight layer Helps adding a glow effect around a mesh.
  53639. *
  53640. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53641. * glowy meshes to your scene.
  53642. *
  53643. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53644. */
  53645. export class HighlightLayer extends EffectLayer {
  53646. name: string;
  53647. /**
  53648. * Effect Name of the highlight layer.
  53649. */
  53650. static readonly EffectName: string;
  53651. /**
  53652. * The neutral color used during the preparation of the glow effect.
  53653. * This is black by default as the blend operation is a blend operation.
  53654. */
  53655. static NeutralColor: Color4;
  53656. /**
  53657. * Stencil value used for glowing meshes.
  53658. */
  53659. static GlowingMeshStencilReference: number;
  53660. /**
  53661. * Stencil value used for the other meshes in the scene.
  53662. */
  53663. static NormalMeshStencilReference: number;
  53664. /**
  53665. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53666. */
  53667. innerGlow: boolean;
  53668. /**
  53669. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53670. */
  53671. outerGlow: boolean;
  53672. /**
  53673. * Specifies the horizontal size of the blur.
  53674. */
  53675. set blurHorizontalSize(value: number);
  53676. /**
  53677. * Specifies the vertical size of the blur.
  53678. */
  53679. set blurVerticalSize(value: number);
  53680. /**
  53681. * Gets the horizontal size of the blur.
  53682. */
  53683. get blurHorizontalSize(): number;
  53684. /**
  53685. * Gets the vertical size of the blur.
  53686. */
  53687. get blurVerticalSize(): number;
  53688. /**
  53689. * An event triggered when the highlight layer is being blurred.
  53690. */
  53691. onBeforeBlurObservable: Observable<HighlightLayer>;
  53692. /**
  53693. * An event triggered when the highlight layer has been blurred.
  53694. */
  53695. onAfterBlurObservable: Observable<HighlightLayer>;
  53696. private _instanceGlowingMeshStencilReference;
  53697. private _options;
  53698. private _downSamplePostprocess;
  53699. private _horizontalBlurPostprocess;
  53700. private _verticalBlurPostprocess;
  53701. private _blurTexture;
  53702. private _meshes;
  53703. private _excludedMeshes;
  53704. /**
  53705. * Instantiates a new highlight 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 IHighlightLayerOptions for more information)
  53709. */
  53710. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  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 highlight layer.
  53723. */
  53724. protected _createTextureAndPostProcesses(): void;
  53725. /**
  53726. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53727. */
  53728. needStencil(): boolean;
  53729. /**
  53730. * Checks for the readiness of the element composing the layer.
  53731. * @param subMesh the mesh to check for
  53732. * @param useInstances specify wether or not to use instances to render the mesh
  53733. * @param emissiveTexture the associated emissive texture used to generate the glow
  53734. * @return true if ready otherwise, false
  53735. */
  53736. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53737. /**
  53738. * Implementation specific of rendering the generating effect on the main canvas.
  53739. * @param effect The effect used to render through
  53740. */
  53741. protected _internalRender(effect: Effect): void;
  53742. /**
  53743. * Returns true if the layer contains information to display, otherwise false.
  53744. */
  53745. shouldRender(): boolean;
  53746. /**
  53747. * Returns true if the mesh should render, otherwise false.
  53748. * @param mesh The mesh to render
  53749. * @returns true if it should render otherwise false
  53750. */
  53751. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53752. /**
  53753. * Sets the required values for both the emissive texture and and the main color.
  53754. */
  53755. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53756. /**
  53757. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53758. * @param mesh The mesh to exclude from the highlight layer
  53759. */
  53760. addExcludedMesh(mesh: Mesh): void;
  53761. /**
  53762. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53763. * @param mesh The mesh to highlight
  53764. */
  53765. removeExcludedMesh(mesh: Mesh): void;
  53766. /**
  53767. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53768. * @param mesh mesh to test
  53769. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53770. */
  53771. hasMesh(mesh: AbstractMesh): boolean;
  53772. /**
  53773. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53774. * @param mesh The mesh to highlight
  53775. * @param color The color of the highlight
  53776. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53777. */
  53778. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53779. /**
  53780. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53781. * @param mesh The mesh to highlight
  53782. */
  53783. removeMesh(mesh: Mesh): void;
  53784. /**
  53785. * Remove all the meshes currently referenced in the highlight layer
  53786. */
  53787. removeAllMeshes(): void;
  53788. /**
  53789. * Force the stencil to the normal expected value for none glowing parts
  53790. */
  53791. private _defaultStencilReference;
  53792. /**
  53793. * Free any resources and references associated to a mesh.
  53794. * Internal use
  53795. * @param mesh The mesh to free.
  53796. * @hidden
  53797. */
  53798. _disposeMesh(mesh: Mesh): void;
  53799. /**
  53800. * Dispose the highlight layer and free resources.
  53801. */
  53802. dispose(): void;
  53803. /**
  53804. * Gets the class name of the effect layer
  53805. * @returns the string with the class name of the effect layer
  53806. */
  53807. getClassName(): string;
  53808. /**
  53809. * Serializes this Highlight layer
  53810. * @returns a serialized Highlight layer object
  53811. */
  53812. serialize(): any;
  53813. /**
  53814. * Creates a Highlight layer from parsed Highlight layer data
  53815. * @param parsedHightlightLayer defines the Highlight layer data
  53816. * @param scene defines the current scene
  53817. * @param rootUrl defines the root URL containing the Highlight layer information
  53818. * @returns a parsed Highlight layer
  53819. */
  53820. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53821. }
  53822. }
  53823. declare module BABYLON {
  53824. interface AbstractScene {
  53825. /**
  53826. * The list of layers (background and foreground) of the scene
  53827. */
  53828. layers: Array<Layer>;
  53829. }
  53830. /**
  53831. * Defines the layer scene component responsible to manage any layers
  53832. * in a given scene.
  53833. */
  53834. export class LayerSceneComponent implements ISceneComponent {
  53835. /**
  53836. * The component name helpfull to identify the component in the list of scene components.
  53837. */
  53838. readonly name: string;
  53839. /**
  53840. * The scene the component belongs to.
  53841. */
  53842. scene: Scene;
  53843. private _engine;
  53844. /**
  53845. * Creates a new instance of the component for the given scene
  53846. * @param scene Defines the scene to register the component in
  53847. */
  53848. constructor(scene: Scene);
  53849. /**
  53850. * Registers the component in a given scene
  53851. */
  53852. register(): void;
  53853. /**
  53854. * Rebuilds the elements related to this component in case of
  53855. * context lost for instance.
  53856. */
  53857. rebuild(): void;
  53858. /**
  53859. * Disposes the component and the associated ressources.
  53860. */
  53861. dispose(): void;
  53862. private _draw;
  53863. private _drawCameraPredicate;
  53864. private _drawCameraBackground;
  53865. private _drawCameraForeground;
  53866. private _drawRenderTargetPredicate;
  53867. private _drawRenderTargetBackground;
  53868. private _drawRenderTargetForeground;
  53869. /**
  53870. * Adds all the elements from the container to the scene
  53871. * @param container the container holding the elements
  53872. */
  53873. addFromContainer(container: AbstractScene): void;
  53874. /**
  53875. * Removes all the elements in the container from the scene
  53876. * @param container contains the elements to remove
  53877. * @param dispose if the removed element should be disposed (default: false)
  53878. */
  53879. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53880. }
  53881. }
  53882. declare module BABYLON {
  53883. /** @hidden */
  53884. export var layerPixelShader: {
  53885. name: string;
  53886. shader: string;
  53887. };
  53888. }
  53889. declare module BABYLON {
  53890. /** @hidden */
  53891. export var layerVertexShader: {
  53892. name: string;
  53893. shader: string;
  53894. };
  53895. }
  53896. declare module BABYLON {
  53897. /**
  53898. * This represents a full screen 2d layer.
  53899. * This can be useful to display a picture in the background of your scene for instance.
  53900. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53901. */
  53902. export class Layer {
  53903. /**
  53904. * Define the name of the layer.
  53905. */
  53906. name: string;
  53907. /**
  53908. * Define the texture the layer should display.
  53909. */
  53910. texture: Nullable<Texture>;
  53911. /**
  53912. * Is the layer in background or foreground.
  53913. */
  53914. isBackground: boolean;
  53915. /**
  53916. * Define the color of the layer (instead of texture).
  53917. */
  53918. color: Color4;
  53919. /**
  53920. * Define the scale of the layer in order to zoom in out of the texture.
  53921. */
  53922. scale: Vector2;
  53923. /**
  53924. * Define an offset for the layer in order to shift the texture.
  53925. */
  53926. offset: Vector2;
  53927. /**
  53928. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53929. */
  53930. alphaBlendingMode: number;
  53931. /**
  53932. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53933. * Alpha test will not mix with the background color in case of transparency.
  53934. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53935. */
  53936. alphaTest: boolean;
  53937. /**
  53938. * Define a mask to restrict the layer to only some of the scene cameras.
  53939. */
  53940. layerMask: number;
  53941. /**
  53942. * Define the list of render target the layer is visible into.
  53943. */
  53944. renderTargetTextures: RenderTargetTexture[];
  53945. /**
  53946. * Define if the layer is only used in renderTarget or if it also
  53947. * renders in the main frame buffer of the canvas.
  53948. */
  53949. renderOnlyInRenderTargetTextures: boolean;
  53950. private _scene;
  53951. private _vertexBuffers;
  53952. private _indexBuffer;
  53953. private _effect;
  53954. private _previousDefines;
  53955. /**
  53956. * An event triggered when the layer is disposed.
  53957. */
  53958. onDisposeObservable: Observable<Layer>;
  53959. private _onDisposeObserver;
  53960. /**
  53961. * Back compatibility with callback before the onDisposeObservable existed.
  53962. * The set callback will be triggered when the layer has been disposed.
  53963. */
  53964. set onDispose(callback: () => void);
  53965. /**
  53966. * An event triggered before rendering the scene
  53967. */
  53968. onBeforeRenderObservable: Observable<Layer>;
  53969. private _onBeforeRenderObserver;
  53970. /**
  53971. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53972. * The set callback will be triggered just before rendering the layer.
  53973. */
  53974. set onBeforeRender(callback: () => void);
  53975. /**
  53976. * An event triggered after rendering the scene
  53977. */
  53978. onAfterRenderObservable: Observable<Layer>;
  53979. private _onAfterRenderObserver;
  53980. /**
  53981. * Back compatibility with callback before the onAfterRenderObservable existed.
  53982. * The set callback will be triggered just after rendering the layer.
  53983. */
  53984. set onAfterRender(callback: () => void);
  53985. /**
  53986. * Instantiates a new layer.
  53987. * This represents a full screen 2d layer.
  53988. * This can be useful to display a picture in the background of your scene for instance.
  53989. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53990. * @param name Define the name of the layer in the scene
  53991. * @param imgUrl Define the url of the texture to display in the layer
  53992. * @param scene Define the scene the layer belongs to
  53993. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53994. * @param color Defines a color for the layer
  53995. */
  53996. constructor(
  53997. /**
  53998. * Define the name of the layer.
  53999. */
  54000. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54001. private _createIndexBuffer;
  54002. /** @hidden */
  54003. _rebuild(): void;
  54004. /**
  54005. * Renders the layer in the scene.
  54006. */
  54007. render(): void;
  54008. /**
  54009. * Disposes and releases the associated ressources.
  54010. */
  54011. dispose(): void;
  54012. }
  54013. }
  54014. declare module BABYLON {
  54015. /** @hidden */
  54016. export var lensFlarePixelShader: {
  54017. name: string;
  54018. shader: string;
  54019. };
  54020. }
  54021. declare module BABYLON {
  54022. /** @hidden */
  54023. export var lensFlareVertexShader: {
  54024. name: string;
  54025. shader: string;
  54026. };
  54027. }
  54028. declare module BABYLON {
  54029. /**
  54030. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54031. * It is usually composed of several `lensFlare`.
  54032. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54033. */
  54034. export class LensFlareSystem {
  54035. /**
  54036. * Define the name of the lens flare system
  54037. */
  54038. name: string;
  54039. /**
  54040. * List of lens flares used in this system.
  54041. */
  54042. lensFlares: LensFlare[];
  54043. /**
  54044. * Define a limit from the border the lens flare can be visible.
  54045. */
  54046. borderLimit: number;
  54047. /**
  54048. * Define a viewport border we do not want to see the lens flare in.
  54049. */
  54050. viewportBorder: number;
  54051. /**
  54052. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54053. */
  54054. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54055. /**
  54056. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54057. */
  54058. layerMask: number;
  54059. /**
  54060. * Define the id of the lens flare system in the scene.
  54061. * (equal to name by default)
  54062. */
  54063. id: string;
  54064. private _scene;
  54065. private _emitter;
  54066. private _vertexBuffers;
  54067. private _indexBuffer;
  54068. private _effect;
  54069. private _positionX;
  54070. private _positionY;
  54071. private _isEnabled;
  54072. /** @hidden */
  54073. static _SceneComponentInitialization: (scene: Scene) => void;
  54074. /**
  54075. * Instantiates a lens flare system.
  54076. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54077. * It is usually composed of several `lensFlare`.
  54078. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54079. * @param name Define the name of the lens flare system in the scene
  54080. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54081. * @param scene Define the scene the lens flare system belongs to
  54082. */
  54083. constructor(
  54084. /**
  54085. * Define the name of the lens flare system
  54086. */
  54087. name: string, emitter: any, scene: Scene);
  54088. /**
  54089. * Define if the lens flare system is enabled.
  54090. */
  54091. get isEnabled(): boolean;
  54092. set isEnabled(value: boolean);
  54093. /**
  54094. * Get the scene the effects belongs to.
  54095. * @returns the scene holding the lens flare system
  54096. */
  54097. getScene(): Scene;
  54098. /**
  54099. * Get the emitter of the lens flare system.
  54100. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54101. * @returns the emitter of the lens flare system
  54102. */
  54103. getEmitter(): any;
  54104. /**
  54105. * Set the emitter of the lens flare system.
  54106. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54107. * @param newEmitter Define the new emitter of the system
  54108. */
  54109. setEmitter(newEmitter: any): void;
  54110. /**
  54111. * Get the lens flare system emitter position.
  54112. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54113. * @returns the position
  54114. */
  54115. getEmitterPosition(): Vector3;
  54116. /**
  54117. * @hidden
  54118. */
  54119. computeEffectivePosition(globalViewport: Viewport): boolean;
  54120. /** @hidden */
  54121. _isVisible(): boolean;
  54122. /**
  54123. * @hidden
  54124. */
  54125. render(): boolean;
  54126. /**
  54127. * Dispose and release the lens flare with its associated resources.
  54128. */
  54129. dispose(): void;
  54130. /**
  54131. * Parse a lens flare system from a JSON repressentation
  54132. * @param parsedLensFlareSystem Define the JSON to parse
  54133. * @param scene Define the scene the parsed system should be instantiated in
  54134. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54135. * @returns the parsed system
  54136. */
  54137. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54138. /**
  54139. * Serialize the current Lens Flare System into a JSON representation.
  54140. * @returns the serialized JSON
  54141. */
  54142. serialize(): any;
  54143. }
  54144. }
  54145. declare module BABYLON {
  54146. /**
  54147. * This represents one of the lens effect in a `lensFlareSystem`.
  54148. * It controls one of the indiviual texture used in the effect.
  54149. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54150. */
  54151. export class LensFlare {
  54152. /**
  54153. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54154. */
  54155. size: number;
  54156. /**
  54157. * 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.
  54158. */
  54159. position: number;
  54160. /**
  54161. * Define the lens color.
  54162. */
  54163. color: Color3;
  54164. /**
  54165. * Define the lens texture.
  54166. */
  54167. texture: Nullable<Texture>;
  54168. /**
  54169. * Define the alpha mode to render this particular lens.
  54170. */
  54171. alphaMode: number;
  54172. private _system;
  54173. /**
  54174. * Creates a new Lens Flare.
  54175. * This represents one of the lens effect in a `lensFlareSystem`.
  54176. * It controls one of the indiviual texture used in the effect.
  54177. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54178. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54179. * @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.
  54180. * @param color Define the lens color
  54181. * @param imgUrl Define the lens texture url
  54182. * @param system Define the `lensFlareSystem` this flare is part of
  54183. * @returns The newly created Lens Flare
  54184. */
  54185. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54186. /**
  54187. * Instantiates a new Lens Flare.
  54188. * This represents one of the lens effect in a `lensFlareSystem`.
  54189. * It controls one of the indiviual texture used in the effect.
  54190. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54191. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54192. * @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.
  54193. * @param color Define the lens color
  54194. * @param imgUrl Define the lens texture url
  54195. * @param system Define the `lensFlareSystem` this flare is part of
  54196. */
  54197. constructor(
  54198. /**
  54199. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54200. */
  54201. size: number,
  54202. /**
  54203. * 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.
  54204. */
  54205. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54206. /**
  54207. * Dispose and release the lens flare with its associated resources.
  54208. */
  54209. dispose(): void;
  54210. }
  54211. }
  54212. declare module BABYLON {
  54213. interface AbstractScene {
  54214. /**
  54215. * The list of lens flare system added to the scene
  54216. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54217. */
  54218. lensFlareSystems: Array<LensFlareSystem>;
  54219. /**
  54220. * Removes the given lens flare system from this scene.
  54221. * @param toRemove The lens flare system to remove
  54222. * @returns The index of the removed lens flare system
  54223. */
  54224. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54225. /**
  54226. * Adds the given lens flare system to this scene
  54227. * @param newLensFlareSystem The lens flare system to add
  54228. */
  54229. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54230. /**
  54231. * Gets a lens flare system using its name
  54232. * @param name defines the name to look for
  54233. * @returns the lens flare system or null if not found
  54234. */
  54235. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54236. /**
  54237. * Gets a lens flare system using its id
  54238. * @param id defines the id to look for
  54239. * @returns the lens flare system or null if not found
  54240. */
  54241. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54242. }
  54243. /**
  54244. * Defines the lens flare scene component responsible to manage any lens flares
  54245. * in a given scene.
  54246. */
  54247. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54248. /**
  54249. * The component name helpfull to identify the component in the list of scene components.
  54250. */
  54251. readonly name: string;
  54252. /**
  54253. * The scene the component belongs to.
  54254. */
  54255. scene: Scene;
  54256. /**
  54257. * Creates a new instance of the component for the given scene
  54258. * @param scene Defines the scene to register the component in
  54259. */
  54260. constructor(scene: Scene);
  54261. /**
  54262. * Registers the component in a given scene
  54263. */
  54264. register(): void;
  54265. /**
  54266. * Rebuilds the elements related to this component in case of
  54267. * context lost for instance.
  54268. */
  54269. rebuild(): void;
  54270. /**
  54271. * Adds all the elements from the container to the scene
  54272. * @param container the container holding the elements
  54273. */
  54274. addFromContainer(container: AbstractScene): void;
  54275. /**
  54276. * Removes all the elements in the container from the scene
  54277. * @param container contains the elements to remove
  54278. * @param dispose if the removed element should be disposed (default: false)
  54279. */
  54280. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54281. /**
  54282. * Serializes the component data to the specified json object
  54283. * @param serializationObject The object to serialize to
  54284. */
  54285. serialize(serializationObject: any): void;
  54286. /**
  54287. * Disposes the component and the associated ressources.
  54288. */
  54289. dispose(): void;
  54290. private _draw;
  54291. }
  54292. }
  54293. declare module BABYLON {
  54294. /** @hidden */
  54295. export var depthPixelShader: {
  54296. name: string;
  54297. shader: string;
  54298. };
  54299. }
  54300. declare module BABYLON {
  54301. /** @hidden */
  54302. export var depthVertexShader: {
  54303. name: string;
  54304. shader: string;
  54305. };
  54306. }
  54307. declare module BABYLON {
  54308. /**
  54309. * This represents a depth renderer in Babylon.
  54310. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54311. */
  54312. export class DepthRenderer {
  54313. private _scene;
  54314. private _depthMap;
  54315. private _effect;
  54316. private readonly _storeNonLinearDepth;
  54317. private readonly _clearColor;
  54318. /** Get if the depth renderer is using packed depth or not */
  54319. readonly isPacked: boolean;
  54320. private _cachedDefines;
  54321. private _camera;
  54322. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54323. enabled: boolean;
  54324. /**
  54325. * Specifiess that the depth renderer will only be used within
  54326. * the camera it is created for.
  54327. * This can help forcing its rendering during the camera processing.
  54328. */
  54329. useOnlyInActiveCamera: boolean;
  54330. /** @hidden */
  54331. static _SceneComponentInitialization: (scene: Scene) => void;
  54332. /**
  54333. * Instantiates a depth renderer
  54334. * @param scene The scene the renderer belongs to
  54335. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54336. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54337. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54338. */
  54339. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54340. /**
  54341. * Creates the depth rendering effect and checks if the effect is ready.
  54342. * @param subMesh The submesh to be used to render the depth map of
  54343. * @param useInstances If multiple world instances should be used
  54344. * @returns if the depth renderer is ready to render the depth map
  54345. */
  54346. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54347. /**
  54348. * Gets the texture which the depth map will be written to.
  54349. * @returns The depth map texture
  54350. */
  54351. getDepthMap(): RenderTargetTexture;
  54352. /**
  54353. * Disposes of the depth renderer.
  54354. */
  54355. dispose(): void;
  54356. }
  54357. }
  54358. declare module BABYLON {
  54359. /** @hidden */
  54360. export var minmaxReduxPixelShader: {
  54361. name: string;
  54362. shader: string;
  54363. };
  54364. }
  54365. declare module BABYLON {
  54366. /**
  54367. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54368. * and maximum values from all values of the texture.
  54369. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54370. * The source values are read from the red channel of the texture.
  54371. */
  54372. export class MinMaxReducer {
  54373. /**
  54374. * Observable triggered when the computation has been performed
  54375. */
  54376. onAfterReductionPerformed: Observable<{
  54377. min: number;
  54378. max: number;
  54379. }>;
  54380. protected _camera: Camera;
  54381. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54382. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54383. protected _postProcessManager: PostProcessManager;
  54384. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54385. protected _forceFullscreenViewport: boolean;
  54386. /**
  54387. * Creates a min/max reducer
  54388. * @param camera The camera to use for the post processes
  54389. */
  54390. constructor(camera: Camera);
  54391. /**
  54392. * Gets the texture used to read the values from.
  54393. */
  54394. get sourceTexture(): Nullable<RenderTargetTexture>;
  54395. /**
  54396. * Sets the source texture to read the values from.
  54397. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54398. * because in such textures '1' value must not be taken into account to compute the maximum
  54399. * as this value is used to clear the texture.
  54400. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54401. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54402. * @param depthRedux Indicates if the texture is a depth texture or not
  54403. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54404. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54405. */
  54406. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54407. /**
  54408. * Defines the refresh rate of the computation.
  54409. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54410. */
  54411. get refreshRate(): number;
  54412. set refreshRate(value: number);
  54413. protected _activated: boolean;
  54414. /**
  54415. * Gets the activation status of the reducer
  54416. */
  54417. get activated(): boolean;
  54418. /**
  54419. * Activates the reduction computation.
  54420. * When activated, the observers registered in onAfterReductionPerformed are
  54421. * called after the compuation is performed
  54422. */
  54423. activate(): void;
  54424. /**
  54425. * Deactivates the reduction computation.
  54426. */
  54427. deactivate(): void;
  54428. /**
  54429. * Disposes the min/max reducer
  54430. * @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.
  54431. */
  54432. dispose(disposeAll?: boolean): void;
  54433. }
  54434. }
  54435. declare module BABYLON {
  54436. /**
  54437. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54438. */
  54439. export class DepthReducer extends MinMaxReducer {
  54440. private _depthRenderer;
  54441. private _depthRendererId;
  54442. /**
  54443. * Gets the depth renderer used for the computation.
  54444. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54445. */
  54446. get depthRenderer(): Nullable<DepthRenderer>;
  54447. /**
  54448. * Creates a depth reducer
  54449. * @param camera The camera used to render the depth texture
  54450. */
  54451. constructor(camera: Camera);
  54452. /**
  54453. * Sets the depth renderer to use to generate the depth map
  54454. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54455. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54456. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54457. */
  54458. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54459. /** @hidden */
  54460. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54461. /**
  54462. * Activates the reduction computation.
  54463. * When activated, the observers registered in onAfterReductionPerformed are
  54464. * called after the compuation is performed
  54465. */
  54466. activate(): void;
  54467. /**
  54468. * Deactivates the reduction computation.
  54469. */
  54470. deactivate(): void;
  54471. /**
  54472. * Disposes the depth reducer
  54473. * @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.
  54474. */
  54475. dispose(disposeAll?: boolean): void;
  54476. }
  54477. }
  54478. declare module BABYLON {
  54479. /**
  54480. * A CSM implementation allowing casting shadows on large scenes.
  54481. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54482. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54483. */
  54484. export class CascadedShadowGenerator extends ShadowGenerator {
  54485. private static readonly frustumCornersNDCSpace;
  54486. /**
  54487. * Name of the CSM class
  54488. */
  54489. static CLASSNAME: string;
  54490. /**
  54491. * Defines the default number of cascades used by the CSM.
  54492. */
  54493. static readonly DEFAULT_CASCADES_COUNT: number;
  54494. /**
  54495. * Defines the minimum number of cascades used by the CSM.
  54496. */
  54497. static readonly MIN_CASCADES_COUNT: number;
  54498. /**
  54499. * Defines the maximum number of cascades used by the CSM.
  54500. */
  54501. static readonly MAX_CASCADES_COUNT: number;
  54502. protected _validateFilter(filter: number): number;
  54503. /**
  54504. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54505. */
  54506. penumbraDarkness: number;
  54507. private _numCascades;
  54508. /**
  54509. * Gets or set the number of cascades used by the CSM.
  54510. */
  54511. get numCascades(): number;
  54512. set numCascades(value: number);
  54513. /**
  54514. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54515. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54516. */
  54517. stabilizeCascades: boolean;
  54518. private _freezeShadowCastersBoundingInfo;
  54519. private _freezeShadowCastersBoundingInfoObservable;
  54520. /**
  54521. * Enables or disables the shadow casters bounding info computation.
  54522. * If your shadow casters don't move, you can disable this feature.
  54523. * If it is enabled, the bounding box computation is done every frame.
  54524. */
  54525. get freezeShadowCastersBoundingInfo(): boolean;
  54526. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54527. private _scbiMin;
  54528. private _scbiMax;
  54529. protected _computeShadowCastersBoundingInfo(): void;
  54530. protected _shadowCastersBoundingInfo: BoundingInfo;
  54531. /**
  54532. * Gets or sets the shadow casters bounding info.
  54533. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54534. * so that the system won't overwrite the bounds you provide
  54535. */
  54536. get shadowCastersBoundingInfo(): BoundingInfo;
  54537. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54538. protected _breaksAreDirty: boolean;
  54539. protected _minDistance: number;
  54540. protected _maxDistance: number;
  54541. /**
  54542. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54543. *
  54544. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54545. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54546. * @param min minimal distance for the breaks (default to 0.)
  54547. * @param max maximal distance for the breaks (default to 1.)
  54548. */
  54549. setMinMaxDistance(min: number, max: number): void;
  54550. /** Gets the minimal distance used in the cascade break computation */
  54551. get minDistance(): number;
  54552. /** Gets the maximal distance used in the cascade break computation */
  54553. get maxDistance(): number;
  54554. /**
  54555. * Gets the class name of that object
  54556. * @returns "CascadedShadowGenerator"
  54557. */
  54558. getClassName(): string;
  54559. private _cascadeMinExtents;
  54560. private _cascadeMaxExtents;
  54561. /**
  54562. * Gets a cascade minimum extents
  54563. * @param cascadeIndex index of the cascade
  54564. * @returns the minimum cascade extents
  54565. */
  54566. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54567. /**
  54568. * Gets a cascade maximum extents
  54569. * @param cascadeIndex index of the cascade
  54570. * @returns the maximum cascade extents
  54571. */
  54572. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54573. private _cascades;
  54574. private _currentLayer;
  54575. private _viewSpaceFrustumsZ;
  54576. private _viewMatrices;
  54577. private _projectionMatrices;
  54578. private _transformMatrices;
  54579. private _transformMatricesAsArray;
  54580. private _frustumLengths;
  54581. private _lightSizeUVCorrection;
  54582. private _depthCorrection;
  54583. private _frustumCornersWorldSpace;
  54584. private _frustumCenter;
  54585. private _shadowCameraPos;
  54586. private _shadowMaxZ;
  54587. /**
  54588. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54589. * It defaults to camera.maxZ
  54590. */
  54591. get shadowMaxZ(): number;
  54592. /**
  54593. * Sets the shadow max z distance.
  54594. */
  54595. set shadowMaxZ(value: number);
  54596. protected _debug: boolean;
  54597. /**
  54598. * Gets or sets the debug flag.
  54599. * When enabled, the cascades are materialized by different colors on the screen.
  54600. */
  54601. get debug(): boolean;
  54602. set debug(dbg: boolean);
  54603. private _depthClamp;
  54604. /**
  54605. * Gets or sets the depth clamping value.
  54606. *
  54607. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54608. * to account for the shadow casters far away.
  54609. *
  54610. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54611. */
  54612. get depthClamp(): boolean;
  54613. set depthClamp(value: boolean);
  54614. private _cascadeBlendPercentage;
  54615. /**
  54616. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54617. * It defaults to 0.1 (10% blending).
  54618. */
  54619. get cascadeBlendPercentage(): number;
  54620. set cascadeBlendPercentage(value: number);
  54621. private _lambda;
  54622. /**
  54623. * Gets or set the lambda parameter.
  54624. * This parameter is used to split the camera frustum and create the cascades.
  54625. * 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.
  54626. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54627. */
  54628. get lambda(): number;
  54629. set lambda(value: number);
  54630. /**
  54631. * Gets the view matrix corresponding to a given cascade
  54632. * @param cascadeNum cascade to retrieve the view matrix from
  54633. * @returns the cascade view matrix
  54634. */
  54635. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54636. /**
  54637. * Gets the projection matrix corresponding to a given cascade
  54638. * @param cascadeNum cascade to retrieve the projection matrix from
  54639. * @returns the cascade projection matrix
  54640. */
  54641. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54642. /**
  54643. * Gets the transformation matrix corresponding to a given cascade
  54644. * @param cascadeNum cascade to retrieve the transformation matrix from
  54645. * @returns the cascade transformation matrix
  54646. */
  54647. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54648. private _depthRenderer;
  54649. /**
  54650. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54651. *
  54652. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54653. *
  54654. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54655. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54656. * @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
  54657. */
  54658. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54659. private _depthReducer;
  54660. private _autoCalcDepthBounds;
  54661. /**
  54662. * Gets or sets the autoCalcDepthBounds property.
  54663. *
  54664. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54665. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54666. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54667. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54668. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54669. */
  54670. get autoCalcDepthBounds(): boolean;
  54671. set autoCalcDepthBounds(value: boolean);
  54672. /**
  54673. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54674. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54675. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54676. * for setting the refresh rate on the renderer yourself!
  54677. */
  54678. get autoCalcDepthBoundsRefreshRate(): number;
  54679. set autoCalcDepthBoundsRefreshRate(value: number);
  54680. /**
  54681. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54682. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54683. * you change the camera near/far planes!
  54684. */
  54685. splitFrustum(): void;
  54686. private _splitFrustum;
  54687. private _computeMatrices;
  54688. private _computeFrustumInWorldSpace;
  54689. private _computeCascadeFrustum;
  54690. /**
  54691. * Support test.
  54692. */
  54693. static get IsSupported(): boolean;
  54694. /** @hidden */
  54695. static _SceneComponentInitialization: (scene: Scene) => void;
  54696. /**
  54697. * Creates a Cascaded Shadow Generator object.
  54698. * A ShadowGenerator is the required tool to use the shadows.
  54699. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54700. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54701. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54702. * @param light The directional light object generating the shadows.
  54703. * @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.
  54704. */
  54705. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54706. protected _initializeGenerator(): void;
  54707. protected _createTargetRenderTexture(): void;
  54708. protected _initializeShadowMap(): void;
  54709. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54710. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54711. /**
  54712. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54713. * @param defines Defines of the material we want to update
  54714. * @param lightIndex Index of the light in the enabled light list of the material
  54715. */
  54716. prepareDefines(defines: any, lightIndex: number): void;
  54717. /**
  54718. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54719. * defined in the generator but impacting the effect).
  54720. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54721. * @param effect The effect we are binfing the information for
  54722. */
  54723. bindShadowLight(lightIndex: string, effect: Effect): void;
  54724. /**
  54725. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54726. * (eq to view projection * shadow projection matrices)
  54727. * @returns The transform matrix used to create the shadow map
  54728. */
  54729. getTransformMatrix(): Matrix;
  54730. /**
  54731. * Disposes the ShadowGenerator.
  54732. * Returns nothing.
  54733. */
  54734. dispose(): void;
  54735. /**
  54736. * Serializes the shadow generator setup to a json object.
  54737. * @returns The serialized JSON object
  54738. */
  54739. serialize(): any;
  54740. /**
  54741. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54742. * @param parsedShadowGenerator The JSON object to parse
  54743. * @param scene The scene to create the shadow map for
  54744. * @returns The parsed shadow generator
  54745. */
  54746. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54747. }
  54748. }
  54749. declare module BABYLON {
  54750. /**
  54751. * Defines the shadow generator component responsible to manage any shadow generators
  54752. * in a given scene.
  54753. */
  54754. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54755. /**
  54756. * The component name helpfull to identify the component in the list of scene components.
  54757. */
  54758. readonly name: string;
  54759. /**
  54760. * The scene the component belongs to.
  54761. */
  54762. scene: Scene;
  54763. /**
  54764. * Creates a new instance of the component for the given scene
  54765. * @param scene Defines the scene to register the component in
  54766. */
  54767. constructor(scene: Scene);
  54768. /**
  54769. * Registers the component in a given scene
  54770. */
  54771. register(): void;
  54772. /**
  54773. * Rebuilds the elements related to this component in case of
  54774. * context lost for instance.
  54775. */
  54776. rebuild(): void;
  54777. /**
  54778. * Serializes the component data to the specified json object
  54779. * @param serializationObject The object to serialize to
  54780. */
  54781. serialize(serializationObject: any): void;
  54782. /**
  54783. * Adds all the elements from the container to the scene
  54784. * @param container the container holding the elements
  54785. */
  54786. addFromContainer(container: AbstractScene): void;
  54787. /**
  54788. * Removes all the elements in the container from the scene
  54789. * @param container contains the elements to remove
  54790. * @param dispose if the removed element should be disposed (default: false)
  54791. */
  54792. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54793. /**
  54794. * Rebuilds the elements related to this component in case of
  54795. * context lost for instance.
  54796. */
  54797. dispose(): void;
  54798. private _gatherRenderTargets;
  54799. }
  54800. }
  54801. declare module BABYLON {
  54802. /**
  54803. * A point light is a light defined by an unique point in world space.
  54804. * The light is emitted in every direction from this point.
  54805. * A good example of a point light is a standard light bulb.
  54806. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54807. */
  54808. export class PointLight extends ShadowLight {
  54809. private _shadowAngle;
  54810. /**
  54811. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54812. * This specifies what angle the shadow will use to be created.
  54813. *
  54814. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54815. */
  54816. get shadowAngle(): number;
  54817. /**
  54818. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54819. * This specifies what angle the shadow will use to be created.
  54820. *
  54821. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54822. */
  54823. set shadowAngle(value: number);
  54824. /**
  54825. * Gets the direction if it has been set.
  54826. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54827. */
  54828. get direction(): Vector3;
  54829. /**
  54830. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54831. */
  54832. set direction(value: Vector3);
  54833. /**
  54834. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54835. * A PointLight emits the light in every direction.
  54836. * It can cast shadows.
  54837. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54838. * ```javascript
  54839. * var pointLight = new PointLight("pl", camera.position, scene);
  54840. * ```
  54841. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54842. * @param name The light friendly name
  54843. * @param position The position of the point light in the scene
  54844. * @param scene The scene the lights belongs to
  54845. */
  54846. constructor(name: string, position: Vector3, scene: Scene);
  54847. /**
  54848. * Returns the string "PointLight"
  54849. * @returns the class name
  54850. */
  54851. getClassName(): string;
  54852. /**
  54853. * Returns the integer 0.
  54854. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54855. */
  54856. getTypeID(): number;
  54857. /**
  54858. * Specifies wether or not the shadowmap should be a cube texture.
  54859. * @returns true if the shadowmap needs to be a cube texture.
  54860. */
  54861. needCube(): boolean;
  54862. /**
  54863. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54864. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54865. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54866. */
  54867. getShadowDirection(faceIndex?: number): Vector3;
  54868. /**
  54869. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54870. * - fov = PI / 2
  54871. * - aspect ratio : 1.0
  54872. * - z-near and far equal to the active camera minZ and maxZ.
  54873. * Returns the PointLight.
  54874. */
  54875. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54876. protected _buildUniformLayout(): void;
  54877. /**
  54878. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54879. * @param effect The effect to update
  54880. * @param lightIndex The index of the light in the effect to update
  54881. * @returns The point light
  54882. */
  54883. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54884. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54885. /**
  54886. * Prepares the list of defines specific to the light type.
  54887. * @param defines the list of defines
  54888. * @param lightIndex defines the index of the light for the effect
  54889. */
  54890. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54891. }
  54892. }
  54893. declare module BABYLON {
  54894. /**
  54895. * Header information of HDR texture files.
  54896. */
  54897. export interface HDRInfo {
  54898. /**
  54899. * The height of the texture in pixels.
  54900. */
  54901. height: number;
  54902. /**
  54903. * The width of the texture in pixels.
  54904. */
  54905. width: number;
  54906. /**
  54907. * The index of the beginning of the data in the binary file.
  54908. */
  54909. dataPosition: number;
  54910. }
  54911. /**
  54912. * This groups tools to convert HDR texture to native colors array.
  54913. */
  54914. export class HDRTools {
  54915. private static Ldexp;
  54916. private static Rgbe2float;
  54917. private static readStringLine;
  54918. /**
  54919. * Reads header information from an RGBE texture stored in a native array.
  54920. * More information on this format are available here:
  54921. * https://en.wikipedia.org/wiki/RGBE_image_format
  54922. *
  54923. * @param uint8array The binary file stored in native array.
  54924. * @return The header information.
  54925. */
  54926. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54927. /**
  54928. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54929. * This RGBE texture needs to store the information as a panorama.
  54930. *
  54931. * More information on this format are available here:
  54932. * https://en.wikipedia.org/wiki/RGBE_image_format
  54933. *
  54934. * @param buffer The binary file stored in an array buffer.
  54935. * @param size The expected size of the extracted cubemap.
  54936. * @return The Cube Map information.
  54937. */
  54938. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54939. /**
  54940. * Returns the pixels data extracted from an RGBE texture.
  54941. * This pixels will be stored left to right up to down in the R G B order in one array.
  54942. *
  54943. * More information on this format are available here:
  54944. * https://en.wikipedia.org/wiki/RGBE_image_format
  54945. *
  54946. * @param uint8array The binary file stored in an array buffer.
  54947. * @param hdrInfo The header information of the file.
  54948. * @return The pixels data in RGB right to left up to down order.
  54949. */
  54950. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54951. private static RGBE_ReadPixels_RLE;
  54952. }
  54953. }
  54954. declare module BABYLON {
  54955. /**
  54956. * This represents a texture coming from an HDR input.
  54957. *
  54958. * The only supported format is currently panorama picture stored in RGBE format.
  54959. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54960. */
  54961. export class HDRCubeTexture extends BaseTexture {
  54962. private static _facesMapping;
  54963. private _generateHarmonics;
  54964. private _noMipmap;
  54965. private _textureMatrix;
  54966. private _size;
  54967. private _onLoad;
  54968. private _onError;
  54969. /**
  54970. * The texture URL.
  54971. */
  54972. url: string;
  54973. /**
  54974. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54975. */
  54976. coordinatesMode: number;
  54977. protected _isBlocking: boolean;
  54978. /**
  54979. * Sets wether or not the texture is blocking during loading.
  54980. */
  54981. set isBlocking(value: boolean);
  54982. /**
  54983. * Gets wether or not the texture is blocking during loading.
  54984. */
  54985. get isBlocking(): boolean;
  54986. protected _rotationY: number;
  54987. /**
  54988. * Sets texture matrix rotation angle around Y axis in radians.
  54989. */
  54990. set rotationY(value: number);
  54991. /**
  54992. * Gets texture matrix rotation angle around Y axis radians.
  54993. */
  54994. get rotationY(): number;
  54995. /**
  54996. * Gets or sets the center of the bounding box associated with the cube texture
  54997. * It must define where the camera used to render the texture was set
  54998. */
  54999. boundingBoxPosition: Vector3;
  55000. private _boundingBoxSize;
  55001. /**
  55002. * Gets or sets the size of the bounding box associated with the cube texture
  55003. * When defined, the cubemap will switch to local mode
  55004. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55005. * @example https://www.babylonjs-playground.com/#RNASML
  55006. */
  55007. set boundingBoxSize(value: Vector3);
  55008. get boundingBoxSize(): Vector3;
  55009. /**
  55010. * Instantiates an HDRTexture from the following parameters.
  55011. *
  55012. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55013. * @param scene The scene the texture will be used in
  55014. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55015. * @param noMipmap Forces to not generate the mipmap if true
  55016. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55017. * @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)
  55018. * @param reserved Reserved flag for internal use.
  55019. */
  55020. 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>);
  55021. /**
  55022. * Get the current class name of the texture useful for serialization or dynamic coding.
  55023. * @returns "HDRCubeTexture"
  55024. */
  55025. getClassName(): string;
  55026. /**
  55027. * Occurs when the file is raw .hdr file.
  55028. */
  55029. private loadTexture;
  55030. clone(): HDRCubeTexture;
  55031. delayLoad(): void;
  55032. /**
  55033. * Get the texture reflection matrix used to rotate/transform the reflection.
  55034. * @returns the reflection matrix
  55035. */
  55036. getReflectionTextureMatrix(): Matrix;
  55037. /**
  55038. * Set the texture reflection matrix used to rotate/transform the reflection.
  55039. * @param value Define the reflection matrix to set
  55040. */
  55041. setReflectionTextureMatrix(value: Matrix): void;
  55042. /**
  55043. * Parses a JSON representation of an HDR Texture in order to create the texture
  55044. * @param parsedTexture Define the JSON representation
  55045. * @param scene Define the scene the texture should be created in
  55046. * @param rootUrl Define the root url in case we need to load relative dependencies
  55047. * @returns the newly created texture after parsing
  55048. */
  55049. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55050. serialize(): any;
  55051. }
  55052. }
  55053. declare module BABYLON {
  55054. /**
  55055. * Class used to control physics engine
  55056. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55057. */
  55058. export class PhysicsEngine implements IPhysicsEngine {
  55059. private _physicsPlugin;
  55060. /**
  55061. * Global value used to control the smallest number supported by the simulation
  55062. */
  55063. static Epsilon: number;
  55064. private _impostors;
  55065. private _joints;
  55066. private _subTimeStep;
  55067. /**
  55068. * Gets the gravity vector used by the simulation
  55069. */
  55070. gravity: Vector3;
  55071. /**
  55072. * Factory used to create the default physics plugin.
  55073. * @returns The default physics plugin
  55074. */
  55075. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55076. /**
  55077. * Creates a new Physics Engine
  55078. * @param gravity defines the gravity vector used by the simulation
  55079. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55080. */
  55081. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55082. /**
  55083. * Sets the gravity vector used by the simulation
  55084. * @param gravity defines the gravity vector to use
  55085. */
  55086. setGravity(gravity: Vector3): void;
  55087. /**
  55088. * Set the time step of the physics engine.
  55089. * Default is 1/60.
  55090. * To slow it down, enter 1/600 for example.
  55091. * To speed it up, 1/30
  55092. * @param newTimeStep defines the new timestep to apply to this world.
  55093. */
  55094. setTimeStep(newTimeStep?: number): void;
  55095. /**
  55096. * Get the time step of the physics engine.
  55097. * @returns the current time step
  55098. */
  55099. getTimeStep(): number;
  55100. /**
  55101. * Set the sub time step of the physics engine.
  55102. * Default is 0 meaning there is no sub steps
  55103. * To increase physics resolution precision, set a small value (like 1 ms)
  55104. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55105. */
  55106. setSubTimeStep(subTimeStep?: number): void;
  55107. /**
  55108. * Get the sub time step of the physics engine.
  55109. * @returns the current sub time step
  55110. */
  55111. getSubTimeStep(): number;
  55112. /**
  55113. * Release all resources
  55114. */
  55115. dispose(): void;
  55116. /**
  55117. * Gets the name of the current physics plugin
  55118. * @returns the name of the plugin
  55119. */
  55120. getPhysicsPluginName(): string;
  55121. /**
  55122. * Adding a new impostor for the impostor tracking.
  55123. * This will be done by the impostor itself.
  55124. * @param impostor the impostor to add
  55125. */
  55126. addImpostor(impostor: PhysicsImpostor): void;
  55127. /**
  55128. * Remove an impostor from the engine.
  55129. * This impostor and its mesh will not longer be updated by the physics engine.
  55130. * @param impostor the impostor to remove
  55131. */
  55132. removeImpostor(impostor: PhysicsImpostor): void;
  55133. /**
  55134. * Add a joint to the physics engine
  55135. * @param mainImpostor defines the main impostor to which the joint is added.
  55136. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55137. * @param joint defines the joint that will connect both impostors.
  55138. */
  55139. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55140. /**
  55141. * Removes a joint from the simulation
  55142. * @param mainImpostor defines the impostor used with the joint
  55143. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55144. * @param joint defines the joint to remove
  55145. */
  55146. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55147. /**
  55148. * Called by the scene. No need to call it.
  55149. * @param delta defines the timespam between frames
  55150. */
  55151. _step(delta: number): void;
  55152. /**
  55153. * Gets the current plugin used to run the simulation
  55154. * @returns current plugin
  55155. */
  55156. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55157. /**
  55158. * Gets the list of physic impostors
  55159. * @returns an array of PhysicsImpostor
  55160. */
  55161. getImpostors(): Array<PhysicsImpostor>;
  55162. /**
  55163. * Gets the impostor for a physics enabled object
  55164. * @param object defines the object impersonated by the impostor
  55165. * @returns the PhysicsImpostor or null if not found
  55166. */
  55167. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55168. /**
  55169. * Gets the impostor for a physics body object
  55170. * @param body defines physics body used by the impostor
  55171. * @returns the PhysicsImpostor or null if not found
  55172. */
  55173. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55174. /**
  55175. * Does a raycast in the physics world
  55176. * @param from when should the ray start?
  55177. * @param to when should the ray end?
  55178. * @returns PhysicsRaycastResult
  55179. */
  55180. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55181. }
  55182. }
  55183. declare module BABYLON {
  55184. /** @hidden */
  55185. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55186. private _useDeltaForWorldStep;
  55187. world: any;
  55188. name: string;
  55189. private _physicsMaterials;
  55190. private _fixedTimeStep;
  55191. private _cannonRaycastResult;
  55192. private _raycastResult;
  55193. private _physicsBodysToRemoveAfterStep;
  55194. BJSCANNON: any;
  55195. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55196. setGravity(gravity: Vector3): void;
  55197. setTimeStep(timeStep: number): void;
  55198. getTimeStep(): number;
  55199. executeStep(delta: number): void;
  55200. private _removeMarkedPhysicsBodiesFromWorld;
  55201. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55202. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55203. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55204. private _processChildMeshes;
  55205. removePhysicsBody(impostor: PhysicsImpostor): void;
  55206. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55207. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55208. private _addMaterial;
  55209. private _checkWithEpsilon;
  55210. private _createShape;
  55211. private _createHeightmap;
  55212. private _minus90X;
  55213. private _plus90X;
  55214. private _tmpPosition;
  55215. private _tmpDeltaPosition;
  55216. private _tmpUnityRotation;
  55217. private _updatePhysicsBodyTransformation;
  55218. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55219. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55220. isSupported(): boolean;
  55221. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55222. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55223. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55224. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55225. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55226. getBodyMass(impostor: PhysicsImpostor): number;
  55227. getBodyFriction(impostor: PhysicsImpostor): number;
  55228. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55229. getBodyRestitution(impostor: PhysicsImpostor): number;
  55230. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55231. sleepBody(impostor: PhysicsImpostor): void;
  55232. wakeUpBody(impostor: PhysicsImpostor): void;
  55233. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55234. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55235. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55236. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55237. getRadius(impostor: PhysicsImpostor): number;
  55238. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55239. dispose(): void;
  55240. private _extendNamespace;
  55241. /**
  55242. * Does a raycast in the physics world
  55243. * @param from when should the ray start?
  55244. * @param to when should the ray end?
  55245. * @returns PhysicsRaycastResult
  55246. */
  55247. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55248. }
  55249. }
  55250. declare module BABYLON {
  55251. /** @hidden */
  55252. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55253. world: any;
  55254. name: string;
  55255. BJSOIMO: any;
  55256. private _raycastResult;
  55257. constructor(iterations?: number, oimoInjection?: any);
  55258. setGravity(gravity: Vector3): void;
  55259. setTimeStep(timeStep: number): void;
  55260. getTimeStep(): number;
  55261. private _tmpImpostorsArray;
  55262. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55263. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55264. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55265. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55266. private _tmpPositionVector;
  55267. removePhysicsBody(impostor: PhysicsImpostor): void;
  55268. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55269. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55270. isSupported(): boolean;
  55271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55273. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55275. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55276. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55278. getBodyMass(impostor: PhysicsImpostor): number;
  55279. getBodyFriction(impostor: PhysicsImpostor): number;
  55280. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55281. getBodyRestitution(impostor: PhysicsImpostor): number;
  55282. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55283. sleepBody(impostor: PhysicsImpostor): void;
  55284. wakeUpBody(impostor: PhysicsImpostor): void;
  55285. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55286. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55287. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55288. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55289. getRadius(impostor: PhysicsImpostor): number;
  55290. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55291. dispose(): void;
  55292. /**
  55293. * Does a raycast in the physics world
  55294. * @param from when should the ray start?
  55295. * @param to when should the ray end?
  55296. * @returns PhysicsRaycastResult
  55297. */
  55298. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55299. }
  55300. }
  55301. declare module BABYLON {
  55302. /**
  55303. * Class containing static functions to help procedurally build meshes
  55304. */
  55305. export class RibbonBuilder {
  55306. /**
  55307. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55308. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55309. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55310. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55311. * * 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
  55312. * * 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
  55313. * * 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
  55314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55315. * * 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
  55316. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55317. * * 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
  55318. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55319. * * 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
  55320. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55322. * @param name defines the name of the mesh
  55323. * @param options defines the options used to create the mesh
  55324. * @param scene defines the hosting scene
  55325. * @returns the ribbon mesh
  55326. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55327. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55328. */
  55329. static CreateRibbon(name: string, options: {
  55330. pathArray: Vector3[][];
  55331. closeArray?: boolean;
  55332. closePath?: boolean;
  55333. offset?: number;
  55334. updatable?: boolean;
  55335. sideOrientation?: number;
  55336. frontUVs?: Vector4;
  55337. backUVs?: Vector4;
  55338. instance?: Mesh;
  55339. invertUV?: boolean;
  55340. uvs?: Vector2[];
  55341. colors?: Color4[];
  55342. }, scene?: Nullable<Scene>): Mesh;
  55343. }
  55344. }
  55345. declare module BABYLON {
  55346. /**
  55347. * Class containing static functions to help procedurally build meshes
  55348. */
  55349. export class ShapeBuilder {
  55350. /**
  55351. * 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.
  55352. * * 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.
  55353. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55354. * * 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.
  55355. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55356. * * 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
  55357. * * 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
  55358. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55360. * * 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
  55361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55363. * @param name defines the name of the mesh
  55364. * @param options defines the options used to create the mesh
  55365. * @param scene defines the hosting scene
  55366. * @returns the extruded shape mesh
  55367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55369. */
  55370. static ExtrudeShape(name: string, options: {
  55371. shape: Vector3[];
  55372. path: Vector3[];
  55373. scale?: number;
  55374. rotation?: number;
  55375. cap?: number;
  55376. updatable?: boolean;
  55377. sideOrientation?: number;
  55378. frontUVs?: Vector4;
  55379. backUVs?: Vector4;
  55380. instance?: Mesh;
  55381. invertUV?: boolean;
  55382. }, scene?: Nullable<Scene>): Mesh;
  55383. /**
  55384. * Creates an custom extruded shape mesh.
  55385. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55386. * * 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.
  55387. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55388. * * 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
  55389. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55390. * * 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
  55391. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55392. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55393. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55394. * * 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
  55395. * * 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
  55396. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55398. * * 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
  55399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55401. * @param name defines the name of the mesh
  55402. * @param options defines the options used to create the mesh
  55403. * @param scene defines the hosting scene
  55404. * @returns the custom extruded shape mesh
  55405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55406. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55408. */
  55409. static ExtrudeShapeCustom(name: string, options: {
  55410. shape: Vector3[];
  55411. path: Vector3[];
  55412. scaleFunction?: any;
  55413. rotationFunction?: any;
  55414. ribbonCloseArray?: boolean;
  55415. ribbonClosePath?: boolean;
  55416. cap?: number;
  55417. updatable?: boolean;
  55418. sideOrientation?: number;
  55419. frontUVs?: Vector4;
  55420. backUVs?: Vector4;
  55421. instance?: Mesh;
  55422. invertUV?: boolean;
  55423. }, scene?: Nullable<Scene>): Mesh;
  55424. private static _ExtrudeShapeGeneric;
  55425. }
  55426. }
  55427. declare module BABYLON {
  55428. /**
  55429. * AmmoJS Physics plugin
  55430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55431. * @see https://github.com/kripken/ammo.js/
  55432. */
  55433. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55434. private _useDeltaForWorldStep;
  55435. /**
  55436. * Reference to the Ammo library
  55437. */
  55438. bjsAMMO: any;
  55439. /**
  55440. * Created ammoJS world which physics bodies are added to
  55441. */
  55442. world: any;
  55443. /**
  55444. * Name of the plugin
  55445. */
  55446. name: string;
  55447. private _timeStep;
  55448. private _fixedTimeStep;
  55449. private _maxSteps;
  55450. private _tmpQuaternion;
  55451. private _tmpAmmoTransform;
  55452. private _tmpAmmoQuaternion;
  55453. private _tmpAmmoConcreteContactResultCallback;
  55454. private _collisionConfiguration;
  55455. private _dispatcher;
  55456. private _overlappingPairCache;
  55457. private _solver;
  55458. private _softBodySolver;
  55459. private _tmpAmmoVectorA;
  55460. private _tmpAmmoVectorB;
  55461. private _tmpAmmoVectorC;
  55462. private _tmpAmmoVectorD;
  55463. private _tmpContactCallbackResult;
  55464. private _tmpAmmoVectorRCA;
  55465. private _tmpAmmoVectorRCB;
  55466. private _raycastResult;
  55467. private static readonly DISABLE_COLLISION_FLAG;
  55468. private static readonly KINEMATIC_FLAG;
  55469. private static readonly DISABLE_DEACTIVATION_FLAG;
  55470. /**
  55471. * Initializes the ammoJS plugin
  55472. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55473. * @param ammoInjection can be used to inject your own ammo reference
  55474. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55475. */
  55476. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55477. /**
  55478. * Sets the gravity of the physics world (m/(s^2))
  55479. * @param gravity Gravity to set
  55480. */
  55481. setGravity(gravity: Vector3): void;
  55482. /**
  55483. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55484. * @param timeStep timestep to use in seconds
  55485. */
  55486. setTimeStep(timeStep: number): void;
  55487. /**
  55488. * 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)
  55489. * @param fixedTimeStep fixedTimeStep to use in seconds
  55490. */
  55491. setFixedTimeStep(fixedTimeStep: number): void;
  55492. /**
  55493. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55494. * @param maxSteps the maximum number of steps by the physics engine per frame
  55495. */
  55496. setMaxSteps(maxSteps: number): void;
  55497. /**
  55498. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55499. * @returns the current timestep in seconds
  55500. */
  55501. getTimeStep(): number;
  55502. /**
  55503. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55504. */
  55505. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55506. private _isImpostorInContact;
  55507. private _isImpostorPairInContact;
  55508. private _stepSimulation;
  55509. /**
  55510. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55511. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55512. * After the step the babylon meshes are set to the position of the physics imposters
  55513. * @param delta amount of time to step forward
  55514. * @param impostors array of imposters to update before/after the step
  55515. */
  55516. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55517. /**
  55518. * Update babylon mesh to match physics world object
  55519. * @param impostor imposter to match
  55520. */
  55521. private _afterSoftStep;
  55522. /**
  55523. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55524. * @param impostor imposter to match
  55525. */
  55526. private _ropeStep;
  55527. /**
  55528. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55529. * @param impostor imposter to match
  55530. */
  55531. private _softbodyOrClothStep;
  55532. private _tmpVector;
  55533. private _tmpMatrix;
  55534. /**
  55535. * Applies an impulse on the imposter
  55536. * @param impostor imposter to apply impulse to
  55537. * @param force amount of force to be applied to the imposter
  55538. * @param contactPoint the location to apply the impulse on the imposter
  55539. */
  55540. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55541. /**
  55542. * Applies a force on the imposter
  55543. * @param impostor imposter to apply force
  55544. * @param force amount of force to be applied to the imposter
  55545. * @param contactPoint the location to apply the force on the imposter
  55546. */
  55547. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55548. /**
  55549. * Creates a physics body using the plugin
  55550. * @param impostor the imposter to create the physics body on
  55551. */
  55552. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55553. /**
  55554. * Removes the physics body from the imposter and disposes of the body's memory
  55555. * @param impostor imposter to remove the physics body from
  55556. */
  55557. removePhysicsBody(impostor: PhysicsImpostor): void;
  55558. /**
  55559. * Generates a joint
  55560. * @param impostorJoint the imposter joint to create the joint with
  55561. */
  55562. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55563. /**
  55564. * Removes a joint
  55565. * @param impostorJoint the imposter joint to remove the joint from
  55566. */
  55567. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55568. private _addMeshVerts;
  55569. /**
  55570. * Initialise the soft body vertices to match its object's (mesh) vertices
  55571. * Softbody vertices (nodes) are in world space and to match this
  55572. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55573. * @param impostor to create the softbody for
  55574. */
  55575. private _softVertexData;
  55576. /**
  55577. * Create an impostor's soft body
  55578. * @param impostor to create the softbody for
  55579. */
  55580. private _createSoftbody;
  55581. /**
  55582. * Create cloth for an impostor
  55583. * @param impostor to create the softbody for
  55584. */
  55585. private _createCloth;
  55586. /**
  55587. * Create rope for an impostor
  55588. * @param impostor to create the softbody for
  55589. */
  55590. private _createRope;
  55591. /**
  55592. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55593. * @param impostor to create the custom physics shape for
  55594. */
  55595. private _createCustom;
  55596. private _addHullVerts;
  55597. private _createShape;
  55598. /**
  55599. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55600. * @param impostor imposter containing the physics body and babylon object
  55601. */
  55602. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55603. /**
  55604. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55605. * @param impostor imposter containing the physics body and babylon object
  55606. * @param newPosition new position
  55607. * @param newRotation new rotation
  55608. */
  55609. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55610. /**
  55611. * If this plugin is supported
  55612. * @returns true if its supported
  55613. */
  55614. isSupported(): boolean;
  55615. /**
  55616. * Sets the linear velocity of the physics body
  55617. * @param impostor imposter to set the velocity on
  55618. * @param velocity velocity to set
  55619. */
  55620. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55621. /**
  55622. * Sets the angular velocity of the physics body
  55623. * @param impostor imposter to set the velocity on
  55624. * @param velocity velocity to set
  55625. */
  55626. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55627. /**
  55628. * gets the linear velocity
  55629. * @param impostor imposter to get linear velocity from
  55630. * @returns linear velocity
  55631. */
  55632. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55633. /**
  55634. * gets the angular velocity
  55635. * @param impostor imposter to get angular velocity from
  55636. * @returns angular velocity
  55637. */
  55638. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55639. /**
  55640. * Sets the mass of physics body
  55641. * @param impostor imposter to set the mass on
  55642. * @param mass mass to set
  55643. */
  55644. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55645. /**
  55646. * Gets the mass of the physics body
  55647. * @param impostor imposter to get the mass from
  55648. * @returns mass
  55649. */
  55650. getBodyMass(impostor: PhysicsImpostor): number;
  55651. /**
  55652. * Gets friction of the impostor
  55653. * @param impostor impostor to get friction from
  55654. * @returns friction value
  55655. */
  55656. getBodyFriction(impostor: PhysicsImpostor): number;
  55657. /**
  55658. * Sets friction of the impostor
  55659. * @param impostor impostor to set friction on
  55660. * @param friction friction value
  55661. */
  55662. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55663. /**
  55664. * Gets restitution of the impostor
  55665. * @param impostor impostor to get restitution from
  55666. * @returns restitution value
  55667. */
  55668. getBodyRestitution(impostor: PhysicsImpostor): number;
  55669. /**
  55670. * Sets resitution of the impostor
  55671. * @param impostor impostor to set resitution on
  55672. * @param restitution resitution value
  55673. */
  55674. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55675. /**
  55676. * Gets pressure inside the impostor
  55677. * @param impostor impostor to get pressure from
  55678. * @returns pressure value
  55679. */
  55680. getBodyPressure(impostor: PhysicsImpostor): number;
  55681. /**
  55682. * Sets pressure inside a soft body impostor
  55683. * Cloth and rope must remain 0 pressure
  55684. * @param impostor impostor to set pressure on
  55685. * @param pressure pressure value
  55686. */
  55687. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55688. /**
  55689. * Gets stiffness of the impostor
  55690. * @param impostor impostor to get stiffness from
  55691. * @returns pressure value
  55692. */
  55693. getBodyStiffness(impostor: PhysicsImpostor): number;
  55694. /**
  55695. * Sets stiffness of the impostor
  55696. * @param impostor impostor to set stiffness on
  55697. * @param stiffness stiffness value from 0 to 1
  55698. */
  55699. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55700. /**
  55701. * Gets velocityIterations of the impostor
  55702. * @param impostor impostor to get velocity iterations from
  55703. * @returns velocityIterations value
  55704. */
  55705. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55706. /**
  55707. * Sets velocityIterations of the impostor
  55708. * @param impostor impostor to set velocity iterations on
  55709. * @param velocityIterations velocityIterations value
  55710. */
  55711. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55712. /**
  55713. * Gets positionIterations of the impostor
  55714. * @param impostor impostor to get position iterations from
  55715. * @returns positionIterations value
  55716. */
  55717. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55718. /**
  55719. * Sets positionIterations of the impostor
  55720. * @param impostor impostor to set position on
  55721. * @param positionIterations positionIterations value
  55722. */
  55723. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55724. /**
  55725. * Append an anchor to a cloth object
  55726. * @param impostor is the cloth impostor to add anchor to
  55727. * @param otherImpostor is the rigid impostor to anchor to
  55728. * @param width ratio across width from 0 to 1
  55729. * @param height ratio up height from 0 to 1
  55730. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55731. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55732. */
  55733. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55734. /**
  55735. * Append an hook to a rope object
  55736. * @param impostor is the rope impostor to add hook to
  55737. * @param otherImpostor is the rigid impostor to hook to
  55738. * @param length ratio along the rope from 0 to 1
  55739. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55740. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55741. */
  55742. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55743. /**
  55744. * Sleeps the physics body and stops it from being active
  55745. * @param impostor impostor to sleep
  55746. */
  55747. sleepBody(impostor: PhysicsImpostor): void;
  55748. /**
  55749. * Activates the physics body
  55750. * @param impostor impostor to activate
  55751. */
  55752. wakeUpBody(impostor: PhysicsImpostor): void;
  55753. /**
  55754. * Updates the distance parameters of the joint
  55755. * @param joint joint to update
  55756. * @param maxDistance maximum distance of the joint
  55757. * @param minDistance minimum distance of the joint
  55758. */
  55759. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55760. /**
  55761. * Sets a motor on the joint
  55762. * @param joint joint to set motor on
  55763. * @param speed speed of the motor
  55764. * @param maxForce maximum force of the motor
  55765. * @param motorIndex index of the motor
  55766. */
  55767. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55768. /**
  55769. * Sets the motors limit
  55770. * @param joint joint to set limit on
  55771. * @param upperLimit upper limit
  55772. * @param lowerLimit lower limit
  55773. */
  55774. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55775. /**
  55776. * Syncs the position and rotation of a mesh with the impostor
  55777. * @param mesh mesh to sync
  55778. * @param impostor impostor to update the mesh with
  55779. */
  55780. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55781. /**
  55782. * Gets the radius of the impostor
  55783. * @param impostor impostor to get radius from
  55784. * @returns the radius
  55785. */
  55786. getRadius(impostor: PhysicsImpostor): number;
  55787. /**
  55788. * Gets the box size of the impostor
  55789. * @param impostor impostor to get box size from
  55790. * @param result the resulting box size
  55791. */
  55792. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55793. /**
  55794. * Disposes of the impostor
  55795. */
  55796. dispose(): void;
  55797. /**
  55798. * Does a raycast in the physics world
  55799. * @param from when should the ray start?
  55800. * @param to when should the ray end?
  55801. * @returns PhysicsRaycastResult
  55802. */
  55803. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55804. }
  55805. }
  55806. declare module BABYLON {
  55807. interface AbstractScene {
  55808. /**
  55809. * The list of reflection probes added to the scene
  55810. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55811. */
  55812. reflectionProbes: Array<ReflectionProbe>;
  55813. /**
  55814. * Removes the given reflection probe from this scene.
  55815. * @param toRemove The reflection probe to remove
  55816. * @returns The index of the removed reflection probe
  55817. */
  55818. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55819. /**
  55820. * Adds the given reflection probe to this scene.
  55821. * @param newReflectionProbe The reflection probe to add
  55822. */
  55823. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55824. }
  55825. /**
  55826. * Class used to generate realtime reflection / refraction cube textures
  55827. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55828. */
  55829. export class ReflectionProbe {
  55830. /** defines the name of the probe */
  55831. name: string;
  55832. private _scene;
  55833. private _renderTargetTexture;
  55834. private _projectionMatrix;
  55835. private _viewMatrix;
  55836. private _target;
  55837. private _add;
  55838. private _attachedMesh;
  55839. private _invertYAxis;
  55840. /** Gets or sets probe position (center of the cube map) */
  55841. position: Vector3;
  55842. /**
  55843. * Creates a new reflection probe
  55844. * @param name defines the name of the probe
  55845. * @param size defines the texture resolution (for each face)
  55846. * @param scene defines the hosting scene
  55847. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55848. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55849. */
  55850. constructor(
  55851. /** defines the name of the probe */
  55852. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55853. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55854. get samples(): number;
  55855. set samples(value: number);
  55856. /** Gets or sets the refresh rate to use (on every frame by default) */
  55857. get refreshRate(): number;
  55858. set refreshRate(value: number);
  55859. /**
  55860. * Gets the hosting scene
  55861. * @returns a Scene
  55862. */
  55863. getScene(): Scene;
  55864. /** Gets the internal CubeTexture used to render to */
  55865. get cubeTexture(): RenderTargetTexture;
  55866. /** Gets the list of meshes to render */
  55867. get renderList(): Nullable<AbstractMesh[]>;
  55868. /**
  55869. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55870. * @param mesh defines the mesh to attach to
  55871. */
  55872. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55873. /**
  55874. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55875. * @param renderingGroupId The rendering group id corresponding to its index
  55876. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55877. */
  55878. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55879. /**
  55880. * Clean all associated resources
  55881. */
  55882. dispose(): void;
  55883. /**
  55884. * Converts the reflection probe information to a readable string for debug purpose.
  55885. * @param fullDetails Supports for multiple levels of logging within scene loading
  55886. * @returns the human readable reflection probe info
  55887. */
  55888. toString(fullDetails?: boolean): string;
  55889. /**
  55890. * Get the class name of the relfection probe.
  55891. * @returns "ReflectionProbe"
  55892. */
  55893. getClassName(): string;
  55894. /**
  55895. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55896. * @returns The JSON representation of the texture
  55897. */
  55898. serialize(): any;
  55899. /**
  55900. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55901. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55902. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55903. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55904. * @returns The parsed reflection probe if successful
  55905. */
  55906. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55907. }
  55908. }
  55909. declare module BABYLON {
  55910. /** @hidden */
  55911. export var _BabylonLoaderRegistered: boolean;
  55912. /**
  55913. * Helps setting up some configuration for the babylon file loader.
  55914. */
  55915. export class BabylonFileLoaderConfiguration {
  55916. /**
  55917. * The loader does not allow injecting custom physix engine into the plugins.
  55918. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55919. * So you could set this variable to your engine import to make it work.
  55920. */
  55921. static LoaderInjectedPhysicsEngine: any;
  55922. }
  55923. }
  55924. declare module BABYLON {
  55925. /**
  55926. * The Physically based simple base material of BJS.
  55927. *
  55928. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55929. * It is used as the base class for both the specGloss and metalRough conventions.
  55930. */
  55931. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55932. /**
  55933. * Number of Simultaneous lights allowed on the material.
  55934. */
  55935. maxSimultaneousLights: number;
  55936. /**
  55937. * If sets to true, disables all the lights affecting the material.
  55938. */
  55939. disableLighting: boolean;
  55940. /**
  55941. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55942. */
  55943. environmentTexture: BaseTexture;
  55944. /**
  55945. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55946. */
  55947. invertNormalMapX: boolean;
  55948. /**
  55949. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55950. */
  55951. invertNormalMapY: boolean;
  55952. /**
  55953. * Normal map used in the model.
  55954. */
  55955. normalTexture: BaseTexture;
  55956. /**
  55957. * Emissivie color used to self-illuminate the model.
  55958. */
  55959. emissiveColor: Color3;
  55960. /**
  55961. * Emissivie texture used to self-illuminate the model.
  55962. */
  55963. emissiveTexture: BaseTexture;
  55964. /**
  55965. * Occlusion Channel Strenght.
  55966. */
  55967. occlusionStrength: number;
  55968. /**
  55969. * Occlusion Texture of the material (adding extra occlusion effects).
  55970. */
  55971. occlusionTexture: BaseTexture;
  55972. /**
  55973. * Defines the alpha limits in alpha test mode.
  55974. */
  55975. alphaCutOff: number;
  55976. /**
  55977. * Gets the current double sided mode.
  55978. */
  55979. get doubleSided(): boolean;
  55980. /**
  55981. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55982. */
  55983. set doubleSided(value: boolean);
  55984. /**
  55985. * Stores the pre-calculated light information of a mesh in a texture.
  55986. */
  55987. lightmapTexture: BaseTexture;
  55988. /**
  55989. * If true, the light map contains occlusion information instead of lighting info.
  55990. */
  55991. useLightmapAsShadowmap: boolean;
  55992. /**
  55993. * Instantiates a new PBRMaterial instance.
  55994. *
  55995. * @param name The material name
  55996. * @param scene The scene the material will be use in.
  55997. */
  55998. constructor(name: string, scene: Scene);
  55999. getClassName(): string;
  56000. }
  56001. }
  56002. declare module BABYLON {
  56003. /**
  56004. * The PBR material of BJS following the metal roughness convention.
  56005. *
  56006. * This fits to the PBR convention in the GLTF definition:
  56007. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56008. */
  56009. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56010. /**
  56011. * The base color has two different interpretations depending on the value of metalness.
  56012. * When the material is a metal, the base color is the specific measured reflectance value
  56013. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56014. * of the material.
  56015. */
  56016. baseColor: Color3;
  56017. /**
  56018. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56019. * well as opacity information in the alpha channel.
  56020. */
  56021. baseTexture: BaseTexture;
  56022. /**
  56023. * Specifies the metallic scalar value of the material.
  56024. * Can also be used to scale the metalness values of the metallic texture.
  56025. */
  56026. metallic: number;
  56027. /**
  56028. * Specifies the roughness scalar value of the material.
  56029. * Can also be used to scale the roughness values of the metallic texture.
  56030. */
  56031. roughness: number;
  56032. /**
  56033. * Texture containing both the metallic value in the B channel and the
  56034. * roughness value in the G channel to keep better precision.
  56035. */
  56036. metallicRoughnessTexture: BaseTexture;
  56037. /**
  56038. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56039. *
  56040. * @param name The material name
  56041. * @param scene The scene the material will be use in.
  56042. */
  56043. constructor(name: string, scene: Scene);
  56044. /**
  56045. * Return the currrent class name of the material.
  56046. */
  56047. getClassName(): string;
  56048. /**
  56049. * Makes a duplicate of the current material.
  56050. * @param name - name to use for the new material.
  56051. */
  56052. clone(name: string): PBRMetallicRoughnessMaterial;
  56053. /**
  56054. * Serialize the material to a parsable JSON object.
  56055. */
  56056. serialize(): any;
  56057. /**
  56058. * Parses a JSON object correponding to the serialize function.
  56059. */
  56060. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56061. }
  56062. }
  56063. declare module BABYLON {
  56064. /**
  56065. * The PBR material of BJS following the specular glossiness convention.
  56066. *
  56067. * This fits to the PBR convention in the GLTF definition:
  56068. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56069. */
  56070. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56071. /**
  56072. * Specifies the diffuse color of the material.
  56073. */
  56074. diffuseColor: Color3;
  56075. /**
  56076. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56077. * channel.
  56078. */
  56079. diffuseTexture: BaseTexture;
  56080. /**
  56081. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56082. */
  56083. specularColor: Color3;
  56084. /**
  56085. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56086. */
  56087. glossiness: number;
  56088. /**
  56089. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56090. */
  56091. specularGlossinessTexture: BaseTexture;
  56092. /**
  56093. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56094. *
  56095. * @param name The material name
  56096. * @param scene The scene the material will be use in.
  56097. */
  56098. constructor(name: string, scene: Scene);
  56099. /**
  56100. * Return the currrent class name of the material.
  56101. */
  56102. getClassName(): string;
  56103. /**
  56104. * Makes a duplicate of the current material.
  56105. * @param name - name to use for the new material.
  56106. */
  56107. clone(name: string): PBRSpecularGlossinessMaterial;
  56108. /**
  56109. * Serialize the material to a parsable JSON object.
  56110. */
  56111. serialize(): any;
  56112. /**
  56113. * Parses a JSON object correponding to the serialize function.
  56114. */
  56115. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56116. }
  56117. }
  56118. declare module BABYLON {
  56119. /**
  56120. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56121. * It can help converting any input color in a desired output one. This can then be used to create effects
  56122. * from sepia, black and white to sixties or futuristic rendering...
  56123. *
  56124. * The only supported format is currently 3dl.
  56125. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56126. */
  56127. export class ColorGradingTexture extends BaseTexture {
  56128. /**
  56129. * The current texture matrix. (will always be identity in color grading texture)
  56130. */
  56131. private _textureMatrix;
  56132. /**
  56133. * The texture URL.
  56134. */
  56135. url: string;
  56136. /**
  56137. * Empty line regex stored for GC.
  56138. */
  56139. private static _noneEmptyLineRegex;
  56140. private _engine;
  56141. /**
  56142. * Instantiates a ColorGradingTexture from the following parameters.
  56143. *
  56144. * @param url The location of the color gradind data (currently only supporting 3dl)
  56145. * @param scene The scene the texture will be used in
  56146. */
  56147. constructor(url: string, scene: Scene);
  56148. /**
  56149. * Returns the texture matrix used in most of the material.
  56150. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56151. */
  56152. getTextureMatrix(): Matrix;
  56153. /**
  56154. * Occurs when the file being loaded is a .3dl LUT file.
  56155. */
  56156. private load3dlTexture;
  56157. /**
  56158. * Starts the loading process of the texture.
  56159. */
  56160. private loadTexture;
  56161. /**
  56162. * Clones the color gradind texture.
  56163. */
  56164. clone(): ColorGradingTexture;
  56165. /**
  56166. * Called during delayed load for textures.
  56167. */
  56168. delayLoad(): void;
  56169. /**
  56170. * Parses a color grading texture serialized by Babylon.
  56171. * @param parsedTexture The texture information being parsedTexture
  56172. * @param scene The scene to load the texture in
  56173. * @param rootUrl The root url of the data assets to load
  56174. * @return A color gradind texture
  56175. */
  56176. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56177. /**
  56178. * Serializes the LUT texture to json format.
  56179. */
  56180. serialize(): any;
  56181. }
  56182. }
  56183. declare module BABYLON {
  56184. /**
  56185. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56186. */
  56187. export class EquiRectangularCubeTexture extends BaseTexture {
  56188. /** The six faces of the cube. */
  56189. private static _FacesMapping;
  56190. private _noMipmap;
  56191. private _onLoad;
  56192. private _onError;
  56193. /** The size of the cubemap. */
  56194. private _size;
  56195. /** The buffer of the image. */
  56196. private _buffer;
  56197. /** The width of the input image. */
  56198. private _width;
  56199. /** The height of the input image. */
  56200. private _height;
  56201. /** The URL to the image. */
  56202. url: string;
  56203. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56204. coordinatesMode: number;
  56205. /**
  56206. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56207. * @param url The location of the image
  56208. * @param scene The scene the texture will be used in
  56209. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56210. * @param noMipmap Forces to not generate the mipmap if true
  56211. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56212. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56213. * @param onLoad — defines a callback called when texture is loaded
  56214. * @param onError — defines a callback called if there is an error
  56215. */
  56216. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56217. /**
  56218. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56219. */
  56220. private loadImage;
  56221. /**
  56222. * Convert the image buffer into a cubemap and create a CubeTexture.
  56223. */
  56224. private loadTexture;
  56225. /**
  56226. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56227. * @param buffer The ArrayBuffer that should be converted.
  56228. * @returns The buffer as Float32Array.
  56229. */
  56230. private getFloat32ArrayFromArrayBuffer;
  56231. /**
  56232. * Get the current class name of the texture useful for serialization or dynamic coding.
  56233. * @returns "EquiRectangularCubeTexture"
  56234. */
  56235. getClassName(): string;
  56236. /**
  56237. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56238. * @returns A clone of the current EquiRectangularCubeTexture.
  56239. */
  56240. clone(): EquiRectangularCubeTexture;
  56241. }
  56242. }
  56243. declare module BABYLON {
  56244. /**
  56245. * Based on jsTGALoader - Javascript loader for TGA file
  56246. * By Vincent Thibault
  56247. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56248. */
  56249. export class TGATools {
  56250. private static _TYPE_INDEXED;
  56251. private static _TYPE_RGB;
  56252. private static _TYPE_GREY;
  56253. private static _TYPE_RLE_INDEXED;
  56254. private static _TYPE_RLE_RGB;
  56255. private static _TYPE_RLE_GREY;
  56256. private static _ORIGIN_MASK;
  56257. private static _ORIGIN_SHIFT;
  56258. private static _ORIGIN_BL;
  56259. private static _ORIGIN_BR;
  56260. private static _ORIGIN_UL;
  56261. private static _ORIGIN_UR;
  56262. /**
  56263. * Gets the header of a TGA file
  56264. * @param data defines the TGA data
  56265. * @returns the header
  56266. */
  56267. static GetTGAHeader(data: Uint8Array): any;
  56268. /**
  56269. * Uploads TGA content to a Babylon Texture
  56270. * @hidden
  56271. */
  56272. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56273. /** @hidden */
  56274. 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;
  56275. /** @hidden */
  56276. 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;
  56277. /** @hidden */
  56278. 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;
  56279. /** @hidden */
  56280. 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;
  56281. /** @hidden */
  56282. 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;
  56283. /** @hidden */
  56284. 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;
  56285. }
  56286. }
  56287. declare module BABYLON {
  56288. /**
  56289. * Implementation of the TGA Texture Loader.
  56290. * @hidden
  56291. */
  56292. export class _TGATextureLoader implements IInternalTextureLoader {
  56293. /**
  56294. * Defines wether the loader supports cascade loading the different faces.
  56295. */
  56296. readonly supportCascades: boolean;
  56297. /**
  56298. * This returns if the loader support the current file information.
  56299. * @param extension defines the file extension of the file being loaded
  56300. * @returns true if the loader can load the specified file
  56301. */
  56302. canLoad(extension: string): boolean;
  56303. /**
  56304. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56305. * @param data contains the texture data
  56306. * @param texture defines the BabylonJS internal texture
  56307. * @param createPolynomials will be true if polynomials have been requested
  56308. * @param onLoad defines the callback to trigger once the texture is ready
  56309. * @param onError defines the callback to trigger in case of error
  56310. */
  56311. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56312. /**
  56313. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56314. * @param data contains the texture data
  56315. * @param texture defines the BabylonJS internal texture
  56316. * @param callback defines the method to call once ready to upload
  56317. */
  56318. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56319. }
  56320. }
  56321. declare module BABYLON {
  56322. /**
  56323. * Info about the .basis files
  56324. */
  56325. class BasisFileInfo {
  56326. /**
  56327. * If the file has alpha
  56328. */
  56329. hasAlpha: boolean;
  56330. /**
  56331. * Info about each image of the basis file
  56332. */
  56333. images: Array<{
  56334. levels: Array<{
  56335. width: number;
  56336. height: number;
  56337. transcodedPixels: ArrayBufferView;
  56338. }>;
  56339. }>;
  56340. }
  56341. /**
  56342. * Result of transcoding a basis file
  56343. */
  56344. class TranscodeResult {
  56345. /**
  56346. * Info about the .basis file
  56347. */
  56348. fileInfo: BasisFileInfo;
  56349. /**
  56350. * Format to use when loading the file
  56351. */
  56352. format: number;
  56353. }
  56354. /**
  56355. * Configuration options for the Basis transcoder
  56356. */
  56357. export class BasisTranscodeConfiguration {
  56358. /**
  56359. * Supported compression formats used to determine the supported output format of the transcoder
  56360. */
  56361. supportedCompressionFormats?: {
  56362. /**
  56363. * etc1 compression format
  56364. */
  56365. etc1?: boolean;
  56366. /**
  56367. * s3tc compression format
  56368. */
  56369. s3tc?: boolean;
  56370. /**
  56371. * pvrtc compression format
  56372. */
  56373. pvrtc?: boolean;
  56374. /**
  56375. * etc2 compression format
  56376. */
  56377. etc2?: boolean;
  56378. };
  56379. /**
  56380. * If mipmap levels should be loaded for transcoded images (Default: true)
  56381. */
  56382. loadMipmapLevels?: boolean;
  56383. /**
  56384. * Index of a single image to load (Default: all images)
  56385. */
  56386. loadSingleImage?: number;
  56387. }
  56388. /**
  56389. * Used to load .Basis files
  56390. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56391. */
  56392. export class BasisTools {
  56393. private static _IgnoreSupportedFormats;
  56394. /**
  56395. * URL to use when loading the basis transcoder
  56396. */
  56397. static JSModuleURL: string;
  56398. /**
  56399. * URL to use when loading the wasm module for the transcoder
  56400. */
  56401. static WasmModuleURL: string;
  56402. /**
  56403. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56404. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56405. * @returns internal format corresponding to the Basis format
  56406. */
  56407. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56408. private static _WorkerPromise;
  56409. private static _Worker;
  56410. private static _actionId;
  56411. private static _CreateWorkerAsync;
  56412. /**
  56413. * Transcodes a loaded image file to compressed pixel data
  56414. * @param data image data to transcode
  56415. * @param config configuration options for the transcoding
  56416. * @returns a promise resulting in the transcoded image
  56417. */
  56418. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56419. /**
  56420. * Loads a texture from the transcode result
  56421. * @param texture texture load to
  56422. * @param transcodeResult the result of transcoding the basis file to load from
  56423. */
  56424. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56425. }
  56426. }
  56427. declare module BABYLON {
  56428. /**
  56429. * Loader for .basis file format
  56430. */
  56431. export class _BasisTextureLoader implements IInternalTextureLoader {
  56432. /**
  56433. * Defines whether the loader supports cascade loading the different faces.
  56434. */
  56435. readonly supportCascades: boolean;
  56436. /**
  56437. * This returns if the loader support the current file information.
  56438. * @param extension defines the file extension of the file being loaded
  56439. * @returns true if the loader can load the specified file
  56440. */
  56441. canLoad(extension: string): boolean;
  56442. /**
  56443. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56444. * @param data contains the texture data
  56445. * @param texture defines the BabylonJS internal texture
  56446. * @param createPolynomials will be true if polynomials have been requested
  56447. * @param onLoad defines the callback to trigger once the texture is ready
  56448. * @param onError defines the callback to trigger in case of error
  56449. */
  56450. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56451. /**
  56452. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56453. * @param data contains the texture data
  56454. * @param texture defines the BabylonJS internal texture
  56455. * @param callback defines the method to call once ready to upload
  56456. */
  56457. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56458. }
  56459. }
  56460. declare module BABYLON {
  56461. /**
  56462. * 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.
  56463. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56464. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56465. */
  56466. export class CustomProceduralTexture extends ProceduralTexture {
  56467. private _animate;
  56468. private _time;
  56469. private _config;
  56470. private _texturePath;
  56471. /**
  56472. * Instantiates a new Custom Procedural Texture.
  56473. * 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.
  56474. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56475. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56476. * @param name Define the name of the texture
  56477. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56478. * @param size Define the size of the texture to create
  56479. * @param scene Define the scene the texture belongs to
  56480. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56481. * @param generateMipMaps Define if the texture should creates mip maps or not
  56482. */
  56483. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56484. private _loadJson;
  56485. /**
  56486. * Is the texture ready to be used ? (rendered at least once)
  56487. * @returns true if ready, otherwise, false.
  56488. */
  56489. isReady(): boolean;
  56490. /**
  56491. * Render the texture to its associated render target.
  56492. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56493. */
  56494. render(useCameraPostProcess?: boolean): void;
  56495. /**
  56496. * Update the list of dependant textures samplers in the shader.
  56497. */
  56498. updateTextures(): void;
  56499. /**
  56500. * Update the uniform values of the procedural texture in the shader.
  56501. */
  56502. updateShaderUniforms(): void;
  56503. /**
  56504. * Define if the texture animates or not.
  56505. */
  56506. get animate(): boolean;
  56507. set animate(value: boolean);
  56508. }
  56509. }
  56510. declare module BABYLON {
  56511. /** @hidden */
  56512. export var noisePixelShader: {
  56513. name: string;
  56514. shader: string;
  56515. };
  56516. }
  56517. declare module BABYLON {
  56518. /**
  56519. * Class used to generate noise procedural textures
  56520. */
  56521. export class NoiseProceduralTexture extends ProceduralTexture {
  56522. private _time;
  56523. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56524. brightness: number;
  56525. /** Defines the number of octaves to process */
  56526. octaves: number;
  56527. /** Defines the level of persistence (0.8 by default) */
  56528. persistence: number;
  56529. /** Gets or sets animation speed factor (default is 1) */
  56530. animationSpeedFactor: number;
  56531. /**
  56532. * Creates a new NoiseProceduralTexture
  56533. * @param name defines the name fo the texture
  56534. * @param size defines the size of the texture (default is 256)
  56535. * @param scene defines the hosting scene
  56536. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56537. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56538. */
  56539. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56540. private _updateShaderUniforms;
  56541. protected _getDefines(): string;
  56542. /** Generate the current state of the procedural texture */
  56543. render(useCameraPostProcess?: boolean): void;
  56544. /**
  56545. * Serializes this noise procedural texture
  56546. * @returns a serialized noise procedural texture object
  56547. */
  56548. serialize(): any;
  56549. /**
  56550. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56551. * @param parsedTexture defines parsed texture data
  56552. * @param scene defines the current scene
  56553. * @param rootUrl defines the root URL containing noise procedural texture information
  56554. * @returns a parsed NoiseProceduralTexture
  56555. */
  56556. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56557. }
  56558. }
  56559. declare module BABYLON {
  56560. /**
  56561. * Raw cube texture where the raw buffers are passed in
  56562. */
  56563. export class RawCubeTexture extends CubeTexture {
  56564. /**
  56565. * Creates a cube texture where the raw buffers are passed in.
  56566. * @param scene defines the scene the texture is attached to
  56567. * @param data defines the array of data to use to create each face
  56568. * @param size defines the size of the textures
  56569. * @param format defines the format of the data
  56570. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56571. * @param generateMipMaps defines if the engine should generate the mip levels
  56572. * @param invertY defines if data must be stored with Y axis inverted
  56573. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56574. * @param compression defines the compression used (null by default)
  56575. */
  56576. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56577. /**
  56578. * Updates the raw cube texture.
  56579. * @param data defines the data to store
  56580. * @param format defines the data format
  56581. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56582. * @param invertY defines if data must be stored with Y axis inverted
  56583. * @param compression defines the compression used (null by default)
  56584. * @param level defines which level of the texture to update
  56585. */
  56586. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56587. /**
  56588. * Updates a raw cube texture with RGBD encoded data.
  56589. * @param data defines the array of data [mipmap][face] to use to create each face
  56590. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56591. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56592. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56593. * @returns a promsie that resolves when the operation is complete
  56594. */
  56595. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56596. /**
  56597. * Clones the raw cube texture.
  56598. * @return a new cube texture
  56599. */
  56600. clone(): CubeTexture;
  56601. /** @hidden */
  56602. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56603. }
  56604. }
  56605. declare module BABYLON {
  56606. /**
  56607. * Class used to store 3D textures containing user data
  56608. */
  56609. export class RawTexture3D extends Texture {
  56610. /** Gets or sets the texture format to use */
  56611. format: number;
  56612. private _engine;
  56613. /**
  56614. * Create a new RawTexture3D
  56615. * @param data defines the data of the texture
  56616. * @param width defines the width of the texture
  56617. * @param height defines the height of the texture
  56618. * @param depth defines the depth of the texture
  56619. * @param format defines the texture format to use
  56620. * @param scene defines the hosting scene
  56621. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56622. * @param invertY defines if texture must be stored with Y axis inverted
  56623. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56624. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56625. */
  56626. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56627. /** Gets or sets the texture format to use */
  56628. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56629. /**
  56630. * Update the texture with new data
  56631. * @param data defines the data to store in the texture
  56632. */
  56633. update(data: ArrayBufferView): void;
  56634. }
  56635. }
  56636. declare module BABYLON {
  56637. /**
  56638. * Class used to store 2D array textures containing user data
  56639. */
  56640. export class RawTexture2DArray extends Texture {
  56641. /** Gets or sets the texture format to use */
  56642. format: number;
  56643. private _engine;
  56644. /**
  56645. * Create a new RawTexture2DArray
  56646. * @param data defines the data of the texture
  56647. * @param width defines the width of the texture
  56648. * @param height defines the height of the texture
  56649. * @param depth defines the number of layers of the texture
  56650. * @param format defines the texture format to use
  56651. * @param scene defines the hosting scene
  56652. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56653. * @param invertY defines if texture must be stored with Y axis inverted
  56654. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56655. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56656. */
  56657. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56658. /** Gets or sets the texture format to use */
  56659. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56660. /**
  56661. * Update the texture with new data
  56662. * @param data defines the data to store in the texture
  56663. */
  56664. update(data: ArrayBufferView): void;
  56665. }
  56666. }
  56667. declare module BABYLON {
  56668. /**
  56669. * Creates a refraction texture used by refraction channel of the standard material.
  56670. * It is like a mirror but to see through a material.
  56671. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56672. */
  56673. export class RefractionTexture extends RenderTargetTexture {
  56674. /**
  56675. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56676. * 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.
  56677. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56678. */
  56679. refractionPlane: Plane;
  56680. /**
  56681. * Define how deep under the surface we should see.
  56682. */
  56683. depth: number;
  56684. /**
  56685. * Creates a refraction texture used by refraction channel of the standard material.
  56686. * It is like a mirror but to see through a material.
  56687. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56688. * @param name Define the texture name
  56689. * @param size Define the size of the underlying texture
  56690. * @param scene Define the scene the refraction belongs to
  56691. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56692. */
  56693. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56694. /**
  56695. * Clone the refraction texture.
  56696. * @returns the cloned texture
  56697. */
  56698. clone(): RefractionTexture;
  56699. /**
  56700. * Serialize the texture to a JSON representation you could use in Parse later on
  56701. * @returns the serialized JSON representation
  56702. */
  56703. serialize(): any;
  56704. }
  56705. }
  56706. declare module BABYLON {
  56707. /**
  56708. * Defines the options related to the creation of an HtmlElementTexture
  56709. */
  56710. export interface IHtmlElementTextureOptions {
  56711. /**
  56712. * Defines wether mip maps should be created or not.
  56713. */
  56714. generateMipMaps?: boolean;
  56715. /**
  56716. * Defines the sampling mode of the texture.
  56717. */
  56718. samplingMode?: number;
  56719. /**
  56720. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56721. */
  56722. engine: Nullable<ThinEngine>;
  56723. /**
  56724. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56725. */
  56726. scene: Nullable<Scene>;
  56727. }
  56728. /**
  56729. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56730. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56731. * is automatically managed.
  56732. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56733. * in your application.
  56734. *
  56735. * As the update is not automatic, you need to call them manually.
  56736. */
  56737. export class HtmlElementTexture extends BaseTexture {
  56738. /**
  56739. * The texture URL.
  56740. */
  56741. element: HTMLVideoElement | HTMLCanvasElement;
  56742. private static readonly DefaultOptions;
  56743. private _textureMatrix;
  56744. private _engine;
  56745. private _isVideo;
  56746. private _generateMipMaps;
  56747. private _samplingMode;
  56748. /**
  56749. * Instantiates a HtmlElementTexture from the following parameters.
  56750. *
  56751. * @param name Defines the name of the texture
  56752. * @param element Defines the video or canvas the texture is filled with
  56753. * @param options Defines the other none mandatory texture creation options
  56754. */
  56755. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56756. private _createInternalTexture;
  56757. /**
  56758. * Returns the texture matrix used in most of the material.
  56759. */
  56760. getTextureMatrix(): Matrix;
  56761. /**
  56762. * Updates the content of the texture.
  56763. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56764. */
  56765. update(invertY?: Nullable<boolean>): void;
  56766. }
  56767. }
  56768. declare module BABYLON {
  56769. /**
  56770. * Defines the basic options interface of a TexturePacker Frame
  56771. */
  56772. export interface ITexturePackerFrame {
  56773. /**
  56774. * The frame ID
  56775. */
  56776. id: number;
  56777. /**
  56778. * The frames Scale
  56779. */
  56780. scale: Vector2;
  56781. /**
  56782. * The Frames offset
  56783. */
  56784. offset: Vector2;
  56785. }
  56786. /**
  56787. * This is a support class for frame Data on texture packer sets.
  56788. */
  56789. export class TexturePackerFrame implements ITexturePackerFrame {
  56790. /**
  56791. * The frame ID
  56792. */
  56793. id: number;
  56794. /**
  56795. * The frames Scale
  56796. */
  56797. scale: Vector2;
  56798. /**
  56799. * The Frames offset
  56800. */
  56801. offset: Vector2;
  56802. /**
  56803. * Initializes a texture package frame.
  56804. * @param id The numerical frame identifier
  56805. * @param scale Scalar Vector2 for UV frame
  56806. * @param offset Vector2 for the frame position in UV units.
  56807. * @returns TexturePackerFrame
  56808. */
  56809. constructor(id: number, scale: Vector2, offset: Vector2);
  56810. }
  56811. }
  56812. declare module BABYLON {
  56813. /**
  56814. * Defines the basic options interface of a TexturePacker
  56815. */
  56816. export interface ITexturePackerOptions {
  56817. /**
  56818. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56819. */
  56820. map?: string[];
  56821. /**
  56822. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56823. */
  56824. uvsIn?: string;
  56825. /**
  56826. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56827. */
  56828. uvsOut?: string;
  56829. /**
  56830. * number representing the layout style. Defaults to LAYOUT_STRIP
  56831. */
  56832. layout?: number;
  56833. /**
  56834. * number of columns if using custom column count layout(2). This defaults to 4.
  56835. */
  56836. colnum?: number;
  56837. /**
  56838. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56839. */
  56840. updateInputMeshes?: boolean;
  56841. /**
  56842. * boolean flag to dispose all the source textures. Defaults to true.
  56843. */
  56844. disposeSources?: boolean;
  56845. /**
  56846. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56847. */
  56848. fillBlanks?: boolean;
  56849. /**
  56850. * string value representing the context fill style color. Defaults to 'black'.
  56851. */
  56852. customFillColor?: string;
  56853. /**
  56854. * Width and Height Value of each Frame in the TexturePacker Sets
  56855. */
  56856. frameSize?: number;
  56857. /**
  56858. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56859. */
  56860. paddingRatio?: number;
  56861. /**
  56862. * Number that declares the fill method for the padding gutter.
  56863. */
  56864. paddingMode?: number;
  56865. /**
  56866. * If in SUBUV_COLOR padding mode what color to use.
  56867. */
  56868. paddingColor?: Color3 | Color4;
  56869. }
  56870. /**
  56871. * Defines the basic interface of a TexturePacker JSON File
  56872. */
  56873. export interface ITexturePackerJSON {
  56874. /**
  56875. * The frame ID
  56876. */
  56877. name: string;
  56878. /**
  56879. * The base64 channel data
  56880. */
  56881. sets: any;
  56882. /**
  56883. * The options of the Packer
  56884. */
  56885. options: ITexturePackerOptions;
  56886. /**
  56887. * The frame data of the Packer
  56888. */
  56889. frames: Array<number>;
  56890. }
  56891. /**
  56892. * This is a support class that generates a series of packed texture sets.
  56893. * @see https://doc.babylonjs.com/babylon101/materials
  56894. */
  56895. export class TexturePacker {
  56896. /** Packer Layout Constant 0 */
  56897. static readonly LAYOUT_STRIP: number;
  56898. /** Packer Layout Constant 1 */
  56899. static readonly LAYOUT_POWER2: number;
  56900. /** Packer Layout Constant 2 */
  56901. static readonly LAYOUT_COLNUM: number;
  56902. /** Packer Layout Constant 0 */
  56903. static readonly SUBUV_WRAP: number;
  56904. /** Packer Layout Constant 1 */
  56905. static readonly SUBUV_EXTEND: number;
  56906. /** Packer Layout Constant 2 */
  56907. static readonly SUBUV_COLOR: number;
  56908. /** The Name of the Texture Package */
  56909. name: string;
  56910. /** The scene scope of the TexturePacker */
  56911. scene: Scene;
  56912. /** The Meshes to target */
  56913. meshes: AbstractMesh[];
  56914. /** Arguments passed with the Constructor */
  56915. options: ITexturePackerOptions;
  56916. /** The promise that is started upon initialization */
  56917. promise: Nullable<Promise<TexturePacker | string>>;
  56918. /** The Container object for the channel sets that are generated */
  56919. sets: object;
  56920. /** The Container array for the frames that are generated */
  56921. frames: TexturePackerFrame[];
  56922. /** The expected number of textures the system is parsing. */
  56923. private _expecting;
  56924. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56925. private _paddingValue;
  56926. /**
  56927. * Initializes a texture package series from an array of meshes or a single mesh.
  56928. * @param name The name of the package
  56929. * @param meshes The target meshes to compose the package from
  56930. * @param options The arguments that texture packer should follow while building.
  56931. * @param scene The scene which the textures are scoped to.
  56932. * @returns TexturePacker
  56933. */
  56934. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56935. /**
  56936. * Starts the package process
  56937. * @param resolve The promises resolution function
  56938. * @returns TexturePacker
  56939. */
  56940. private _createFrames;
  56941. /**
  56942. * Calculates the Size of the Channel Sets
  56943. * @returns Vector2
  56944. */
  56945. private _calculateSize;
  56946. /**
  56947. * Calculates the UV data for the frames.
  56948. * @param baseSize the base frameSize
  56949. * @param padding the base frame padding
  56950. * @param dtSize size of the Dynamic Texture for that channel
  56951. * @param dtUnits is 1/dtSize
  56952. * @param update flag to update the input meshes
  56953. */
  56954. private _calculateMeshUVFrames;
  56955. /**
  56956. * Calculates the frames Offset.
  56957. * @param index of the frame
  56958. * @returns Vector2
  56959. */
  56960. private _getFrameOffset;
  56961. /**
  56962. * Updates a Mesh to the frame data
  56963. * @param mesh that is the target
  56964. * @param frameID or the frame index
  56965. */
  56966. private _updateMeshUV;
  56967. /**
  56968. * Updates a Meshes materials to use the texture packer channels
  56969. * @param m is the mesh to target
  56970. * @param force all channels on the packer to be set.
  56971. */
  56972. private _updateTextureReferences;
  56973. /**
  56974. * Public method to set a Mesh to a frame
  56975. * @param m that is the target
  56976. * @param frameID or the frame index
  56977. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56978. */
  56979. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56980. /**
  56981. * Starts the async promise to compile the texture packer.
  56982. * @returns Promise<void>
  56983. */
  56984. processAsync(): Promise<void>;
  56985. /**
  56986. * Disposes all textures associated with this packer
  56987. */
  56988. dispose(): void;
  56989. /**
  56990. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56991. * @param imageType is the image type to use.
  56992. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56993. */
  56994. download(imageType?: string, quality?: number): void;
  56995. /**
  56996. * Public method to load a texturePacker JSON file.
  56997. * @param data of the JSON file in string format.
  56998. */
  56999. updateFromJSON(data: string): void;
  57000. }
  57001. }
  57002. declare module BABYLON {
  57003. /**
  57004. * Enum used to define the target of a block
  57005. */
  57006. export enum NodeMaterialBlockTargets {
  57007. /** Vertex shader */
  57008. Vertex = 1,
  57009. /** Fragment shader */
  57010. Fragment = 2,
  57011. /** Neutral */
  57012. Neutral = 4,
  57013. /** Vertex and Fragment */
  57014. VertexAndFragment = 3
  57015. }
  57016. }
  57017. declare module BABYLON {
  57018. /**
  57019. * Defines the kind of connection point for node based material
  57020. */
  57021. export enum NodeMaterialBlockConnectionPointTypes {
  57022. /** Float */
  57023. Float = 1,
  57024. /** Int */
  57025. Int = 2,
  57026. /** Vector2 */
  57027. Vector2 = 4,
  57028. /** Vector3 */
  57029. Vector3 = 8,
  57030. /** Vector4 */
  57031. Vector4 = 16,
  57032. /** Color3 */
  57033. Color3 = 32,
  57034. /** Color4 */
  57035. Color4 = 64,
  57036. /** Matrix */
  57037. Matrix = 128,
  57038. /** Detect type based on connection */
  57039. AutoDetect = 1024,
  57040. /** Output type that will be defined by input type */
  57041. BasedOnInput = 2048
  57042. }
  57043. }
  57044. declare module BABYLON {
  57045. /**
  57046. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57047. */
  57048. export enum NodeMaterialBlockConnectionPointMode {
  57049. /** Value is an uniform */
  57050. Uniform = 0,
  57051. /** Value is a mesh attribute */
  57052. Attribute = 1,
  57053. /** Value is a varying between vertex and fragment shaders */
  57054. Varying = 2,
  57055. /** Mode is undefined */
  57056. Undefined = 3
  57057. }
  57058. }
  57059. declare module BABYLON {
  57060. /**
  57061. * Enum used to define system values e.g. values automatically provided by the system
  57062. */
  57063. export enum NodeMaterialSystemValues {
  57064. /** World */
  57065. World = 1,
  57066. /** View */
  57067. View = 2,
  57068. /** Projection */
  57069. Projection = 3,
  57070. /** ViewProjection */
  57071. ViewProjection = 4,
  57072. /** WorldView */
  57073. WorldView = 5,
  57074. /** WorldViewProjection */
  57075. WorldViewProjection = 6,
  57076. /** CameraPosition */
  57077. CameraPosition = 7,
  57078. /** Fog Color */
  57079. FogColor = 8,
  57080. /** Delta time */
  57081. DeltaTime = 9
  57082. }
  57083. }
  57084. declare module BABYLON {
  57085. /**
  57086. * Root class for all node material optimizers
  57087. */
  57088. export class NodeMaterialOptimizer {
  57089. /**
  57090. * Function used to optimize a NodeMaterial graph
  57091. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57092. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57093. */
  57094. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57095. }
  57096. }
  57097. declare module BABYLON {
  57098. /**
  57099. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57100. */
  57101. export class TransformBlock extends NodeMaterialBlock {
  57102. /**
  57103. * Defines the value to use to complement W value to transform it to a Vector4
  57104. */
  57105. complementW: number;
  57106. /**
  57107. * Defines the value to use to complement z value to transform it to a Vector4
  57108. */
  57109. complementZ: number;
  57110. /**
  57111. * Creates a new TransformBlock
  57112. * @param name defines the block name
  57113. */
  57114. constructor(name: string);
  57115. /**
  57116. * Gets the current class name
  57117. * @returns the class name
  57118. */
  57119. getClassName(): string;
  57120. /**
  57121. * Gets the vector input
  57122. */
  57123. get vector(): NodeMaterialConnectionPoint;
  57124. /**
  57125. * Gets the output component
  57126. */
  57127. get output(): NodeMaterialConnectionPoint;
  57128. /**
  57129. * Gets the xyz output component
  57130. */
  57131. get xyz(): NodeMaterialConnectionPoint;
  57132. /**
  57133. * Gets the matrix transform input
  57134. */
  57135. get transform(): NodeMaterialConnectionPoint;
  57136. protected _buildBlock(state: NodeMaterialBuildState): this;
  57137. serialize(): any;
  57138. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57139. protected _dumpPropertiesCode(): string;
  57140. }
  57141. }
  57142. declare module BABYLON {
  57143. /**
  57144. * Block used to output the vertex position
  57145. */
  57146. export class VertexOutputBlock extends NodeMaterialBlock {
  57147. /**
  57148. * Creates a new VertexOutputBlock
  57149. * @param name defines the block name
  57150. */
  57151. constructor(name: string);
  57152. /**
  57153. * Gets the current class name
  57154. * @returns the class name
  57155. */
  57156. getClassName(): string;
  57157. /**
  57158. * Gets the vector input component
  57159. */
  57160. get vector(): NodeMaterialConnectionPoint;
  57161. protected _buildBlock(state: NodeMaterialBuildState): this;
  57162. }
  57163. }
  57164. declare module BABYLON {
  57165. /**
  57166. * Block used to output the final color
  57167. */
  57168. export class FragmentOutputBlock extends NodeMaterialBlock {
  57169. /**
  57170. * Create a new FragmentOutputBlock
  57171. * @param name defines the block name
  57172. */
  57173. constructor(name: string);
  57174. /**
  57175. * Gets the current class name
  57176. * @returns the class name
  57177. */
  57178. getClassName(): string;
  57179. /**
  57180. * Gets the rgba input component
  57181. */
  57182. get rgba(): NodeMaterialConnectionPoint;
  57183. /**
  57184. * Gets the rgb input component
  57185. */
  57186. get rgb(): NodeMaterialConnectionPoint;
  57187. /**
  57188. * Gets the a input component
  57189. */
  57190. get a(): NodeMaterialConnectionPoint;
  57191. protected _buildBlock(state: NodeMaterialBuildState): this;
  57192. }
  57193. }
  57194. declare module BABYLON {
  57195. /**
  57196. * Block used to read a reflection texture from a sampler
  57197. */
  57198. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57199. private _define3DName;
  57200. private _defineCubicName;
  57201. private _defineExplicitName;
  57202. private _defineProjectionName;
  57203. private _defineLocalCubicName;
  57204. private _defineSphericalName;
  57205. private _definePlanarName;
  57206. private _defineEquirectangularName;
  57207. private _defineMirroredEquirectangularFixedName;
  57208. private _defineEquirectangularFixedName;
  57209. private _defineSkyboxName;
  57210. private _cubeSamplerName;
  57211. private _2DSamplerName;
  57212. private _positionUVWName;
  57213. private _directionWName;
  57214. private _reflectionCoordsName;
  57215. private _reflection2DCoordsName;
  57216. private _reflectionColorName;
  57217. private _reflectionMatrixName;
  57218. /**
  57219. * Gets or sets the texture associated with the node
  57220. */
  57221. texture: Nullable<BaseTexture>;
  57222. /**
  57223. * Create a new TextureBlock
  57224. * @param name defines the block name
  57225. */
  57226. constructor(name: string);
  57227. /**
  57228. * Gets the current class name
  57229. * @returns the class name
  57230. */
  57231. getClassName(): string;
  57232. /**
  57233. * Gets the world position input component
  57234. */
  57235. get position(): NodeMaterialConnectionPoint;
  57236. /**
  57237. * Gets the world position input component
  57238. */
  57239. get worldPosition(): NodeMaterialConnectionPoint;
  57240. /**
  57241. * Gets the world normal input component
  57242. */
  57243. get worldNormal(): NodeMaterialConnectionPoint;
  57244. /**
  57245. * Gets the world input component
  57246. */
  57247. get world(): NodeMaterialConnectionPoint;
  57248. /**
  57249. * Gets the camera (or eye) position component
  57250. */
  57251. get cameraPosition(): NodeMaterialConnectionPoint;
  57252. /**
  57253. * Gets the view input component
  57254. */
  57255. get view(): NodeMaterialConnectionPoint;
  57256. /**
  57257. * Gets the rgb output component
  57258. */
  57259. get rgb(): NodeMaterialConnectionPoint;
  57260. /**
  57261. * Gets the r output component
  57262. */
  57263. get r(): NodeMaterialConnectionPoint;
  57264. /**
  57265. * Gets the g output component
  57266. */
  57267. get g(): NodeMaterialConnectionPoint;
  57268. /**
  57269. * Gets the b output component
  57270. */
  57271. get b(): NodeMaterialConnectionPoint;
  57272. autoConfigure(material: NodeMaterial): void;
  57273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57274. isReady(): boolean;
  57275. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57276. private _injectVertexCode;
  57277. private _writeOutput;
  57278. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57279. protected _dumpPropertiesCode(): string;
  57280. serialize(): any;
  57281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57282. }
  57283. }
  57284. declare module BABYLON {
  57285. /**
  57286. * Interface used to configure the node material editor
  57287. */
  57288. export interface INodeMaterialEditorOptions {
  57289. /** Define the URl to load node editor script */
  57290. editorURL?: string;
  57291. }
  57292. /** @hidden */
  57293. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57294. NORMAL: boolean;
  57295. TANGENT: boolean;
  57296. UV1: boolean;
  57297. /** BONES */
  57298. NUM_BONE_INFLUENCERS: number;
  57299. BonesPerMesh: number;
  57300. BONETEXTURE: boolean;
  57301. /** MORPH TARGETS */
  57302. MORPHTARGETS: boolean;
  57303. MORPHTARGETS_NORMAL: boolean;
  57304. MORPHTARGETS_TANGENT: boolean;
  57305. MORPHTARGETS_UV: boolean;
  57306. NUM_MORPH_INFLUENCERS: number;
  57307. /** IMAGE PROCESSING */
  57308. IMAGEPROCESSING: boolean;
  57309. VIGNETTE: boolean;
  57310. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57311. VIGNETTEBLENDMODEOPAQUE: boolean;
  57312. TONEMAPPING: boolean;
  57313. TONEMAPPING_ACES: boolean;
  57314. CONTRAST: boolean;
  57315. EXPOSURE: boolean;
  57316. COLORCURVES: boolean;
  57317. COLORGRADING: boolean;
  57318. COLORGRADING3D: boolean;
  57319. SAMPLER3DGREENDEPTH: boolean;
  57320. SAMPLER3DBGRMAP: boolean;
  57321. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57322. /** MISC. */
  57323. BUMPDIRECTUV: number;
  57324. constructor();
  57325. setValue(name: string, value: boolean): void;
  57326. }
  57327. /**
  57328. * Class used to configure NodeMaterial
  57329. */
  57330. export interface INodeMaterialOptions {
  57331. /**
  57332. * Defines if blocks should emit comments
  57333. */
  57334. emitComments: boolean;
  57335. }
  57336. /**
  57337. * Class used to create a node based material built by assembling shader blocks
  57338. */
  57339. export class NodeMaterial extends PushMaterial {
  57340. private static _BuildIdGenerator;
  57341. private _options;
  57342. private _vertexCompilationState;
  57343. private _fragmentCompilationState;
  57344. private _sharedData;
  57345. private _buildId;
  57346. private _buildWasSuccessful;
  57347. private _cachedWorldViewMatrix;
  57348. private _cachedWorldViewProjectionMatrix;
  57349. private _optimizers;
  57350. private _animationFrame;
  57351. /** Define the Url to load node editor script */
  57352. static EditorURL: string;
  57353. /** Define the Url to load snippets */
  57354. static SnippetUrl: string;
  57355. private BJSNODEMATERIALEDITOR;
  57356. /** Get the inspector from bundle or global */
  57357. private _getGlobalNodeMaterialEditor;
  57358. /**
  57359. * Gets or sets data used by visual editor
  57360. * @see https://nme.babylonjs.com
  57361. */
  57362. editorData: any;
  57363. /**
  57364. * 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)
  57365. */
  57366. ignoreAlpha: boolean;
  57367. /**
  57368. * Defines the maximum number of lights that can be used in the material
  57369. */
  57370. maxSimultaneousLights: number;
  57371. /**
  57372. * Observable raised when the material is built
  57373. */
  57374. onBuildObservable: Observable<NodeMaterial>;
  57375. /**
  57376. * Gets or sets the root nodes of the material vertex shader
  57377. */
  57378. _vertexOutputNodes: NodeMaterialBlock[];
  57379. /**
  57380. * Gets or sets the root nodes of the material fragment (pixel) shader
  57381. */
  57382. _fragmentOutputNodes: NodeMaterialBlock[];
  57383. /** Gets or sets options to control the node material overall behavior */
  57384. get options(): INodeMaterialOptions;
  57385. set options(options: INodeMaterialOptions);
  57386. /**
  57387. * Default configuration related to image processing available in the standard Material.
  57388. */
  57389. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57390. /**
  57391. * Gets the image processing configuration used either in this material.
  57392. */
  57393. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57394. /**
  57395. * Sets the Default image processing configuration used either in the this material.
  57396. *
  57397. * If sets to null, the scene one is in use.
  57398. */
  57399. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57400. /**
  57401. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57402. */
  57403. attachedBlocks: NodeMaterialBlock[];
  57404. /**
  57405. * Create a new node based material
  57406. * @param name defines the material name
  57407. * @param scene defines the hosting scene
  57408. * @param options defines creation option
  57409. */
  57410. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57411. /**
  57412. * Gets the current class name of the material e.g. "NodeMaterial"
  57413. * @returns the class name
  57414. */
  57415. getClassName(): string;
  57416. /**
  57417. * Keep track of the image processing observer to allow dispose and replace.
  57418. */
  57419. private _imageProcessingObserver;
  57420. /**
  57421. * Attaches a new image processing configuration to the Standard Material.
  57422. * @param configuration
  57423. */
  57424. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57425. /**
  57426. * Get a block by its name
  57427. * @param name defines the name of the block to retrieve
  57428. * @returns the required block or null if not found
  57429. */
  57430. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57431. /**
  57432. * Get a block by its name
  57433. * @param predicate defines the predicate used to find the good candidate
  57434. * @returns the required block or null if not found
  57435. */
  57436. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57437. /**
  57438. * Get an input block by its name
  57439. * @param predicate defines the predicate used to find the good candidate
  57440. * @returns the required input block or null if not found
  57441. */
  57442. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57443. /**
  57444. * Gets the list of input blocks attached to this material
  57445. * @returns an array of InputBlocks
  57446. */
  57447. getInputBlocks(): InputBlock[];
  57448. /**
  57449. * Adds a new optimizer to the list of optimizers
  57450. * @param optimizer defines the optimizers to add
  57451. * @returns the current material
  57452. */
  57453. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57454. /**
  57455. * Remove an optimizer from the list of optimizers
  57456. * @param optimizer defines the optimizers to remove
  57457. * @returns the current material
  57458. */
  57459. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57460. /**
  57461. * Add a new block to the list of output nodes
  57462. * @param node defines the node to add
  57463. * @returns the current material
  57464. */
  57465. addOutputNode(node: NodeMaterialBlock): this;
  57466. /**
  57467. * Remove a block from the list of root nodes
  57468. * @param node defines the node to remove
  57469. * @returns the current material
  57470. */
  57471. removeOutputNode(node: NodeMaterialBlock): this;
  57472. private _addVertexOutputNode;
  57473. private _removeVertexOutputNode;
  57474. private _addFragmentOutputNode;
  57475. private _removeFragmentOutputNode;
  57476. /**
  57477. * Specifies if the material will require alpha blending
  57478. * @returns a boolean specifying if alpha blending is needed
  57479. */
  57480. needAlphaBlending(): boolean;
  57481. /**
  57482. * Specifies if this material should be rendered in alpha test mode
  57483. * @returns a boolean specifying if an alpha test is needed.
  57484. */
  57485. needAlphaTesting(): boolean;
  57486. private _initializeBlock;
  57487. private _resetDualBlocks;
  57488. /**
  57489. * Remove a block from the current node material
  57490. * @param block defines the block to remove
  57491. */
  57492. removeBlock(block: NodeMaterialBlock): void;
  57493. /**
  57494. * Build the material and generates the inner effect
  57495. * @param verbose defines if the build should log activity
  57496. */
  57497. build(verbose?: boolean): void;
  57498. /**
  57499. * Runs an otpimization phase to try to improve the shader code
  57500. */
  57501. optimize(): void;
  57502. private _prepareDefinesForAttributes;
  57503. /**
  57504. * Get if the submesh is ready to be used and all its information available.
  57505. * Child classes can use it to update shaders
  57506. * @param mesh defines the mesh to check
  57507. * @param subMesh defines which submesh to check
  57508. * @param useInstances specifies that instances should be used
  57509. * @returns a boolean indicating that the submesh is ready or not
  57510. */
  57511. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57512. /**
  57513. * Get a string representing the shaders built by the current node graph
  57514. */
  57515. get compiledShaders(): string;
  57516. /**
  57517. * Binds the world matrix to the material
  57518. * @param world defines the world transformation matrix
  57519. */
  57520. bindOnlyWorldMatrix(world: Matrix): void;
  57521. /**
  57522. * Binds the submesh to this material by preparing the effect and shader to draw
  57523. * @param world defines the world transformation matrix
  57524. * @param mesh defines the mesh containing the submesh
  57525. * @param subMesh defines the submesh to bind the material to
  57526. */
  57527. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57528. /**
  57529. * Gets the active textures from the material
  57530. * @returns an array of textures
  57531. */
  57532. getActiveTextures(): BaseTexture[];
  57533. /**
  57534. * Gets the list of texture blocks
  57535. * @returns an array of texture blocks
  57536. */
  57537. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57538. /**
  57539. * Specifies if the material uses a texture
  57540. * @param texture defines the texture to check against the material
  57541. * @returns a boolean specifying if the material uses the texture
  57542. */
  57543. hasTexture(texture: BaseTexture): boolean;
  57544. /**
  57545. * Disposes the material
  57546. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57547. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57548. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57549. */
  57550. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57551. /** Creates the node editor window. */
  57552. private _createNodeEditor;
  57553. /**
  57554. * Launch the node material editor
  57555. * @param config Define the configuration of the editor
  57556. * @return a promise fulfilled when the node editor is visible
  57557. */
  57558. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57559. /**
  57560. * Clear the current material
  57561. */
  57562. clear(): void;
  57563. /**
  57564. * Clear the current material and set it to a default state
  57565. */
  57566. setToDefault(): void;
  57567. /**
  57568. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57569. * @param url defines the url to load from
  57570. * @returns a promise that will fullfil when the material is fully loaded
  57571. */
  57572. loadAsync(url: string): Promise<void>;
  57573. private _gatherBlocks;
  57574. /**
  57575. * Generate a string containing the code declaration required to create an equivalent of this material
  57576. * @returns a string
  57577. */
  57578. generateCode(): string;
  57579. /**
  57580. * Serializes this material in a JSON representation
  57581. * @returns the serialized material object
  57582. */
  57583. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57584. private _restoreConnections;
  57585. /**
  57586. * Clear the current graph and load a new one from a serialization object
  57587. * @param source defines the JSON representation of the material
  57588. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57589. */
  57590. loadFromSerialization(source: any, rootUrl?: string): void;
  57591. /**
  57592. * Makes a duplicate of the current material.
  57593. * @param name - name to use for the new material.
  57594. */
  57595. clone(name: string): NodeMaterial;
  57596. /**
  57597. * Creates a node material from parsed material data
  57598. * @param source defines the JSON representation of the material
  57599. * @param scene defines the hosting scene
  57600. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57601. * @returns a new node material
  57602. */
  57603. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57604. /**
  57605. * Creates a node material from a snippet saved in a remote file
  57606. * @param name defines the name of the material to create
  57607. * @param url defines the url to load from
  57608. * @param scene defines the hosting scene
  57609. * @returns a promise that will resolve to the new node material
  57610. */
  57611. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57612. /**
  57613. * Creates a node material from a snippet saved by the node material editor
  57614. * @param snippetId defines the snippet to load
  57615. * @param scene defines the hosting scene
  57616. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57617. * @returns a promise that will resolve to the new node material
  57618. */
  57619. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57620. /**
  57621. * Creates a new node material set to default basic configuration
  57622. * @param name defines the name of the material
  57623. * @param scene defines the hosting scene
  57624. * @returns a new NodeMaterial
  57625. */
  57626. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57627. }
  57628. }
  57629. declare module BABYLON {
  57630. /**
  57631. * Block used to read a texture from a sampler
  57632. */
  57633. export class TextureBlock extends NodeMaterialBlock {
  57634. private _defineName;
  57635. private _linearDefineName;
  57636. private _tempTextureRead;
  57637. private _samplerName;
  57638. private _transformedUVName;
  57639. private _textureTransformName;
  57640. private _textureInfoName;
  57641. private _mainUVName;
  57642. private _mainUVDefineName;
  57643. /**
  57644. * Gets or sets the texture associated with the node
  57645. */
  57646. texture: Nullable<Texture>;
  57647. /**
  57648. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57649. */
  57650. convertToGammaSpace: boolean;
  57651. /**
  57652. * Create a new TextureBlock
  57653. * @param name defines the block name
  57654. */
  57655. constructor(name: string);
  57656. /**
  57657. * Gets the current class name
  57658. * @returns the class name
  57659. */
  57660. getClassName(): string;
  57661. /**
  57662. * Gets the uv input component
  57663. */
  57664. get uv(): NodeMaterialConnectionPoint;
  57665. /**
  57666. * Gets the rgba output component
  57667. */
  57668. get rgba(): NodeMaterialConnectionPoint;
  57669. /**
  57670. * Gets the rgb output component
  57671. */
  57672. get rgb(): NodeMaterialConnectionPoint;
  57673. /**
  57674. * Gets the r output component
  57675. */
  57676. get r(): NodeMaterialConnectionPoint;
  57677. /**
  57678. * Gets the g output component
  57679. */
  57680. get g(): NodeMaterialConnectionPoint;
  57681. /**
  57682. * Gets the b output component
  57683. */
  57684. get b(): NodeMaterialConnectionPoint;
  57685. /**
  57686. * Gets the a output component
  57687. */
  57688. get a(): NodeMaterialConnectionPoint;
  57689. get target(): NodeMaterialBlockTargets;
  57690. autoConfigure(material: NodeMaterial): void;
  57691. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57693. isReady(): boolean;
  57694. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57695. private get _isMixed();
  57696. private _injectVertexCode;
  57697. private _writeTextureRead;
  57698. private _writeOutput;
  57699. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57700. protected _dumpPropertiesCode(): string;
  57701. serialize(): any;
  57702. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57703. }
  57704. }
  57705. declare module BABYLON {
  57706. /**
  57707. * Class used to store shared data between 2 NodeMaterialBuildState
  57708. */
  57709. export class NodeMaterialBuildStateSharedData {
  57710. /**
  57711. * Gets the list of emitted varyings
  57712. */
  57713. temps: string[];
  57714. /**
  57715. * Gets the list of emitted varyings
  57716. */
  57717. varyings: string[];
  57718. /**
  57719. * Gets the varying declaration string
  57720. */
  57721. varyingDeclaration: string;
  57722. /**
  57723. * Input blocks
  57724. */
  57725. inputBlocks: InputBlock[];
  57726. /**
  57727. * Input blocks
  57728. */
  57729. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57730. /**
  57731. * Bindable blocks (Blocks that need to set data to the effect)
  57732. */
  57733. bindableBlocks: NodeMaterialBlock[];
  57734. /**
  57735. * List of blocks that can provide a compilation fallback
  57736. */
  57737. blocksWithFallbacks: NodeMaterialBlock[];
  57738. /**
  57739. * List of blocks that can provide a define update
  57740. */
  57741. blocksWithDefines: NodeMaterialBlock[];
  57742. /**
  57743. * List of blocks that can provide a repeatable content
  57744. */
  57745. repeatableContentBlocks: NodeMaterialBlock[];
  57746. /**
  57747. * List of blocks that can provide a dynamic list of uniforms
  57748. */
  57749. dynamicUniformBlocks: NodeMaterialBlock[];
  57750. /**
  57751. * List of blocks that can block the isReady function for the material
  57752. */
  57753. blockingBlocks: NodeMaterialBlock[];
  57754. /**
  57755. * Gets the list of animated inputs
  57756. */
  57757. animatedInputs: InputBlock[];
  57758. /**
  57759. * Build Id used to avoid multiple recompilations
  57760. */
  57761. buildId: number;
  57762. /** List of emitted variables */
  57763. variableNames: {
  57764. [key: string]: number;
  57765. };
  57766. /** List of emitted defines */
  57767. defineNames: {
  57768. [key: string]: number;
  57769. };
  57770. /** Should emit comments? */
  57771. emitComments: boolean;
  57772. /** Emit build activity */
  57773. verbose: boolean;
  57774. /** Gets or sets the hosting scene */
  57775. scene: Scene;
  57776. /**
  57777. * Gets the compilation hints emitted at compilation time
  57778. */
  57779. hints: {
  57780. needWorldViewMatrix: boolean;
  57781. needWorldViewProjectionMatrix: boolean;
  57782. needAlphaBlending: boolean;
  57783. needAlphaTesting: boolean;
  57784. };
  57785. /**
  57786. * List of compilation checks
  57787. */
  57788. checks: {
  57789. emitVertex: boolean;
  57790. emitFragment: boolean;
  57791. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57792. };
  57793. /** Creates a new shared data */
  57794. constructor();
  57795. /**
  57796. * Emits console errors and exceptions if there is a failing check
  57797. */
  57798. emitErrors(): void;
  57799. }
  57800. }
  57801. declare module BABYLON {
  57802. /**
  57803. * Class used to store node based material build state
  57804. */
  57805. export class NodeMaterialBuildState {
  57806. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57807. supportUniformBuffers: boolean;
  57808. /**
  57809. * Gets the list of emitted attributes
  57810. */
  57811. attributes: string[];
  57812. /**
  57813. * Gets the list of emitted uniforms
  57814. */
  57815. uniforms: string[];
  57816. /**
  57817. * Gets the list of emitted constants
  57818. */
  57819. constants: string[];
  57820. /**
  57821. * Gets the list of emitted samplers
  57822. */
  57823. samplers: string[];
  57824. /**
  57825. * Gets the list of emitted functions
  57826. */
  57827. functions: {
  57828. [key: string]: string;
  57829. };
  57830. /**
  57831. * Gets the list of emitted extensions
  57832. */
  57833. extensions: {
  57834. [key: string]: string;
  57835. };
  57836. /**
  57837. * Gets the target of the compilation state
  57838. */
  57839. target: NodeMaterialBlockTargets;
  57840. /**
  57841. * Gets the list of emitted counters
  57842. */
  57843. counters: {
  57844. [key: string]: number;
  57845. };
  57846. /**
  57847. * Shared data between multiple NodeMaterialBuildState instances
  57848. */
  57849. sharedData: NodeMaterialBuildStateSharedData;
  57850. /** @hidden */
  57851. _vertexState: NodeMaterialBuildState;
  57852. /** @hidden */
  57853. _attributeDeclaration: string;
  57854. /** @hidden */
  57855. _uniformDeclaration: string;
  57856. /** @hidden */
  57857. _constantDeclaration: string;
  57858. /** @hidden */
  57859. _samplerDeclaration: string;
  57860. /** @hidden */
  57861. _varyingTransfer: string;
  57862. private _repeatableContentAnchorIndex;
  57863. /** @hidden */
  57864. _builtCompilationString: string;
  57865. /**
  57866. * Gets the emitted compilation strings
  57867. */
  57868. compilationString: string;
  57869. /**
  57870. * Finalize the compilation strings
  57871. * @param state defines the current compilation state
  57872. */
  57873. finalize(state: NodeMaterialBuildState): void;
  57874. /** @hidden */
  57875. get _repeatableContentAnchor(): string;
  57876. /** @hidden */
  57877. _getFreeVariableName(prefix: string): string;
  57878. /** @hidden */
  57879. _getFreeDefineName(prefix: string): string;
  57880. /** @hidden */
  57881. _excludeVariableName(name: string): void;
  57882. /** @hidden */
  57883. _emit2DSampler(name: string): void;
  57884. /** @hidden */
  57885. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57886. /** @hidden */
  57887. _emitExtension(name: string, extension: string): void;
  57888. /** @hidden */
  57889. _emitFunction(name: string, code: string, comments: string): void;
  57890. /** @hidden */
  57891. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57892. replaceStrings?: {
  57893. search: RegExp;
  57894. replace: string;
  57895. }[];
  57896. repeatKey?: string;
  57897. }): string;
  57898. /** @hidden */
  57899. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57900. repeatKey?: string;
  57901. removeAttributes?: boolean;
  57902. removeUniforms?: boolean;
  57903. removeVaryings?: boolean;
  57904. removeIfDef?: boolean;
  57905. replaceStrings?: {
  57906. search: RegExp;
  57907. replace: string;
  57908. }[];
  57909. }, storeKey?: string): void;
  57910. /** @hidden */
  57911. _registerTempVariable(name: string): boolean;
  57912. /** @hidden */
  57913. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57914. /** @hidden */
  57915. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57916. /** @hidden */
  57917. _emitFloat(value: number): string;
  57918. }
  57919. }
  57920. declare module BABYLON {
  57921. /**
  57922. * Defines a block that can be used inside a node based material
  57923. */
  57924. export class NodeMaterialBlock {
  57925. private _buildId;
  57926. private _buildTarget;
  57927. private _target;
  57928. private _isFinalMerger;
  57929. private _isInput;
  57930. protected _isUnique: boolean;
  57931. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57932. inputsAreExclusive: boolean;
  57933. /** @hidden */
  57934. _codeVariableName: string;
  57935. /** @hidden */
  57936. _inputs: NodeMaterialConnectionPoint[];
  57937. /** @hidden */
  57938. _outputs: NodeMaterialConnectionPoint[];
  57939. /** @hidden */
  57940. _preparationId: number;
  57941. /**
  57942. * Gets or sets the name of the block
  57943. */
  57944. name: string;
  57945. /**
  57946. * Gets or sets the unique id of the node
  57947. */
  57948. uniqueId: number;
  57949. /**
  57950. * Gets or sets the comments associated with this block
  57951. */
  57952. comments: string;
  57953. /**
  57954. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57955. */
  57956. get isUnique(): boolean;
  57957. /**
  57958. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57959. */
  57960. get isFinalMerger(): boolean;
  57961. /**
  57962. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57963. */
  57964. get isInput(): boolean;
  57965. /**
  57966. * Gets or sets the build Id
  57967. */
  57968. get buildId(): number;
  57969. set buildId(value: number);
  57970. /**
  57971. * Gets or sets the target of the block
  57972. */
  57973. get target(): NodeMaterialBlockTargets;
  57974. set target(value: NodeMaterialBlockTargets);
  57975. /**
  57976. * Gets the list of input points
  57977. */
  57978. get inputs(): NodeMaterialConnectionPoint[];
  57979. /** Gets the list of output points */
  57980. get outputs(): NodeMaterialConnectionPoint[];
  57981. /**
  57982. * Find an input by its name
  57983. * @param name defines the name of the input to look for
  57984. * @returns the input or null if not found
  57985. */
  57986. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57987. /**
  57988. * Find an output by its name
  57989. * @param name defines the name of the outputto look for
  57990. * @returns the output or null if not found
  57991. */
  57992. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57993. /**
  57994. * Creates a new NodeMaterialBlock
  57995. * @param name defines the block name
  57996. * @param target defines the target of that block (Vertex by default)
  57997. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57998. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57999. */
  58000. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58001. /**
  58002. * Initialize the block and prepare the context for build
  58003. * @param state defines the state that will be used for the build
  58004. */
  58005. initialize(state: NodeMaterialBuildState): void;
  58006. /**
  58007. * Bind data to effect. Will only be called for blocks with isBindable === true
  58008. * @param effect defines the effect to bind data to
  58009. * @param nodeMaterial defines the hosting NodeMaterial
  58010. * @param mesh defines the mesh that will be rendered
  58011. */
  58012. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58013. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58014. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58015. protected _writeFloat(value: number): string;
  58016. /**
  58017. * Gets the current class name e.g. "NodeMaterialBlock"
  58018. * @returns the class name
  58019. */
  58020. getClassName(): string;
  58021. /**
  58022. * Register a new input. Must be called inside a block constructor
  58023. * @param name defines the connection point name
  58024. * @param type defines the connection point type
  58025. * @param isOptional defines a boolean indicating that this input can be omitted
  58026. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58027. * @returns the current block
  58028. */
  58029. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58030. /**
  58031. * Register a new output. Must be called inside a block constructor
  58032. * @param name defines the connection point name
  58033. * @param type defines the connection point type
  58034. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58035. * @returns the current block
  58036. */
  58037. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58038. /**
  58039. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58040. * @param forOutput defines an optional connection point to check compatibility with
  58041. * @returns the first available input or null
  58042. */
  58043. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58044. /**
  58045. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58046. * @param forBlock defines an optional block to check compatibility with
  58047. * @returns the first available input or null
  58048. */
  58049. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58050. /**
  58051. * Gets the sibling of the given output
  58052. * @param current defines the current output
  58053. * @returns the next output in the list or null
  58054. */
  58055. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58056. /**
  58057. * Connect current block with another block
  58058. * @param other defines the block to connect with
  58059. * @param options define the various options to help pick the right connections
  58060. * @returns the current block
  58061. */
  58062. connectTo(other: NodeMaterialBlock, options?: {
  58063. input?: string;
  58064. output?: string;
  58065. outputSwizzle?: string;
  58066. }): this | undefined;
  58067. protected _buildBlock(state: NodeMaterialBuildState): void;
  58068. /**
  58069. * Add uniforms, samplers and uniform buffers at compilation time
  58070. * @param state defines the state to update
  58071. * @param nodeMaterial defines the node material requesting the update
  58072. * @param defines defines the material defines to update
  58073. * @param uniformBuffers defines the list of uniform buffer names
  58074. */
  58075. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58076. /**
  58077. * Add potential fallbacks if shader compilation fails
  58078. * @param mesh defines the mesh to be rendered
  58079. * @param fallbacks defines the current prioritized list of fallbacks
  58080. */
  58081. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58082. /**
  58083. * Initialize defines for shader compilation
  58084. * @param mesh defines the mesh to be rendered
  58085. * @param nodeMaterial defines the node material requesting the update
  58086. * @param defines defines the material defines to update
  58087. * @param useInstances specifies that instances should be used
  58088. */
  58089. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58090. /**
  58091. * Update defines for shader compilation
  58092. * @param mesh defines the mesh to be rendered
  58093. * @param nodeMaterial defines the node material requesting the update
  58094. * @param defines defines the material defines to update
  58095. * @param useInstances specifies that instances should be used
  58096. */
  58097. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58098. /**
  58099. * Lets the block try to connect some inputs automatically
  58100. * @param material defines the hosting NodeMaterial
  58101. */
  58102. autoConfigure(material: NodeMaterial): void;
  58103. /**
  58104. * Function called when a block is declared as repeatable content generator
  58105. * @param vertexShaderState defines the current compilation state for the vertex shader
  58106. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58107. * @param mesh defines the mesh to be rendered
  58108. * @param defines defines the material defines to update
  58109. */
  58110. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58111. /**
  58112. * Checks if the block is ready
  58113. * @param mesh defines the mesh to be rendered
  58114. * @param nodeMaterial defines the node material requesting the update
  58115. * @param defines defines the material defines to update
  58116. * @param useInstances specifies that instances should be used
  58117. * @returns true if the block is ready
  58118. */
  58119. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58120. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58121. private _processBuild;
  58122. /**
  58123. * Compile the current node and generate the shader code
  58124. * @param state defines the current compilation state (uniforms, samplers, current string)
  58125. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58126. * @returns true if already built
  58127. */
  58128. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58129. protected _inputRename(name: string): string;
  58130. protected _outputRename(name: string): string;
  58131. protected _dumpPropertiesCode(): string;
  58132. /** @hidden */
  58133. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58134. /** @hidden */
  58135. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58136. /**
  58137. * Clone the current block to a new identical block
  58138. * @param scene defines the hosting scene
  58139. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58140. * @returns a copy of the current block
  58141. */
  58142. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58143. /**
  58144. * Serializes this block in a JSON representation
  58145. * @returns the serialized block object
  58146. */
  58147. serialize(): any;
  58148. /** @hidden */
  58149. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58150. /**
  58151. * Release resources
  58152. */
  58153. dispose(): void;
  58154. }
  58155. }
  58156. declare module BABYLON {
  58157. /**
  58158. * Enum defining the type of animations supported by InputBlock
  58159. */
  58160. export enum AnimatedInputBlockTypes {
  58161. /** No animation */
  58162. None = 0,
  58163. /** Time based animation. Will only work for floats */
  58164. Time = 1
  58165. }
  58166. }
  58167. declare module BABYLON {
  58168. /**
  58169. * Block used to expose an input value
  58170. */
  58171. export class InputBlock extends NodeMaterialBlock {
  58172. private _mode;
  58173. private _associatedVariableName;
  58174. private _storedValue;
  58175. private _valueCallback;
  58176. private _type;
  58177. private _animationType;
  58178. /** Gets or set a value used to limit the range of float values */
  58179. min: number;
  58180. /** Gets or set a value used to limit the range of float values */
  58181. max: number;
  58182. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58183. isBoolean: boolean;
  58184. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58185. matrixMode: number;
  58186. /** @hidden */
  58187. _systemValue: Nullable<NodeMaterialSystemValues>;
  58188. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58189. visibleInInspector: boolean;
  58190. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58191. isConstant: boolean;
  58192. /** Gets or sets the group to use to display this block in the Inspector */
  58193. groupInInspector: string;
  58194. /** Gets an observable raised when the value is changed */
  58195. onValueChangedObservable: Observable<InputBlock>;
  58196. /**
  58197. * Gets or sets the connection point type (default is float)
  58198. */
  58199. get type(): NodeMaterialBlockConnectionPointTypes;
  58200. /**
  58201. * Creates a new InputBlock
  58202. * @param name defines the block name
  58203. * @param target defines the target of that block (Vertex by default)
  58204. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58205. */
  58206. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58207. /**
  58208. * Gets the output component
  58209. */
  58210. get output(): NodeMaterialConnectionPoint;
  58211. /**
  58212. * Set the source of this connection point to a vertex attribute
  58213. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58214. * @returns the current connection point
  58215. */
  58216. setAsAttribute(attributeName?: string): InputBlock;
  58217. /**
  58218. * Set the source of this connection point to a system value
  58219. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58220. * @returns the current connection point
  58221. */
  58222. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58223. /**
  58224. * Gets or sets the value of that point.
  58225. * Please note that this value will be ignored if valueCallback is defined
  58226. */
  58227. get value(): any;
  58228. set value(value: any);
  58229. /**
  58230. * Gets or sets a callback used to get the value of that point.
  58231. * Please note that setting this value will force the connection point to ignore the value property
  58232. */
  58233. get valueCallback(): () => any;
  58234. set valueCallback(value: () => any);
  58235. /**
  58236. * Gets or sets the associated variable name in the shader
  58237. */
  58238. get associatedVariableName(): string;
  58239. set associatedVariableName(value: string);
  58240. /** Gets or sets the type of animation applied to the input */
  58241. get animationType(): AnimatedInputBlockTypes;
  58242. set animationType(value: AnimatedInputBlockTypes);
  58243. /**
  58244. * Gets a boolean indicating that this connection point not defined yet
  58245. */
  58246. get isUndefined(): boolean;
  58247. /**
  58248. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58249. * In this case the connection point name must be the name of the uniform to use.
  58250. * Can only be set on inputs
  58251. */
  58252. get isUniform(): boolean;
  58253. set isUniform(value: boolean);
  58254. /**
  58255. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58256. * In this case the connection point name must be the name of the attribute to use
  58257. * Can only be set on inputs
  58258. */
  58259. get isAttribute(): boolean;
  58260. set isAttribute(value: boolean);
  58261. /**
  58262. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58263. * Can only be set on exit points
  58264. */
  58265. get isVarying(): boolean;
  58266. set isVarying(value: boolean);
  58267. /**
  58268. * Gets a boolean indicating that the current connection point is a system value
  58269. */
  58270. get isSystemValue(): boolean;
  58271. /**
  58272. * Gets or sets the current well known value or null if not defined as a system value
  58273. */
  58274. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58275. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58276. /**
  58277. * Gets the current class name
  58278. * @returns the class name
  58279. */
  58280. getClassName(): string;
  58281. /**
  58282. * Animate the input if animationType !== None
  58283. * @param scene defines the rendering scene
  58284. */
  58285. animate(scene: Scene): void;
  58286. private _emitDefine;
  58287. initialize(state: NodeMaterialBuildState): void;
  58288. /**
  58289. * Set the input block to its default value (based on its type)
  58290. */
  58291. setDefaultValue(): void;
  58292. private _emitConstant;
  58293. private _emit;
  58294. /** @hidden */
  58295. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58296. /** @hidden */
  58297. _transmit(effect: Effect, scene: Scene): void;
  58298. protected _buildBlock(state: NodeMaterialBuildState): void;
  58299. protected _dumpPropertiesCode(): string;
  58300. dispose(): void;
  58301. serialize(): any;
  58302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58303. }
  58304. }
  58305. declare module BABYLON {
  58306. /**
  58307. * Enum used to define the compatibility state between two connection points
  58308. */
  58309. export enum NodeMaterialConnectionPointCompatibilityStates {
  58310. /** Points are compatibles */
  58311. Compatible = 0,
  58312. /** Points are incompatible because of their types */
  58313. TypeIncompatible = 1,
  58314. /** Points are incompatible because of their targets (vertex vs fragment) */
  58315. TargetIncompatible = 2
  58316. }
  58317. /**
  58318. * Defines the direction of a connection point
  58319. */
  58320. export enum NodeMaterialConnectionPointDirection {
  58321. /** Input */
  58322. Input = 0,
  58323. /** Output */
  58324. Output = 1
  58325. }
  58326. /**
  58327. * Defines a connection point for a block
  58328. */
  58329. export class NodeMaterialConnectionPoint {
  58330. /** @hidden */
  58331. _ownerBlock: NodeMaterialBlock;
  58332. /** @hidden */
  58333. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58334. private _endpoints;
  58335. private _associatedVariableName;
  58336. private _direction;
  58337. /** @hidden */
  58338. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58339. /** @hidden */
  58340. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58341. private _type;
  58342. /** @hidden */
  58343. _enforceAssociatedVariableName: boolean;
  58344. /** Gets the direction of the point */
  58345. get direction(): NodeMaterialConnectionPointDirection;
  58346. /**
  58347. * Gets or sets the additional types supported by this connection point
  58348. */
  58349. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58350. /**
  58351. * Gets or sets the additional types excluded by this connection point
  58352. */
  58353. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58354. /**
  58355. * Observable triggered when this point is connected
  58356. */
  58357. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58358. /**
  58359. * Gets or sets the associated variable name in the shader
  58360. */
  58361. get associatedVariableName(): string;
  58362. set associatedVariableName(value: string);
  58363. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58364. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58365. /**
  58366. * Gets or sets the connection point type (default is float)
  58367. */
  58368. get type(): NodeMaterialBlockConnectionPointTypes;
  58369. set type(value: NodeMaterialBlockConnectionPointTypes);
  58370. /**
  58371. * Gets or sets the connection point name
  58372. */
  58373. name: string;
  58374. /**
  58375. * Gets or sets a boolean indicating that this connection point can be omitted
  58376. */
  58377. isOptional: boolean;
  58378. /**
  58379. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58380. */
  58381. define: string;
  58382. /** @hidden */
  58383. _prioritizeVertex: boolean;
  58384. private _target;
  58385. /** Gets or sets the target of that connection point */
  58386. get target(): NodeMaterialBlockTargets;
  58387. set target(value: NodeMaterialBlockTargets);
  58388. /**
  58389. * Gets a boolean indicating that the current point is connected
  58390. */
  58391. get isConnected(): boolean;
  58392. /**
  58393. * Gets a boolean indicating that the current point is connected to an input block
  58394. */
  58395. get isConnectedToInputBlock(): boolean;
  58396. /**
  58397. * Gets a the connected input block (if any)
  58398. */
  58399. get connectInputBlock(): Nullable<InputBlock>;
  58400. /** Get the other side of the connection (if any) */
  58401. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58402. /** Get the block that owns this connection point */
  58403. get ownerBlock(): NodeMaterialBlock;
  58404. /** Get the block connected on the other side of this connection (if any) */
  58405. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58406. /** Get the block connected on the endpoints of this connection (if any) */
  58407. get connectedBlocks(): Array<NodeMaterialBlock>;
  58408. /** Gets the list of connected endpoints */
  58409. get endpoints(): NodeMaterialConnectionPoint[];
  58410. /** Gets a boolean indicating if that output point is connected to at least one input */
  58411. get hasEndpoints(): boolean;
  58412. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58413. get isConnectedInVertexShader(): boolean;
  58414. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58415. get isConnectedInFragmentShader(): boolean;
  58416. /**
  58417. * Creates a new connection point
  58418. * @param name defines the connection point name
  58419. * @param ownerBlock defines the block hosting this connection point
  58420. * @param direction defines the direction of the connection point
  58421. */
  58422. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58423. /**
  58424. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58425. * @returns the class name
  58426. */
  58427. getClassName(): string;
  58428. /**
  58429. * Gets a boolean indicating if the current point can be connected to another point
  58430. * @param connectionPoint defines the other connection point
  58431. * @returns a boolean
  58432. */
  58433. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58434. /**
  58435. * Gets a number indicating if the current point can be connected to another point
  58436. * @param connectionPoint defines the other connection point
  58437. * @returns a number defining the compatibility state
  58438. */
  58439. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58440. /**
  58441. * Connect this point to another connection point
  58442. * @param connectionPoint defines the other connection point
  58443. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58444. * @returns the current connection point
  58445. */
  58446. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58447. /**
  58448. * Disconnect this point from one of his endpoint
  58449. * @param endpoint defines the other connection point
  58450. * @returns the current connection point
  58451. */
  58452. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58453. /**
  58454. * Serializes this point in a JSON representation
  58455. * @returns the serialized point object
  58456. */
  58457. serialize(): any;
  58458. /**
  58459. * Release resources
  58460. */
  58461. dispose(): void;
  58462. }
  58463. }
  58464. declare module BABYLON {
  58465. /**
  58466. * Block used to add support for vertex skinning (bones)
  58467. */
  58468. export class BonesBlock extends NodeMaterialBlock {
  58469. /**
  58470. * Creates a new BonesBlock
  58471. * @param name defines the block name
  58472. */
  58473. constructor(name: string);
  58474. /**
  58475. * Initialize the block and prepare the context for build
  58476. * @param state defines the state that will be used for the build
  58477. */
  58478. initialize(state: NodeMaterialBuildState): void;
  58479. /**
  58480. * Gets the current class name
  58481. * @returns the class name
  58482. */
  58483. getClassName(): string;
  58484. /**
  58485. * Gets the matrix indices input component
  58486. */
  58487. get matricesIndices(): NodeMaterialConnectionPoint;
  58488. /**
  58489. * Gets the matrix weights input component
  58490. */
  58491. get matricesWeights(): NodeMaterialConnectionPoint;
  58492. /**
  58493. * Gets the extra matrix indices input component
  58494. */
  58495. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58496. /**
  58497. * Gets the extra matrix weights input component
  58498. */
  58499. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58500. /**
  58501. * Gets the world input component
  58502. */
  58503. get world(): NodeMaterialConnectionPoint;
  58504. /**
  58505. * Gets the output component
  58506. */
  58507. get output(): NodeMaterialConnectionPoint;
  58508. autoConfigure(material: NodeMaterial): void;
  58509. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58510. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58511. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58512. protected _buildBlock(state: NodeMaterialBuildState): this;
  58513. }
  58514. }
  58515. declare module BABYLON {
  58516. /**
  58517. * Block used to add support for instances
  58518. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58519. */
  58520. export class InstancesBlock extends NodeMaterialBlock {
  58521. /**
  58522. * Creates a new InstancesBlock
  58523. * @param name defines the block name
  58524. */
  58525. constructor(name: string);
  58526. /**
  58527. * Gets the current class name
  58528. * @returns the class name
  58529. */
  58530. getClassName(): string;
  58531. /**
  58532. * Gets the first world row input component
  58533. */
  58534. get world0(): NodeMaterialConnectionPoint;
  58535. /**
  58536. * Gets the second world row input component
  58537. */
  58538. get world1(): NodeMaterialConnectionPoint;
  58539. /**
  58540. * Gets the third world row input component
  58541. */
  58542. get world2(): NodeMaterialConnectionPoint;
  58543. /**
  58544. * Gets the forth world row input component
  58545. */
  58546. get world3(): NodeMaterialConnectionPoint;
  58547. /**
  58548. * Gets the world input component
  58549. */
  58550. get world(): NodeMaterialConnectionPoint;
  58551. /**
  58552. * Gets the output component
  58553. */
  58554. get output(): NodeMaterialConnectionPoint;
  58555. /**
  58556. * Gets the isntanceID component
  58557. */
  58558. get instanceID(): NodeMaterialConnectionPoint;
  58559. autoConfigure(material: NodeMaterial): void;
  58560. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58561. protected _buildBlock(state: NodeMaterialBuildState): this;
  58562. }
  58563. }
  58564. declare module BABYLON {
  58565. /**
  58566. * Block used to add morph targets support to vertex shader
  58567. */
  58568. export class MorphTargetsBlock extends NodeMaterialBlock {
  58569. private _repeatableContentAnchor;
  58570. /**
  58571. * Create a new MorphTargetsBlock
  58572. * @param name defines the block name
  58573. */
  58574. constructor(name: string);
  58575. /**
  58576. * Gets the current class name
  58577. * @returns the class name
  58578. */
  58579. getClassName(): string;
  58580. /**
  58581. * Gets the position input component
  58582. */
  58583. get position(): NodeMaterialConnectionPoint;
  58584. /**
  58585. * Gets the normal input component
  58586. */
  58587. get normal(): NodeMaterialConnectionPoint;
  58588. /**
  58589. * Gets the tangent input component
  58590. */
  58591. get tangent(): NodeMaterialConnectionPoint;
  58592. /**
  58593. * Gets the tangent input component
  58594. */
  58595. get uv(): NodeMaterialConnectionPoint;
  58596. /**
  58597. * Gets the position output component
  58598. */
  58599. get positionOutput(): NodeMaterialConnectionPoint;
  58600. /**
  58601. * Gets the normal output component
  58602. */
  58603. get normalOutput(): NodeMaterialConnectionPoint;
  58604. /**
  58605. * Gets the tangent output component
  58606. */
  58607. get tangentOutput(): NodeMaterialConnectionPoint;
  58608. /**
  58609. * Gets the tangent output component
  58610. */
  58611. get uvOutput(): NodeMaterialConnectionPoint;
  58612. initialize(state: NodeMaterialBuildState): void;
  58613. autoConfigure(material: NodeMaterial): void;
  58614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58615. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58616. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58617. protected _buildBlock(state: NodeMaterialBuildState): this;
  58618. }
  58619. }
  58620. declare module BABYLON {
  58621. /**
  58622. * Block used to get data information from a light
  58623. */
  58624. export class LightInformationBlock extends NodeMaterialBlock {
  58625. private _lightDataUniformName;
  58626. private _lightColorUniformName;
  58627. private _lightTypeDefineName;
  58628. /**
  58629. * Gets or sets the light associated with this block
  58630. */
  58631. light: Nullable<Light>;
  58632. /**
  58633. * Creates a new LightInformationBlock
  58634. * @param name defines the block name
  58635. */
  58636. constructor(name: string);
  58637. /**
  58638. * Gets the current class name
  58639. * @returns the class name
  58640. */
  58641. getClassName(): string;
  58642. /**
  58643. * Gets the world position input component
  58644. */
  58645. get worldPosition(): NodeMaterialConnectionPoint;
  58646. /**
  58647. * Gets the direction output component
  58648. */
  58649. get direction(): NodeMaterialConnectionPoint;
  58650. /**
  58651. * Gets the direction output component
  58652. */
  58653. get color(): NodeMaterialConnectionPoint;
  58654. /**
  58655. * Gets the direction output component
  58656. */
  58657. get intensity(): NodeMaterialConnectionPoint;
  58658. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58659. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58660. protected _buildBlock(state: NodeMaterialBuildState): this;
  58661. serialize(): any;
  58662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58663. }
  58664. }
  58665. declare module BABYLON {
  58666. /**
  58667. * Block used to add image processing support to fragment shader
  58668. */
  58669. export class ImageProcessingBlock extends NodeMaterialBlock {
  58670. /**
  58671. * Create a new ImageProcessingBlock
  58672. * @param name defines the block name
  58673. */
  58674. constructor(name: string);
  58675. /**
  58676. * Gets the current class name
  58677. * @returns the class name
  58678. */
  58679. getClassName(): string;
  58680. /**
  58681. * Gets the color input component
  58682. */
  58683. get color(): NodeMaterialConnectionPoint;
  58684. /**
  58685. * Gets the output component
  58686. */
  58687. get output(): NodeMaterialConnectionPoint;
  58688. /**
  58689. * Initialize the block and prepare the context for build
  58690. * @param state defines the state that will be used for the build
  58691. */
  58692. initialize(state: NodeMaterialBuildState): void;
  58693. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58696. protected _buildBlock(state: NodeMaterialBuildState): this;
  58697. }
  58698. }
  58699. declare module BABYLON {
  58700. /**
  58701. * Block used to pertub normals based on a normal map
  58702. */
  58703. export class PerturbNormalBlock extends NodeMaterialBlock {
  58704. private _tangentSpaceParameterName;
  58705. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58706. invertX: boolean;
  58707. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58708. invertY: boolean;
  58709. /**
  58710. * Create a new PerturbNormalBlock
  58711. * @param name defines the block name
  58712. */
  58713. constructor(name: string);
  58714. /**
  58715. * Gets the current class name
  58716. * @returns the class name
  58717. */
  58718. getClassName(): string;
  58719. /**
  58720. * Gets the world position input component
  58721. */
  58722. get worldPosition(): NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the world normal input component
  58725. */
  58726. get worldNormal(): NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the world tangent input component
  58729. */
  58730. get worldTangent(): NodeMaterialConnectionPoint;
  58731. /**
  58732. * Gets the uv input component
  58733. */
  58734. get uv(): NodeMaterialConnectionPoint;
  58735. /**
  58736. * Gets the normal map color input component
  58737. */
  58738. get normalMapColor(): NodeMaterialConnectionPoint;
  58739. /**
  58740. * Gets the strength input component
  58741. */
  58742. get strength(): NodeMaterialConnectionPoint;
  58743. /**
  58744. * Gets the output component
  58745. */
  58746. get output(): NodeMaterialConnectionPoint;
  58747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58748. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58749. autoConfigure(material: NodeMaterial): void;
  58750. protected _buildBlock(state: NodeMaterialBuildState): this;
  58751. protected _dumpPropertiesCode(): string;
  58752. serialize(): any;
  58753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58754. }
  58755. }
  58756. declare module BABYLON {
  58757. /**
  58758. * Block used to discard a pixel if a value is smaller than a cutoff
  58759. */
  58760. export class DiscardBlock extends NodeMaterialBlock {
  58761. /**
  58762. * Create a new DiscardBlock
  58763. * @param name defines the block name
  58764. */
  58765. constructor(name: string);
  58766. /**
  58767. * Gets the current class name
  58768. * @returns the class name
  58769. */
  58770. getClassName(): string;
  58771. /**
  58772. * Gets the color input component
  58773. */
  58774. get value(): NodeMaterialConnectionPoint;
  58775. /**
  58776. * Gets the cutoff input component
  58777. */
  58778. get cutoff(): NodeMaterialConnectionPoint;
  58779. protected _buildBlock(state: NodeMaterialBuildState): this;
  58780. }
  58781. }
  58782. declare module BABYLON {
  58783. /**
  58784. * Block used to test if the fragment shader is front facing
  58785. */
  58786. export class FrontFacingBlock extends NodeMaterialBlock {
  58787. /**
  58788. * Creates a new FrontFacingBlock
  58789. * @param name defines the block name
  58790. */
  58791. constructor(name: string);
  58792. /**
  58793. * Gets the current class name
  58794. * @returns the class name
  58795. */
  58796. getClassName(): string;
  58797. /**
  58798. * Gets the output component
  58799. */
  58800. get output(): NodeMaterialConnectionPoint;
  58801. protected _buildBlock(state: NodeMaterialBuildState): this;
  58802. }
  58803. }
  58804. declare module BABYLON {
  58805. /**
  58806. * Block used to get the derivative value on x and y of a given input
  58807. */
  58808. export class DerivativeBlock extends NodeMaterialBlock {
  58809. /**
  58810. * Create a new DerivativeBlock
  58811. * @param name defines the block name
  58812. */
  58813. constructor(name: string);
  58814. /**
  58815. * Gets the current class name
  58816. * @returns the class name
  58817. */
  58818. getClassName(): string;
  58819. /**
  58820. * Gets the input component
  58821. */
  58822. get input(): NodeMaterialConnectionPoint;
  58823. /**
  58824. * Gets the derivative output on x
  58825. */
  58826. get dx(): NodeMaterialConnectionPoint;
  58827. /**
  58828. * Gets the derivative output on y
  58829. */
  58830. get dy(): NodeMaterialConnectionPoint;
  58831. protected _buildBlock(state: NodeMaterialBuildState): this;
  58832. }
  58833. }
  58834. declare module BABYLON {
  58835. /**
  58836. * Block used to add support for scene fog
  58837. */
  58838. export class FogBlock extends NodeMaterialBlock {
  58839. private _fogDistanceName;
  58840. private _fogParameters;
  58841. /**
  58842. * Create a new FogBlock
  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 world position input component
  58853. */
  58854. get worldPosition(): NodeMaterialConnectionPoint;
  58855. /**
  58856. * Gets the view input component
  58857. */
  58858. get view(): NodeMaterialConnectionPoint;
  58859. /**
  58860. * Gets the color input component
  58861. */
  58862. get input(): NodeMaterialConnectionPoint;
  58863. /**
  58864. * Gets the fog color input component
  58865. */
  58866. get fogColor(): NodeMaterialConnectionPoint;
  58867. /**
  58868. * Gets the output component
  58869. */
  58870. get output(): NodeMaterialConnectionPoint;
  58871. autoConfigure(material: NodeMaterial): void;
  58872. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58873. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58874. protected _buildBlock(state: NodeMaterialBuildState): this;
  58875. }
  58876. }
  58877. declare module BABYLON {
  58878. /**
  58879. * Block used to add light in the fragment shader
  58880. */
  58881. export class LightBlock extends NodeMaterialBlock {
  58882. private _lightId;
  58883. /**
  58884. * Gets or sets the light associated with this block
  58885. */
  58886. light: Nullable<Light>;
  58887. /**
  58888. * Create a new LightBlock
  58889. * @param name defines the block name
  58890. */
  58891. constructor(name: string);
  58892. /**
  58893. * Gets the current class name
  58894. * @returns the class name
  58895. */
  58896. getClassName(): string;
  58897. /**
  58898. * Gets the world position input component
  58899. */
  58900. get worldPosition(): NodeMaterialConnectionPoint;
  58901. /**
  58902. * Gets the world normal input component
  58903. */
  58904. get worldNormal(): NodeMaterialConnectionPoint;
  58905. /**
  58906. * Gets the camera (or eye) position component
  58907. */
  58908. get cameraPosition(): NodeMaterialConnectionPoint;
  58909. /**
  58910. * Gets the glossiness component
  58911. */
  58912. get glossiness(): NodeMaterialConnectionPoint;
  58913. /**
  58914. * Gets the glossinness power component
  58915. */
  58916. get glossPower(): NodeMaterialConnectionPoint;
  58917. /**
  58918. * Gets the diffuse color component
  58919. */
  58920. get diffuseColor(): NodeMaterialConnectionPoint;
  58921. /**
  58922. * Gets the specular color component
  58923. */
  58924. get specularColor(): NodeMaterialConnectionPoint;
  58925. /**
  58926. * Gets the diffuse output component
  58927. */
  58928. get diffuseOutput(): NodeMaterialConnectionPoint;
  58929. /**
  58930. * Gets the specular output component
  58931. */
  58932. get specularOutput(): NodeMaterialConnectionPoint;
  58933. /**
  58934. * Gets the shadow output component
  58935. */
  58936. get shadow(): NodeMaterialConnectionPoint;
  58937. autoConfigure(material: NodeMaterial): void;
  58938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58939. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58940. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58941. private _injectVertexCode;
  58942. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58943. serialize(): any;
  58944. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58945. }
  58946. }
  58947. declare module BABYLON {
  58948. /**
  58949. * Block used to multiply 2 values
  58950. */
  58951. export class MultiplyBlock extends NodeMaterialBlock {
  58952. /**
  58953. * Creates a new MultiplyBlock
  58954. * @param name defines the block name
  58955. */
  58956. constructor(name: string);
  58957. /**
  58958. * Gets the current class name
  58959. * @returns the class name
  58960. */
  58961. getClassName(): string;
  58962. /**
  58963. * Gets the left operand input component
  58964. */
  58965. get left(): NodeMaterialConnectionPoint;
  58966. /**
  58967. * Gets the right operand input component
  58968. */
  58969. get right(): NodeMaterialConnectionPoint;
  58970. /**
  58971. * Gets the output component
  58972. */
  58973. get output(): NodeMaterialConnectionPoint;
  58974. protected _buildBlock(state: NodeMaterialBuildState): this;
  58975. }
  58976. }
  58977. declare module BABYLON {
  58978. /**
  58979. * Block used to add 2 vectors
  58980. */
  58981. export class AddBlock extends NodeMaterialBlock {
  58982. /**
  58983. * Creates a new AddBlock
  58984. * @param name defines the block name
  58985. */
  58986. constructor(name: string);
  58987. /**
  58988. * Gets the current class name
  58989. * @returns the class name
  58990. */
  58991. getClassName(): string;
  58992. /**
  58993. * Gets the left operand input component
  58994. */
  58995. get left(): NodeMaterialConnectionPoint;
  58996. /**
  58997. * Gets the right operand input component
  58998. */
  58999. get right(): NodeMaterialConnectionPoint;
  59000. /**
  59001. * Gets the output component
  59002. */
  59003. get output(): NodeMaterialConnectionPoint;
  59004. protected _buildBlock(state: NodeMaterialBuildState): this;
  59005. }
  59006. }
  59007. declare module BABYLON {
  59008. /**
  59009. * Block used to scale a vector by a float
  59010. */
  59011. export class ScaleBlock extends NodeMaterialBlock {
  59012. /**
  59013. * Creates a new ScaleBlock
  59014. * @param name defines the block name
  59015. */
  59016. constructor(name: string);
  59017. /**
  59018. * Gets the current class name
  59019. * @returns the class name
  59020. */
  59021. getClassName(): string;
  59022. /**
  59023. * Gets the input component
  59024. */
  59025. get input(): NodeMaterialConnectionPoint;
  59026. /**
  59027. * Gets the factor input component
  59028. */
  59029. get factor(): NodeMaterialConnectionPoint;
  59030. /**
  59031. * Gets the output component
  59032. */
  59033. get output(): NodeMaterialConnectionPoint;
  59034. protected _buildBlock(state: NodeMaterialBuildState): this;
  59035. }
  59036. }
  59037. declare module BABYLON {
  59038. /**
  59039. * Block used to clamp a float
  59040. */
  59041. export class ClampBlock extends NodeMaterialBlock {
  59042. /** Gets or sets the minimum range */
  59043. minimum: number;
  59044. /** Gets or sets the maximum range */
  59045. maximum: number;
  59046. /**
  59047. * Creates a new ClampBlock
  59048. * @param name defines the block name
  59049. */
  59050. constructor(name: string);
  59051. /**
  59052. * Gets the current class name
  59053. * @returns the class name
  59054. */
  59055. getClassName(): string;
  59056. /**
  59057. * Gets the value input component
  59058. */
  59059. get value(): NodeMaterialConnectionPoint;
  59060. /**
  59061. * Gets the output component
  59062. */
  59063. get output(): NodeMaterialConnectionPoint;
  59064. protected _buildBlock(state: NodeMaterialBuildState): this;
  59065. protected _dumpPropertiesCode(): string;
  59066. serialize(): any;
  59067. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59068. }
  59069. }
  59070. declare module BABYLON {
  59071. /**
  59072. * Block used to apply a cross product between 2 vectors
  59073. */
  59074. export class CrossBlock extends NodeMaterialBlock {
  59075. /**
  59076. * Creates a new CrossBlock
  59077. * @param name defines the block name
  59078. */
  59079. constructor(name: string);
  59080. /**
  59081. * Gets the current class name
  59082. * @returns the class name
  59083. */
  59084. getClassName(): string;
  59085. /**
  59086. * Gets the left operand input component
  59087. */
  59088. get left(): NodeMaterialConnectionPoint;
  59089. /**
  59090. * Gets the right operand input component
  59091. */
  59092. get right(): NodeMaterialConnectionPoint;
  59093. /**
  59094. * Gets the output component
  59095. */
  59096. get output(): NodeMaterialConnectionPoint;
  59097. protected _buildBlock(state: NodeMaterialBuildState): this;
  59098. }
  59099. }
  59100. declare module BABYLON {
  59101. /**
  59102. * Block used to apply a dot product between 2 vectors
  59103. */
  59104. export class DotBlock extends NodeMaterialBlock {
  59105. /**
  59106. * Creates a new DotBlock
  59107. * @param name defines the block name
  59108. */
  59109. constructor(name: string);
  59110. /**
  59111. * Gets the current class name
  59112. * @returns the class name
  59113. */
  59114. getClassName(): string;
  59115. /**
  59116. * Gets the left operand input component
  59117. */
  59118. get left(): NodeMaterialConnectionPoint;
  59119. /**
  59120. * Gets the right operand input component
  59121. */
  59122. get right(): NodeMaterialConnectionPoint;
  59123. /**
  59124. * Gets the output component
  59125. */
  59126. get output(): NodeMaterialConnectionPoint;
  59127. protected _buildBlock(state: NodeMaterialBuildState): this;
  59128. }
  59129. }
  59130. declare module BABYLON {
  59131. /**
  59132. * Block used to remap a float from a range to a new one
  59133. */
  59134. export class RemapBlock extends NodeMaterialBlock {
  59135. /**
  59136. * Gets or sets the source range
  59137. */
  59138. sourceRange: Vector2;
  59139. /**
  59140. * Gets or sets the target range
  59141. */
  59142. targetRange: Vector2;
  59143. /**
  59144. * Creates a new RemapBlock
  59145. * @param name defines the block name
  59146. */
  59147. constructor(name: string);
  59148. /**
  59149. * Gets the current class name
  59150. * @returns the class name
  59151. */
  59152. getClassName(): string;
  59153. /**
  59154. * Gets the input component
  59155. */
  59156. get input(): NodeMaterialConnectionPoint;
  59157. /**
  59158. * Gets the source min input component
  59159. */
  59160. get sourceMin(): NodeMaterialConnectionPoint;
  59161. /**
  59162. * Gets the source max input component
  59163. */
  59164. get sourceMax(): NodeMaterialConnectionPoint;
  59165. /**
  59166. * Gets the target min input component
  59167. */
  59168. get targetMin(): NodeMaterialConnectionPoint;
  59169. /**
  59170. * Gets the target max input component
  59171. */
  59172. get targetMax(): NodeMaterialConnectionPoint;
  59173. /**
  59174. * Gets the output component
  59175. */
  59176. get output(): NodeMaterialConnectionPoint;
  59177. protected _buildBlock(state: NodeMaterialBuildState): this;
  59178. protected _dumpPropertiesCode(): string;
  59179. serialize(): any;
  59180. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59181. }
  59182. }
  59183. declare module BABYLON {
  59184. /**
  59185. * Block used to normalize a vector
  59186. */
  59187. export class NormalizeBlock extends NodeMaterialBlock {
  59188. /**
  59189. * Creates a new NormalizeBlock
  59190. * @param name defines the block name
  59191. */
  59192. constructor(name: string);
  59193. /**
  59194. * Gets the current class name
  59195. * @returns the class name
  59196. */
  59197. getClassName(): string;
  59198. /**
  59199. * Gets the input component
  59200. */
  59201. get input(): NodeMaterialConnectionPoint;
  59202. /**
  59203. * Gets the output component
  59204. */
  59205. get output(): NodeMaterialConnectionPoint;
  59206. protected _buildBlock(state: NodeMaterialBuildState): this;
  59207. }
  59208. }
  59209. declare module BABYLON {
  59210. /**
  59211. * Operations supported by the Trigonometry block
  59212. */
  59213. export enum TrigonometryBlockOperations {
  59214. /** Cos */
  59215. Cos = 0,
  59216. /** Sin */
  59217. Sin = 1,
  59218. /** Abs */
  59219. Abs = 2,
  59220. /** Exp */
  59221. Exp = 3,
  59222. /** Exp2 */
  59223. Exp2 = 4,
  59224. /** Round */
  59225. Round = 5,
  59226. /** Floor */
  59227. Floor = 6,
  59228. /** Ceiling */
  59229. Ceiling = 7,
  59230. /** Square root */
  59231. Sqrt = 8,
  59232. /** Log */
  59233. Log = 9,
  59234. /** Tangent */
  59235. Tan = 10,
  59236. /** Arc tangent */
  59237. ArcTan = 11,
  59238. /** Arc cosinus */
  59239. ArcCos = 12,
  59240. /** Arc sinus */
  59241. ArcSin = 13,
  59242. /** Fraction */
  59243. Fract = 14,
  59244. /** Sign */
  59245. Sign = 15,
  59246. /** To radians (from degrees) */
  59247. Radians = 16,
  59248. /** To degrees (from radians) */
  59249. Degrees = 17
  59250. }
  59251. /**
  59252. * Block used to apply trigonometry operation to floats
  59253. */
  59254. export class TrigonometryBlock extends NodeMaterialBlock {
  59255. /**
  59256. * Gets or sets the operation applied by the block
  59257. */
  59258. operation: TrigonometryBlockOperations;
  59259. /**
  59260. * Creates a new TrigonometryBlock
  59261. * @param name defines the block name
  59262. */
  59263. constructor(name: string);
  59264. /**
  59265. * Gets the current class name
  59266. * @returns the class name
  59267. */
  59268. getClassName(): string;
  59269. /**
  59270. * Gets the input component
  59271. */
  59272. get input(): NodeMaterialConnectionPoint;
  59273. /**
  59274. * Gets the output component
  59275. */
  59276. get output(): NodeMaterialConnectionPoint;
  59277. protected _buildBlock(state: NodeMaterialBuildState): this;
  59278. serialize(): any;
  59279. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59280. protected _dumpPropertiesCode(): string;
  59281. }
  59282. }
  59283. declare module BABYLON {
  59284. /**
  59285. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59286. */
  59287. export class ColorMergerBlock extends NodeMaterialBlock {
  59288. /**
  59289. * Create a new ColorMergerBlock
  59290. * @param name defines the block name
  59291. */
  59292. constructor(name: string);
  59293. /**
  59294. * Gets the current class name
  59295. * @returns the class name
  59296. */
  59297. getClassName(): string;
  59298. /**
  59299. * Gets the rgb component (input)
  59300. */
  59301. get rgbIn(): NodeMaterialConnectionPoint;
  59302. /**
  59303. * Gets the r component (input)
  59304. */
  59305. get r(): NodeMaterialConnectionPoint;
  59306. /**
  59307. * Gets the g component (input)
  59308. */
  59309. get g(): NodeMaterialConnectionPoint;
  59310. /**
  59311. * Gets the b component (input)
  59312. */
  59313. get b(): NodeMaterialConnectionPoint;
  59314. /**
  59315. * Gets the a component (input)
  59316. */
  59317. get a(): NodeMaterialConnectionPoint;
  59318. /**
  59319. * Gets the rgba component (output)
  59320. */
  59321. get rgba(): NodeMaterialConnectionPoint;
  59322. /**
  59323. * Gets the rgb component (output)
  59324. */
  59325. get rgbOut(): NodeMaterialConnectionPoint;
  59326. /**
  59327. * Gets the rgb component (output)
  59328. * @deprecated Please use rgbOut instead.
  59329. */
  59330. get rgb(): NodeMaterialConnectionPoint;
  59331. protected _buildBlock(state: NodeMaterialBuildState): this;
  59332. }
  59333. }
  59334. declare module BABYLON {
  59335. /**
  59336. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59337. */
  59338. export class VectorMergerBlock extends NodeMaterialBlock {
  59339. /**
  59340. * Create a new VectorMergerBlock
  59341. * @param name defines the block name
  59342. */
  59343. constructor(name: string);
  59344. /**
  59345. * Gets the current class name
  59346. * @returns the class name
  59347. */
  59348. getClassName(): string;
  59349. /**
  59350. * Gets the xyz component (input)
  59351. */
  59352. get xyzIn(): NodeMaterialConnectionPoint;
  59353. /**
  59354. * Gets the xy component (input)
  59355. */
  59356. get xyIn(): NodeMaterialConnectionPoint;
  59357. /**
  59358. * Gets the x component (input)
  59359. */
  59360. get x(): NodeMaterialConnectionPoint;
  59361. /**
  59362. * Gets the y component (input)
  59363. */
  59364. get y(): NodeMaterialConnectionPoint;
  59365. /**
  59366. * Gets the z component (input)
  59367. */
  59368. get z(): NodeMaterialConnectionPoint;
  59369. /**
  59370. * Gets the w component (input)
  59371. */
  59372. get w(): NodeMaterialConnectionPoint;
  59373. /**
  59374. * Gets the xyzw component (output)
  59375. */
  59376. get xyzw(): NodeMaterialConnectionPoint;
  59377. /**
  59378. * Gets the xyz component (output)
  59379. */
  59380. get xyzOut(): NodeMaterialConnectionPoint;
  59381. /**
  59382. * Gets the xy component (output)
  59383. */
  59384. get xyOut(): NodeMaterialConnectionPoint;
  59385. /**
  59386. * Gets the xy component (output)
  59387. * @deprecated Please use xyOut instead.
  59388. */
  59389. get xy(): NodeMaterialConnectionPoint;
  59390. /**
  59391. * Gets the xyz component (output)
  59392. * @deprecated Please use xyzOut instead.
  59393. */
  59394. get xyz(): NodeMaterialConnectionPoint;
  59395. protected _buildBlock(state: NodeMaterialBuildState): this;
  59396. }
  59397. }
  59398. declare module BABYLON {
  59399. /**
  59400. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59401. */
  59402. export class ColorSplitterBlock extends NodeMaterialBlock {
  59403. /**
  59404. * Create a new ColorSplitterBlock
  59405. * @param name defines the block name
  59406. */
  59407. constructor(name: string);
  59408. /**
  59409. * Gets the current class name
  59410. * @returns the class name
  59411. */
  59412. getClassName(): string;
  59413. /**
  59414. * Gets the rgba component (input)
  59415. */
  59416. get rgba(): NodeMaterialConnectionPoint;
  59417. /**
  59418. * Gets the rgb component (input)
  59419. */
  59420. get rgbIn(): NodeMaterialConnectionPoint;
  59421. /**
  59422. * Gets the rgb component (output)
  59423. */
  59424. get rgbOut(): NodeMaterialConnectionPoint;
  59425. /**
  59426. * Gets the r component (output)
  59427. */
  59428. get r(): NodeMaterialConnectionPoint;
  59429. /**
  59430. * Gets the g component (output)
  59431. */
  59432. get g(): NodeMaterialConnectionPoint;
  59433. /**
  59434. * Gets the b component (output)
  59435. */
  59436. get b(): NodeMaterialConnectionPoint;
  59437. /**
  59438. * Gets the a component (output)
  59439. */
  59440. get a(): NodeMaterialConnectionPoint;
  59441. protected _inputRename(name: string): string;
  59442. protected _outputRename(name: string): string;
  59443. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59444. }
  59445. }
  59446. declare module BABYLON {
  59447. /**
  59448. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59449. */
  59450. export class VectorSplitterBlock extends NodeMaterialBlock {
  59451. /**
  59452. * Create a new VectorSplitterBlock
  59453. * @param name defines the block name
  59454. */
  59455. constructor(name: string);
  59456. /**
  59457. * Gets the current class name
  59458. * @returns the class name
  59459. */
  59460. getClassName(): string;
  59461. /**
  59462. * Gets the xyzw component (input)
  59463. */
  59464. get xyzw(): NodeMaterialConnectionPoint;
  59465. /**
  59466. * Gets the xyz component (input)
  59467. */
  59468. get xyzIn(): NodeMaterialConnectionPoint;
  59469. /**
  59470. * Gets the xy component (input)
  59471. */
  59472. get xyIn(): NodeMaterialConnectionPoint;
  59473. /**
  59474. * Gets the xyz component (output)
  59475. */
  59476. get xyzOut(): NodeMaterialConnectionPoint;
  59477. /**
  59478. * Gets the xy component (output)
  59479. */
  59480. get xyOut(): NodeMaterialConnectionPoint;
  59481. /**
  59482. * Gets the x component (output)
  59483. */
  59484. get x(): NodeMaterialConnectionPoint;
  59485. /**
  59486. * Gets the y component (output)
  59487. */
  59488. get y(): NodeMaterialConnectionPoint;
  59489. /**
  59490. * Gets the z component (output)
  59491. */
  59492. get z(): NodeMaterialConnectionPoint;
  59493. /**
  59494. * Gets the w component (output)
  59495. */
  59496. get w(): NodeMaterialConnectionPoint;
  59497. protected _inputRename(name: string): string;
  59498. protected _outputRename(name: string): string;
  59499. protected _buildBlock(state: NodeMaterialBuildState): this;
  59500. }
  59501. }
  59502. declare module BABYLON {
  59503. /**
  59504. * Block used to lerp between 2 values
  59505. */
  59506. export class LerpBlock extends NodeMaterialBlock {
  59507. /**
  59508. * Creates a new LerpBlock
  59509. * @param name defines the block name
  59510. */
  59511. constructor(name: string);
  59512. /**
  59513. * Gets the current class name
  59514. * @returns the class name
  59515. */
  59516. getClassName(): string;
  59517. /**
  59518. * Gets the left operand input component
  59519. */
  59520. get left(): NodeMaterialConnectionPoint;
  59521. /**
  59522. * Gets the right operand input component
  59523. */
  59524. get right(): NodeMaterialConnectionPoint;
  59525. /**
  59526. * Gets the gradient operand input component
  59527. */
  59528. get gradient(): NodeMaterialConnectionPoint;
  59529. /**
  59530. * Gets the output component
  59531. */
  59532. get output(): NodeMaterialConnectionPoint;
  59533. protected _buildBlock(state: NodeMaterialBuildState): this;
  59534. }
  59535. }
  59536. declare module BABYLON {
  59537. /**
  59538. * Block used to divide 2 vectors
  59539. */
  59540. export class DivideBlock extends NodeMaterialBlock {
  59541. /**
  59542. * Creates a new DivideBlock
  59543. * @param name defines the block name
  59544. */
  59545. constructor(name: string);
  59546. /**
  59547. * Gets the current class name
  59548. * @returns the class name
  59549. */
  59550. getClassName(): string;
  59551. /**
  59552. * Gets the left operand input component
  59553. */
  59554. get left(): NodeMaterialConnectionPoint;
  59555. /**
  59556. * Gets the right operand input component
  59557. */
  59558. get right(): NodeMaterialConnectionPoint;
  59559. /**
  59560. * Gets the output component
  59561. */
  59562. get output(): NodeMaterialConnectionPoint;
  59563. protected _buildBlock(state: NodeMaterialBuildState): this;
  59564. }
  59565. }
  59566. declare module BABYLON {
  59567. /**
  59568. * Block used to subtract 2 vectors
  59569. */
  59570. export class SubtractBlock extends NodeMaterialBlock {
  59571. /**
  59572. * Creates a new SubtractBlock
  59573. * @param name defines the block name
  59574. */
  59575. constructor(name: string);
  59576. /**
  59577. * Gets the current class name
  59578. * @returns the class name
  59579. */
  59580. getClassName(): string;
  59581. /**
  59582. * Gets the left operand input component
  59583. */
  59584. get left(): NodeMaterialConnectionPoint;
  59585. /**
  59586. * Gets the right operand input component
  59587. */
  59588. get right(): NodeMaterialConnectionPoint;
  59589. /**
  59590. * Gets the output component
  59591. */
  59592. get output(): NodeMaterialConnectionPoint;
  59593. protected _buildBlock(state: NodeMaterialBuildState): this;
  59594. }
  59595. }
  59596. declare module BABYLON {
  59597. /**
  59598. * Block used to step a value
  59599. */
  59600. export class StepBlock extends NodeMaterialBlock {
  59601. /**
  59602. * Creates a new StepBlock
  59603. * @param name defines the block name
  59604. */
  59605. constructor(name: string);
  59606. /**
  59607. * Gets the current class name
  59608. * @returns the class name
  59609. */
  59610. getClassName(): string;
  59611. /**
  59612. * Gets the value operand input component
  59613. */
  59614. get value(): NodeMaterialConnectionPoint;
  59615. /**
  59616. * Gets the edge operand input component
  59617. */
  59618. get edge(): NodeMaterialConnectionPoint;
  59619. /**
  59620. * Gets the output component
  59621. */
  59622. get output(): NodeMaterialConnectionPoint;
  59623. protected _buildBlock(state: NodeMaterialBuildState): this;
  59624. }
  59625. }
  59626. declare module BABYLON {
  59627. /**
  59628. * Block used to get the opposite (1 - x) of a value
  59629. */
  59630. export class OneMinusBlock extends NodeMaterialBlock {
  59631. /**
  59632. * Creates a new OneMinusBlock
  59633. * @param name defines the block name
  59634. */
  59635. constructor(name: string);
  59636. /**
  59637. * Gets the current class name
  59638. * @returns the class name
  59639. */
  59640. getClassName(): string;
  59641. /**
  59642. * Gets the input component
  59643. */
  59644. get input(): NodeMaterialConnectionPoint;
  59645. /**
  59646. * Gets the output component
  59647. */
  59648. get output(): NodeMaterialConnectionPoint;
  59649. protected _buildBlock(state: NodeMaterialBuildState): this;
  59650. }
  59651. }
  59652. declare module BABYLON {
  59653. /**
  59654. * Block used to get the view direction
  59655. */
  59656. export class ViewDirectionBlock extends NodeMaterialBlock {
  59657. /**
  59658. * Creates a new ViewDirectionBlock
  59659. * @param name defines the block name
  59660. */
  59661. constructor(name: string);
  59662. /**
  59663. * Gets the current class name
  59664. * @returns the class name
  59665. */
  59666. getClassName(): string;
  59667. /**
  59668. * Gets the world position component
  59669. */
  59670. get worldPosition(): NodeMaterialConnectionPoint;
  59671. /**
  59672. * Gets the camera position component
  59673. */
  59674. get cameraPosition(): NodeMaterialConnectionPoint;
  59675. /**
  59676. * Gets the output component
  59677. */
  59678. get output(): NodeMaterialConnectionPoint;
  59679. autoConfigure(material: NodeMaterial): void;
  59680. protected _buildBlock(state: NodeMaterialBuildState): this;
  59681. }
  59682. }
  59683. declare module BABYLON {
  59684. /**
  59685. * Block used to compute fresnel value
  59686. */
  59687. export class FresnelBlock extends NodeMaterialBlock {
  59688. /**
  59689. * Create a new FresnelBlock
  59690. * @param name defines the block name
  59691. */
  59692. constructor(name: string);
  59693. /**
  59694. * Gets the current class name
  59695. * @returns the class name
  59696. */
  59697. getClassName(): string;
  59698. /**
  59699. * Gets the world normal input component
  59700. */
  59701. get worldNormal(): NodeMaterialConnectionPoint;
  59702. /**
  59703. * Gets the view direction input component
  59704. */
  59705. get viewDirection(): NodeMaterialConnectionPoint;
  59706. /**
  59707. * Gets the bias input component
  59708. */
  59709. get bias(): NodeMaterialConnectionPoint;
  59710. /**
  59711. * Gets the camera (or eye) position component
  59712. */
  59713. get power(): NodeMaterialConnectionPoint;
  59714. /**
  59715. * Gets the fresnel output component
  59716. */
  59717. get fresnel(): NodeMaterialConnectionPoint;
  59718. autoConfigure(material: NodeMaterial): void;
  59719. protected _buildBlock(state: NodeMaterialBuildState): this;
  59720. }
  59721. }
  59722. declare module BABYLON {
  59723. /**
  59724. * Block used to get the max of 2 values
  59725. */
  59726. export class MaxBlock extends NodeMaterialBlock {
  59727. /**
  59728. * Creates a new MaxBlock
  59729. * @param name defines the block name
  59730. */
  59731. constructor(name: string);
  59732. /**
  59733. * Gets the current class name
  59734. * @returns the class name
  59735. */
  59736. getClassName(): string;
  59737. /**
  59738. * Gets the left operand input component
  59739. */
  59740. get left(): NodeMaterialConnectionPoint;
  59741. /**
  59742. * Gets the right operand input component
  59743. */
  59744. get right(): NodeMaterialConnectionPoint;
  59745. /**
  59746. * Gets the output component
  59747. */
  59748. get output(): NodeMaterialConnectionPoint;
  59749. protected _buildBlock(state: NodeMaterialBuildState): this;
  59750. }
  59751. }
  59752. declare module BABYLON {
  59753. /**
  59754. * Block used to get the min of 2 values
  59755. */
  59756. export class MinBlock extends NodeMaterialBlock {
  59757. /**
  59758. * Creates a new MinBlock
  59759. * @param name defines the block name
  59760. */
  59761. constructor(name: string);
  59762. /**
  59763. * Gets the current class name
  59764. * @returns the class name
  59765. */
  59766. getClassName(): string;
  59767. /**
  59768. * Gets the left operand input component
  59769. */
  59770. get left(): NodeMaterialConnectionPoint;
  59771. /**
  59772. * Gets the right operand input component
  59773. */
  59774. get right(): NodeMaterialConnectionPoint;
  59775. /**
  59776. * Gets the output component
  59777. */
  59778. get output(): NodeMaterialConnectionPoint;
  59779. protected _buildBlock(state: NodeMaterialBuildState): this;
  59780. }
  59781. }
  59782. declare module BABYLON {
  59783. /**
  59784. * Block used to get the distance between 2 values
  59785. */
  59786. export class DistanceBlock extends NodeMaterialBlock {
  59787. /**
  59788. * Creates a new DistanceBlock
  59789. * @param name defines the block name
  59790. */
  59791. constructor(name: string);
  59792. /**
  59793. * Gets the current class name
  59794. * @returns the class name
  59795. */
  59796. getClassName(): string;
  59797. /**
  59798. * Gets the left operand input component
  59799. */
  59800. get left(): NodeMaterialConnectionPoint;
  59801. /**
  59802. * Gets the right operand input component
  59803. */
  59804. get right(): NodeMaterialConnectionPoint;
  59805. /**
  59806. * Gets the output component
  59807. */
  59808. get output(): NodeMaterialConnectionPoint;
  59809. protected _buildBlock(state: NodeMaterialBuildState): this;
  59810. }
  59811. }
  59812. declare module BABYLON {
  59813. /**
  59814. * Block used to get the length of a vector
  59815. */
  59816. export class LengthBlock extends NodeMaterialBlock {
  59817. /**
  59818. * Creates a new LengthBlock
  59819. * @param name defines the block name
  59820. */
  59821. constructor(name: string);
  59822. /**
  59823. * Gets the current class name
  59824. * @returns the class name
  59825. */
  59826. getClassName(): string;
  59827. /**
  59828. * Gets the value input component
  59829. */
  59830. get value(): NodeMaterialConnectionPoint;
  59831. /**
  59832. * Gets the output component
  59833. */
  59834. get output(): NodeMaterialConnectionPoint;
  59835. protected _buildBlock(state: NodeMaterialBuildState): this;
  59836. }
  59837. }
  59838. declare module BABYLON {
  59839. /**
  59840. * Block used to get negative version of a value (i.e. x * -1)
  59841. */
  59842. export class NegateBlock extends NodeMaterialBlock {
  59843. /**
  59844. * Creates a new NegateBlock
  59845. * @param name defines the block name
  59846. */
  59847. constructor(name: string);
  59848. /**
  59849. * Gets the current class name
  59850. * @returns the class name
  59851. */
  59852. getClassName(): string;
  59853. /**
  59854. * Gets the value input component
  59855. */
  59856. get value(): NodeMaterialConnectionPoint;
  59857. /**
  59858. * Gets the output component
  59859. */
  59860. get output(): NodeMaterialConnectionPoint;
  59861. protected _buildBlock(state: NodeMaterialBuildState): this;
  59862. }
  59863. }
  59864. declare module BABYLON {
  59865. /**
  59866. * Block used to get the value of the first parameter raised to the power of the second
  59867. */
  59868. export class PowBlock extends NodeMaterialBlock {
  59869. /**
  59870. * Creates a new PowBlock
  59871. * @param name defines the block name
  59872. */
  59873. constructor(name: string);
  59874. /**
  59875. * Gets the current class name
  59876. * @returns the class name
  59877. */
  59878. getClassName(): string;
  59879. /**
  59880. * Gets the value operand input component
  59881. */
  59882. get value(): NodeMaterialConnectionPoint;
  59883. /**
  59884. * Gets the power operand input component
  59885. */
  59886. get power(): NodeMaterialConnectionPoint;
  59887. /**
  59888. * Gets the output component
  59889. */
  59890. get output(): NodeMaterialConnectionPoint;
  59891. protected _buildBlock(state: NodeMaterialBuildState): this;
  59892. }
  59893. }
  59894. declare module BABYLON {
  59895. /**
  59896. * Block used to get a random number
  59897. */
  59898. export class RandomNumberBlock extends NodeMaterialBlock {
  59899. /**
  59900. * Creates a new RandomNumberBlock
  59901. * @param name defines the block name
  59902. */
  59903. constructor(name: string);
  59904. /**
  59905. * Gets the current class name
  59906. * @returns the class name
  59907. */
  59908. getClassName(): string;
  59909. /**
  59910. * Gets the seed input component
  59911. */
  59912. get seed(): NodeMaterialConnectionPoint;
  59913. /**
  59914. * Gets the output component
  59915. */
  59916. get output(): NodeMaterialConnectionPoint;
  59917. protected _buildBlock(state: NodeMaterialBuildState): this;
  59918. }
  59919. }
  59920. declare module BABYLON {
  59921. /**
  59922. * Block used to compute arc tangent of 2 values
  59923. */
  59924. export class ArcTan2Block extends NodeMaterialBlock {
  59925. /**
  59926. * Creates a new ArcTan2Block
  59927. * @param name defines the block name
  59928. */
  59929. constructor(name: string);
  59930. /**
  59931. * Gets the current class name
  59932. * @returns the class name
  59933. */
  59934. getClassName(): string;
  59935. /**
  59936. * Gets the x operand input component
  59937. */
  59938. get x(): NodeMaterialConnectionPoint;
  59939. /**
  59940. * Gets the y operand input component
  59941. */
  59942. get y(): NodeMaterialConnectionPoint;
  59943. /**
  59944. * Gets the output component
  59945. */
  59946. get output(): NodeMaterialConnectionPoint;
  59947. protected _buildBlock(state: NodeMaterialBuildState): this;
  59948. }
  59949. }
  59950. declare module BABYLON {
  59951. /**
  59952. * Block used to smooth step a value
  59953. */
  59954. export class SmoothStepBlock extends NodeMaterialBlock {
  59955. /**
  59956. * Creates a new SmoothStepBlock
  59957. * @param name defines the block name
  59958. */
  59959. constructor(name: string);
  59960. /**
  59961. * Gets the current class name
  59962. * @returns the class name
  59963. */
  59964. getClassName(): string;
  59965. /**
  59966. * Gets the value operand input component
  59967. */
  59968. get value(): NodeMaterialConnectionPoint;
  59969. /**
  59970. * Gets the first edge operand input component
  59971. */
  59972. get edge0(): NodeMaterialConnectionPoint;
  59973. /**
  59974. * Gets the second edge operand input component
  59975. */
  59976. get edge1(): NodeMaterialConnectionPoint;
  59977. /**
  59978. * Gets the output component
  59979. */
  59980. get output(): NodeMaterialConnectionPoint;
  59981. protected _buildBlock(state: NodeMaterialBuildState): this;
  59982. }
  59983. }
  59984. declare module BABYLON {
  59985. /**
  59986. * Block used to get the reciprocal (1 / x) of a value
  59987. */
  59988. export class ReciprocalBlock extends NodeMaterialBlock {
  59989. /**
  59990. * Creates a new ReciprocalBlock
  59991. * @param name defines the block name
  59992. */
  59993. constructor(name: string);
  59994. /**
  59995. * Gets the current class name
  59996. * @returns the class name
  59997. */
  59998. getClassName(): string;
  59999. /**
  60000. * Gets the input component
  60001. */
  60002. get input(): NodeMaterialConnectionPoint;
  60003. /**
  60004. * Gets the output component
  60005. */
  60006. get output(): NodeMaterialConnectionPoint;
  60007. protected _buildBlock(state: NodeMaterialBuildState): this;
  60008. }
  60009. }
  60010. declare module BABYLON {
  60011. /**
  60012. * Block used to replace a color by another one
  60013. */
  60014. export class ReplaceColorBlock extends NodeMaterialBlock {
  60015. /**
  60016. * Creates a new ReplaceColorBlock
  60017. * @param name defines the block name
  60018. */
  60019. constructor(name: string);
  60020. /**
  60021. * Gets the current class name
  60022. * @returns the class name
  60023. */
  60024. getClassName(): string;
  60025. /**
  60026. * Gets the value input component
  60027. */
  60028. get value(): NodeMaterialConnectionPoint;
  60029. /**
  60030. * Gets the reference input component
  60031. */
  60032. get reference(): NodeMaterialConnectionPoint;
  60033. /**
  60034. * Gets the distance input component
  60035. */
  60036. get distance(): NodeMaterialConnectionPoint;
  60037. /**
  60038. * Gets the replacement input component
  60039. */
  60040. get replacement(): NodeMaterialConnectionPoint;
  60041. /**
  60042. * Gets the output component
  60043. */
  60044. get output(): NodeMaterialConnectionPoint;
  60045. protected _buildBlock(state: NodeMaterialBuildState): this;
  60046. }
  60047. }
  60048. declare module BABYLON {
  60049. /**
  60050. * Block used to posterize a value
  60051. * @see https://en.wikipedia.org/wiki/Posterization
  60052. */
  60053. export class PosterizeBlock extends NodeMaterialBlock {
  60054. /**
  60055. * Creates a new PosterizeBlock
  60056. * @param name defines the block name
  60057. */
  60058. constructor(name: string);
  60059. /**
  60060. * Gets the current class name
  60061. * @returns the class name
  60062. */
  60063. getClassName(): string;
  60064. /**
  60065. * Gets the value input component
  60066. */
  60067. get value(): NodeMaterialConnectionPoint;
  60068. /**
  60069. * Gets the steps input component
  60070. */
  60071. get steps(): NodeMaterialConnectionPoint;
  60072. /**
  60073. * Gets the output component
  60074. */
  60075. get output(): NodeMaterialConnectionPoint;
  60076. protected _buildBlock(state: NodeMaterialBuildState): this;
  60077. }
  60078. }
  60079. declare module BABYLON {
  60080. /**
  60081. * Operations supported by the Wave block
  60082. */
  60083. export enum WaveBlockKind {
  60084. /** SawTooth */
  60085. SawTooth = 0,
  60086. /** Square */
  60087. Square = 1,
  60088. /** Triangle */
  60089. Triangle = 2
  60090. }
  60091. /**
  60092. * Block used to apply wave operation to floats
  60093. */
  60094. export class WaveBlock extends NodeMaterialBlock {
  60095. /**
  60096. * Gets or sets the kibnd of wave to be applied by the block
  60097. */
  60098. kind: WaveBlockKind;
  60099. /**
  60100. * Creates a new WaveBlock
  60101. * @param name defines the block name
  60102. */
  60103. constructor(name: string);
  60104. /**
  60105. * Gets the current class name
  60106. * @returns the class name
  60107. */
  60108. getClassName(): string;
  60109. /**
  60110. * Gets the input component
  60111. */
  60112. get input(): NodeMaterialConnectionPoint;
  60113. /**
  60114. * Gets the output component
  60115. */
  60116. get output(): NodeMaterialConnectionPoint;
  60117. protected _buildBlock(state: NodeMaterialBuildState): this;
  60118. serialize(): any;
  60119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60120. }
  60121. }
  60122. declare module BABYLON {
  60123. /**
  60124. * Class used to store a color step for the GradientBlock
  60125. */
  60126. export class GradientBlockColorStep {
  60127. /**
  60128. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60129. */
  60130. step: number;
  60131. /**
  60132. * Gets or sets the color associated with this step
  60133. */
  60134. color: Color3;
  60135. /**
  60136. * Creates a new GradientBlockColorStep
  60137. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60138. * @param color defines the color associated with this step
  60139. */
  60140. constructor(
  60141. /**
  60142. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60143. */
  60144. step: number,
  60145. /**
  60146. * Gets or sets the color associated with this step
  60147. */
  60148. color: Color3);
  60149. }
  60150. /**
  60151. * Block used to return a color from a gradient based on an input value between 0 and 1
  60152. */
  60153. export class GradientBlock extends NodeMaterialBlock {
  60154. /**
  60155. * Gets or sets the list of color steps
  60156. */
  60157. colorSteps: GradientBlockColorStep[];
  60158. /**
  60159. * Creates a new GradientBlock
  60160. * @param name defines the block name
  60161. */
  60162. constructor(name: string);
  60163. /**
  60164. * Gets the current class name
  60165. * @returns the class name
  60166. */
  60167. getClassName(): string;
  60168. /**
  60169. * Gets the gradient input component
  60170. */
  60171. get gradient(): NodeMaterialConnectionPoint;
  60172. /**
  60173. * Gets the output component
  60174. */
  60175. get output(): NodeMaterialConnectionPoint;
  60176. private _writeColorConstant;
  60177. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60178. serialize(): any;
  60179. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60180. protected _dumpPropertiesCode(): string;
  60181. }
  60182. }
  60183. declare module BABYLON {
  60184. /**
  60185. * Block used to normalize lerp between 2 values
  60186. */
  60187. export class NLerpBlock extends NodeMaterialBlock {
  60188. /**
  60189. * Creates a new NLerpBlock
  60190. * @param name defines the block name
  60191. */
  60192. constructor(name: string);
  60193. /**
  60194. * Gets the current class name
  60195. * @returns the class name
  60196. */
  60197. getClassName(): string;
  60198. /**
  60199. * Gets the left operand input component
  60200. */
  60201. get left(): NodeMaterialConnectionPoint;
  60202. /**
  60203. * Gets the right operand input component
  60204. */
  60205. get right(): NodeMaterialConnectionPoint;
  60206. /**
  60207. * Gets the gradient operand input component
  60208. */
  60209. get gradient(): NodeMaterialConnectionPoint;
  60210. /**
  60211. * Gets the output component
  60212. */
  60213. get output(): NodeMaterialConnectionPoint;
  60214. protected _buildBlock(state: NodeMaterialBuildState): this;
  60215. }
  60216. }
  60217. declare module BABYLON {
  60218. /**
  60219. * block used to Generate a Worley Noise 3D Noise Pattern
  60220. */
  60221. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60222. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60223. manhattanDistance: boolean;
  60224. /**
  60225. * Creates a new WorleyNoise3DBlock
  60226. * @param name defines the block name
  60227. */
  60228. constructor(name: string);
  60229. /**
  60230. * Gets the current class name
  60231. * @returns the class name
  60232. */
  60233. getClassName(): string;
  60234. /**
  60235. * Gets the seed input component
  60236. */
  60237. get seed(): NodeMaterialConnectionPoint;
  60238. /**
  60239. * Gets the jitter input component
  60240. */
  60241. get jitter(): NodeMaterialConnectionPoint;
  60242. /**
  60243. * Gets the output component
  60244. */
  60245. get output(): NodeMaterialConnectionPoint;
  60246. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60247. /**
  60248. * Exposes the properties to the UI?
  60249. */
  60250. protected _dumpPropertiesCode(): string;
  60251. /**
  60252. * Exposes the properties to the Seralize?
  60253. */
  60254. serialize(): any;
  60255. /**
  60256. * Exposes the properties to the deseralize?
  60257. */
  60258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60259. }
  60260. }
  60261. declare module BABYLON {
  60262. /**
  60263. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60264. */
  60265. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60266. /**
  60267. * Creates a new SimplexPerlin3DBlock
  60268. * @param name defines the block name
  60269. */
  60270. constructor(name: string);
  60271. /**
  60272. * Gets the current class name
  60273. * @returns the class name
  60274. */
  60275. getClassName(): string;
  60276. /**
  60277. * Gets the seed operand input component
  60278. */
  60279. get seed(): NodeMaterialConnectionPoint;
  60280. /**
  60281. * Gets the output component
  60282. */
  60283. get output(): NodeMaterialConnectionPoint;
  60284. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60285. }
  60286. }
  60287. declare module BABYLON {
  60288. /**
  60289. * Block used to blend normals
  60290. */
  60291. export class NormalBlendBlock extends NodeMaterialBlock {
  60292. /**
  60293. * Creates a new NormalBlendBlock
  60294. * @param name defines the block name
  60295. */
  60296. constructor(name: string);
  60297. /**
  60298. * Gets the current class name
  60299. * @returns the class name
  60300. */
  60301. getClassName(): string;
  60302. /**
  60303. * Gets the first input component
  60304. */
  60305. get normalMap0(): NodeMaterialConnectionPoint;
  60306. /**
  60307. * Gets the second input component
  60308. */
  60309. get normalMap1(): NodeMaterialConnectionPoint;
  60310. /**
  60311. * Gets the output component
  60312. */
  60313. get output(): NodeMaterialConnectionPoint;
  60314. protected _buildBlock(state: NodeMaterialBuildState): this;
  60315. }
  60316. }
  60317. declare module BABYLON {
  60318. /**
  60319. * Block used to rotate a 2d vector by a given angle
  60320. */
  60321. export class Rotate2dBlock extends NodeMaterialBlock {
  60322. /**
  60323. * Creates a new Rotate2dBlock
  60324. * @param name defines the block name
  60325. */
  60326. constructor(name: string);
  60327. /**
  60328. * Gets the current class name
  60329. * @returns the class name
  60330. */
  60331. getClassName(): string;
  60332. /**
  60333. * Gets the input vector
  60334. */
  60335. get input(): NodeMaterialConnectionPoint;
  60336. /**
  60337. * Gets the input angle
  60338. */
  60339. get angle(): NodeMaterialConnectionPoint;
  60340. /**
  60341. * Gets the output component
  60342. */
  60343. get output(): NodeMaterialConnectionPoint;
  60344. autoConfigure(material: NodeMaterial): void;
  60345. protected _buildBlock(state: NodeMaterialBuildState): this;
  60346. }
  60347. }
  60348. declare module BABYLON {
  60349. /**
  60350. * Block used to get the reflected vector from a direction and a normal
  60351. */
  60352. export class ReflectBlock extends NodeMaterialBlock {
  60353. /**
  60354. * Creates a new ReflectBlock
  60355. * @param name defines the block name
  60356. */
  60357. constructor(name: string);
  60358. /**
  60359. * Gets the current class name
  60360. * @returns the class name
  60361. */
  60362. getClassName(): string;
  60363. /**
  60364. * Gets the incident component
  60365. */
  60366. get incident(): NodeMaterialConnectionPoint;
  60367. /**
  60368. * Gets the normal component
  60369. */
  60370. get normal(): NodeMaterialConnectionPoint;
  60371. /**
  60372. * Gets the output component
  60373. */
  60374. get output(): NodeMaterialConnectionPoint;
  60375. protected _buildBlock(state: NodeMaterialBuildState): this;
  60376. }
  60377. }
  60378. declare module BABYLON {
  60379. /**
  60380. * Block used to get the refracted vector from a direction and a normal
  60381. */
  60382. export class RefractBlock extends NodeMaterialBlock {
  60383. /**
  60384. * Creates a new RefractBlock
  60385. * @param name defines the block name
  60386. */
  60387. constructor(name: string);
  60388. /**
  60389. * Gets the current class name
  60390. * @returns the class name
  60391. */
  60392. getClassName(): string;
  60393. /**
  60394. * Gets the incident component
  60395. */
  60396. get incident(): NodeMaterialConnectionPoint;
  60397. /**
  60398. * Gets the normal component
  60399. */
  60400. get normal(): NodeMaterialConnectionPoint;
  60401. /**
  60402. * Gets the index of refraction component
  60403. */
  60404. get ior(): NodeMaterialConnectionPoint;
  60405. /**
  60406. * Gets the output component
  60407. */
  60408. get output(): NodeMaterialConnectionPoint;
  60409. protected _buildBlock(state: NodeMaterialBuildState): this;
  60410. }
  60411. }
  60412. declare module BABYLON {
  60413. /**
  60414. * Block used to desaturate a color
  60415. */
  60416. export class DesaturateBlock extends NodeMaterialBlock {
  60417. /**
  60418. * Creates a new DesaturateBlock
  60419. * @param name defines the block name
  60420. */
  60421. constructor(name: string);
  60422. /**
  60423. * Gets the current class name
  60424. * @returns the class name
  60425. */
  60426. getClassName(): string;
  60427. /**
  60428. * Gets the color operand input component
  60429. */
  60430. get color(): NodeMaterialConnectionPoint;
  60431. /**
  60432. * Gets the level operand input component
  60433. */
  60434. get level(): NodeMaterialConnectionPoint;
  60435. /**
  60436. * Gets the output component
  60437. */
  60438. get output(): NodeMaterialConnectionPoint;
  60439. protected _buildBlock(state: NodeMaterialBuildState): this;
  60440. }
  60441. }
  60442. declare module BABYLON {
  60443. /**
  60444. * Effect Render Options
  60445. */
  60446. export interface IEffectRendererOptions {
  60447. /**
  60448. * Defines the vertices positions.
  60449. */
  60450. positions?: number[];
  60451. /**
  60452. * Defines the indices.
  60453. */
  60454. indices?: number[];
  60455. }
  60456. /**
  60457. * Helper class to render one or more effects
  60458. */
  60459. export class EffectRenderer {
  60460. private engine;
  60461. private static _DefaultOptions;
  60462. private _vertexBuffers;
  60463. private _indexBuffer;
  60464. private _ringBufferIndex;
  60465. private _ringScreenBuffer;
  60466. private _fullscreenViewport;
  60467. private _getNextFrameBuffer;
  60468. /**
  60469. * Creates an effect renderer
  60470. * @param engine the engine to use for rendering
  60471. * @param options defines the options of the effect renderer
  60472. */
  60473. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60474. /**
  60475. * Sets the current viewport in normalized coordinates 0-1
  60476. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60477. */
  60478. setViewport(viewport?: Viewport): void;
  60479. /**
  60480. * Binds the embedded attributes buffer to the effect.
  60481. * @param effect Defines the effect to bind the attributes for
  60482. */
  60483. bindBuffers(effect: Effect): void;
  60484. /**
  60485. * Sets the current effect wrapper to use during draw.
  60486. * The effect needs to be ready before calling this api.
  60487. * This also sets the default full screen position attribute.
  60488. * @param effectWrapper Defines the effect to draw with
  60489. */
  60490. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60491. /**
  60492. * Draws a full screen quad.
  60493. */
  60494. draw(): void;
  60495. /**
  60496. * renders one or more effects to a specified texture
  60497. * @param effectWrappers list of effects to renderer
  60498. * @param outputTexture texture to draw to, if null it will render to the screen
  60499. */
  60500. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60501. /**
  60502. * Disposes of the effect renderer
  60503. */
  60504. dispose(): void;
  60505. }
  60506. /**
  60507. * Options to create an EffectWrapper
  60508. */
  60509. interface EffectWrapperCreationOptions {
  60510. /**
  60511. * Engine to use to create the effect
  60512. */
  60513. engine: ThinEngine;
  60514. /**
  60515. * Fragment shader for the effect
  60516. */
  60517. fragmentShader: string;
  60518. /**
  60519. * Vertex shader for the effect
  60520. */
  60521. vertexShader?: string;
  60522. /**
  60523. * Attributes to use in the shader
  60524. */
  60525. attributeNames?: Array<string>;
  60526. /**
  60527. * Uniforms to use in the shader
  60528. */
  60529. uniformNames?: Array<string>;
  60530. /**
  60531. * Texture sampler names to use in the shader
  60532. */
  60533. samplerNames?: Array<string>;
  60534. /**
  60535. * The friendly name of the effect displayed in Spector.
  60536. */
  60537. name?: string;
  60538. }
  60539. /**
  60540. * Wraps an effect to be used for rendering
  60541. */
  60542. export class EffectWrapper {
  60543. /**
  60544. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60545. */
  60546. onApplyObservable: Observable<{}>;
  60547. /**
  60548. * The underlying effect
  60549. */
  60550. effect: Effect;
  60551. /**
  60552. * Creates an effect to be renderer
  60553. * @param creationOptions options to create the effect
  60554. */
  60555. constructor(creationOptions: EffectWrapperCreationOptions);
  60556. /**
  60557. * Disposes of the effect wrapper
  60558. */
  60559. dispose(): void;
  60560. }
  60561. }
  60562. declare module BABYLON {
  60563. /**
  60564. * Helper class to push actions to a pool of workers.
  60565. */
  60566. export class WorkerPool implements IDisposable {
  60567. private _workerInfos;
  60568. private _pendingActions;
  60569. /**
  60570. * Constructor
  60571. * @param workers Array of workers to use for actions
  60572. */
  60573. constructor(workers: Array<Worker>);
  60574. /**
  60575. * Terminates all workers and clears any pending actions.
  60576. */
  60577. dispose(): void;
  60578. /**
  60579. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60580. * pended until a worker has completed its action.
  60581. * @param action The action to perform. Call onComplete when the action is complete.
  60582. */
  60583. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60584. private _execute;
  60585. }
  60586. }
  60587. declare module BABYLON {
  60588. /**
  60589. * Configuration for Draco compression
  60590. */
  60591. export interface IDracoCompressionConfiguration {
  60592. /**
  60593. * Configuration for the decoder.
  60594. */
  60595. decoder: {
  60596. /**
  60597. * The url to the WebAssembly module.
  60598. */
  60599. wasmUrl?: string;
  60600. /**
  60601. * The url to the WebAssembly binary.
  60602. */
  60603. wasmBinaryUrl?: string;
  60604. /**
  60605. * The url to the fallback JavaScript module.
  60606. */
  60607. fallbackUrl?: string;
  60608. };
  60609. }
  60610. /**
  60611. * Draco compression (https://google.github.io/draco/)
  60612. *
  60613. * This class wraps the Draco module.
  60614. *
  60615. * **Encoder**
  60616. *
  60617. * The encoder is not currently implemented.
  60618. *
  60619. * **Decoder**
  60620. *
  60621. * 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.
  60622. *
  60623. * To update the configuration, use the following code:
  60624. * ```javascript
  60625. * DracoCompression.Configuration = {
  60626. * decoder: {
  60627. * wasmUrl: "<url to the WebAssembly library>",
  60628. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60629. * fallbackUrl: "<url to the fallback JavaScript library>",
  60630. * }
  60631. * };
  60632. * ```
  60633. *
  60634. * 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.
  60635. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60636. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60637. *
  60638. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60639. * ```javascript
  60640. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60641. * ```
  60642. *
  60643. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60644. */
  60645. export class DracoCompression implements IDisposable {
  60646. private _workerPoolPromise?;
  60647. private _decoderModulePromise?;
  60648. /**
  60649. * The configuration. Defaults to the following urls:
  60650. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60651. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60652. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60653. */
  60654. static Configuration: IDracoCompressionConfiguration;
  60655. /**
  60656. * Returns true if the decoder configuration is available.
  60657. */
  60658. static get DecoderAvailable(): boolean;
  60659. /**
  60660. * Default number of workers to create when creating the draco compression object.
  60661. */
  60662. static DefaultNumWorkers: number;
  60663. private static GetDefaultNumWorkers;
  60664. private static _Default;
  60665. /**
  60666. * Default instance for the draco compression object.
  60667. */
  60668. static get Default(): DracoCompression;
  60669. /**
  60670. * Constructor
  60671. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60672. */
  60673. constructor(numWorkers?: number);
  60674. /**
  60675. * Stop all async operations and release resources.
  60676. */
  60677. dispose(): void;
  60678. /**
  60679. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60680. * @returns a promise that resolves when ready
  60681. */
  60682. whenReadyAsync(): Promise<void>;
  60683. /**
  60684. * Decode Draco compressed mesh data to vertex data.
  60685. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60686. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60687. * @returns A promise that resolves with the decoded vertex data
  60688. */
  60689. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60690. [kind: string]: number;
  60691. }): Promise<VertexData>;
  60692. }
  60693. }
  60694. declare module BABYLON {
  60695. /**
  60696. * Class for building Constructive Solid Geometry
  60697. */
  60698. export class CSG {
  60699. private polygons;
  60700. /**
  60701. * The world matrix
  60702. */
  60703. matrix: Matrix;
  60704. /**
  60705. * Stores the position
  60706. */
  60707. position: Vector3;
  60708. /**
  60709. * Stores the rotation
  60710. */
  60711. rotation: Vector3;
  60712. /**
  60713. * Stores the rotation quaternion
  60714. */
  60715. rotationQuaternion: Nullable<Quaternion>;
  60716. /**
  60717. * Stores the scaling vector
  60718. */
  60719. scaling: Vector3;
  60720. /**
  60721. * Convert the Mesh to CSG
  60722. * @param mesh The Mesh to convert to CSG
  60723. * @returns A new CSG from the Mesh
  60724. */
  60725. static FromMesh(mesh: Mesh): CSG;
  60726. /**
  60727. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60728. * @param polygons Polygons used to construct a CSG solid
  60729. */
  60730. private static FromPolygons;
  60731. /**
  60732. * Clones, or makes a deep copy, of the CSG
  60733. * @returns A new CSG
  60734. */
  60735. clone(): CSG;
  60736. /**
  60737. * Unions this CSG with another CSG
  60738. * @param csg The CSG to union against this CSG
  60739. * @returns The unioned CSG
  60740. */
  60741. union(csg: CSG): CSG;
  60742. /**
  60743. * Unions this CSG with another CSG in place
  60744. * @param csg The CSG to union against this CSG
  60745. */
  60746. unionInPlace(csg: CSG): void;
  60747. /**
  60748. * Subtracts this CSG with another CSG
  60749. * @param csg The CSG to subtract against this CSG
  60750. * @returns A new CSG
  60751. */
  60752. subtract(csg: CSG): CSG;
  60753. /**
  60754. * Subtracts this CSG with another CSG in place
  60755. * @param csg The CSG to subtact against this CSG
  60756. */
  60757. subtractInPlace(csg: CSG): void;
  60758. /**
  60759. * Intersect this CSG with another CSG
  60760. * @param csg The CSG to intersect against this CSG
  60761. * @returns A new CSG
  60762. */
  60763. intersect(csg: CSG): CSG;
  60764. /**
  60765. * Intersects this CSG with another CSG in place
  60766. * @param csg The CSG to intersect against this CSG
  60767. */
  60768. intersectInPlace(csg: CSG): void;
  60769. /**
  60770. * Return a new CSG solid with solid and empty space switched. This solid is
  60771. * not modified.
  60772. * @returns A new CSG solid with solid and empty space switched
  60773. */
  60774. inverse(): CSG;
  60775. /**
  60776. * Inverses the CSG in place
  60777. */
  60778. inverseInPlace(): void;
  60779. /**
  60780. * This is used to keep meshes transformations so they can be restored
  60781. * when we build back a Babylon Mesh
  60782. * NB : All CSG operations are performed in world coordinates
  60783. * @param csg The CSG to copy the transform attributes from
  60784. * @returns This CSG
  60785. */
  60786. copyTransformAttributes(csg: CSG): CSG;
  60787. /**
  60788. * Build Raw mesh from CSG
  60789. * Coordinates here are in world space
  60790. * @param name The name of the mesh geometry
  60791. * @param scene The Scene
  60792. * @param keepSubMeshes Specifies if the submeshes should be kept
  60793. * @returns A new Mesh
  60794. */
  60795. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60796. /**
  60797. * Build Mesh from CSG taking material and transforms into account
  60798. * @param name The name of the Mesh
  60799. * @param material The material of the Mesh
  60800. * @param scene The Scene
  60801. * @param keepSubMeshes Specifies if submeshes should be kept
  60802. * @returns The new Mesh
  60803. */
  60804. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60805. }
  60806. }
  60807. declare module BABYLON {
  60808. /**
  60809. * Class used to create a trail following a mesh
  60810. */
  60811. export class TrailMesh extends Mesh {
  60812. private _generator;
  60813. private _autoStart;
  60814. private _running;
  60815. private _diameter;
  60816. private _length;
  60817. private _sectionPolygonPointsCount;
  60818. private _sectionVectors;
  60819. private _sectionNormalVectors;
  60820. private _beforeRenderObserver;
  60821. /**
  60822. * @constructor
  60823. * @param name The value used by scene.getMeshByName() to do a lookup.
  60824. * @param generator The mesh or transform node to generate a trail.
  60825. * @param scene The scene to add this mesh to.
  60826. * @param diameter Diameter of trailing mesh. Default is 1.
  60827. * @param length Length of trailing mesh. Default is 60.
  60828. * @param autoStart Automatically start trailing mesh. Default true.
  60829. */
  60830. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60831. /**
  60832. * "TrailMesh"
  60833. * @returns "TrailMesh"
  60834. */
  60835. getClassName(): string;
  60836. private _createMesh;
  60837. /**
  60838. * Start trailing mesh.
  60839. */
  60840. start(): void;
  60841. /**
  60842. * Stop trailing mesh.
  60843. */
  60844. stop(): void;
  60845. /**
  60846. * Update trailing mesh geometry.
  60847. */
  60848. update(): void;
  60849. /**
  60850. * Returns a new TrailMesh object.
  60851. * @param name is a string, the name given to the new mesh
  60852. * @param newGenerator use new generator object for cloned trail mesh
  60853. * @returns a new mesh
  60854. */
  60855. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60856. /**
  60857. * Serializes this trail mesh
  60858. * @param serializationObject object to write serialization to
  60859. */
  60860. serialize(serializationObject: any): void;
  60861. /**
  60862. * Parses a serialized trail mesh
  60863. * @param parsedMesh the serialized mesh
  60864. * @param scene the scene to create the trail mesh in
  60865. * @returns the created trail mesh
  60866. */
  60867. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60868. }
  60869. }
  60870. declare module BABYLON {
  60871. /**
  60872. * Class containing static functions to help procedurally build meshes
  60873. */
  60874. export class TiledBoxBuilder {
  60875. /**
  60876. * Creates a box mesh
  60877. * 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)
  60878. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60880. * * 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
  60881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60882. * @param name defines the name of the mesh
  60883. * @param options defines the options used to create the mesh
  60884. * @param scene defines the hosting scene
  60885. * @returns the box mesh
  60886. */
  60887. static CreateTiledBox(name: string, options: {
  60888. pattern?: number;
  60889. width?: number;
  60890. height?: number;
  60891. depth?: number;
  60892. tileSize?: number;
  60893. tileWidth?: number;
  60894. tileHeight?: number;
  60895. alignHorizontal?: number;
  60896. alignVertical?: number;
  60897. faceUV?: Vector4[];
  60898. faceColors?: Color4[];
  60899. sideOrientation?: number;
  60900. updatable?: boolean;
  60901. }, scene?: Nullable<Scene>): Mesh;
  60902. }
  60903. }
  60904. declare module BABYLON {
  60905. /**
  60906. * Class containing static functions to help procedurally build meshes
  60907. */
  60908. export class TorusKnotBuilder {
  60909. /**
  60910. * Creates a torus knot mesh
  60911. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60912. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60913. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60914. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60916. * * 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
  60917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60918. * @param name defines the name of the mesh
  60919. * @param options defines the options used to create the mesh
  60920. * @param scene defines the hosting scene
  60921. * @returns the torus knot mesh
  60922. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60923. */
  60924. static CreateTorusKnot(name: string, options: {
  60925. radius?: number;
  60926. tube?: number;
  60927. radialSegments?: number;
  60928. tubularSegments?: number;
  60929. p?: number;
  60930. q?: number;
  60931. updatable?: boolean;
  60932. sideOrientation?: number;
  60933. frontUVs?: Vector4;
  60934. backUVs?: Vector4;
  60935. }, scene: any): Mesh;
  60936. }
  60937. }
  60938. declare module BABYLON {
  60939. /**
  60940. * Polygon
  60941. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60942. */
  60943. export class Polygon {
  60944. /**
  60945. * Creates a rectangle
  60946. * @param xmin bottom X coord
  60947. * @param ymin bottom Y coord
  60948. * @param xmax top X coord
  60949. * @param ymax top Y coord
  60950. * @returns points that make the resulting rectation
  60951. */
  60952. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60953. /**
  60954. * Creates a circle
  60955. * @param radius radius of circle
  60956. * @param cx scale in x
  60957. * @param cy scale in y
  60958. * @param numberOfSides number of sides that make up the circle
  60959. * @returns points that make the resulting circle
  60960. */
  60961. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60962. /**
  60963. * Creates a polygon from input string
  60964. * @param input Input polygon data
  60965. * @returns the parsed points
  60966. */
  60967. static Parse(input: string): Vector2[];
  60968. /**
  60969. * Starts building a polygon from x and y coordinates
  60970. * @param x x coordinate
  60971. * @param y y coordinate
  60972. * @returns the started path2
  60973. */
  60974. static StartingAt(x: number, y: number): Path2;
  60975. }
  60976. /**
  60977. * Builds a polygon
  60978. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60979. */
  60980. export class PolygonMeshBuilder {
  60981. private _points;
  60982. private _outlinepoints;
  60983. private _holes;
  60984. private _name;
  60985. private _scene;
  60986. private _epoints;
  60987. private _eholes;
  60988. private _addToepoint;
  60989. /**
  60990. * Babylon reference to the earcut plugin.
  60991. */
  60992. bjsEarcut: any;
  60993. /**
  60994. * Creates a PolygonMeshBuilder
  60995. * @param name name of the builder
  60996. * @param contours Path of the polygon
  60997. * @param scene scene to add to when creating the mesh
  60998. * @param earcutInjection can be used to inject your own earcut reference
  60999. */
  61000. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61001. /**
  61002. * Adds a whole within the polygon
  61003. * @param hole Array of points defining the hole
  61004. * @returns this
  61005. */
  61006. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61007. /**
  61008. * Creates the polygon
  61009. * @param updatable If the mesh should be updatable
  61010. * @param depth The depth of the mesh created
  61011. * @returns the created mesh
  61012. */
  61013. build(updatable?: boolean, depth?: number): Mesh;
  61014. /**
  61015. * Creates the polygon
  61016. * @param depth The depth of the mesh created
  61017. * @returns the created VertexData
  61018. */
  61019. buildVertexData(depth?: number): VertexData;
  61020. /**
  61021. * Adds a side to the polygon
  61022. * @param positions points that make the polygon
  61023. * @param normals normals of the polygon
  61024. * @param uvs uvs of the polygon
  61025. * @param indices indices of the polygon
  61026. * @param bounds bounds of the polygon
  61027. * @param points points of the polygon
  61028. * @param depth depth of the polygon
  61029. * @param flip flip of the polygon
  61030. */
  61031. private addSide;
  61032. }
  61033. }
  61034. declare module BABYLON {
  61035. /**
  61036. * Class containing static functions to help procedurally build meshes
  61037. */
  61038. export class PolygonBuilder {
  61039. /**
  61040. * Creates a polygon mesh
  61041. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61042. * * 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
  61043. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61045. * * 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)
  61046. * * Remember you can only change the shape positions, not their number when updating a polygon
  61047. * @param name defines the name of the mesh
  61048. * @param options defines the options used to create the mesh
  61049. * @param scene defines the hosting scene
  61050. * @param earcutInjection can be used to inject your own earcut reference
  61051. * @returns the polygon mesh
  61052. */
  61053. static CreatePolygon(name: string, options: {
  61054. shape: Vector3[];
  61055. holes?: Vector3[][];
  61056. depth?: number;
  61057. faceUV?: Vector4[];
  61058. faceColors?: Color4[];
  61059. updatable?: boolean;
  61060. sideOrientation?: number;
  61061. frontUVs?: Vector4;
  61062. backUVs?: Vector4;
  61063. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61064. /**
  61065. * Creates an extruded polygon mesh, with depth in the Y direction.
  61066. * * 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)
  61067. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61068. * @param name defines the name of the mesh
  61069. * @param options defines the options used to create the mesh
  61070. * @param scene defines the hosting scene
  61071. * @param earcutInjection can be used to inject your own earcut reference
  61072. * @returns the polygon mesh
  61073. */
  61074. static ExtrudePolygon(name: string, options: {
  61075. shape: Vector3[];
  61076. holes?: Vector3[][];
  61077. depth?: number;
  61078. faceUV?: Vector4[];
  61079. faceColors?: Color4[];
  61080. updatable?: boolean;
  61081. sideOrientation?: number;
  61082. frontUVs?: Vector4;
  61083. backUVs?: Vector4;
  61084. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61085. }
  61086. }
  61087. declare module BABYLON {
  61088. /**
  61089. * Class containing static functions to help procedurally build meshes
  61090. */
  61091. export class LatheBuilder {
  61092. /**
  61093. * Creates lathe mesh.
  61094. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61095. * * 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
  61096. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61097. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61098. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61099. * * 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
  61100. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61101. * * 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
  61102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61103. * * 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
  61104. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61106. * @param name defines the name of the mesh
  61107. * @param options defines the options used to create the mesh
  61108. * @param scene defines the hosting scene
  61109. * @returns the lathe mesh
  61110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61111. */
  61112. static CreateLathe(name: string, options: {
  61113. shape: Vector3[];
  61114. radius?: number;
  61115. tessellation?: number;
  61116. clip?: number;
  61117. arc?: number;
  61118. closed?: boolean;
  61119. updatable?: boolean;
  61120. sideOrientation?: number;
  61121. frontUVs?: Vector4;
  61122. backUVs?: Vector4;
  61123. cap?: number;
  61124. invertUV?: boolean;
  61125. }, scene?: Nullable<Scene>): Mesh;
  61126. }
  61127. }
  61128. declare module BABYLON {
  61129. /**
  61130. * Class containing static functions to help procedurally build meshes
  61131. */
  61132. export class TiledPlaneBuilder {
  61133. /**
  61134. * Creates a tiled plane mesh
  61135. * * The parameter `pattern` will, depending on value, do nothing or
  61136. * * * flip (reflect about central vertical) alternate tiles across and up
  61137. * * * flip every tile on alternate rows
  61138. * * * rotate (180 degs) alternate tiles across and up
  61139. * * * rotate every tile on alternate rows
  61140. * * * flip and rotate alternate tiles across and up
  61141. * * * flip and rotate every tile on alternate rows
  61142. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61143. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61144. * * 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
  61145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61146. * * 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)
  61147. * * 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)
  61148. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61149. * @param name defines the name of the mesh
  61150. * @param options defines the options used to create the mesh
  61151. * @param scene defines the hosting scene
  61152. * @returns the box mesh
  61153. */
  61154. static CreateTiledPlane(name: string, options: {
  61155. pattern?: number;
  61156. tileSize?: number;
  61157. tileWidth?: number;
  61158. tileHeight?: number;
  61159. size?: number;
  61160. width?: number;
  61161. height?: number;
  61162. alignHorizontal?: number;
  61163. alignVertical?: number;
  61164. sideOrientation?: number;
  61165. frontUVs?: Vector4;
  61166. backUVs?: Vector4;
  61167. updatable?: boolean;
  61168. }, scene?: Nullable<Scene>): Mesh;
  61169. }
  61170. }
  61171. declare module BABYLON {
  61172. /**
  61173. * Class containing static functions to help procedurally build meshes
  61174. */
  61175. export class TubeBuilder {
  61176. /**
  61177. * Creates a tube mesh.
  61178. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61179. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61180. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61181. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61182. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61183. * * 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)
  61184. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61185. * * 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
  61186. * * 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
  61187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61188. * * 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
  61189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61191. * @param name defines the name of the mesh
  61192. * @param options defines the options used to create the mesh
  61193. * @param scene defines the hosting scene
  61194. * @returns the tube mesh
  61195. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61196. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61197. */
  61198. static CreateTube(name: string, options: {
  61199. path: Vector3[];
  61200. radius?: number;
  61201. tessellation?: number;
  61202. radiusFunction?: {
  61203. (i: number, distance: number): number;
  61204. };
  61205. cap?: number;
  61206. arc?: number;
  61207. updatable?: boolean;
  61208. sideOrientation?: number;
  61209. frontUVs?: Vector4;
  61210. backUVs?: Vector4;
  61211. instance?: Mesh;
  61212. invertUV?: boolean;
  61213. }, scene?: Nullable<Scene>): Mesh;
  61214. }
  61215. }
  61216. declare module BABYLON {
  61217. /**
  61218. * Class containing static functions to help procedurally build meshes
  61219. */
  61220. export class IcoSphereBuilder {
  61221. /**
  61222. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61223. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61224. * * 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`)
  61225. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61226. * * 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
  61227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61228. * * 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
  61229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61230. * @param name defines the name of the mesh
  61231. * @param options defines the options used to create the mesh
  61232. * @param scene defines the hosting scene
  61233. * @returns the icosahedron mesh
  61234. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61235. */
  61236. static CreateIcoSphere(name: string, options: {
  61237. radius?: number;
  61238. radiusX?: number;
  61239. radiusY?: number;
  61240. radiusZ?: number;
  61241. flat?: boolean;
  61242. subdivisions?: number;
  61243. sideOrientation?: number;
  61244. frontUVs?: Vector4;
  61245. backUVs?: Vector4;
  61246. updatable?: boolean;
  61247. }, scene?: Nullable<Scene>): Mesh;
  61248. }
  61249. }
  61250. declare module BABYLON {
  61251. /**
  61252. * Class containing static functions to help procedurally build meshes
  61253. */
  61254. export class DecalBuilder {
  61255. /**
  61256. * Creates a decal mesh.
  61257. * 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
  61258. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61259. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61260. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61261. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61262. * @param name defines the name of the mesh
  61263. * @param sourceMesh defines the mesh where the decal must be applied
  61264. * @param options defines the options used to create the mesh
  61265. * @param scene defines the hosting scene
  61266. * @returns the decal mesh
  61267. * @see https://doc.babylonjs.com/how_to/decals
  61268. */
  61269. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61270. position?: Vector3;
  61271. normal?: Vector3;
  61272. size?: Vector3;
  61273. angle?: number;
  61274. }): Mesh;
  61275. }
  61276. }
  61277. declare module BABYLON {
  61278. /**
  61279. * Class containing static functions to help procedurally build meshes
  61280. */
  61281. export class MeshBuilder {
  61282. /**
  61283. * Creates a box mesh
  61284. * * The parameter `size` sets the size (float) of each box side (default 1)
  61285. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61286. * * 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)
  61287. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61289. * * 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
  61290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61291. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61292. * @param name defines the name of the mesh
  61293. * @param options defines the options used to create the mesh
  61294. * @param scene defines the hosting scene
  61295. * @returns the box mesh
  61296. */
  61297. static CreateBox(name: string, options: {
  61298. size?: number;
  61299. width?: number;
  61300. height?: number;
  61301. depth?: number;
  61302. faceUV?: Vector4[];
  61303. faceColors?: Color4[];
  61304. sideOrientation?: number;
  61305. frontUVs?: Vector4;
  61306. backUVs?: Vector4;
  61307. wrap?: boolean;
  61308. topBaseAt?: number;
  61309. bottomBaseAt?: number;
  61310. updatable?: boolean;
  61311. }, scene?: Nullable<Scene>): Mesh;
  61312. /**
  61313. * Creates a tiled box mesh
  61314. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61316. * @param name defines the name of the mesh
  61317. * @param options defines the options used to create the mesh
  61318. * @param scene defines the hosting scene
  61319. * @returns the tiled box mesh
  61320. */
  61321. static CreateTiledBox(name: string, options: {
  61322. pattern?: number;
  61323. size?: number;
  61324. width?: number;
  61325. height?: number;
  61326. depth: number;
  61327. tileSize?: number;
  61328. tileWidth?: number;
  61329. tileHeight?: number;
  61330. faceUV?: Vector4[];
  61331. faceColors?: Color4[];
  61332. alignHorizontal?: number;
  61333. alignVertical?: number;
  61334. sideOrientation?: number;
  61335. updatable?: boolean;
  61336. }, scene?: Nullable<Scene>): Mesh;
  61337. /**
  61338. * Creates a sphere mesh
  61339. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61340. * * 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`)
  61341. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61342. * * 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
  61343. * * 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)
  61344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61345. * * 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
  61346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61347. * @param name defines the name of the mesh
  61348. * @param options defines the options used to create the mesh
  61349. * @param scene defines the hosting scene
  61350. * @returns the sphere mesh
  61351. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61352. */
  61353. static CreateSphere(name: string, options: {
  61354. segments?: number;
  61355. diameter?: number;
  61356. diameterX?: number;
  61357. diameterY?: number;
  61358. diameterZ?: number;
  61359. arc?: number;
  61360. slice?: number;
  61361. sideOrientation?: number;
  61362. frontUVs?: Vector4;
  61363. backUVs?: Vector4;
  61364. updatable?: boolean;
  61365. }, scene?: Nullable<Scene>): Mesh;
  61366. /**
  61367. * Creates a plane polygonal mesh. By default, this is a disc
  61368. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61369. * * 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
  61370. * * 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
  61371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61372. * * 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
  61373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61374. * @param name defines the name of the mesh
  61375. * @param options defines the options used to create the mesh
  61376. * @param scene defines the hosting scene
  61377. * @returns the plane polygonal mesh
  61378. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61379. */
  61380. static CreateDisc(name: string, options: {
  61381. radius?: number;
  61382. tessellation?: number;
  61383. arc?: number;
  61384. updatable?: boolean;
  61385. sideOrientation?: number;
  61386. frontUVs?: Vector4;
  61387. backUVs?: Vector4;
  61388. }, scene?: Nullable<Scene>): Mesh;
  61389. /**
  61390. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61391. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61392. * * 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`)
  61393. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61394. * * 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
  61395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61396. * * 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
  61397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61398. * @param name defines the name of the mesh
  61399. * @param options defines the options used to create the mesh
  61400. * @param scene defines the hosting scene
  61401. * @returns the icosahedron mesh
  61402. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61403. */
  61404. static CreateIcoSphere(name: string, options: {
  61405. radius?: number;
  61406. radiusX?: number;
  61407. radiusY?: number;
  61408. radiusZ?: number;
  61409. flat?: boolean;
  61410. subdivisions?: number;
  61411. sideOrientation?: number;
  61412. frontUVs?: Vector4;
  61413. backUVs?: Vector4;
  61414. updatable?: boolean;
  61415. }, scene?: Nullable<Scene>): Mesh;
  61416. /**
  61417. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61418. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61419. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61420. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61421. * * 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
  61422. * * 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
  61423. * * 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
  61424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61427. * * The 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
  61428. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61429. * * 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
  61430. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61432. * @param name defines the name of the mesh
  61433. * @param options defines the options used to create the mesh
  61434. * @param scene defines the hosting scene
  61435. * @returns the ribbon mesh
  61436. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61437. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61438. */
  61439. static CreateRibbon(name: string, options: {
  61440. pathArray: Vector3[][];
  61441. closeArray?: boolean;
  61442. closePath?: boolean;
  61443. offset?: number;
  61444. updatable?: boolean;
  61445. sideOrientation?: number;
  61446. frontUVs?: Vector4;
  61447. backUVs?: Vector4;
  61448. instance?: Mesh;
  61449. invertUV?: boolean;
  61450. uvs?: Vector2[];
  61451. colors?: Color4[];
  61452. }, scene?: Nullable<Scene>): Mesh;
  61453. /**
  61454. * Creates a cylinder or a cone mesh
  61455. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61456. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61457. * * 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.
  61458. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61459. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61460. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61461. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61462. * * 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).
  61463. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61464. * * 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).
  61465. * * 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
  61466. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61467. * * 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
  61468. * * 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.
  61469. * * If `enclose` is false, a ring surface is one element.
  61470. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61471. * * 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
  61472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61473. * * 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
  61474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61475. * @param name defines the name of the mesh
  61476. * @param options defines the options used to create the mesh
  61477. * @param scene defines the hosting scene
  61478. * @returns the cylinder mesh
  61479. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61480. */
  61481. static CreateCylinder(name: string, options: {
  61482. height?: number;
  61483. diameterTop?: number;
  61484. diameterBottom?: number;
  61485. diameter?: number;
  61486. tessellation?: number;
  61487. subdivisions?: number;
  61488. arc?: number;
  61489. faceColors?: Color4[];
  61490. faceUV?: Vector4[];
  61491. updatable?: boolean;
  61492. hasRings?: boolean;
  61493. enclose?: boolean;
  61494. cap?: number;
  61495. sideOrientation?: number;
  61496. frontUVs?: Vector4;
  61497. backUVs?: Vector4;
  61498. }, scene?: Nullable<Scene>): Mesh;
  61499. /**
  61500. * Creates a torus mesh
  61501. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61502. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61503. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61505. * * 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
  61506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61507. * @param name defines the name of the mesh
  61508. * @param options defines the options used to create the mesh
  61509. * @param scene defines the hosting scene
  61510. * @returns the torus mesh
  61511. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61512. */
  61513. static CreateTorus(name: string, options: {
  61514. diameter?: number;
  61515. thickness?: number;
  61516. tessellation?: number;
  61517. updatable?: boolean;
  61518. sideOrientation?: number;
  61519. frontUVs?: Vector4;
  61520. backUVs?: Vector4;
  61521. }, scene?: Nullable<Scene>): Mesh;
  61522. /**
  61523. * Creates a torus knot mesh
  61524. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61525. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61526. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61527. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61529. * * 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
  61530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61531. * @param name defines the name of the mesh
  61532. * @param options defines the options used to create the mesh
  61533. * @param scene defines the hosting scene
  61534. * @returns the torus knot mesh
  61535. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61536. */
  61537. static CreateTorusKnot(name: string, options: {
  61538. radius?: number;
  61539. tube?: number;
  61540. radialSegments?: number;
  61541. tubularSegments?: number;
  61542. p?: number;
  61543. q?: number;
  61544. updatable?: boolean;
  61545. sideOrientation?: number;
  61546. frontUVs?: Vector4;
  61547. backUVs?: Vector4;
  61548. }, scene?: Nullable<Scene>): Mesh;
  61549. /**
  61550. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61551. * * 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
  61552. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61553. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61554. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61555. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61556. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61557. * * 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
  61558. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61561. * @param name defines the name of the new line system
  61562. * @param options defines the options used to create the line system
  61563. * @param scene defines the hosting scene
  61564. * @returns a new line system mesh
  61565. */
  61566. static CreateLineSystem(name: string, options: {
  61567. lines: Vector3[][];
  61568. updatable?: boolean;
  61569. instance?: Nullable<LinesMesh>;
  61570. colors?: Nullable<Color4[][]>;
  61571. useVertexAlpha?: boolean;
  61572. }, scene: Nullable<Scene>): LinesMesh;
  61573. /**
  61574. * Creates a line mesh
  61575. * 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
  61576. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61577. * * The parameter `points` is an array successive Vector3
  61578. * * 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
  61579. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61580. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61581. * * When updating an instance, remember that only point positions can change, not the number of points
  61582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61584. * @param name defines the name of the new line system
  61585. * @param options defines the options used to create the line system
  61586. * @param scene defines the hosting scene
  61587. * @returns a new line mesh
  61588. */
  61589. static CreateLines(name: string, options: {
  61590. points: Vector3[];
  61591. updatable?: boolean;
  61592. instance?: Nullable<LinesMesh>;
  61593. colors?: Color4[];
  61594. useVertexAlpha?: boolean;
  61595. }, scene?: Nullable<Scene>): LinesMesh;
  61596. /**
  61597. * Creates a dashed line mesh
  61598. * * 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
  61599. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61600. * * The parameter `points` is an array successive Vector3
  61601. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61602. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61603. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61604. * * 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
  61605. * * When updating an instance, remember that only point positions can change, not the number of points
  61606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61607. * @param name defines the name of the mesh
  61608. * @param options defines the options used to create the mesh
  61609. * @param scene defines the hosting scene
  61610. * @returns the dashed line mesh
  61611. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61612. */
  61613. static CreateDashedLines(name: string, options: {
  61614. points: Vector3[];
  61615. dashSize?: number;
  61616. gapSize?: number;
  61617. dashNb?: number;
  61618. updatable?: boolean;
  61619. instance?: LinesMesh;
  61620. }, scene?: Nullable<Scene>): LinesMesh;
  61621. /**
  61622. * 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.
  61623. * * 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.
  61624. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61625. * * 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.
  61626. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61627. * * 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
  61628. * * 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
  61629. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61631. * * 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
  61632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61634. * @param name defines the name of the mesh
  61635. * @param options defines the options used to create the mesh
  61636. * @param scene defines the hosting scene
  61637. * @returns the extruded shape mesh
  61638. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61640. */
  61641. static ExtrudeShape(name: string, options: {
  61642. shape: Vector3[];
  61643. path: Vector3[];
  61644. scale?: number;
  61645. rotation?: number;
  61646. cap?: number;
  61647. updatable?: boolean;
  61648. sideOrientation?: number;
  61649. frontUVs?: Vector4;
  61650. backUVs?: Vector4;
  61651. instance?: Mesh;
  61652. invertUV?: boolean;
  61653. }, scene?: Nullable<Scene>): Mesh;
  61654. /**
  61655. * Creates an custom extruded shape mesh.
  61656. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61657. * * 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.
  61658. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61659. * * 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
  61660. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61661. * * 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
  61662. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61663. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61664. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61665. * * 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
  61666. * * 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
  61667. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61669. * * 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
  61670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61672. * @param name defines the name of the mesh
  61673. * @param options defines the options used to create the mesh
  61674. * @param scene defines the hosting scene
  61675. * @returns the custom extruded shape mesh
  61676. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61677. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61678. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61679. */
  61680. static ExtrudeShapeCustom(name: string, options: {
  61681. shape: Vector3[];
  61682. path: Vector3[];
  61683. scaleFunction?: any;
  61684. rotationFunction?: any;
  61685. ribbonCloseArray?: boolean;
  61686. ribbonClosePath?: boolean;
  61687. cap?: number;
  61688. updatable?: boolean;
  61689. sideOrientation?: number;
  61690. frontUVs?: Vector4;
  61691. backUVs?: Vector4;
  61692. instance?: Mesh;
  61693. invertUV?: boolean;
  61694. }, scene?: Nullable<Scene>): Mesh;
  61695. /**
  61696. * Creates lathe mesh.
  61697. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61698. * * 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
  61699. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61700. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61701. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61702. * * 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
  61703. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61704. * * 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
  61705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61706. * * 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
  61707. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61709. * @param name defines the name of the mesh
  61710. * @param options defines the options used to create the mesh
  61711. * @param scene defines the hosting scene
  61712. * @returns the lathe mesh
  61713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61714. */
  61715. static CreateLathe(name: string, options: {
  61716. shape: Vector3[];
  61717. radius?: number;
  61718. tessellation?: number;
  61719. clip?: number;
  61720. arc?: number;
  61721. closed?: boolean;
  61722. updatable?: boolean;
  61723. sideOrientation?: number;
  61724. frontUVs?: Vector4;
  61725. backUVs?: Vector4;
  61726. cap?: number;
  61727. invertUV?: boolean;
  61728. }, scene?: Nullable<Scene>): Mesh;
  61729. /**
  61730. * Creates a tiled plane mesh
  61731. * * You can set a limited pattern arrangement with the tiles
  61732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61733. * * 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
  61734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61735. * @param name defines the name of the mesh
  61736. * @param options defines the options used to create the mesh
  61737. * @param scene defines the hosting scene
  61738. * @returns the plane mesh
  61739. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61740. */
  61741. static CreateTiledPlane(name: string, options: {
  61742. pattern?: number;
  61743. tileSize?: number;
  61744. tileWidth?: number;
  61745. tileHeight?: number;
  61746. size?: number;
  61747. width?: number;
  61748. height?: number;
  61749. alignHorizontal?: number;
  61750. alignVertical?: number;
  61751. sideOrientation?: number;
  61752. frontUVs?: Vector4;
  61753. backUVs?: Vector4;
  61754. updatable?: boolean;
  61755. }, scene?: Nullable<Scene>): Mesh;
  61756. /**
  61757. * Creates a plane mesh
  61758. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61759. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61760. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61762. * * 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
  61763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61764. * @param name defines the name of the mesh
  61765. * @param options defines the options used to create the mesh
  61766. * @param scene defines the hosting scene
  61767. * @returns the plane mesh
  61768. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61769. */
  61770. static CreatePlane(name: string, options: {
  61771. size?: number;
  61772. width?: number;
  61773. height?: number;
  61774. sideOrientation?: number;
  61775. frontUVs?: Vector4;
  61776. backUVs?: Vector4;
  61777. updatable?: boolean;
  61778. sourcePlane?: Plane;
  61779. }, scene?: Nullable<Scene>): Mesh;
  61780. /**
  61781. * Creates a ground mesh
  61782. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61783. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61785. * @param name defines the name of the mesh
  61786. * @param options defines the options used to create the mesh
  61787. * @param scene defines the hosting scene
  61788. * @returns the ground mesh
  61789. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61790. */
  61791. static CreateGround(name: string, options: {
  61792. width?: number;
  61793. height?: number;
  61794. subdivisions?: number;
  61795. subdivisionsX?: number;
  61796. subdivisionsY?: number;
  61797. updatable?: boolean;
  61798. }, scene?: Nullable<Scene>): Mesh;
  61799. /**
  61800. * Creates a tiled ground mesh
  61801. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61802. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61803. * * 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
  61804. * * 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
  61805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61806. * @param name defines the name of the mesh
  61807. * @param options defines the options used to create the mesh
  61808. * @param scene defines the hosting scene
  61809. * @returns the tiled ground mesh
  61810. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61811. */
  61812. static CreateTiledGround(name: string, options: {
  61813. xmin: number;
  61814. zmin: number;
  61815. xmax: number;
  61816. zmax: number;
  61817. subdivisions?: {
  61818. w: number;
  61819. h: number;
  61820. };
  61821. precision?: {
  61822. w: number;
  61823. h: number;
  61824. };
  61825. updatable?: boolean;
  61826. }, scene?: Nullable<Scene>): Mesh;
  61827. /**
  61828. * Creates a ground mesh from a height map
  61829. * * The parameter `url` sets the URL of the height map image resource.
  61830. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61831. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61832. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61833. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61834. * * 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.
  61835. * * 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).
  61836. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61838. * @param name defines the name of the mesh
  61839. * @param url defines the url to the height map
  61840. * @param options defines the options used to create the mesh
  61841. * @param scene defines the hosting scene
  61842. * @returns the ground mesh
  61843. * @see https://doc.babylonjs.com/babylon101/height_map
  61844. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61845. */
  61846. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61847. width?: number;
  61848. height?: number;
  61849. subdivisions?: number;
  61850. minHeight?: number;
  61851. maxHeight?: number;
  61852. colorFilter?: Color3;
  61853. alphaFilter?: number;
  61854. updatable?: boolean;
  61855. onReady?: (mesh: GroundMesh) => void;
  61856. }, scene?: Nullable<Scene>): GroundMesh;
  61857. /**
  61858. * Creates a polygon mesh
  61859. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61860. * * 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
  61861. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61863. * * 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)
  61864. * * Remember you can only change the shape positions, not their number when updating a polygon
  61865. * @param name defines the name of the mesh
  61866. * @param options defines the options used to create the mesh
  61867. * @param scene defines the hosting scene
  61868. * @param earcutInjection can be used to inject your own earcut reference
  61869. * @returns the polygon mesh
  61870. */
  61871. static CreatePolygon(name: string, options: {
  61872. shape: Vector3[];
  61873. holes?: Vector3[][];
  61874. depth?: number;
  61875. faceUV?: Vector4[];
  61876. faceColors?: Color4[];
  61877. updatable?: boolean;
  61878. sideOrientation?: number;
  61879. frontUVs?: Vector4;
  61880. backUVs?: Vector4;
  61881. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61882. /**
  61883. * Creates an extruded polygon mesh, with depth in the Y direction.
  61884. * * 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)
  61885. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61886. * @param name defines the name of the mesh
  61887. * @param options defines the options used to create the mesh
  61888. * @param scene defines the hosting scene
  61889. * @param earcutInjection can be used to inject your own earcut reference
  61890. * @returns the polygon mesh
  61891. */
  61892. static ExtrudePolygon(name: string, options: {
  61893. shape: Vector3[];
  61894. holes?: Vector3[][];
  61895. depth?: number;
  61896. faceUV?: Vector4[];
  61897. faceColors?: Color4[];
  61898. updatable?: boolean;
  61899. sideOrientation?: number;
  61900. frontUVs?: Vector4;
  61901. backUVs?: Vector4;
  61902. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61903. /**
  61904. * Creates a tube mesh.
  61905. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61906. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61907. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61908. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61909. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61910. * * 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)
  61911. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61912. * * 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
  61913. * * 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
  61914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61915. * * 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
  61916. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61918. * @param name defines the name of the mesh
  61919. * @param options defines the options used to create the mesh
  61920. * @param scene defines the hosting scene
  61921. * @returns the tube mesh
  61922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61923. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61924. */
  61925. static CreateTube(name: string, options: {
  61926. path: Vector3[];
  61927. radius?: number;
  61928. tessellation?: number;
  61929. radiusFunction?: {
  61930. (i: number, distance: number): number;
  61931. };
  61932. cap?: number;
  61933. arc?: number;
  61934. updatable?: boolean;
  61935. sideOrientation?: number;
  61936. frontUVs?: Vector4;
  61937. backUVs?: Vector4;
  61938. instance?: Mesh;
  61939. invertUV?: boolean;
  61940. }, scene?: Nullable<Scene>): Mesh;
  61941. /**
  61942. * Creates a polyhedron mesh
  61943. * * 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
  61944. * * The parameter `size` (positive float, default 1) sets the polygon size
  61945. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61946. * * 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`
  61947. * * 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
  61948. * * 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)`)
  61949. * * 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
  61950. * * 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
  61951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61952. * * 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
  61953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61954. * @param name defines the name of the mesh
  61955. * @param options defines the options used to create the mesh
  61956. * @param scene defines the hosting scene
  61957. * @returns the polyhedron mesh
  61958. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61959. */
  61960. static CreatePolyhedron(name: string, options: {
  61961. type?: number;
  61962. size?: number;
  61963. sizeX?: number;
  61964. sizeY?: number;
  61965. sizeZ?: number;
  61966. custom?: any;
  61967. faceUV?: Vector4[];
  61968. faceColors?: Color4[];
  61969. flat?: boolean;
  61970. updatable?: boolean;
  61971. sideOrientation?: number;
  61972. frontUVs?: Vector4;
  61973. backUVs?: Vector4;
  61974. }, scene?: Nullable<Scene>): Mesh;
  61975. /**
  61976. * Creates a decal mesh.
  61977. * 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
  61978. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61979. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61980. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61981. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61982. * @param name defines the name of the mesh
  61983. * @param sourceMesh defines the mesh where the decal must be applied
  61984. * @param options defines the options used to create the mesh
  61985. * @param scene defines the hosting scene
  61986. * @returns the decal mesh
  61987. * @see https://doc.babylonjs.com/how_to/decals
  61988. */
  61989. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61990. position?: Vector3;
  61991. normal?: Vector3;
  61992. size?: Vector3;
  61993. angle?: number;
  61994. }): Mesh;
  61995. }
  61996. }
  61997. declare module BABYLON {
  61998. /**
  61999. * A simplifier interface for future simplification implementations
  62000. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62001. */
  62002. export interface ISimplifier {
  62003. /**
  62004. * Simplification of a given mesh according to the given settings.
  62005. * Since this requires computation, it is assumed that the function runs async.
  62006. * @param settings The settings of the simplification, including quality and distance
  62007. * @param successCallback A callback that will be called after the mesh was simplified.
  62008. * @param errorCallback in case of an error, this callback will be called. optional.
  62009. */
  62010. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62011. }
  62012. /**
  62013. * Expected simplification settings.
  62014. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62015. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62016. */
  62017. export interface ISimplificationSettings {
  62018. /**
  62019. * Gets or sets the expected quality
  62020. */
  62021. quality: number;
  62022. /**
  62023. * Gets or sets the distance when this optimized version should be used
  62024. */
  62025. distance: number;
  62026. /**
  62027. * Gets an already optimized mesh
  62028. */
  62029. optimizeMesh?: boolean;
  62030. }
  62031. /**
  62032. * Class used to specify simplification options
  62033. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62034. */
  62035. export class SimplificationSettings implements ISimplificationSettings {
  62036. /** expected quality */
  62037. quality: number;
  62038. /** distance when this optimized version should be used */
  62039. distance: number;
  62040. /** already optimized mesh */
  62041. optimizeMesh?: boolean | undefined;
  62042. /**
  62043. * Creates a SimplificationSettings
  62044. * @param quality expected quality
  62045. * @param distance distance when this optimized version should be used
  62046. * @param optimizeMesh already optimized mesh
  62047. */
  62048. constructor(
  62049. /** expected quality */
  62050. quality: number,
  62051. /** distance when this optimized version should be used */
  62052. distance: number,
  62053. /** already optimized mesh */
  62054. optimizeMesh?: boolean | undefined);
  62055. }
  62056. /**
  62057. * Interface used to define a simplification task
  62058. */
  62059. export interface ISimplificationTask {
  62060. /**
  62061. * Array of settings
  62062. */
  62063. settings: Array<ISimplificationSettings>;
  62064. /**
  62065. * Simplification type
  62066. */
  62067. simplificationType: SimplificationType;
  62068. /**
  62069. * Mesh to simplify
  62070. */
  62071. mesh: Mesh;
  62072. /**
  62073. * Callback called on success
  62074. */
  62075. successCallback?: () => void;
  62076. /**
  62077. * Defines if parallel processing can be used
  62078. */
  62079. parallelProcessing: boolean;
  62080. }
  62081. /**
  62082. * Queue used to order the simplification tasks
  62083. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62084. */
  62085. export class SimplificationQueue {
  62086. private _simplificationArray;
  62087. /**
  62088. * Gets a boolean indicating that the process is still running
  62089. */
  62090. running: boolean;
  62091. /**
  62092. * Creates a new queue
  62093. */
  62094. constructor();
  62095. /**
  62096. * Adds a new simplification task
  62097. * @param task defines a task to add
  62098. */
  62099. addTask(task: ISimplificationTask): void;
  62100. /**
  62101. * Execute next task
  62102. */
  62103. executeNext(): void;
  62104. /**
  62105. * Execute a simplification task
  62106. * @param task defines the task to run
  62107. */
  62108. runSimplification(task: ISimplificationTask): void;
  62109. private getSimplifier;
  62110. }
  62111. /**
  62112. * The implemented types of simplification
  62113. * At the moment only Quadratic Error Decimation is implemented
  62114. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62115. */
  62116. export enum SimplificationType {
  62117. /** Quadratic error decimation */
  62118. QUADRATIC = 0
  62119. }
  62120. /**
  62121. * An implementation of the Quadratic Error simplification algorithm.
  62122. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62123. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62124. * @author RaananW
  62125. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62126. */
  62127. export class QuadraticErrorSimplification implements ISimplifier {
  62128. private _mesh;
  62129. private triangles;
  62130. private vertices;
  62131. private references;
  62132. private _reconstructedMesh;
  62133. /** Gets or sets the number pf sync interations */
  62134. syncIterations: number;
  62135. /** Gets or sets the aggressiveness of the simplifier */
  62136. aggressiveness: number;
  62137. /** Gets or sets the number of allowed iterations for decimation */
  62138. decimationIterations: number;
  62139. /** Gets or sets the espilon to use for bounding box computation */
  62140. boundingBoxEpsilon: number;
  62141. /**
  62142. * Creates a new QuadraticErrorSimplification
  62143. * @param _mesh defines the target mesh
  62144. */
  62145. constructor(_mesh: Mesh);
  62146. /**
  62147. * Simplification of a given mesh according to the given settings.
  62148. * Since this requires computation, it is assumed that the function runs async.
  62149. * @param settings The settings of the simplification, including quality and distance
  62150. * @param successCallback A callback that will be called after the mesh was simplified.
  62151. */
  62152. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62153. private runDecimation;
  62154. private initWithMesh;
  62155. private init;
  62156. private reconstructMesh;
  62157. private initDecimatedMesh;
  62158. private isFlipped;
  62159. private updateTriangles;
  62160. private identifyBorder;
  62161. private updateMesh;
  62162. private vertexError;
  62163. private calculateError;
  62164. }
  62165. }
  62166. declare module BABYLON {
  62167. interface Scene {
  62168. /** @hidden (Backing field) */
  62169. _simplificationQueue: SimplificationQueue;
  62170. /**
  62171. * Gets or sets the simplification queue attached to the scene
  62172. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62173. */
  62174. simplificationQueue: SimplificationQueue;
  62175. }
  62176. interface Mesh {
  62177. /**
  62178. * Simplify the mesh according to the given array of settings.
  62179. * Function will return immediately and will simplify async
  62180. * @param settings a collection of simplification settings
  62181. * @param parallelProcessing should all levels calculate parallel or one after the other
  62182. * @param simplificationType the type of simplification to run
  62183. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62184. * @returns the current mesh
  62185. */
  62186. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62187. }
  62188. /**
  62189. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62190. * created in a scene
  62191. */
  62192. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62193. /**
  62194. * The component name helpfull to identify the component in the list of scene components.
  62195. */
  62196. readonly name: string;
  62197. /**
  62198. * The scene the component belongs to.
  62199. */
  62200. scene: Scene;
  62201. /**
  62202. * Creates a new instance of the component for the given scene
  62203. * @param scene Defines the scene to register the component in
  62204. */
  62205. constructor(scene: Scene);
  62206. /**
  62207. * Registers the component in a given scene
  62208. */
  62209. register(): void;
  62210. /**
  62211. * Rebuilds the elements related to this component in case of
  62212. * context lost for instance.
  62213. */
  62214. rebuild(): void;
  62215. /**
  62216. * Disposes the component and the associated ressources
  62217. */
  62218. dispose(): void;
  62219. private _beforeCameraUpdate;
  62220. }
  62221. }
  62222. declare module BABYLON {
  62223. /**
  62224. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62225. */
  62226. export interface INavigationEnginePlugin {
  62227. /**
  62228. * plugin name
  62229. */
  62230. name: string;
  62231. /**
  62232. * Creates a navigation mesh
  62233. * @param meshes array of all the geometry used to compute the navigatio mesh
  62234. * @param parameters bunch of parameters used to filter geometry
  62235. */
  62236. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62237. /**
  62238. * Create a navigation mesh debug mesh
  62239. * @param scene is where the mesh will be added
  62240. * @returns debug display mesh
  62241. */
  62242. createDebugNavMesh(scene: Scene): Mesh;
  62243. /**
  62244. * Get a navigation mesh constrained position, closest to the parameter position
  62245. * @param position world position
  62246. * @returns the closest point to position constrained by the navigation mesh
  62247. */
  62248. getClosestPoint(position: Vector3): Vector3;
  62249. /**
  62250. * Get a navigation mesh constrained position, closest to the parameter position
  62251. * @param position world position
  62252. * @param result output the closest point to position constrained by the navigation mesh
  62253. */
  62254. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62255. /**
  62256. * Get a navigation mesh constrained position, within a particular radius
  62257. * @param position world position
  62258. * @param maxRadius the maximum distance to the constrained world position
  62259. * @returns the closest point to position constrained by the navigation mesh
  62260. */
  62261. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62262. /**
  62263. * Get a navigation mesh constrained position, within a particular radius
  62264. * @param position world position
  62265. * @param maxRadius the maximum distance to the constrained world position
  62266. * @param result output the closest point to position constrained by the navigation mesh
  62267. */
  62268. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62269. /**
  62270. * Compute the final position from a segment made of destination-position
  62271. * @param position world position
  62272. * @param destination world position
  62273. * @returns the resulting point along the navmesh
  62274. */
  62275. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62276. /**
  62277. * Compute the final position from a segment made of destination-position
  62278. * @param position world position
  62279. * @param destination world position
  62280. * @param result output the resulting point along the navmesh
  62281. */
  62282. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62283. /**
  62284. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62285. * @param start world position
  62286. * @param end world position
  62287. * @returns array containing world position composing the path
  62288. */
  62289. computePath(start: Vector3, end: Vector3): Vector3[];
  62290. /**
  62291. * If this plugin is supported
  62292. * @returns true if plugin is supported
  62293. */
  62294. isSupported(): boolean;
  62295. /**
  62296. * Create a new Crowd so you can add agents
  62297. * @param maxAgents the maximum agent count in the crowd
  62298. * @param maxAgentRadius the maximum radius an agent can have
  62299. * @param scene to attach the crowd to
  62300. * @returns the crowd you can add agents to
  62301. */
  62302. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62303. /**
  62304. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62305. * The queries will try to find a solution within those bounds
  62306. * default is (1,1,1)
  62307. * @param extent x,y,z value that define the extent around the queries point of reference
  62308. */
  62309. setDefaultQueryExtent(extent: Vector3): void;
  62310. /**
  62311. * Get the Bounding box extent specified by setDefaultQueryExtent
  62312. * @returns the box extent values
  62313. */
  62314. getDefaultQueryExtent(): Vector3;
  62315. /**
  62316. * build the navmesh from a previously saved state using getNavmeshData
  62317. * @param data the Uint8Array returned by getNavmeshData
  62318. */
  62319. buildFromNavmeshData(data: Uint8Array): void;
  62320. /**
  62321. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62322. * @returns data the Uint8Array that can be saved and reused
  62323. */
  62324. getNavmeshData(): Uint8Array;
  62325. /**
  62326. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62327. * @param result output the box extent values
  62328. */
  62329. getDefaultQueryExtentToRef(result: Vector3): void;
  62330. /**
  62331. * Release all resources
  62332. */
  62333. dispose(): void;
  62334. }
  62335. /**
  62336. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62337. */
  62338. export interface ICrowd {
  62339. /**
  62340. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62341. * You can attach anything to that node. The node position is updated in the scene update tick.
  62342. * @param pos world position that will be constrained by the navigation mesh
  62343. * @param parameters agent parameters
  62344. * @param transform hooked to the agent that will be update by the scene
  62345. * @returns agent index
  62346. */
  62347. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62348. /**
  62349. * Returns the agent position in world space
  62350. * @param index agent index returned by addAgent
  62351. * @returns world space position
  62352. */
  62353. getAgentPosition(index: number): Vector3;
  62354. /**
  62355. * Gets the agent position result in world space
  62356. * @param index agent index returned by addAgent
  62357. * @param result output world space position
  62358. */
  62359. getAgentPositionToRef(index: number, result: Vector3): void;
  62360. /**
  62361. * Gets the agent velocity in world space
  62362. * @param index agent index returned by addAgent
  62363. * @returns world space velocity
  62364. */
  62365. getAgentVelocity(index: number): Vector3;
  62366. /**
  62367. * Gets the agent velocity result in world space
  62368. * @param index agent index returned by addAgent
  62369. * @param result output world space velocity
  62370. */
  62371. getAgentVelocityToRef(index: number, result: Vector3): void;
  62372. /**
  62373. * remove a particular agent previously created
  62374. * @param index agent index returned by addAgent
  62375. */
  62376. removeAgent(index: number): void;
  62377. /**
  62378. * get the list of all agents attached to this crowd
  62379. * @returns list of agent indices
  62380. */
  62381. getAgents(): number[];
  62382. /**
  62383. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62384. * @param deltaTime in seconds
  62385. */
  62386. update(deltaTime: number): void;
  62387. /**
  62388. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62389. * @param index agent index returned by addAgent
  62390. * @param destination targeted world position
  62391. */
  62392. agentGoto(index: number, destination: Vector3): void;
  62393. /**
  62394. * Teleport the agent to a new position
  62395. * @param index agent index returned by addAgent
  62396. * @param destination targeted world position
  62397. */
  62398. agentTeleport(index: number, destination: Vector3): void;
  62399. /**
  62400. * Update agent parameters
  62401. * @param index agent index returned by addAgent
  62402. * @param parameters agent parameters
  62403. */
  62404. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62405. /**
  62406. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62407. * The queries will try to find a solution within those bounds
  62408. * default is (1,1,1)
  62409. * @param extent x,y,z value that define the extent around the queries point of reference
  62410. */
  62411. setDefaultQueryExtent(extent: Vector3): void;
  62412. /**
  62413. * Get the Bounding box extent specified by setDefaultQueryExtent
  62414. * @returns the box extent values
  62415. */
  62416. getDefaultQueryExtent(): Vector3;
  62417. /**
  62418. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62419. * @param result output the box extent values
  62420. */
  62421. getDefaultQueryExtentToRef(result: Vector3): void;
  62422. /**
  62423. * Release all resources
  62424. */
  62425. dispose(): void;
  62426. }
  62427. /**
  62428. * Configures an agent
  62429. */
  62430. export interface IAgentParameters {
  62431. /**
  62432. * Agent radius. [Limit: >= 0]
  62433. */
  62434. radius: number;
  62435. /**
  62436. * Agent height. [Limit: > 0]
  62437. */
  62438. height: number;
  62439. /**
  62440. * Maximum allowed acceleration. [Limit: >= 0]
  62441. */
  62442. maxAcceleration: number;
  62443. /**
  62444. * Maximum allowed speed. [Limit: >= 0]
  62445. */
  62446. maxSpeed: number;
  62447. /**
  62448. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62449. */
  62450. collisionQueryRange: number;
  62451. /**
  62452. * The path visibility optimization range. [Limit: > 0]
  62453. */
  62454. pathOptimizationRange: number;
  62455. /**
  62456. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62457. */
  62458. separationWeight: number;
  62459. }
  62460. /**
  62461. * Configures the navigation mesh creation
  62462. */
  62463. export interface INavMeshParameters {
  62464. /**
  62465. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62466. */
  62467. cs: number;
  62468. /**
  62469. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62470. */
  62471. ch: number;
  62472. /**
  62473. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62474. */
  62475. walkableSlopeAngle: number;
  62476. /**
  62477. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62478. * be considered walkable. [Limit: >= 3] [Units: vx]
  62479. */
  62480. walkableHeight: number;
  62481. /**
  62482. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62483. */
  62484. walkableClimb: number;
  62485. /**
  62486. * The distance to erode/shrink the walkable area of the heightfield away from
  62487. * obstructions. [Limit: >=0] [Units: vx]
  62488. */
  62489. walkableRadius: number;
  62490. /**
  62491. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62492. */
  62493. maxEdgeLen: number;
  62494. /**
  62495. * The maximum distance a simplfied contour's border edges should deviate
  62496. * the original raw contour. [Limit: >=0] [Units: vx]
  62497. */
  62498. maxSimplificationError: number;
  62499. /**
  62500. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62501. */
  62502. minRegionArea: number;
  62503. /**
  62504. * Any regions with a span count smaller than this value will, if possible,
  62505. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62506. */
  62507. mergeRegionArea: number;
  62508. /**
  62509. * The maximum number of vertices allowed for polygons generated during the
  62510. * contour to polygon conversion process. [Limit: >= 3]
  62511. */
  62512. maxVertsPerPoly: number;
  62513. /**
  62514. * Sets the sampling distance to use when generating the detail mesh.
  62515. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62516. */
  62517. detailSampleDist: number;
  62518. /**
  62519. * The maximum distance the detail mesh surface should deviate from heightfield
  62520. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62521. */
  62522. detailSampleMaxError: number;
  62523. }
  62524. }
  62525. declare module BABYLON {
  62526. /**
  62527. * RecastJS navigation plugin
  62528. */
  62529. export class RecastJSPlugin implements INavigationEnginePlugin {
  62530. /**
  62531. * Reference to the Recast library
  62532. */
  62533. bjsRECAST: any;
  62534. /**
  62535. * plugin name
  62536. */
  62537. name: string;
  62538. /**
  62539. * the first navmesh created. We might extend this to support multiple navmeshes
  62540. */
  62541. navMesh: any;
  62542. /**
  62543. * Initializes the recastJS plugin
  62544. * @param recastInjection can be used to inject your own recast reference
  62545. */
  62546. constructor(recastInjection?: any);
  62547. /**
  62548. * Creates a navigation mesh
  62549. * @param meshes array of all the geometry used to compute the navigatio mesh
  62550. * @param parameters bunch of parameters used to filter geometry
  62551. */
  62552. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62553. /**
  62554. * Create a navigation mesh debug mesh
  62555. * @param scene is where the mesh will be added
  62556. * @returns debug display mesh
  62557. */
  62558. createDebugNavMesh(scene: Scene): Mesh;
  62559. /**
  62560. * Get a navigation mesh constrained position, closest to the parameter position
  62561. * @param position world position
  62562. * @returns the closest point to position constrained by the navigation mesh
  62563. */
  62564. getClosestPoint(position: Vector3): Vector3;
  62565. /**
  62566. * Get a navigation mesh constrained position, closest to the parameter position
  62567. * @param position world position
  62568. * @param result output the closest point to position constrained by the navigation mesh
  62569. */
  62570. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62571. /**
  62572. * Get a navigation mesh constrained position, within a particular radius
  62573. * @param position world position
  62574. * @param maxRadius the maximum distance to the constrained world position
  62575. * @returns the closest point to position constrained by the navigation mesh
  62576. */
  62577. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62578. /**
  62579. * Get a navigation mesh constrained position, within a particular radius
  62580. * @param position world position
  62581. * @param maxRadius the maximum distance to the constrained world position
  62582. * @param result output the closest point to position constrained by the navigation mesh
  62583. */
  62584. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62585. /**
  62586. * Compute the final position from a segment made of destination-position
  62587. * @param position world position
  62588. * @param destination world position
  62589. * @returns the resulting point along the navmesh
  62590. */
  62591. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62592. /**
  62593. * Compute the final position from a segment made of destination-position
  62594. * @param position world position
  62595. * @param destination world position
  62596. * @param result output the resulting point along the navmesh
  62597. */
  62598. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62599. /**
  62600. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62601. * @param start world position
  62602. * @param end world position
  62603. * @returns array containing world position composing the path
  62604. */
  62605. computePath(start: Vector3, end: Vector3): Vector3[];
  62606. /**
  62607. * Create a new Crowd so you can add agents
  62608. * @param maxAgents the maximum agent count in the crowd
  62609. * @param maxAgentRadius the maximum radius an agent can have
  62610. * @param scene to attach the crowd to
  62611. * @returns the crowd you can add agents to
  62612. */
  62613. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62614. /**
  62615. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62616. * The queries will try to find a solution within those bounds
  62617. * default is (1,1,1)
  62618. * @param extent x,y,z value that define the extent around the queries point of reference
  62619. */
  62620. setDefaultQueryExtent(extent: Vector3): void;
  62621. /**
  62622. * Get the Bounding box extent specified by setDefaultQueryExtent
  62623. * @returns the box extent values
  62624. */
  62625. getDefaultQueryExtent(): Vector3;
  62626. /**
  62627. * build the navmesh from a previously saved state using getNavmeshData
  62628. * @param data the Uint8Array returned by getNavmeshData
  62629. */
  62630. buildFromNavmeshData(data: Uint8Array): void;
  62631. /**
  62632. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62633. * @returns data the Uint8Array that can be saved and reused
  62634. */
  62635. getNavmeshData(): Uint8Array;
  62636. /**
  62637. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62638. * @param result output the box extent values
  62639. */
  62640. getDefaultQueryExtentToRef(result: Vector3): void;
  62641. /**
  62642. * Disposes
  62643. */
  62644. dispose(): void;
  62645. /**
  62646. * If this plugin is supported
  62647. * @returns true if plugin is supported
  62648. */
  62649. isSupported(): boolean;
  62650. }
  62651. /**
  62652. * Recast detour crowd implementation
  62653. */
  62654. export class RecastJSCrowd implements ICrowd {
  62655. /**
  62656. * Recast/detour plugin
  62657. */
  62658. bjsRECASTPlugin: RecastJSPlugin;
  62659. /**
  62660. * Link to the detour crowd
  62661. */
  62662. recastCrowd: any;
  62663. /**
  62664. * One transform per agent
  62665. */
  62666. transforms: TransformNode[];
  62667. /**
  62668. * All agents created
  62669. */
  62670. agents: number[];
  62671. /**
  62672. * Link to the scene is kept to unregister the crowd from the scene
  62673. */
  62674. private _scene;
  62675. /**
  62676. * Observer for crowd updates
  62677. */
  62678. private _onBeforeAnimationsObserver;
  62679. /**
  62680. * Constructor
  62681. * @param plugin recastJS plugin
  62682. * @param maxAgents the maximum agent count in the crowd
  62683. * @param maxAgentRadius the maximum radius an agent can have
  62684. * @param scene to attach the crowd to
  62685. * @returns the crowd you can add agents to
  62686. */
  62687. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62688. /**
  62689. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62690. * You can attach anything to that node. The node position is updated in the scene update tick.
  62691. * @param pos world position that will be constrained by the navigation mesh
  62692. * @param parameters agent parameters
  62693. * @param transform hooked to the agent that will be update by the scene
  62694. * @returns agent index
  62695. */
  62696. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62697. /**
  62698. * Returns the agent position in world space
  62699. * @param index agent index returned by addAgent
  62700. * @returns world space position
  62701. */
  62702. getAgentPosition(index: number): Vector3;
  62703. /**
  62704. * Returns the agent position result in world space
  62705. * @param index agent index returned by addAgent
  62706. * @param result output world space position
  62707. */
  62708. getAgentPositionToRef(index: number, result: Vector3): void;
  62709. /**
  62710. * Returns the agent velocity in world space
  62711. * @param index agent index returned by addAgent
  62712. * @returns world space velocity
  62713. */
  62714. getAgentVelocity(index: number): Vector3;
  62715. /**
  62716. * Returns the agent velocity result in world space
  62717. * @param index agent index returned by addAgent
  62718. * @param result output world space velocity
  62719. */
  62720. getAgentVelocityToRef(index: number, result: Vector3): void;
  62721. /**
  62722. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62723. * @param index agent index returned by addAgent
  62724. * @param destination targeted world position
  62725. */
  62726. agentGoto(index: number, destination: Vector3): void;
  62727. /**
  62728. * Teleport the agent to a new position
  62729. * @param index agent index returned by addAgent
  62730. * @param destination targeted world position
  62731. */
  62732. agentTeleport(index: number, destination: Vector3): void;
  62733. /**
  62734. * Update agent parameters
  62735. * @param index agent index returned by addAgent
  62736. * @param parameters agent parameters
  62737. */
  62738. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62739. /**
  62740. * remove a particular agent previously created
  62741. * @param index agent index returned by addAgent
  62742. */
  62743. removeAgent(index: number): void;
  62744. /**
  62745. * get the list of all agents attached to this crowd
  62746. * @returns list of agent indices
  62747. */
  62748. getAgents(): number[];
  62749. /**
  62750. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62751. * @param deltaTime in seconds
  62752. */
  62753. update(deltaTime: number): void;
  62754. /**
  62755. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62756. * The queries will try to find a solution within those bounds
  62757. * default is (1,1,1)
  62758. * @param extent x,y,z value that define the extent around the queries point of reference
  62759. */
  62760. setDefaultQueryExtent(extent: Vector3): void;
  62761. /**
  62762. * Get the Bounding box extent specified by setDefaultQueryExtent
  62763. * @returns the box extent values
  62764. */
  62765. getDefaultQueryExtent(): Vector3;
  62766. /**
  62767. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62768. * @param result output the box extent values
  62769. */
  62770. getDefaultQueryExtentToRef(result: Vector3): void;
  62771. /**
  62772. * Release all resources
  62773. */
  62774. dispose(): void;
  62775. }
  62776. }
  62777. declare module BABYLON {
  62778. /**
  62779. * Class used to enable access to IndexedDB
  62780. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62781. */
  62782. export class Database implements IOfflineProvider {
  62783. private _callbackManifestChecked;
  62784. private _currentSceneUrl;
  62785. private _db;
  62786. private _enableSceneOffline;
  62787. private _enableTexturesOffline;
  62788. private _manifestVersionFound;
  62789. private _mustUpdateRessources;
  62790. private _hasReachedQuota;
  62791. private _isSupported;
  62792. private _idbFactory;
  62793. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62794. private static IsUASupportingBlobStorage;
  62795. /**
  62796. * Gets a boolean indicating if Database storate is enabled (off by default)
  62797. */
  62798. static IDBStorageEnabled: boolean;
  62799. /**
  62800. * Gets a boolean indicating if scene must be saved in the database
  62801. */
  62802. get enableSceneOffline(): boolean;
  62803. /**
  62804. * Gets a boolean indicating if textures must be saved in the database
  62805. */
  62806. get enableTexturesOffline(): boolean;
  62807. /**
  62808. * Creates a new Database
  62809. * @param urlToScene defines the url to load the scene
  62810. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62811. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62812. */
  62813. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62814. private static _ParseURL;
  62815. private static _ReturnFullUrlLocation;
  62816. private _checkManifestFile;
  62817. /**
  62818. * Open the database and make it available
  62819. * @param successCallback defines the callback to call on success
  62820. * @param errorCallback defines the callback to call on error
  62821. */
  62822. open(successCallback: () => void, errorCallback: () => void): void;
  62823. /**
  62824. * Loads an image from the database
  62825. * @param url defines the url to load from
  62826. * @param image defines the target DOM image
  62827. */
  62828. loadImage(url: string, image: HTMLImageElement): void;
  62829. private _loadImageFromDBAsync;
  62830. private _saveImageIntoDBAsync;
  62831. private _checkVersionFromDB;
  62832. private _loadVersionFromDBAsync;
  62833. private _saveVersionIntoDBAsync;
  62834. /**
  62835. * Loads a file from database
  62836. * @param url defines the URL to load from
  62837. * @param sceneLoaded defines a callback to call on success
  62838. * @param progressCallBack defines a callback to call when progress changed
  62839. * @param errorCallback defines a callback to call on error
  62840. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62841. */
  62842. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62843. private _loadFileAsync;
  62844. private _saveFileAsync;
  62845. /**
  62846. * Validates if xhr data is correct
  62847. * @param xhr defines the request to validate
  62848. * @param dataType defines the expected data type
  62849. * @returns true if data is correct
  62850. */
  62851. private static _ValidateXHRData;
  62852. }
  62853. }
  62854. declare module BABYLON {
  62855. /** @hidden */
  62856. export var gpuUpdateParticlesPixelShader: {
  62857. name: string;
  62858. shader: string;
  62859. };
  62860. }
  62861. declare module BABYLON {
  62862. /** @hidden */
  62863. export var gpuUpdateParticlesVertexShader: {
  62864. name: string;
  62865. shader: string;
  62866. };
  62867. }
  62868. declare module BABYLON {
  62869. /** @hidden */
  62870. export var clipPlaneFragmentDeclaration2: {
  62871. name: string;
  62872. shader: string;
  62873. };
  62874. }
  62875. declare module BABYLON {
  62876. /** @hidden */
  62877. export var gpuRenderParticlesPixelShader: {
  62878. name: string;
  62879. shader: string;
  62880. };
  62881. }
  62882. declare module BABYLON {
  62883. /** @hidden */
  62884. export var clipPlaneVertexDeclaration2: {
  62885. name: string;
  62886. shader: string;
  62887. };
  62888. }
  62889. declare module BABYLON {
  62890. /** @hidden */
  62891. export var gpuRenderParticlesVertexShader: {
  62892. name: string;
  62893. shader: string;
  62894. };
  62895. }
  62896. declare module BABYLON {
  62897. /**
  62898. * This represents a GPU particle system in Babylon
  62899. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62900. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62901. */
  62902. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62903. /**
  62904. * The layer mask we are rendering the particles through.
  62905. */
  62906. layerMask: number;
  62907. private _capacity;
  62908. private _activeCount;
  62909. private _currentActiveCount;
  62910. private _accumulatedCount;
  62911. private _renderEffect;
  62912. private _updateEffect;
  62913. private _buffer0;
  62914. private _buffer1;
  62915. private _spriteBuffer;
  62916. private _updateVAO;
  62917. private _renderVAO;
  62918. private _targetIndex;
  62919. private _sourceBuffer;
  62920. private _targetBuffer;
  62921. private _engine;
  62922. private _currentRenderId;
  62923. private _started;
  62924. private _stopped;
  62925. private _timeDelta;
  62926. private _randomTexture;
  62927. private _randomTexture2;
  62928. private _attributesStrideSize;
  62929. private _updateEffectOptions;
  62930. private _randomTextureSize;
  62931. private _actualFrame;
  62932. private readonly _rawTextureWidth;
  62933. /**
  62934. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62935. */
  62936. static get IsSupported(): boolean;
  62937. /**
  62938. * An event triggered when the system is disposed.
  62939. */
  62940. onDisposeObservable: Observable<GPUParticleSystem>;
  62941. /**
  62942. * Gets the maximum number of particles active at the same time.
  62943. * @returns The max number of active particles.
  62944. */
  62945. getCapacity(): number;
  62946. /**
  62947. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62948. * to override the particles.
  62949. */
  62950. forceDepthWrite: boolean;
  62951. /**
  62952. * Gets or set the number of active particles
  62953. */
  62954. get activeParticleCount(): number;
  62955. set activeParticleCount(value: number);
  62956. private _preWarmDone;
  62957. /**
  62958. * Specifies if the particles are updated in emitter local space or world space.
  62959. * This is always false for GPU particles
  62960. */
  62961. get isLocal(): boolean;
  62962. set isLocal(value: boolean);
  62963. /**
  62964. * Is this system ready to be used/rendered
  62965. * @return true if the system is ready
  62966. */
  62967. isReady(): boolean;
  62968. /**
  62969. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62970. * @returns True if it has been started, otherwise false.
  62971. */
  62972. isStarted(): boolean;
  62973. /**
  62974. * Starts the particle system and begins to emit
  62975. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62976. */
  62977. start(delay?: number): void;
  62978. /**
  62979. * Stops the particle system.
  62980. */
  62981. stop(): void;
  62982. /**
  62983. * Remove all active particles
  62984. */
  62985. reset(): void;
  62986. /**
  62987. * Returns the string "GPUParticleSystem"
  62988. * @returns a string containing the class name
  62989. */
  62990. getClassName(): string;
  62991. private _colorGradientsTexture;
  62992. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62993. /**
  62994. * Adds a new color gradient
  62995. * @param gradient defines the gradient to use (between 0 and 1)
  62996. * @param color1 defines the color to affect to the specified gradient
  62997. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62998. * @returns the current particle system
  62999. */
  63000. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63001. /**
  63002. * Remove a specific color gradient
  63003. * @param gradient defines the gradient to remove
  63004. * @returns the current particle system
  63005. */
  63006. removeColorGradient(gradient: number): GPUParticleSystem;
  63007. private _angularSpeedGradientsTexture;
  63008. private _sizeGradientsTexture;
  63009. private _velocityGradientsTexture;
  63010. private _limitVelocityGradientsTexture;
  63011. private _dragGradientsTexture;
  63012. private _addFactorGradient;
  63013. /**
  63014. * Adds a new size gradient
  63015. * @param gradient defines the gradient to use (between 0 and 1)
  63016. * @param factor defines the size factor to affect to the specified gradient
  63017. * @returns the current particle system
  63018. */
  63019. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63020. /**
  63021. * Remove a specific size gradient
  63022. * @param gradient defines the gradient to remove
  63023. * @returns the current particle system
  63024. */
  63025. removeSizeGradient(gradient: number): GPUParticleSystem;
  63026. /**
  63027. * Adds a new angular speed gradient
  63028. * @param gradient defines the gradient to use (between 0 and 1)
  63029. * @param factor defines the angular speed to affect to the specified gradient
  63030. * @returns the current particle system
  63031. */
  63032. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63033. /**
  63034. * Remove a specific angular speed gradient
  63035. * @param gradient defines the gradient to remove
  63036. * @returns the current particle system
  63037. */
  63038. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63039. /**
  63040. * Adds a new velocity gradient
  63041. * @param gradient defines the gradient to use (between 0 and 1)
  63042. * @param factor defines the velocity to affect to the specified gradient
  63043. * @returns the current particle system
  63044. */
  63045. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63046. /**
  63047. * Remove a specific velocity gradient
  63048. * @param gradient defines the gradient to remove
  63049. * @returns the current particle system
  63050. */
  63051. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63052. /**
  63053. * Adds a new limit velocity gradient
  63054. * @param gradient defines the gradient to use (between 0 and 1)
  63055. * @param factor defines the limit velocity value to affect to the specified gradient
  63056. * @returns the current particle system
  63057. */
  63058. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63059. /**
  63060. * Remove a specific limit velocity gradient
  63061. * @param gradient defines the gradient to remove
  63062. * @returns the current particle system
  63063. */
  63064. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63065. /**
  63066. * Adds a new drag gradient
  63067. * @param gradient defines the gradient to use (between 0 and 1)
  63068. * @param factor defines the drag value to affect to the specified gradient
  63069. * @returns the current particle system
  63070. */
  63071. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63072. /**
  63073. * Remove a specific drag gradient
  63074. * @param gradient defines the gradient to remove
  63075. * @returns the current particle system
  63076. */
  63077. removeDragGradient(gradient: number): GPUParticleSystem;
  63078. /**
  63079. * Not supported by GPUParticleSystem
  63080. * @param gradient defines the gradient to use (between 0 and 1)
  63081. * @param factor defines the emit rate value to affect to the specified gradient
  63082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63083. * @returns the current particle system
  63084. */
  63085. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63086. /**
  63087. * Not supported by GPUParticleSystem
  63088. * @param gradient defines the gradient to remove
  63089. * @returns the current particle system
  63090. */
  63091. removeEmitRateGradient(gradient: number): IParticleSystem;
  63092. /**
  63093. * Not supported by GPUParticleSystem
  63094. * @param gradient defines the gradient to use (between 0 and 1)
  63095. * @param factor defines the start size value to affect to the specified gradient
  63096. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63097. * @returns the current particle system
  63098. */
  63099. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63100. /**
  63101. * Not supported by GPUParticleSystem
  63102. * @param gradient defines the gradient to remove
  63103. * @returns the current particle system
  63104. */
  63105. removeStartSizeGradient(gradient: number): IParticleSystem;
  63106. /**
  63107. * Not supported by GPUParticleSystem
  63108. * @param gradient defines the gradient to use (between 0 and 1)
  63109. * @param min defines the color remap minimal range
  63110. * @param max defines the color remap maximal range
  63111. * @returns the current particle system
  63112. */
  63113. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63114. /**
  63115. * Not supported by GPUParticleSystem
  63116. * @param gradient defines the gradient to remove
  63117. * @returns the current particle system
  63118. */
  63119. removeColorRemapGradient(): IParticleSystem;
  63120. /**
  63121. * Not supported by GPUParticleSystem
  63122. * @param gradient defines the gradient to use (between 0 and 1)
  63123. * @param min defines the alpha remap minimal range
  63124. * @param max defines the alpha remap maximal range
  63125. * @returns the current particle system
  63126. */
  63127. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63128. /**
  63129. * Not supported by GPUParticleSystem
  63130. * @param gradient defines the gradient to remove
  63131. * @returns the current particle system
  63132. */
  63133. removeAlphaRemapGradient(): IParticleSystem;
  63134. /**
  63135. * Not supported by GPUParticleSystem
  63136. * @param gradient defines the gradient to use (between 0 and 1)
  63137. * @param color defines the color to affect to the specified gradient
  63138. * @returns the current particle system
  63139. */
  63140. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63141. /**
  63142. * Not supported by GPUParticleSystem
  63143. * @param gradient defines the gradient to remove
  63144. * @returns the current particle system
  63145. */
  63146. removeRampGradient(): IParticleSystem;
  63147. /**
  63148. * Not supported by GPUParticleSystem
  63149. * @returns the list of ramp gradients
  63150. */
  63151. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63152. /**
  63153. * Not supported by GPUParticleSystem
  63154. * Gets or sets a boolean indicating that ramp gradients must be used
  63155. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63156. */
  63157. get useRampGradients(): boolean;
  63158. set useRampGradients(value: boolean);
  63159. /**
  63160. * Not supported by GPUParticleSystem
  63161. * @param gradient defines the gradient to use (between 0 and 1)
  63162. * @param factor defines the life time factor to affect to the specified gradient
  63163. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63164. * @returns the current particle system
  63165. */
  63166. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63167. /**
  63168. * Not supported by GPUParticleSystem
  63169. * @param gradient defines the gradient to remove
  63170. * @returns the current particle system
  63171. */
  63172. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63173. /**
  63174. * Instantiates a GPU particle system.
  63175. * 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.
  63176. * @param name The name of the particle system
  63177. * @param options The options used to create the system
  63178. * @param scene The scene the particle system belongs to
  63179. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63180. */
  63181. constructor(name: string, options: Partial<{
  63182. capacity: number;
  63183. randomTextureSize: number;
  63184. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63185. protected _reset(): void;
  63186. private _createUpdateVAO;
  63187. private _createRenderVAO;
  63188. private _initialize;
  63189. /** @hidden */
  63190. _recreateUpdateEffect(): void;
  63191. /** @hidden */
  63192. _recreateRenderEffect(): void;
  63193. /**
  63194. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63195. * @param preWarm defines if we are in the pre-warmimg phase
  63196. */
  63197. animate(preWarm?: boolean): void;
  63198. private _createFactorGradientTexture;
  63199. private _createSizeGradientTexture;
  63200. private _createAngularSpeedGradientTexture;
  63201. private _createVelocityGradientTexture;
  63202. private _createLimitVelocityGradientTexture;
  63203. private _createDragGradientTexture;
  63204. private _createColorGradientTexture;
  63205. /**
  63206. * Renders the particle system in its current state
  63207. * @param preWarm defines if the system should only update the particles but not render them
  63208. * @returns the current number of particles
  63209. */
  63210. render(preWarm?: boolean): number;
  63211. /**
  63212. * Rebuilds the particle system
  63213. */
  63214. rebuild(): void;
  63215. private _releaseBuffers;
  63216. private _releaseVAOs;
  63217. /**
  63218. * Disposes the particle system and free the associated resources
  63219. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63220. */
  63221. dispose(disposeTexture?: boolean): void;
  63222. /**
  63223. * Clones the particle system.
  63224. * @param name The name of the cloned object
  63225. * @param newEmitter The new emitter to use
  63226. * @returns the cloned particle system
  63227. */
  63228. clone(name: string, newEmitter: any): GPUParticleSystem;
  63229. /**
  63230. * Serializes the particle system to a JSON object.
  63231. * @returns the JSON object
  63232. */
  63233. serialize(): any;
  63234. /**
  63235. * Parses a JSON object to create a GPU particle system.
  63236. * @param parsedParticleSystem The JSON object to parse
  63237. * @param scene The scene to create the particle system in
  63238. * @param rootUrl The root url to use to load external dependencies like texture
  63239. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63240. * @returns the parsed GPU particle system
  63241. */
  63242. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63243. }
  63244. }
  63245. declare module BABYLON {
  63246. /**
  63247. * Represents a set of particle systems working together to create a specific effect
  63248. */
  63249. export class ParticleSystemSet implements IDisposable {
  63250. /**
  63251. * Gets or sets base Assets URL
  63252. */
  63253. static BaseAssetsUrl: string;
  63254. private _emitterCreationOptions;
  63255. private _emitterNode;
  63256. /**
  63257. * Gets the particle system list
  63258. */
  63259. systems: IParticleSystem[];
  63260. /**
  63261. * Gets the emitter node used with this set
  63262. */
  63263. get emitterNode(): Nullable<TransformNode>;
  63264. /**
  63265. * Creates a new emitter mesh as a sphere
  63266. * @param options defines the options used to create the sphere
  63267. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63268. * @param scene defines the hosting scene
  63269. */
  63270. setEmitterAsSphere(options: {
  63271. diameter: number;
  63272. segments: number;
  63273. color: Color3;
  63274. }, renderingGroupId: number, scene: Scene): void;
  63275. /**
  63276. * Starts all particle systems of the set
  63277. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63278. */
  63279. start(emitter?: AbstractMesh): void;
  63280. /**
  63281. * Release all associated resources
  63282. */
  63283. dispose(): void;
  63284. /**
  63285. * Serialize the set into a JSON compatible object
  63286. * @returns a JSON compatible representation of the set
  63287. */
  63288. serialize(): any;
  63289. /**
  63290. * Parse a new ParticleSystemSet from a serialized source
  63291. * @param data defines a JSON compatible representation of the set
  63292. * @param scene defines the hosting scene
  63293. * @param gpu defines if we want GPU particles or CPU particles
  63294. * @returns a new ParticleSystemSet
  63295. */
  63296. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63297. }
  63298. }
  63299. declare module BABYLON {
  63300. /**
  63301. * This class is made for on one-liner static method to help creating particle system set.
  63302. */
  63303. export class ParticleHelper {
  63304. /**
  63305. * Gets or sets base Assets URL
  63306. */
  63307. static BaseAssetsUrl: string;
  63308. /**
  63309. * Create a default particle system that you can tweak
  63310. * @param emitter defines the emitter to use
  63311. * @param capacity defines the system capacity (default is 500 particles)
  63312. * @param scene defines the hosting scene
  63313. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63314. * @returns the new Particle system
  63315. */
  63316. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63317. /**
  63318. * This is the main static method (one-liner) of this helper to create different particle systems
  63319. * @param type This string represents the type to the particle system to create
  63320. * @param scene The scene where the particle system should live
  63321. * @param gpu If the system will use gpu
  63322. * @returns the ParticleSystemSet created
  63323. */
  63324. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63325. /**
  63326. * Static function used to export a particle system to a ParticleSystemSet variable.
  63327. * Please note that the emitter shape is not exported
  63328. * @param systems defines the particle systems to export
  63329. * @returns the created particle system set
  63330. */
  63331. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63332. }
  63333. }
  63334. declare module BABYLON {
  63335. interface Engine {
  63336. /**
  63337. * Create an effect to use with particle systems.
  63338. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63339. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63340. * @param uniformsNames defines a list of attribute names
  63341. * @param samplers defines an array of string used to represent textures
  63342. * @param defines defines the string containing the defines to use to compile the shaders
  63343. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63344. * @param onCompiled defines a function to call when the effect creation is successful
  63345. * @param onError defines a function to call when the effect creation has failed
  63346. * @returns the new Effect
  63347. */
  63348. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63349. }
  63350. interface Mesh {
  63351. /**
  63352. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63353. * @returns an array of IParticleSystem
  63354. */
  63355. getEmittedParticleSystems(): IParticleSystem[];
  63356. /**
  63357. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63358. * @returns an array of IParticleSystem
  63359. */
  63360. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63361. }
  63362. /**
  63363. * @hidden
  63364. */
  63365. export var _IDoNeedToBeInTheBuild: number;
  63366. }
  63367. declare module BABYLON {
  63368. /** Defines the 4 color options */
  63369. export enum PointColor {
  63370. /** color value */
  63371. Color = 2,
  63372. /** uv value */
  63373. UV = 1,
  63374. /** random value */
  63375. Random = 0,
  63376. /** stated value */
  63377. Stated = 3
  63378. }
  63379. /**
  63380. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63381. * 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.
  63382. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63383. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63384. *
  63385. * Full documentation here : TO BE ENTERED
  63386. */
  63387. export class PointsCloudSystem implements IDisposable {
  63388. /**
  63389. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63390. * Example : var p = SPS.particles[i];
  63391. */
  63392. particles: CloudPoint[];
  63393. /**
  63394. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63395. */
  63396. nbParticles: number;
  63397. /**
  63398. * This a counter for your own usage. It's not set by any SPS functions.
  63399. */
  63400. counter: number;
  63401. /**
  63402. * The PCS name. This name is also given to the underlying mesh.
  63403. */
  63404. name: string;
  63405. /**
  63406. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63407. */
  63408. mesh: Mesh;
  63409. /**
  63410. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63411. * Please read :
  63412. */
  63413. vars: any;
  63414. /**
  63415. * @hidden
  63416. */
  63417. _size: number;
  63418. private _scene;
  63419. private _promises;
  63420. private _positions;
  63421. private _indices;
  63422. private _normals;
  63423. private _colors;
  63424. private _uvs;
  63425. private _indices32;
  63426. private _positions32;
  63427. private _colors32;
  63428. private _uvs32;
  63429. private _updatable;
  63430. private _isVisibilityBoxLocked;
  63431. private _alwaysVisible;
  63432. private _groups;
  63433. private _groupCounter;
  63434. private _computeParticleColor;
  63435. private _computeParticleTexture;
  63436. private _computeParticleRotation;
  63437. private _computeBoundingBox;
  63438. private _isReady;
  63439. /**
  63440. * Creates a PCS (Points Cloud System) object
  63441. * @param name (String) is the PCS name, this will be the underlying mesh name
  63442. * @param pointSize (number) is the size for each point
  63443. * @param scene (Scene) is the scene in which the PCS is added
  63444. * @param options defines the options of the PCS e.g.
  63445. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63446. */
  63447. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63448. updatable?: boolean;
  63449. });
  63450. /**
  63451. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63452. * If no points were added to the PCS, the returned mesh is just a single point.
  63453. * @returns a promise for the created mesh
  63454. */
  63455. buildMeshAsync(): Promise<Mesh>;
  63456. /**
  63457. * @hidden
  63458. */
  63459. private _buildMesh;
  63460. private _addParticle;
  63461. private _randomUnitVector;
  63462. private _getColorIndicesForCoord;
  63463. private _setPointsColorOrUV;
  63464. private _colorFromTexture;
  63465. private _calculateDensity;
  63466. /**
  63467. * Adds points to the PCS in random positions within a unit sphere
  63468. * @param nb (positive integer) the number of particles to be created from this model
  63469. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63470. * @returns the number of groups in the system
  63471. */
  63472. addPoints(nb: number, pointFunction?: any): number;
  63473. /**
  63474. * Adds points to the PCS from the surface of the model shape
  63475. * @param mesh is any Mesh object that will be used as a surface model for the points
  63476. * @param nb (positive integer) the number of particles to be created from this model
  63477. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63478. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63479. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63480. * @returns the number of groups in the system
  63481. */
  63482. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63483. /**
  63484. * Adds points to the PCS inside the model shape
  63485. * @param mesh is any Mesh object that will be used as a surface model for the points
  63486. * @param nb (positive integer) the number of particles to be created from this model
  63487. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63488. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63489. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63490. * @returns the number of groups in the system
  63491. */
  63492. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63493. /**
  63494. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63495. * This method calls `updateParticle()` for each particle of the SPS.
  63496. * For an animated SPS, it is usually called within the render loop.
  63497. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63498. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63499. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63500. * @returns the PCS.
  63501. */
  63502. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63503. /**
  63504. * Disposes the PCS.
  63505. */
  63506. dispose(): void;
  63507. /**
  63508. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63509. * doc :
  63510. * @returns the PCS.
  63511. */
  63512. refreshVisibleSize(): PointsCloudSystem;
  63513. /**
  63514. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63515. * @param size the size (float) of the visibility box
  63516. * note : this doesn't lock the PCS mesh bounding box.
  63517. * doc :
  63518. */
  63519. setVisibilityBox(size: number): void;
  63520. /**
  63521. * Gets whether the PCS is always visible or not
  63522. * doc :
  63523. */
  63524. get isAlwaysVisible(): boolean;
  63525. /**
  63526. * Sets the PCS as always visible or not
  63527. * doc :
  63528. */
  63529. set isAlwaysVisible(val: boolean);
  63530. /**
  63531. * Tells to `setParticles()` to compute the particle rotations or not
  63532. * Default value : false. The PCS is faster when it's set to false
  63533. * Note : particle rotations are only applied to parent particles
  63534. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63535. */
  63536. set computeParticleRotation(val: boolean);
  63537. /**
  63538. * Tells to `setParticles()` to compute the particle colors or not.
  63539. * Default value : true. The PCS is faster when it's set to false.
  63540. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63541. */
  63542. set computeParticleColor(val: boolean);
  63543. set computeParticleTexture(val: boolean);
  63544. /**
  63545. * Gets if `setParticles()` computes the particle colors or not.
  63546. * Default value : false. The PCS is faster when it's set to false.
  63547. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63548. */
  63549. get computeParticleColor(): boolean;
  63550. /**
  63551. * Gets if `setParticles()` computes the particle textures or not.
  63552. * Default value : false. The PCS is faster when it's set to false.
  63553. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63554. */
  63555. get computeParticleTexture(): boolean;
  63556. /**
  63557. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63558. */
  63559. set computeBoundingBox(val: boolean);
  63560. /**
  63561. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63562. */
  63563. get computeBoundingBox(): boolean;
  63564. /**
  63565. * This function does nothing. It may be overwritten to set all the particle first values.
  63566. * The PCS doesn't call this function, you may have to call it by your own.
  63567. * doc :
  63568. */
  63569. initParticles(): void;
  63570. /**
  63571. * This function does nothing. It may be overwritten to recycle a particle
  63572. * The PCS doesn't call this function, you can to call it
  63573. * doc :
  63574. * @param particle The particle to recycle
  63575. * @returns the recycled particle
  63576. */
  63577. recycleParticle(particle: CloudPoint): CloudPoint;
  63578. /**
  63579. * Updates a particle : this function should be overwritten by the user.
  63580. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63581. * doc :
  63582. * @example : just set a particle position or velocity and recycle conditions
  63583. * @param particle The particle to update
  63584. * @returns the updated particle
  63585. */
  63586. updateParticle(particle: CloudPoint): CloudPoint;
  63587. /**
  63588. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63589. * This does nothing and may be overwritten by the user.
  63590. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63591. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63592. * @param update the boolean update value actually passed to setParticles()
  63593. */
  63594. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63595. /**
  63596. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63597. * This will be passed three parameters.
  63598. * This does nothing and may be overwritten by the user.
  63599. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63600. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63601. * @param update the boolean update value actually passed to setParticles()
  63602. */
  63603. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63604. }
  63605. }
  63606. declare module BABYLON {
  63607. /**
  63608. * Represents one particle of a points cloud system.
  63609. */
  63610. export class CloudPoint {
  63611. /**
  63612. * particle global index
  63613. */
  63614. idx: number;
  63615. /**
  63616. * The color of the particle
  63617. */
  63618. color: Nullable<Color4>;
  63619. /**
  63620. * The world space position of the particle.
  63621. */
  63622. position: Vector3;
  63623. /**
  63624. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63625. */
  63626. rotation: Vector3;
  63627. /**
  63628. * The world space rotation quaternion of the particle.
  63629. */
  63630. rotationQuaternion: Nullable<Quaternion>;
  63631. /**
  63632. * The uv of the particle.
  63633. */
  63634. uv: Nullable<Vector2>;
  63635. /**
  63636. * The current speed of the particle.
  63637. */
  63638. velocity: Vector3;
  63639. /**
  63640. * The pivot point in the particle local space.
  63641. */
  63642. pivot: Vector3;
  63643. /**
  63644. * Must the particle be translated from its pivot point in its local space ?
  63645. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63646. * Default : false
  63647. */
  63648. translateFromPivot: boolean;
  63649. /**
  63650. * Index of this particle in the global "positions" array (Internal use)
  63651. * @hidden
  63652. */
  63653. _pos: number;
  63654. /**
  63655. * @hidden Index of this particle in the global "indices" array (Internal use)
  63656. */
  63657. _ind: number;
  63658. /**
  63659. * Group this particle belongs to
  63660. */
  63661. _group: PointsGroup;
  63662. /**
  63663. * Group id of this particle
  63664. */
  63665. groupId: number;
  63666. /**
  63667. * Index of the particle in its group id (Internal use)
  63668. */
  63669. idxInGroup: number;
  63670. /**
  63671. * @hidden Particle BoundingInfo object (Internal use)
  63672. */
  63673. _boundingInfo: BoundingInfo;
  63674. /**
  63675. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63676. */
  63677. _pcs: PointsCloudSystem;
  63678. /**
  63679. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63680. */
  63681. _stillInvisible: boolean;
  63682. /**
  63683. * @hidden Last computed particle rotation matrix
  63684. */
  63685. _rotationMatrix: number[];
  63686. /**
  63687. * Parent particle Id, if any.
  63688. * Default null.
  63689. */
  63690. parentId: Nullable<number>;
  63691. /**
  63692. * @hidden Internal global position in the PCS.
  63693. */
  63694. _globalPosition: Vector3;
  63695. /**
  63696. * Creates a Point Cloud object.
  63697. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63698. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63699. * @param group (PointsGroup) is the group the particle belongs to
  63700. * @param groupId (integer) is the group identifier in the PCS.
  63701. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63702. * @param pcs defines the PCS it is associated to
  63703. */
  63704. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63705. /**
  63706. * get point size
  63707. */
  63708. get size(): Vector3;
  63709. /**
  63710. * Set point size
  63711. */
  63712. set size(scale: Vector3);
  63713. /**
  63714. * Legacy support, changed quaternion to rotationQuaternion
  63715. */
  63716. get quaternion(): Nullable<Quaternion>;
  63717. /**
  63718. * Legacy support, changed quaternion to rotationQuaternion
  63719. */
  63720. set quaternion(q: Nullable<Quaternion>);
  63721. /**
  63722. * Returns a boolean. True if the particle intersects a mesh, else false
  63723. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63724. * @param target is the object (point or mesh) what the intersection is computed against
  63725. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63726. * @returns true if it intersects
  63727. */
  63728. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63729. /**
  63730. * get the rotation matrix of the particle
  63731. * @hidden
  63732. */
  63733. getRotationMatrix(m: Matrix): void;
  63734. }
  63735. /**
  63736. * Represents a group of points in a points cloud system
  63737. * * PCS internal tool, don't use it manually.
  63738. */
  63739. export class PointsGroup {
  63740. /**
  63741. * The group id
  63742. * @hidden
  63743. */
  63744. groupID: number;
  63745. /**
  63746. * image data for group (internal use)
  63747. * @hidden
  63748. */
  63749. _groupImageData: Nullable<ArrayBufferView>;
  63750. /**
  63751. * Image Width (internal use)
  63752. * @hidden
  63753. */
  63754. _groupImgWidth: number;
  63755. /**
  63756. * Image Height (internal use)
  63757. * @hidden
  63758. */
  63759. _groupImgHeight: number;
  63760. /**
  63761. * Custom position function (internal use)
  63762. * @hidden
  63763. */
  63764. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63765. /**
  63766. * density per facet for surface points
  63767. * @hidden
  63768. */
  63769. _groupDensity: number[];
  63770. /**
  63771. * Only when points are colored by texture carries pointer to texture list array
  63772. * @hidden
  63773. */
  63774. _textureNb: number;
  63775. /**
  63776. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63777. * PCS internal tool, don't use it manually.
  63778. * @hidden
  63779. */
  63780. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63781. }
  63782. }
  63783. declare module BABYLON {
  63784. interface Scene {
  63785. /** @hidden (Backing field) */
  63786. _physicsEngine: Nullable<IPhysicsEngine>;
  63787. /** @hidden */
  63788. _physicsTimeAccumulator: number;
  63789. /**
  63790. * Gets the current physics engine
  63791. * @returns a IPhysicsEngine or null if none attached
  63792. */
  63793. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63794. /**
  63795. * Enables physics to the current scene
  63796. * @param gravity defines the scene's gravity for the physics engine
  63797. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63798. * @return a boolean indicating if the physics engine was initialized
  63799. */
  63800. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63801. /**
  63802. * Disables and disposes the physics engine associated with the scene
  63803. */
  63804. disablePhysicsEngine(): void;
  63805. /**
  63806. * Gets a boolean indicating if there is an active physics engine
  63807. * @returns a boolean indicating if there is an active physics engine
  63808. */
  63809. isPhysicsEnabled(): boolean;
  63810. /**
  63811. * Deletes a physics compound impostor
  63812. * @param compound defines the compound to delete
  63813. */
  63814. deleteCompoundImpostor(compound: any): void;
  63815. /**
  63816. * An event triggered when physic simulation is about to be run
  63817. */
  63818. onBeforePhysicsObservable: Observable<Scene>;
  63819. /**
  63820. * An event triggered when physic simulation has been done
  63821. */
  63822. onAfterPhysicsObservable: Observable<Scene>;
  63823. }
  63824. interface AbstractMesh {
  63825. /** @hidden */
  63826. _physicsImpostor: Nullable<PhysicsImpostor>;
  63827. /**
  63828. * Gets or sets impostor used for physic simulation
  63829. * @see http://doc.babylonjs.com/features/physics_engine
  63830. */
  63831. physicsImpostor: Nullable<PhysicsImpostor>;
  63832. /**
  63833. * Gets the current physics impostor
  63834. * @see http://doc.babylonjs.com/features/physics_engine
  63835. * @returns a physics impostor or null
  63836. */
  63837. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63838. /** Apply a physic impulse to the mesh
  63839. * @param force defines the force to apply
  63840. * @param contactPoint defines where to apply the force
  63841. * @returns the current mesh
  63842. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63843. */
  63844. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63845. /**
  63846. * Creates a physic joint between two meshes
  63847. * @param otherMesh defines the other mesh to use
  63848. * @param pivot1 defines the pivot to use on this mesh
  63849. * @param pivot2 defines the pivot to use on the other mesh
  63850. * @param options defines additional options (can be plugin dependent)
  63851. * @returns the current mesh
  63852. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63853. */
  63854. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63855. /** @hidden */
  63856. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63857. }
  63858. /**
  63859. * Defines the physics engine scene component responsible to manage a physics engine
  63860. */
  63861. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63862. /**
  63863. * The component name helpful to identify the component in the list of scene components.
  63864. */
  63865. readonly name: string;
  63866. /**
  63867. * The scene the component belongs to.
  63868. */
  63869. scene: Scene;
  63870. /**
  63871. * Creates a new instance of the component for the given scene
  63872. * @param scene Defines the scene to register the component in
  63873. */
  63874. constructor(scene: Scene);
  63875. /**
  63876. * Registers the component in a given scene
  63877. */
  63878. register(): void;
  63879. /**
  63880. * Rebuilds the elements related to this component in case of
  63881. * context lost for instance.
  63882. */
  63883. rebuild(): void;
  63884. /**
  63885. * Disposes the component and the associated ressources
  63886. */
  63887. dispose(): void;
  63888. }
  63889. }
  63890. declare module BABYLON {
  63891. /**
  63892. * A helper for physics simulations
  63893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63894. */
  63895. export class PhysicsHelper {
  63896. private _scene;
  63897. private _physicsEngine;
  63898. /**
  63899. * Initializes the Physics helper
  63900. * @param scene Babylon.js scene
  63901. */
  63902. constructor(scene: Scene);
  63903. /**
  63904. * Applies a radial explosion impulse
  63905. * @param origin the origin of the explosion
  63906. * @param radiusOrEventOptions the radius or the options of radial explosion
  63907. * @param strength the explosion strength
  63908. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63909. * @returns A physics radial explosion event, or null
  63910. */
  63911. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63912. /**
  63913. * Applies a radial explosion force
  63914. * @param origin the origin of the explosion
  63915. * @param radiusOrEventOptions the radius or the options of radial explosion
  63916. * @param strength the explosion strength
  63917. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63918. * @returns A physics radial explosion event, or null
  63919. */
  63920. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63921. /**
  63922. * Creates a gravitational field
  63923. * @param origin the origin of the explosion
  63924. * @param radiusOrEventOptions the radius or the options of radial explosion
  63925. * @param strength the explosion strength
  63926. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63927. * @returns A physics gravitational field event, or null
  63928. */
  63929. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63930. /**
  63931. * Creates a physics updraft event
  63932. * @param origin the origin of the updraft
  63933. * @param radiusOrEventOptions the radius or the options of the updraft
  63934. * @param strength the strength of the updraft
  63935. * @param height the height of the updraft
  63936. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63937. * @returns A physics updraft event, or null
  63938. */
  63939. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63940. /**
  63941. * Creates a physics vortex event
  63942. * @param origin the of the vortex
  63943. * @param radiusOrEventOptions the radius or the options of the vortex
  63944. * @param strength the strength of the vortex
  63945. * @param height the height of the vortex
  63946. * @returns a Physics vortex event, or null
  63947. * A physics vortex event or null
  63948. */
  63949. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63950. }
  63951. /**
  63952. * Represents a physics radial explosion event
  63953. */
  63954. class PhysicsRadialExplosionEvent {
  63955. private _scene;
  63956. private _options;
  63957. private _sphere;
  63958. private _dataFetched;
  63959. /**
  63960. * Initializes a radial explosioin event
  63961. * @param _scene BabylonJS scene
  63962. * @param _options The options for the vortex event
  63963. */
  63964. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63965. /**
  63966. * Returns the data related to the radial explosion event (sphere).
  63967. * @returns The radial explosion event data
  63968. */
  63969. getData(): PhysicsRadialExplosionEventData;
  63970. /**
  63971. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63972. * @param impostor A physics imposter
  63973. * @param origin the origin of the explosion
  63974. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63975. */
  63976. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63977. /**
  63978. * Triggers affecterd impostors callbacks
  63979. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63980. */
  63981. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63982. /**
  63983. * Disposes the sphere.
  63984. * @param force Specifies if the sphere should be disposed by force
  63985. */
  63986. dispose(force?: boolean): void;
  63987. /*** Helpers ***/
  63988. private _prepareSphere;
  63989. private _intersectsWithSphere;
  63990. }
  63991. /**
  63992. * Represents a gravitational field event
  63993. */
  63994. class PhysicsGravitationalFieldEvent {
  63995. private _physicsHelper;
  63996. private _scene;
  63997. private _origin;
  63998. private _options;
  63999. private _tickCallback;
  64000. private _sphere;
  64001. private _dataFetched;
  64002. /**
  64003. * Initializes the physics gravitational field event
  64004. * @param _physicsHelper A physics helper
  64005. * @param _scene BabylonJS scene
  64006. * @param _origin The origin position of the gravitational field event
  64007. * @param _options The options for the vortex event
  64008. */
  64009. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64010. /**
  64011. * Returns the data related to the gravitational field event (sphere).
  64012. * @returns A gravitational field event
  64013. */
  64014. getData(): PhysicsGravitationalFieldEventData;
  64015. /**
  64016. * Enables the gravitational field.
  64017. */
  64018. enable(): void;
  64019. /**
  64020. * Disables the gravitational field.
  64021. */
  64022. disable(): void;
  64023. /**
  64024. * Disposes the sphere.
  64025. * @param force The force to dispose from the gravitational field event
  64026. */
  64027. dispose(force?: boolean): void;
  64028. private _tick;
  64029. }
  64030. /**
  64031. * Represents a physics updraft event
  64032. */
  64033. class PhysicsUpdraftEvent {
  64034. private _scene;
  64035. private _origin;
  64036. private _options;
  64037. private _physicsEngine;
  64038. private _originTop;
  64039. private _originDirection;
  64040. private _tickCallback;
  64041. private _cylinder;
  64042. private _cylinderPosition;
  64043. private _dataFetched;
  64044. /**
  64045. * Initializes the physics updraft event
  64046. * @param _scene BabylonJS scene
  64047. * @param _origin The origin position of the updraft
  64048. * @param _options The options for the updraft event
  64049. */
  64050. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64051. /**
  64052. * Returns the data related to the updraft event (cylinder).
  64053. * @returns A physics updraft event
  64054. */
  64055. getData(): PhysicsUpdraftEventData;
  64056. /**
  64057. * Enables the updraft.
  64058. */
  64059. enable(): void;
  64060. /**
  64061. * Disables the updraft.
  64062. */
  64063. disable(): void;
  64064. /**
  64065. * Disposes the cylinder.
  64066. * @param force Specifies if the updraft should be disposed by force
  64067. */
  64068. dispose(force?: boolean): void;
  64069. private getImpostorHitData;
  64070. private _tick;
  64071. /*** Helpers ***/
  64072. private _prepareCylinder;
  64073. private _intersectsWithCylinder;
  64074. }
  64075. /**
  64076. * Represents a physics vortex event
  64077. */
  64078. class PhysicsVortexEvent {
  64079. private _scene;
  64080. private _origin;
  64081. private _options;
  64082. private _physicsEngine;
  64083. private _originTop;
  64084. private _tickCallback;
  64085. private _cylinder;
  64086. private _cylinderPosition;
  64087. private _dataFetched;
  64088. /**
  64089. * Initializes the physics vortex event
  64090. * @param _scene The BabylonJS scene
  64091. * @param _origin The origin position of the vortex
  64092. * @param _options The options for the vortex event
  64093. */
  64094. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64095. /**
  64096. * Returns the data related to the vortex event (cylinder).
  64097. * @returns The physics vortex event data
  64098. */
  64099. getData(): PhysicsVortexEventData;
  64100. /**
  64101. * Enables the vortex.
  64102. */
  64103. enable(): void;
  64104. /**
  64105. * Disables the cortex.
  64106. */
  64107. disable(): void;
  64108. /**
  64109. * Disposes the sphere.
  64110. * @param force
  64111. */
  64112. dispose(force?: boolean): void;
  64113. private getImpostorHitData;
  64114. private _tick;
  64115. /*** Helpers ***/
  64116. private _prepareCylinder;
  64117. private _intersectsWithCylinder;
  64118. }
  64119. /**
  64120. * Options fot the radial explosion event
  64121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64122. */
  64123. export class PhysicsRadialExplosionEventOptions {
  64124. /**
  64125. * The radius of the sphere for the radial explosion.
  64126. */
  64127. radius: number;
  64128. /**
  64129. * The strenth of the explosion.
  64130. */
  64131. strength: number;
  64132. /**
  64133. * The strenght of the force in correspondence to the distance of the affected object
  64134. */
  64135. falloff: PhysicsRadialImpulseFalloff;
  64136. /**
  64137. * Sphere options for the radial explosion.
  64138. */
  64139. sphere: {
  64140. segments: number;
  64141. diameter: number;
  64142. };
  64143. /**
  64144. * Sphere options for the radial explosion.
  64145. */
  64146. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64147. }
  64148. /**
  64149. * Options fot the updraft event
  64150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64151. */
  64152. export class PhysicsUpdraftEventOptions {
  64153. /**
  64154. * The radius of the cylinder for the vortex
  64155. */
  64156. radius: number;
  64157. /**
  64158. * The strenth of the updraft.
  64159. */
  64160. strength: number;
  64161. /**
  64162. * The height of the cylinder for the updraft.
  64163. */
  64164. height: number;
  64165. /**
  64166. * The mode for the the updraft.
  64167. */
  64168. updraftMode: PhysicsUpdraftMode;
  64169. }
  64170. /**
  64171. * Options fot the vortex event
  64172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64173. */
  64174. export class PhysicsVortexEventOptions {
  64175. /**
  64176. * The radius of the cylinder for the vortex
  64177. */
  64178. radius: number;
  64179. /**
  64180. * The strenth of the vortex.
  64181. */
  64182. strength: number;
  64183. /**
  64184. * The height of the cylinder for the vortex.
  64185. */
  64186. height: number;
  64187. /**
  64188. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64189. */
  64190. centripetalForceThreshold: number;
  64191. /**
  64192. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64193. */
  64194. centripetalForceMultiplier: number;
  64195. /**
  64196. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64197. */
  64198. centrifugalForceMultiplier: number;
  64199. /**
  64200. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64201. */
  64202. updraftForceMultiplier: number;
  64203. }
  64204. /**
  64205. * The strenght of the force in correspondence to the distance of the affected object
  64206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64207. */
  64208. export enum PhysicsRadialImpulseFalloff {
  64209. /** Defines that impulse is constant in strength across it's whole radius */
  64210. Constant = 0,
  64211. /** Defines that impulse gets weaker if it's further from the origin */
  64212. Linear = 1
  64213. }
  64214. /**
  64215. * The strength of the force in correspondence to the distance of the affected object
  64216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64217. */
  64218. export enum PhysicsUpdraftMode {
  64219. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64220. Center = 0,
  64221. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64222. Perpendicular = 1
  64223. }
  64224. /**
  64225. * Interface for a physics hit data
  64226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64227. */
  64228. export interface PhysicsHitData {
  64229. /**
  64230. * The force applied at the contact point
  64231. */
  64232. force: Vector3;
  64233. /**
  64234. * The contact point
  64235. */
  64236. contactPoint: Vector3;
  64237. /**
  64238. * The distance from the origin to the contact point
  64239. */
  64240. distanceFromOrigin: number;
  64241. }
  64242. /**
  64243. * Interface for radial explosion event data
  64244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64245. */
  64246. export interface PhysicsRadialExplosionEventData {
  64247. /**
  64248. * A sphere used for the radial explosion event
  64249. */
  64250. sphere: Mesh;
  64251. }
  64252. /**
  64253. * Interface for gravitational field event data
  64254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64255. */
  64256. export interface PhysicsGravitationalFieldEventData {
  64257. /**
  64258. * A sphere mesh used for the gravitational field event
  64259. */
  64260. sphere: Mesh;
  64261. }
  64262. /**
  64263. * Interface for updraft event data
  64264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64265. */
  64266. export interface PhysicsUpdraftEventData {
  64267. /**
  64268. * A cylinder used for the updraft event
  64269. */
  64270. cylinder: Mesh;
  64271. }
  64272. /**
  64273. * Interface for vortex event data
  64274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64275. */
  64276. export interface PhysicsVortexEventData {
  64277. /**
  64278. * A cylinder used for the vortex event
  64279. */
  64280. cylinder: Mesh;
  64281. }
  64282. /**
  64283. * Interface for an affected physics impostor
  64284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64285. */
  64286. export interface PhysicsAffectedImpostorWithData {
  64287. /**
  64288. * The impostor affected by the effect
  64289. */
  64290. impostor: PhysicsImpostor;
  64291. /**
  64292. * The data about the hit/horce from the explosion
  64293. */
  64294. hitData: PhysicsHitData;
  64295. }
  64296. }
  64297. declare module BABYLON {
  64298. /** @hidden */
  64299. export var blackAndWhitePixelShader: {
  64300. name: string;
  64301. shader: string;
  64302. };
  64303. }
  64304. declare module BABYLON {
  64305. /**
  64306. * Post process used to render in black and white
  64307. */
  64308. export class BlackAndWhitePostProcess extends PostProcess {
  64309. /**
  64310. * Linear about to convert he result to black and white (default: 1)
  64311. */
  64312. degree: number;
  64313. /**
  64314. * Creates a black and white post process
  64315. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64316. * @param name The name of the effect.
  64317. * @param options The required width/height ratio to downsize to before computing the render pass.
  64318. * @param camera The camera to apply the render pass to.
  64319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64320. * @param engine The engine which the post process will be applied. (default: current engine)
  64321. * @param reusable If the post process can be reused on the same frame. (default: false)
  64322. */
  64323. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64324. }
  64325. }
  64326. declare module BABYLON {
  64327. /**
  64328. * This represents a set of one or more post processes in Babylon.
  64329. * A post process can be used to apply a shader to a texture after it is rendered.
  64330. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64331. */
  64332. export class PostProcessRenderEffect {
  64333. private _postProcesses;
  64334. private _getPostProcesses;
  64335. private _singleInstance;
  64336. private _cameras;
  64337. private _indicesForCamera;
  64338. /**
  64339. * Name of the effect
  64340. * @hidden
  64341. */
  64342. _name: string;
  64343. /**
  64344. * Instantiates a post process render effect.
  64345. * A post process can be used to apply a shader to a texture after it is rendered.
  64346. * @param engine The engine the effect is tied to
  64347. * @param name The name of the effect
  64348. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64349. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64350. */
  64351. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64352. /**
  64353. * Checks if all the post processes in the effect are supported.
  64354. */
  64355. get isSupported(): boolean;
  64356. /**
  64357. * Updates the current state of the effect
  64358. * @hidden
  64359. */
  64360. _update(): void;
  64361. /**
  64362. * Attaches the effect on cameras
  64363. * @param cameras The camera to attach to.
  64364. * @hidden
  64365. */
  64366. _attachCameras(cameras: Camera): void;
  64367. /**
  64368. * Attaches the effect on cameras
  64369. * @param cameras The camera to attach to.
  64370. * @hidden
  64371. */
  64372. _attachCameras(cameras: Camera[]): void;
  64373. /**
  64374. * Detaches the effect on cameras
  64375. * @param cameras The camera to detatch from.
  64376. * @hidden
  64377. */
  64378. _detachCameras(cameras: Camera): void;
  64379. /**
  64380. * Detatches the effect on cameras
  64381. * @param cameras The camera to detatch from.
  64382. * @hidden
  64383. */
  64384. _detachCameras(cameras: Camera[]): void;
  64385. /**
  64386. * Enables the effect on given cameras
  64387. * @param cameras The camera to enable.
  64388. * @hidden
  64389. */
  64390. _enable(cameras: Camera): void;
  64391. /**
  64392. * Enables the effect on given cameras
  64393. * @param cameras The camera to enable.
  64394. * @hidden
  64395. */
  64396. _enable(cameras: Nullable<Camera[]>): void;
  64397. /**
  64398. * Disables the effect on the given cameras
  64399. * @param cameras The camera to disable.
  64400. * @hidden
  64401. */
  64402. _disable(cameras: Camera): void;
  64403. /**
  64404. * Disables the effect on the given cameras
  64405. * @param cameras The camera to disable.
  64406. * @hidden
  64407. */
  64408. _disable(cameras: Nullable<Camera[]>): void;
  64409. /**
  64410. * Gets a list of the post processes contained in the effect.
  64411. * @param camera The camera to get the post processes on.
  64412. * @returns The list of the post processes in the effect.
  64413. */
  64414. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64415. }
  64416. }
  64417. declare module BABYLON {
  64418. /** @hidden */
  64419. export var extractHighlightsPixelShader: {
  64420. name: string;
  64421. shader: string;
  64422. };
  64423. }
  64424. declare module BABYLON {
  64425. /**
  64426. * 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.
  64427. */
  64428. export class ExtractHighlightsPostProcess extends PostProcess {
  64429. /**
  64430. * The luminance threshold, pixels below this value will be set to black.
  64431. */
  64432. threshold: number;
  64433. /** @hidden */
  64434. _exposure: number;
  64435. /**
  64436. * Post process which has the input texture to be used when performing highlight extraction
  64437. * @hidden
  64438. */
  64439. _inputPostProcess: Nullable<PostProcess>;
  64440. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64441. }
  64442. }
  64443. declare module BABYLON {
  64444. /** @hidden */
  64445. export var bloomMergePixelShader: {
  64446. name: string;
  64447. shader: string;
  64448. };
  64449. }
  64450. declare module BABYLON {
  64451. /**
  64452. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64453. */
  64454. export class BloomMergePostProcess extends PostProcess {
  64455. /** Weight of the bloom to be added to the original input. */
  64456. weight: number;
  64457. /**
  64458. * Creates a new instance of @see BloomMergePostProcess
  64459. * @param name The name of the effect.
  64460. * @param originalFromInput Post process which's input will be used for the merge.
  64461. * @param blurred Blurred highlights post process which's output will be used.
  64462. * @param weight Weight of the bloom to be added to the original input.
  64463. * @param options The required width/height ratio to downsize to before computing the render pass.
  64464. * @param camera The camera to apply the render pass to.
  64465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64466. * @param engine The engine which the post process will be applied. (default: current engine)
  64467. * @param reusable If the post process can be reused on the same frame. (default: false)
  64468. * @param textureType Type of textures used when performing the post process. (default: 0)
  64469. * @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)
  64470. */
  64471. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64472. /** Weight of the bloom to be added to the original input. */
  64473. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64474. }
  64475. }
  64476. declare module BABYLON {
  64477. /**
  64478. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64479. */
  64480. export class BloomEffect extends PostProcessRenderEffect {
  64481. private bloomScale;
  64482. /**
  64483. * @hidden Internal
  64484. */
  64485. _effects: Array<PostProcess>;
  64486. /**
  64487. * @hidden Internal
  64488. */
  64489. _downscale: ExtractHighlightsPostProcess;
  64490. private _blurX;
  64491. private _blurY;
  64492. private _merge;
  64493. /**
  64494. * The luminance threshold to find bright areas of the image to bloom.
  64495. */
  64496. get threshold(): number;
  64497. set threshold(value: number);
  64498. /**
  64499. * The strength of the bloom.
  64500. */
  64501. get weight(): number;
  64502. set weight(value: number);
  64503. /**
  64504. * Specifies the size of the bloom blur kernel, relative to the final output size
  64505. */
  64506. get kernel(): number;
  64507. set kernel(value: number);
  64508. /**
  64509. * Creates a new instance of @see BloomEffect
  64510. * @param scene The scene the effect belongs to.
  64511. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64512. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64513. * @param bloomWeight The the strength of bloom.
  64514. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64515. * @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)
  64516. */
  64517. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64518. /**
  64519. * Disposes each of the internal effects for a given camera.
  64520. * @param camera The camera to dispose the effect on.
  64521. */
  64522. disposeEffects(camera: Camera): void;
  64523. /**
  64524. * @hidden Internal
  64525. */
  64526. _updateEffects(): void;
  64527. /**
  64528. * Internal
  64529. * @returns if all the contained post processes are ready.
  64530. * @hidden
  64531. */
  64532. _isReady(): boolean;
  64533. }
  64534. }
  64535. declare module BABYLON {
  64536. /** @hidden */
  64537. export var chromaticAberrationPixelShader: {
  64538. name: string;
  64539. shader: string;
  64540. };
  64541. }
  64542. declare module BABYLON {
  64543. /**
  64544. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64545. */
  64546. export class ChromaticAberrationPostProcess extends PostProcess {
  64547. /**
  64548. * The amount of seperation of rgb channels (default: 30)
  64549. */
  64550. aberrationAmount: number;
  64551. /**
  64552. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64553. */
  64554. radialIntensity: number;
  64555. /**
  64556. * 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))
  64557. */
  64558. direction: Vector2;
  64559. /**
  64560. * 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))
  64561. */
  64562. centerPosition: Vector2;
  64563. /**
  64564. * Creates a new instance ChromaticAberrationPostProcess
  64565. * @param name The name of the effect.
  64566. * @param screenWidth The width of the screen to apply the effect on.
  64567. * @param screenHeight The height of the screen to apply the effect on.
  64568. * @param options The required width/height ratio to downsize to before computing the render pass.
  64569. * @param camera The camera to apply the render pass to.
  64570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64571. * @param engine The engine which the post process will be applied. (default: current engine)
  64572. * @param reusable If the post process can be reused on the same frame. (default: false)
  64573. * @param textureType Type of textures used when performing the post process. (default: 0)
  64574. * @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)
  64575. */
  64576. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64577. }
  64578. }
  64579. declare module BABYLON {
  64580. /** @hidden */
  64581. export var circleOfConfusionPixelShader: {
  64582. name: string;
  64583. shader: string;
  64584. };
  64585. }
  64586. declare module BABYLON {
  64587. /**
  64588. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64589. */
  64590. export class CircleOfConfusionPostProcess extends PostProcess {
  64591. /**
  64592. * 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.
  64593. */
  64594. lensSize: number;
  64595. /**
  64596. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64597. */
  64598. fStop: number;
  64599. /**
  64600. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64601. */
  64602. focusDistance: number;
  64603. /**
  64604. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64605. */
  64606. focalLength: number;
  64607. private _depthTexture;
  64608. /**
  64609. * Creates a new instance CircleOfConfusionPostProcess
  64610. * @param name The name of the effect.
  64611. * @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.
  64612. * @param options The required width/height ratio to downsize to before computing the render pass.
  64613. * @param camera The camera to apply the render pass to.
  64614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64615. * @param engine The engine which the post process will be applied. (default: current engine)
  64616. * @param reusable If the post process can be reused on the same frame. (default: false)
  64617. * @param textureType Type of textures used when performing the post process. (default: 0)
  64618. * @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)
  64619. */
  64620. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64621. /**
  64622. * 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.
  64623. */
  64624. set depthTexture(value: RenderTargetTexture);
  64625. }
  64626. }
  64627. declare module BABYLON {
  64628. /** @hidden */
  64629. export var colorCorrectionPixelShader: {
  64630. name: string;
  64631. shader: string;
  64632. };
  64633. }
  64634. declare module BABYLON {
  64635. /**
  64636. *
  64637. * This post-process allows the modification of rendered colors by using
  64638. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64639. *
  64640. * The object needs to be provided an url to a texture containing the color
  64641. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64642. * Use an image editing software to tweak the LUT to match your needs.
  64643. *
  64644. * For an example of a color LUT, see here:
  64645. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64646. * For explanations on color grading, see here:
  64647. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64648. *
  64649. */
  64650. export class ColorCorrectionPostProcess extends PostProcess {
  64651. private _colorTableTexture;
  64652. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64653. }
  64654. }
  64655. declare module BABYLON {
  64656. /** @hidden */
  64657. export var convolutionPixelShader: {
  64658. name: string;
  64659. shader: string;
  64660. };
  64661. }
  64662. declare module BABYLON {
  64663. /**
  64664. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64665. * input texture to perform effects such as edge detection or sharpening
  64666. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64667. */
  64668. export class ConvolutionPostProcess extends PostProcess {
  64669. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64670. kernel: number[];
  64671. /**
  64672. * Creates a new instance ConvolutionPostProcess
  64673. * @param name The name of the effect.
  64674. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64675. * @param options The required width/height ratio to downsize to before computing the render pass.
  64676. * @param camera The camera to apply the render pass to.
  64677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64678. * @param engine The engine which the post process will be applied. (default: current engine)
  64679. * @param reusable If the post process can be reused on the same frame. (default: false)
  64680. * @param textureType Type of textures used when performing the post process. (default: 0)
  64681. */
  64682. constructor(name: string,
  64683. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64684. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64685. /**
  64686. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64687. */
  64688. static EdgeDetect0Kernel: number[];
  64689. /**
  64690. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64691. */
  64692. static EdgeDetect1Kernel: number[];
  64693. /**
  64694. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64695. */
  64696. static EdgeDetect2Kernel: number[];
  64697. /**
  64698. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64699. */
  64700. static SharpenKernel: number[];
  64701. /**
  64702. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64703. */
  64704. static EmbossKernel: number[];
  64705. /**
  64706. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64707. */
  64708. static GaussianKernel: number[];
  64709. }
  64710. }
  64711. declare module BABYLON {
  64712. /**
  64713. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64714. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64715. * based on samples that have a large difference in distance than the center pixel.
  64716. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64717. */
  64718. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64719. direction: Vector2;
  64720. /**
  64721. * Creates a new instance CircleOfConfusionPostProcess
  64722. * @param name The name of the effect.
  64723. * @param scene The scene the effect belongs to.
  64724. * @param direction The direction the blur should be applied.
  64725. * @param kernel The size of the kernel used to blur.
  64726. * @param options The required width/height ratio to downsize to before computing the render pass.
  64727. * @param camera The camera to apply the render pass to.
  64728. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64729. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64731. * @param engine The engine which the post process will be applied. (default: current engine)
  64732. * @param reusable If the post process can be reused on the same frame. (default: false)
  64733. * @param textureType Type of textures used when performing the post process. (default: 0)
  64734. * @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)
  64735. */
  64736. 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);
  64737. }
  64738. }
  64739. declare module BABYLON {
  64740. /** @hidden */
  64741. export var depthOfFieldMergePixelShader: {
  64742. name: string;
  64743. shader: string;
  64744. };
  64745. }
  64746. declare module BABYLON {
  64747. /**
  64748. * Options to be set when merging outputs from the default pipeline.
  64749. */
  64750. export class DepthOfFieldMergePostProcessOptions {
  64751. /**
  64752. * The original image to merge on top of
  64753. */
  64754. originalFromInput: PostProcess;
  64755. /**
  64756. * Parameters to perform the merge of the depth of field effect
  64757. */
  64758. depthOfField?: {
  64759. circleOfConfusion: PostProcess;
  64760. blurSteps: Array<PostProcess>;
  64761. };
  64762. /**
  64763. * Parameters to perform the merge of bloom effect
  64764. */
  64765. bloom?: {
  64766. blurred: PostProcess;
  64767. weight: number;
  64768. };
  64769. }
  64770. /**
  64771. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64772. */
  64773. export class DepthOfFieldMergePostProcess extends PostProcess {
  64774. private blurSteps;
  64775. /**
  64776. * Creates a new instance of DepthOfFieldMergePostProcess
  64777. * @param name The name of the effect.
  64778. * @param originalFromInput Post process which's input will be used for the merge.
  64779. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64780. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64781. * @param options The required width/height ratio to downsize to before computing the render pass.
  64782. * @param camera The camera to apply the render pass to.
  64783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64784. * @param engine The engine which the post process will be applied. (default: current engine)
  64785. * @param reusable If the post process can be reused on the same frame. (default: false)
  64786. * @param textureType Type of textures used when performing the post process. (default: 0)
  64787. * @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)
  64788. */
  64789. 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);
  64790. /**
  64791. * Updates the effect with the current post process compile time values and recompiles the shader.
  64792. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64793. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64794. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64795. * @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
  64796. * @param onCompiled Called when the shader has been compiled.
  64797. * @param onError Called if there is an error when compiling a shader.
  64798. */
  64799. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64800. }
  64801. }
  64802. declare module BABYLON {
  64803. /**
  64804. * Specifies the level of max blur that should be applied when using the depth of field effect
  64805. */
  64806. export enum DepthOfFieldEffectBlurLevel {
  64807. /**
  64808. * Subtle blur
  64809. */
  64810. Low = 0,
  64811. /**
  64812. * Medium blur
  64813. */
  64814. Medium = 1,
  64815. /**
  64816. * Large blur
  64817. */
  64818. High = 2
  64819. }
  64820. /**
  64821. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64822. */
  64823. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64824. private _circleOfConfusion;
  64825. /**
  64826. * @hidden Internal, blurs from high to low
  64827. */
  64828. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64829. private _depthOfFieldBlurY;
  64830. private _dofMerge;
  64831. /**
  64832. * @hidden Internal post processes in depth of field effect
  64833. */
  64834. _effects: Array<PostProcess>;
  64835. /**
  64836. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64837. */
  64838. set focalLength(value: number);
  64839. get focalLength(): number;
  64840. /**
  64841. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64842. */
  64843. set fStop(value: number);
  64844. get fStop(): number;
  64845. /**
  64846. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64847. */
  64848. set focusDistance(value: number);
  64849. get focusDistance(): number;
  64850. /**
  64851. * 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.
  64852. */
  64853. set lensSize(value: number);
  64854. get lensSize(): number;
  64855. /**
  64856. * Creates a new instance DepthOfFieldEffect
  64857. * @param scene The scene the effect belongs to.
  64858. * @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.
  64859. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64860. * @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)
  64861. */
  64862. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64863. /**
  64864. * Get the current class name of the current effet
  64865. * @returns "DepthOfFieldEffect"
  64866. */
  64867. getClassName(): string;
  64868. /**
  64869. * 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.
  64870. */
  64871. set depthTexture(value: RenderTargetTexture);
  64872. /**
  64873. * Disposes each of the internal effects for a given camera.
  64874. * @param camera The camera to dispose the effect on.
  64875. */
  64876. disposeEffects(camera: Camera): void;
  64877. /**
  64878. * @hidden Internal
  64879. */
  64880. _updateEffects(): void;
  64881. /**
  64882. * Internal
  64883. * @returns if all the contained post processes are ready.
  64884. * @hidden
  64885. */
  64886. _isReady(): boolean;
  64887. }
  64888. }
  64889. declare module BABYLON {
  64890. /** @hidden */
  64891. export var displayPassPixelShader: {
  64892. name: string;
  64893. shader: string;
  64894. };
  64895. }
  64896. declare module BABYLON {
  64897. /**
  64898. * DisplayPassPostProcess which produces an output the same as it's input
  64899. */
  64900. export class DisplayPassPostProcess extends PostProcess {
  64901. /**
  64902. * Creates the DisplayPassPostProcess
  64903. * @param name The name of the effect.
  64904. * @param options The required width/height ratio to downsize to before computing the render pass.
  64905. * @param camera The camera to apply the render pass to.
  64906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64907. * @param engine The engine which the post process will be applied. (default: current engine)
  64908. * @param reusable If the post process can be reused on the same frame. (default: false)
  64909. */
  64910. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64911. }
  64912. }
  64913. declare module BABYLON {
  64914. /** @hidden */
  64915. export var filterPixelShader: {
  64916. name: string;
  64917. shader: string;
  64918. };
  64919. }
  64920. declare module BABYLON {
  64921. /**
  64922. * Applies a kernel filter to the image
  64923. */
  64924. export class FilterPostProcess extends PostProcess {
  64925. /** The matrix to be applied to the image */
  64926. kernelMatrix: Matrix;
  64927. /**
  64928. *
  64929. * @param name The name of the effect.
  64930. * @param kernelMatrix The matrix to be applied to the image
  64931. * @param options The required width/height ratio to downsize to before computing the render pass.
  64932. * @param camera The camera to apply the render pass to.
  64933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64934. * @param engine The engine which the post process will be applied. (default: current engine)
  64935. * @param reusable If the post process can be reused on the same frame. (default: false)
  64936. */
  64937. constructor(name: string,
  64938. /** The matrix to be applied to the image */
  64939. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64940. }
  64941. }
  64942. declare module BABYLON {
  64943. /** @hidden */
  64944. export var fxaaPixelShader: {
  64945. name: string;
  64946. shader: string;
  64947. };
  64948. }
  64949. declare module BABYLON {
  64950. /** @hidden */
  64951. export var fxaaVertexShader: {
  64952. name: string;
  64953. shader: string;
  64954. };
  64955. }
  64956. declare module BABYLON {
  64957. /**
  64958. * Fxaa post process
  64959. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64960. */
  64961. export class FxaaPostProcess extends PostProcess {
  64962. /** @hidden */
  64963. texelWidth: number;
  64964. /** @hidden */
  64965. texelHeight: number;
  64966. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64967. private _getDefines;
  64968. }
  64969. }
  64970. declare module BABYLON {
  64971. /** @hidden */
  64972. export var grainPixelShader: {
  64973. name: string;
  64974. shader: string;
  64975. };
  64976. }
  64977. declare module BABYLON {
  64978. /**
  64979. * The GrainPostProcess adds noise to the image at mid luminance levels
  64980. */
  64981. export class GrainPostProcess extends PostProcess {
  64982. /**
  64983. * The intensity of the grain added (default: 30)
  64984. */
  64985. intensity: number;
  64986. /**
  64987. * If the grain should be randomized on every frame
  64988. */
  64989. animated: boolean;
  64990. /**
  64991. * Creates a new instance of @see GrainPostProcess
  64992. * @param name The name of the effect.
  64993. * @param options The required width/height ratio to downsize to before computing the render pass.
  64994. * @param camera The camera to apply the render pass to.
  64995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64996. * @param engine The engine which the post process will be applied. (default: current engine)
  64997. * @param reusable If the post process can be reused on the same frame. (default: false)
  64998. * @param textureType Type of textures used when performing the post process. (default: 0)
  64999. * @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)
  65000. */
  65001. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65002. }
  65003. }
  65004. declare module BABYLON {
  65005. /** @hidden */
  65006. export var highlightsPixelShader: {
  65007. name: string;
  65008. shader: string;
  65009. };
  65010. }
  65011. declare module BABYLON {
  65012. /**
  65013. * Extracts highlights from the image
  65014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65015. */
  65016. export class HighlightsPostProcess extends PostProcess {
  65017. /**
  65018. * Extracts highlights from the image
  65019. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65020. * @param name The name of the effect.
  65021. * @param options The required width/height ratio to downsize to before computing the render pass.
  65022. * @param camera The camera to apply the render pass to.
  65023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65024. * @param engine The engine which the post process will be applied. (default: current engine)
  65025. * @param reusable If the post process can be reused on the same frame. (default: false)
  65026. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65027. */
  65028. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65029. }
  65030. }
  65031. declare module BABYLON {
  65032. /** @hidden */
  65033. export var mrtFragmentDeclaration: {
  65034. name: string;
  65035. shader: string;
  65036. };
  65037. }
  65038. declare module BABYLON {
  65039. /** @hidden */
  65040. export var geometryPixelShader: {
  65041. name: string;
  65042. shader: string;
  65043. };
  65044. }
  65045. declare module BABYLON {
  65046. /** @hidden */
  65047. export var geometryVertexShader: {
  65048. name: string;
  65049. shader: string;
  65050. };
  65051. }
  65052. declare module BABYLON {
  65053. /** @hidden */
  65054. interface ISavedTransformationMatrix {
  65055. world: Matrix;
  65056. viewProjection: Matrix;
  65057. }
  65058. /**
  65059. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65060. */
  65061. export class GeometryBufferRenderer {
  65062. /**
  65063. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65064. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65065. */
  65066. static readonly POSITION_TEXTURE_TYPE: number;
  65067. /**
  65068. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65069. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65070. */
  65071. static readonly VELOCITY_TEXTURE_TYPE: number;
  65072. /**
  65073. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65074. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65075. */
  65076. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65077. /**
  65078. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65079. * in order to compute objects velocities when enableVelocity is set to "true"
  65080. * @hidden
  65081. */
  65082. _previousTransformationMatrices: {
  65083. [index: number]: ISavedTransformationMatrix;
  65084. };
  65085. /**
  65086. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65087. * in order to compute objects velocities when enableVelocity is set to "true"
  65088. * @hidden
  65089. */
  65090. _previousBonesTransformationMatrices: {
  65091. [index: number]: Float32Array;
  65092. };
  65093. /**
  65094. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65095. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65096. */
  65097. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65098. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65099. renderTransparentMeshes: boolean;
  65100. private _scene;
  65101. private _multiRenderTarget;
  65102. private _ratio;
  65103. private _enablePosition;
  65104. private _enableVelocity;
  65105. private _enableReflectivity;
  65106. private _positionIndex;
  65107. private _velocityIndex;
  65108. private _reflectivityIndex;
  65109. protected _effect: Effect;
  65110. protected _cachedDefines: string;
  65111. /**
  65112. * Set the render list (meshes to be rendered) used in the G buffer.
  65113. */
  65114. set renderList(meshes: Mesh[]);
  65115. /**
  65116. * Gets wether or not G buffer are supported by the running hardware.
  65117. * This requires draw buffer supports
  65118. */
  65119. get isSupported(): boolean;
  65120. /**
  65121. * Returns the index of the given texture type in the G-Buffer textures array
  65122. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65123. * @returns the index of the given texture type in the G-Buffer textures array
  65124. */
  65125. getTextureIndex(textureType: number): number;
  65126. /**
  65127. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65128. */
  65129. get enablePosition(): boolean;
  65130. /**
  65131. * Sets whether or not objects positions are enabled for the G buffer.
  65132. */
  65133. set enablePosition(enable: boolean);
  65134. /**
  65135. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65136. */
  65137. get enableVelocity(): boolean;
  65138. /**
  65139. * Sets wether or not objects velocities are enabled for the G buffer.
  65140. */
  65141. set enableVelocity(enable: boolean);
  65142. /**
  65143. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65144. */
  65145. get enableReflectivity(): boolean;
  65146. /**
  65147. * Sets wether or not objects roughness are enabled for the G buffer.
  65148. */
  65149. set enableReflectivity(enable: boolean);
  65150. /**
  65151. * Gets the scene associated with the buffer.
  65152. */
  65153. get scene(): Scene;
  65154. /**
  65155. * Gets the ratio used by the buffer during its creation.
  65156. * How big is the buffer related to the main canvas.
  65157. */
  65158. get ratio(): number;
  65159. /** @hidden */
  65160. static _SceneComponentInitialization: (scene: Scene) => void;
  65161. /**
  65162. * Creates a new G Buffer for the scene
  65163. * @param scene The scene the buffer belongs to
  65164. * @param ratio How big is the buffer related to the main canvas.
  65165. */
  65166. constructor(scene: Scene, ratio?: number);
  65167. /**
  65168. * Checks wether everything is ready to render a submesh to the G buffer.
  65169. * @param subMesh the submesh to check readiness for
  65170. * @param useInstances is the mesh drawn using instance or not
  65171. * @returns true if ready otherwise false
  65172. */
  65173. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65174. /**
  65175. * Gets the current underlying G Buffer.
  65176. * @returns the buffer
  65177. */
  65178. getGBuffer(): MultiRenderTarget;
  65179. /**
  65180. * Gets the number of samples used to render the buffer (anti aliasing).
  65181. */
  65182. get samples(): number;
  65183. /**
  65184. * Sets the number of samples used to render the buffer (anti aliasing).
  65185. */
  65186. set samples(value: number);
  65187. /**
  65188. * Disposes the renderer and frees up associated resources.
  65189. */
  65190. dispose(): void;
  65191. protected _createRenderTargets(): void;
  65192. private _copyBonesTransformationMatrices;
  65193. }
  65194. }
  65195. declare module BABYLON {
  65196. interface Scene {
  65197. /** @hidden (Backing field) */
  65198. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65199. /**
  65200. * Gets or Sets the current geometry buffer associated to the scene.
  65201. */
  65202. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65203. /**
  65204. * Enables a GeometryBufferRender and associates it with the scene
  65205. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65206. * @returns the GeometryBufferRenderer
  65207. */
  65208. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65209. /**
  65210. * Disables the GeometryBufferRender associated with the scene
  65211. */
  65212. disableGeometryBufferRenderer(): void;
  65213. }
  65214. /**
  65215. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65216. * in several rendering techniques.
  65217. */
  65218. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65219. /**
  65220. * The component name helpful to identify the component in the list of scene components.
  65221. */
  65222. readonly name: string;
  65223. /**
  65224. * The scene the component belongs to.
  65225. */
  65226. scene: Scene;
  65227. /**
  65228. * Creates a new instance of the component for the given scene
  65229. * @param scene Defines the scene to register the component in
  65230. */
  65231. constructor(scene: Scene);
  65232. /**
  65233. * Registers the component in a given scene
  65234. */
  65235. register(): void;
  65236. /**
  65237. * Rebuilds the elements related to this component in case of
  65238. * context lost for instance.
  65239. */
  65240. rebuild(): void;
  65241. /**
  65242. * Disposes the component and the associated ressources
  65243. */
  65244. dispose(): void;
  65245. private _gatherRenderTargets;
  65246. }
  65247. }
  65248. declare module BABYLON {
  65249. /** @hidden */
  65250. export var motionBlurPixelShader: {
  65251. name: string;
  65252. shader: string;
  65253. };
  65254. }
  65255. declare module BABYLON {
  65256. /**
  65257. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65258. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65259. * As an example, all you have to do is to create the post-process:
  65260. * var mb = new BABYLON.MotionBlurPostProcess(
  65261. * 'mb', // The name of the effect.
  65262. * scene, // The scene containing the objects to blur according to their velocity.
  65263. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65264. * camera // The camera to apply the render pass to.
  65265. * );
  65266. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65267. */
  65268. export class MotionBlurPostProcess extends PostProcess {
  65269. /**
  65270. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65271. */
  65272. motionStrength: number;
  65273. /**
  65274. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65275. */
  65276. get motionBlurSamples(): number;
  65277. /**
  65278. * Sets the number of iterations to be used for motion blur quality
  65279. */
  65280. set motionBlurSamples(samples: number);
  65281. private _motionBlurSamples;
  65282. private _geometryBufferRenderer;
  65283. /**
  65284. * Creates a new instance MotionBlurPostProcess
  65285. * @param name The name of the effect.
  65286. * @param scene The scene containing the objects to blur according to their velocity.
  65287. * @param options The required width/height ratio to downsize to before computing the render pass.
  65288. * @param camera The camera to apply the render pass to.
  65289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65290. * @param engine The engine which the post process will be applied. (default: current engine)
  65291. * @param reusable If the post process can be reused on the same frame. (default: false)
  65292. * @param textureType Type of textures used when performing the post process. (default: 0)
  65293. * @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)
  65294. */
  65295. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65296. /**
  65297. * Excludes the given skinned mesh from computing bones velocities.
  65298. * 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.
  65299. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65300. */
  65301. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65302. /**
  65303. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65304. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65305. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65306. */
  65307. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65308. /**
  65309. * Disposes the post process.
  65310. * @param camera The camera to dispose the post process on.
  65311. */
  65312. dispose(camera?: Camera): void;
  65313. }
  65314. }
  65315. declare module BABYLON {
  65316. /** @hidden */
  65317. export var refractionPixelShader: {
  65318. name: string;
  65319. shader: string;
  65320. };
  65321. }
  65322. declare module BABYLON {
  65323. /**
  65324. * Post process which applies a refractin texture
  65325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65326. */
  65327. export class RefractionPostProcess extends PostProcess {
  65328. /** the base color of the refraction (used to taint the rendering) */
  65329. color: Color3;
  65330. /** simulated refraction depth */
  65331. depth: number;
  65332. /** the coefficient of the base color (0 to remove base color tainting) */
  65333. colorLevel: number;
  65334. private _refTexture;
  65335. private _ownRefractionTexture;
  65336. /**
  65337. * Gets or sets the refraction texture
  65338. * Please note that you are responsible for disposing the texture if you set it manually
  65339. */
  65340. get refractionTexture(): Texture;
  65341. set refractionTexture(value: Texture);
  65342. /**
  65343. * Initializes the RefractionPostProcess
  65344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65345. * @param name The name of the effect.
  65346. * @param refractionTextureUrl Url of the refraction texture to use
  65347. * @param color the base color of the refraction (used to taint the rendering)
  65348. * @param depth simulated refraction depth
  65349. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65350. * @param camera The camera to apply the render pass to.
  65351. * @param options The required width/height ratio to downsize to before computing the render pass.
  65352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65353. * @param engine The engine which the post process will be applied. (default: current engine)
  65354. * @param reusable If the post process can be reused on the same frame. (default: false)
  65355. */
  65356. constructor(name: string, refractionTextureUrl: string,
  65357. /** the base color of the refraction (used to taint the rendering) */
  65358. color: Color3,
  65359. /** simulated refraction depth */
  65360. depth: number,
  65361. /** the coefficient of the base color (0 to remove base color tainting) */
  65362. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65363. /**
  65364. * Disposes of the post process
  65365. * @param camera Camera to dispose post process on
  65366. */
  65367. dispose(camera: Camera): void;
  65368. }
  65369. }
  65370. declare module BABYLON {
  65371. /** @hidden */
  65372. export var sharpenPixelShader: {
  65373. name: string;
  65374. shader: string;
  65375. };
  65376. }
  65377. declare module BABYLON {
  65378. /**
  65379. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65380. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65381. */
  65382. export class SharpenPostProcess extends PostProcess {
  65383. /**
  65384. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65385. */
  65386. colorAmount: number;
  65387. /**
  65388. * How much sharpness should be applied (default: 0.3)
  65389. */
  65390. edgeAmount: number;
  65391. /**
  65392. * Creates a new instance ConvolutionPostProcess
  65393. * @param name The name of the effect.
  65394. * @param options The required width/height ratio to downsize to before computing the render pass.
  65395. * @param camera The camera to apply the render pass to.
  65396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65397. * @param engine The engine which the post process will be applied. (default: current engine)
  65398. * @param reusable If the post process can be reused on the same frame. (default: false)
  65399. * @param textureType Type of textures used when performing the post process. (default: 0)
  65400. * @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)
  65401. */
  65402. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65403. }
  65404. }
  65405. declare module BABYLON {
  65406. /**
  65407. * PostProcessRenderPipeline
  65408. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65409. */
  65410. export class PostProcessRenderPipeline {
  65411. private engine;
  65412. private _renderEffects;
  65413. private _renderEffectsForIsolatedPass;
  65414. /**
  65415. * List of inspectable custom properties (used by the Inspector)
  65416. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65417. */
  65418. inspectableCustomProperties: IInspectable[];
  65419. /**
  65420. * @hidden
  65421. */
  65422. protected _cameras: Camera[];
  65423. /** @hidden */
  65424. _name: string;
  65425. /**
  65426. * Gets pipeline name
  65427. */
  65428. get name(): string;
  65429. /** Gets the list of attached cameras */
  65430. get cameras(): Camera[];
  65431. /**
  65432. * Initializes a PostProcessRenderPipeline
  65433. * @param engine engine to add the pipeline to
  65434. * @param name name of the pipeline
  65435. */
  65436. constructor(engine: Engine, name: string);
  65437. /**
  65438. * Gets the class name
  65439. * @returns "PostProcessRenderPipeline"
  65440. */
  65441. getClassName(): string;
  65442. /**
  65443. * If all the render effects in the pipeline are supported
  65444. */
  65445. get isSupported(): boolean;
  65446. /**
  65447. * Adds an effect to the pipeline
  65448. * @param renderEffect the effect to add
  65449. */
  65450. addEffect(renderEffect: PostProcessRenderEffect): void;
  65451. /** @hidden */
  65452. _rebuild(): void;
  65453. /** @hidden */
  65454. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65455. /** @hidden */
  65456. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65457. /** @hidden */
  65458. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65459. /** @hidden */
  65460. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65461. /** @hidden */
  65462. _attachCameras(cameras: Camera, unique: boolean): void;
  65463. /** @hidden */
  65464. _attachCameras(cameras: Camera[], unique: boolean): void;
  65465. /** @hidden */
  65466. _detachCameras(cameras: Camera): void;
  65467. /** @hidden */
  65468. _detachCameras(cameras: Nullable<Camera[]>): void;
  65469. /** @hidden */
  65470. _update(): void;
  65471. /** @hidden */
  65472. _reset(): void;
  65473. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65474. /**
  65475. * Disposes of the pipeline
  65476. */
  65477. dispose(): void;
  65478. }
  65479. }
  65480. declare module BABYLON {
  65481. /**
  65482. * PostProcessRenderPipelineManager class
  65483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65484. */
  65485. export class PostProcessRenderPipelineManager {
  65486. private _renderPipelines;
  65487. /**
  65488. * Initializes a PostProcessRenderPipelineManager
  65489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65490. */
  65491. constructor();
  65492. /**
  65493. * Gets the list of supported render pipelines
  65494. */
  65495. get supportedPipelines(): PostProcessRenderPipeline[];
  65496. /**
  65497. * Adds a pipeline to the manager
  65498. * @param renderPipeline The pipeline to add
  65499. */
  65500. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65501. /**
  65502. * Attaches a camera to the pipeline
  65503. * @param renderPipelineName The name of the pipeline to attach to
  65504. * @param cameras the camera to attach
  65505. * @param unique if the camera can be attached multiple times to the pipeline
  65506. */
  65507. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65508. /**
  65509. * Detaches a camera from the pipeline
  65510. * @param renderPipelineName The name of the pipeline to detach from
  65511. * @param cameras the camera to detach
  65512. */
  65513. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65514. /**
  65515. * Enables an effect by name on a pipeline
  65516. * @param renderPipelineName the name of the pipeline to enable the effect in
  65517. * @param renderEffectName the name of the effect to enable
  65518. * @param cameras the cameras that the effect should be enabled on
  65519. */
  65520. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65521. /**
  65522. * Disables an effect by name on a pipeline
  65523. * @param renderPipelineName the name of the pipeline to disable the effect in
  65524. * @param renderEffectName the name of the effect to disable
  65525. * @param cameras the cameras that the effect should be disabled on
  65526. */
  65527. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65528. /**
  65529. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65530. */
  65531. update(): void;
  65532. /** @hidden */
  65533. _rebuild(): void;
  65534. /**
  65535. * Disposes of the manager and pipelines
  65536. */
  65537. dispose(): void;
  65538. }
  65539. }
  65540. declare module BABYLON {
  65541. interface Scene {
  65542. /** @hidden (Backing field) */
  65543. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65544. /**
  65545. * Gets the postprocess render pipeline manager
  65546. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65547. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65548. */
  65549. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65550. }
  65551. /**
  65552. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65553. */
  65554. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65555. /**
  65556. * The component name helpfull to identify the component in the list of scene components.
  65557. */
  65558. readonly name: string;
  65559. /**
  65560. * The scene the component belongs to.
  65561. */
  65562. scene: Scene;
  65563. /**
  65564. * Creates a new instance of the component for the given scene
  65565. * @param scene Defines the scene to register the component in
  65566. */
  65567. constructor(scene: Scene);
  65568. /**
  65569. * Registers the component in a given scene
  65570. */
  65571. register(): void;
  65572. /**
  65573. * Rebuilds the elements related to this component in case of
  65574. * context lost for instance.
  65575. */
  65576. rebuild(): void;
  65577. /**
  65578. * Disposes the component and the associated ressources
  65579. */
  65580. dispose(): void;
  65581. private _gatherRenderTargets;
  65582. }
  65583. }
  65584. declare module BABYLON {
  65585. /**
  65586. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65587. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65588. */
  65589. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65590. private _scene;
  65591. private _camerasToBeAttached;
  65592. /**
  65593. * ID of the sharpen post process,
  65594. */
  65595. private readonly SharpenPostProcessId;
  65596. /**
  65597. * @ignore
  65598. * ID of the image processing post process;
  65599. */
  65600. readonly ImageProcessingPostProcessId: string;
  65601. /**
  65602. * @ignore
  65603. * ID of the Fast Approximate Anti-Aliasing post process;
  65604. */
  65605. readonly FxaaPostProcessId: string;
  65606. /**
  65607. * ID of the chromatic aberration post process,
  65608. */
  65609. private readonly ChromaticAberrationPostProcessId;
  65610. /**
  65611. * ID of the grain post process
  65612. */
  65613. private readonly GrainPostProcessId;
  65614. /**
  65615. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65616. */
  65617. sharpen: SharpenPostProcess;
  65618. private _sharpenEffect;
  65619. private bloom;
  65620. /**
  65621. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65622. */
  65623. depthOfField: DepthOfFieldEffect;
  65624. /**
  65625. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65626. */
  65627. fxaa: FxaaPostProcess;
  65628. /**
  65629. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65630. */
  65631. imageProcessing: ImageProcessingPostProcess;
  65632. /**
  65633. * Chromatic aberration post process which will shift rgb colors in the image
  65634. */
  65635. chromaticAberration: ChromaticAberrationPostProcess;
  65636. private _chromaticAberrationEffect;
  65637. /**
  65638. * Grain post process which add noise to the image
  65639. */
  65640. grain: GrainPostProcess;
  65641. private _grainEffect;
  65642. /**
  65643. * Glow post process which adds a glow to emissive areas of the image
  65644. */
  65645. private _glowLayer;
  65646. /**
  65647. * Animations which can be used to tweak settings over a period of time
  65648. */
  65649. animations: Animation[];
  65650. private _imageProcessingConfigurationObserver;
  65651. private _sharpenEnabled;
  65652. private _bloomEnabled;
  65653. private _depthOfFieldEnabled;
  65654. private _depthOfFieldBlurLevel;
  65655. private _fxaaEnabled;
  65656. private _imageProcessingEnabled;
  65657. private _defaultPipelineTextureType;
  65658. private _bloomScale;
  65659. private _chromaticAberrationEnabled;
  65660. private _grainEnabled;
  65661. private _buildAllowed;
  65662. /**
  65663. * Gets active scene
  65664. */
  65665. get scene(): Scene;
  65666. /**
  65667. * Enable or disable the sharpen process from the pipeline
  65668. */
  65669. set sharpenEnabled(enabled: boolean);
  65670. get sharpenEnabled(): boolean;
  65671. private _resizeObserver;
  65672. private _hardwareScaleLevel;
  65673. private _bloomKernel;
  65674. /**
  65675. * Specifies the size of the bloom blur kernel, relative to the final output size
  65676. */
  65677. get bloomKernel(): number;
  65678. set bloomKernel(value: number);
  65679. /**
  65680. * Specifies the weight of the bloom in the final rendering
  65681. */
  65682. private _bloomWeight;
  65683. /**
  65684. * Specifies the luma threshold for the area that will be blurred by the bloom
  65685. */
  65686. private _bloomThreshold;
  65687. private _hdr;
  65688. /**
  65689. * The strength of the bloom.
  65690. */
  65691. set bloomWeight(value: number);
  65692. get bloomWeight(): number;
  65693. /**
  65694. * The strength of the bloom.
  65695. */
  65696. set bloomThreshold(value: number);
  65697. get bloomThreshold(): number;
  65698. /**
  65699. * The scale of the bloom, lower value will provide better performance.
  65700. */
  65701. set bloomScale(value: number);
  65702. get bloomScale(): number;
  65703. /**
  65704. * Enable or disable the bloom from the pipeline
  65705. */
  65706. set bloomEnabled(enabled: boolean);
  65707. get bloomEnabled(): boolean;
  65708. private _rebuildBloom;
  65709. /**
  65710. * If the depth of field is enabled.
  65711. */
  65712. get depthOfFieldEnabled(): boolean;
  65713. set depthOfFieldEnabled(enabled: boolean);
  65714. /**
  65715. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65716. */
  65717. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65718. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65719. /**
  65720. * If the anti aliasing is enabled.
  65721. */
  65722. set fxaaEnabled(enabled: boolean);
  65723. get fxaaEnabled(): boolean;
  65724. private _samples;
  65725. /**
  65726. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65727. */
  65728. set samples(sampleCount: number);
  65729. get samples(): number;
  65730. /**
  65731. * If image processing is enabled.
  65732. */
  65733. set imageProcessingEnabled(enabled: boolean);
  65734. get imageProcessingEnabled(): boolean;
  65735. /**
  65736. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65737. */
  65738. set glowLayerEnabled(enabled: boolean);
  65739. get glowLayerEnabled(): boolean;
  65740. /**
  65741. * Gets the glow layer (or null if not defined)
  65742. */
  65743. get glowLayer(): Nullable<GlowLayer>;
  65744. /**
  65745. * Enable or disable the chromaticAberration process from the pipeline
  65746. */
  65747. set chromaticAberrationEnabled(enabled: boolean);
  65748. get chromaticAberrationEnabled(): boolean;
  65749. /**
  65750. * Enable or disable the grain process from the pipeline
  65751. */
  65752. set grainEnabled(enabled: boolean);
  65753. get grainEnabled(): boolean;
  65754. /**
  65755. * @constructor
  65756. * @param name - The rendering pipeline name (default: "")
  65757. * @param hdr - If high dynamic range textures should be used (default: true)
  65758. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65759. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65760. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65761. */
  65762. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65763. /**
  65764. * Get the class name
  65765. * @returns "DefaultRenderingPipeline"
  65766. */
  65767. getClassName(): string;
  65768. /**
  65769. * Force the compilation of the entire pipeline.
  65770. */
  65771. prepare(): void;
  65772. private _hasCleared;
  65773. private _prevPostProcess;
  65774. private _prevPrevPostProcess;
  65775. private _setAutoClearAndTextureSharing;
  65776. private _depthOfFieldSceneObserver;
  65777. private _buildPipeline;
  65778. private _disposePostProcesses;
  65779. /**
  65780. * Adds a camera to the pipeline
  65781. * @param camera the camera to be added
  65782. */
  65783. addCamera(camera: Camera): void;
  65784. /**
  65785. * Removes a camera from the pipeline
  65786. * @param camera the camera to remove
  65787. */
  65788. removeCamera(camera: Camera): void;
  65789. /**
  65790. * Dispose of the pipeline and stop all post processes
  65791. */
  65792. dispose(): void;
  65793. /**
  65794. * Serialize the rendering pipeline (Used when exporting)
  65795. * @returns the serialized object
  65796. */
  65797. serialize(): any;
  65798. /**
  65799. * Parse the serialized pipeline
  65800. * @param source Source pipeline.
  65801. * @param scene The scene to load the pipeline to.
  65802. * @param rootUrl The URL of the serialized pipeline.
  65803. * @returns An instantiated pipeline from the serialized object.
  65804. */
  65805. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65806. }
  65807. }
  65808. declare module BABYLON {
  65809. /** @hidden */
  65810. export var lensHighlightsPixelShader: {
  65811. name: string;
  65812. shader: string;
  65813. };
  65814. }
  65815. declare module BABYLON {
  65816. /** @hidden */
  65817. export var depthOfFieldPixelShader: {
  65818. name: string;
  65819. shader: string;
  65820. };
  65821. }
  65822. declare module BABYLON {
  65823. /**
  65824. * BABYLON.JS Chromatic Aberration GLSL Shader
  65825. * Author: Olivier Guyot
  65826. * Separates very slightly R, G and B colors on the edges of the screen
  65827. * Inspired by Francois Tarlier & Martins Upitis
  65828. */
  65829. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65830. /**
  65831. * @ignore
  65832. * The chromatic aberration PostProcess id in the pipeline
  65833. */
  65834. LensChromaticAberrationEffect: string;
  65835. /**
  65836. * @ignore
  65837. * The highlights enhancing PostProcess id in the pipeline
  65838. */
  65839. HighlightsEnhancingEffect: string;
  65840. /**
  65841. * @ignore
  65842. * The depth-of-field PostProcess id in the pipeline
  65843. */
  65844. LensDepthOfFieldEffect: string;
  65845. private _scene;
  65846. private _depthTexture;
  65847. private _grainTexture;
  65848. private _chromaticAberrationPostProcess;
  65849. private _highlightsPostProcess;
  65850. private _depthOfFieldPostProcess;
  65851. private _edgeBlur;
  65852. private _grainAmount;
  65853. private _chromaticAberration;
  65854. private _distortion;
  65855. private _highlightsGain;
  65856. private _highlightsThreshold;
  65857. private _dofDistance;
  65858. private _dofAperture;
  65859. private _dofDarken;
  65860. private _dofPentagon;
  65861. private _blurNoise;
  65862. /**
  65863. * @constructor
  65864. *
  65865. * Effect parameters are as follow:
  65866. * {
  65867. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65868. * edge_blur: number; // from 0 to x (1 for realism)
  65869. * distortion: number; // from 0 to x (1 for realism)
  65870. * grain_amount: number; // from 0 to 1
  65871. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65872. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65873. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65874. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65875. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65876. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65877. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65878. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65879. * }
  65880. * Note: if an effect parameter is unset, effect is disabled
  65881. *
  65882. * @param name The rendering pipeline name
  65883. * @param parameters - An object containing all parameters (see above)
  65884. * @param scene The scene linked to this pipeline
  65885. * @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)
  65886. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65887. */
  65888. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65889. /**
  65890. * Get the class name
  65891. * @returns "LensRenderingPipeline"
  65892. */
  65893. getClassName(): string;
  65894. /**
  65895. * Gets associated scene
  65896. */
  65897. get scene(): Scene;
  65898. /**
  65899. * Gets or sets the edge blur
  65900. */
  65901. get edgeBlur(): number;
  65902. set edgeBlur(value: number);
  65903. /**
  65904. * Gets or sets the grain amount
  65905. */
  65906. get grainAmount(): number;
  65907. set grainAmount(value: number);
  65908. /**
  65909. * Gets or sets the chromatic aberration amount
  65910. */
  65911. get chromaticAberration(): number;
  65912. set chromaticAberration(value: number);
  65913. /**
  65914. * Gets or sets the depth of field aperture
  65915. */
  65916. get dofAperture(): number;
  65917. set dofAperture(value: number);
  65918. /**
  65919. * Gets or sets the edge distortion
  65920. */
  65921. get edgeDistortion(): number;
  65922. set edgeDistortion(value: number);
  65923. /**
  65924. * Gets or sets the depth of field distortion
  65925. */
  65926. get dofDistortion(): number;
  65927. set dofDistortion(value: number);
  65928. /**
  65929. * Gets or sets the darken out of focus amount
  65930. */
  65931. get darkenOutOfFocus(): number;
  65932. set darkenOutOfFocus(value: number);
  65933. /**
  65934. * Gets or sets a boolean indicating if blur noise is enabled
  65935. */
  65936. get blurNoise(): boolean;
  65937. set blurNoise(value: boolean);
  65938. /**
  65939. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65940. */
  65941. get pentagonBokeh(): boolean;
  65942. set pentagonBokeh(value: boolean);
  65943. /**
  65944. * Gets or sets the highlight grain amount
  65945. */
  65946. get highlightsGain(): number;
  65947. set highlightsGain(value: number);
  65948. /**
  65949. * Gets or sets the highlight threshold
  65950. */
  65951. get highlightsThreshold(): number;
  65952. set highlightsThreshold(value: number);
  65953. /**
  65954. * Sets the amount of blur at the edges
  65955. * @param amount blur amount
  65956. */
  65957. setEdgeBlur(amount: number): void;
  65958. /**
  65959. * Sets edge blur to 0
  65960. */
  65961. disableEdgeBlur(): void;
  65962. /**
  65963. * Sets the amout of grain
  65964. * @param amount Amount of grain
  65965. */
  65966. setGrainAmount(amount: number): void;
  65967. /**
  65968. * Set grain amount to 0
  65969. */
  65970. disableGrain(): void;
  65971. /**
  65972. * Sets the chromatic aberration amount
  65973. * @param amount amount of chromatic aberration
  65974. */
  65975. setChromaticAberration(amount: number): void;
  65976. /**
  65977. * Sets chromatic aberration amount to 0
  65978. */
  65979. disableChromaticAberration(): void;
  65980. /**
  65981. * Sets the EdgeDistortion amount
  65982. * @param amount amount of EdgeDistortion
  65983. */
  65984. setEdgeDistortion(amount: number): void;
  65985. /**
  65986. * Sets edge distortion to 0
  65987. */
  65988. disableEdgeDistortion(): void;
  65989. /**
  65990. * Sets the FocusDistance amount
  65991. * @param amount amount of FocusDistance
  65992. */
  65993. setFocusDistance(amount: number): void;
  65994. /**
  65995. * Disables depth of field
  65996. */
  65997. disableDepthOfField(): void;
  65998. /**
  65999. * Sets the Aperture amount
  66000. * @param amount amount of Aperture
  66001. */
  66002. setAperture(amount: number): void;
  66003. /**
  66004. * Sets the DarkenOutOfFocus amount
  66005. * @param amount amount of DarkenOutOfFocus
  66006. */
  66007. setDarkenOutOfFocus(amount: number): void;
  66008. private _pentagonBokehIsEnabled;
  66009. /**
  66010. * Creates a pentagon bokeh effect
  66011. */
  66012. enablePentagonBokeh(): void;
  66013. /**
  66014. * Disables the pentagon bokeh effect
  66015. */
  66016. disablePentagonBokeh(): void;
  66017. /**
  66018. * Enables noise blur
  66019. */
  66020. enableNoiseBlur(): void;
  66021. /**
  66022. * Disables noise blur
  66023. */
  66024. disableNoiseBlur(): void;
  66025. /**
  66026. * Sets the HighlightsGain amount
  66027. * @param amount amount of HighlightsGain
  66028. */
  66029. setHighlightsGain(amount: number): void;
  66030. /**
  66031. * Sets the HighlightsThreshold amount
  66032. * @param amount amount of HighlightsThreshold
  66033. */
  66034. setHighlightsThreshold(amount: number): void;
  66035. /**
  66036. * Disables highlights
  66037. */
  66038. disableHighlights(): void;
  66039. /**
  66040. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66041. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66042. */
  66043. dispose(disableDepthRender?: boolean): void;
  66044. private _createChromaticAberrationPostProcess;
  66045. private _createHighlightsPostProcess;
  66046. private _createDepthOfFieldPostProcess;
  66047. private _createGrainTexture;
  66048. }
  66049. }
  66050. declare module BABYLON {
  66051. /** @hidden */
  66052. export var ssao2PixelShader: {
  66053. name: string;
  66054. shader: string;
  66055. };
  66056. }
  66057. declare module BABYLON {
  66058. /** @hidden */
  66059. export var ssaoCombinePixelShader: {
  66060. name: string;
  66061. shader: string;
  66062. };
  66063. }
  66064. declare module BABYLON {
  66065. /**
  66066. * Render pipeline to produce ssao effect
  66067. */
  66068. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66069. /**
  66070. * @ignore
  66071. * The PassPostProcess id in the pipeline that contains the original scene color
  66072. */
  66073. SSAOOriginalSceneColorEffect: string;
  66074. /**
  66075. * @ignore
  66076. * The SSAO PostProcess id in the pipeline
  66077. */
  66078. SSAORenderEffect: string;
  66079. /**
  66080. * @ignore
  66081. * The horizontal blur PostProcess id in the pipeline
  66082. */
  66083. SSAOBlurHRenderEffect: string;
  66084. /**
  66085. * @ignore
  66086. * The vertical blur PostProcess id in the pipeline
  66087. */
  66088. SSAOBlurVRenderEffect: string;
  66089. /**
  66090. * @ignore
  66091. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66092. */
  66093. SSAOCombineRenderEffect: string;
  66094. /**
  66095. * The output strength of the SSAO post-process. Default value is 1.0.
  66096. */
  66097. totalStrength: number;
  66098. /**
  66099. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66100. */
  66101. maxZ: number;
  66102. /**
  66103. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66104. */
  66105. minZAspect: number;
  66106. private _samples;
  66107. /**
  66108. * Number of samples used for the SSAO calculations. Default value is 8
  66109. */
  66110. set samples(n: number);
  66111. get samples(): number;
  66112. private _textureSamples;
  66113. /**
  66114. * Number of samples to use for antialiasing
  66115. */
  66116. set textureSamples(n: number);
  66117. get textureSamples(): number;
  66118. /**
  66119. * Ratio object used for SSAO ratio and blur ratio
  66120. */
  66121. private _ratio;
  66122. /**
  66123. * Dynamically generated sphere sampler.
  66124. */
  66125. private _sampleSphere;
  66126. /**
  66127. * Blur filter offsets
  66128. */
  66129. private _samplerOffsets;
  66130. private _expensiveBlur;
  66131. /**
  66132. * If bilateral blur should be used
  66133. */
  66134. set expensiveBlur(b: boolean);
  66135. get expensiveBlur(): boolean;
  66136. /**
  66137. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66138. */
  66139. radius: number;
  66140. /**
  66141. * The base color of the SSAO post-process
  66142. * The final result is "base + ssao" between [0, 1]
  66143. */
  66144. base: number;
  66145. /**
  66146. * Support test.
  66147. */
  66148. static get IsSupported(): boolean;
  66149. private _scene;
  66150. private _depthTexture;
  66151. private _normalTexture;
  66152. private _randomTexture;
  66153. private _originalColorPostProcess;
  66154. private _ssaoPostProcess;
  66155. private _blurHPostProcess;
  66156. private _blurVPostProcess;
  66157. private _ssaoCombinePostProcess;
  66158. /**
  66159. * Gets active scene
  66160. */
  66161. get scene(): Scene;
  66162. /**
  66163. * @constructor
  66164. * @param name The rendering pipeline name
  66165. * @param scene The scene linked to this pipeline
  66166. * @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 }
  66167. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66168. */
  66169. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66170. /**
  66171. * Get the class name
  66172. * @returns "SSAO2RenderingPipeline"
  66173. */
  66174. getClassName(): string;
  66175. /**
  66176. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66177. */
  66178. dispose(disableGeometryBufferRenderer?: boolean): void;
  66179. private _createBlurPostProcess;
  66180. /** @hidden */
  66181. _rebuild(): void;
  66182. private _bits;
  66183. private _radicalInverse_VdC;
  66184. private _hammersley;
  66185. private _hemisphereSample_uniform;
  66186. private _generateHemisphere;
  66187. private _createSSAOPostProcess;
  66188. private _createSSAOCombinePostProcess;
  66189. private _createRandomTexture;
  66190. /**
  66191. * Serialize the rendering pipeline (Used when exporting)
  66192. * @returns the serialized object
  66193. */
  66194. serialize(): any;
  66195. /**
  66196. * Parse the serialized pipeline
  66197. * @param source Source pipeline.
  66198. * @param scene The scene to load the pipeline to.
  66199. * @param rootUrl The URL of the serialized pipeline.
  66200. * @returns An instantiated pipeline from the serialized object.
  66201. */
  66202. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66203. }
  66204. }
  66205. declare module BABYLON {
  66206. /** @hidden */
  66207. export var ssaoPixelShader: {
  66208. name: string;
  66209. shader: string;
  66210. };
  66211. }
  66212. declare module BABYLON {
  66213. /**
  66214. * Render pipeline to produce ssao effect
  66215. */
  66216. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66217. /**
  66218. * @ignore
  66219. * The PassPostProcess id in the pipeline that contains the original scene color
  66220. */
  66221. SSAOOriginalSceneColorEffect: string;
  66222. /**
  66223. * @ignore
  66224. * The SSAO PostProcess id in the pipeline
  66225. */
  66226. SSAORenderEffect: string;
  66227. /**
  66228. * @ignore
  66229. * The horizontal blur PostProcess id in the pipeline
  66230. */
  66231. SSAOBlurHRenderEffect: string;
  66232. /**
  66233. * @ignore
  66234. * The vertical blur PostProcess id in the pipeline
  66235. */
  66236. SSAOBlurVRenderEffect: string;
  66237. /**
  66238. * @ignore
  66239. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66240. */
  66241. SSAOCombineRenderEffect: string;
  66242. /**
  66243. * The output strength of the SSAO post-process. Default value is 1.0.
  66244. */
  66245. totalStrength: number;
  66246. /**
  66247. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66248. */
  66249. radius: number;
  66250. /**
  66251. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66252. * Must not be equal to fallOff and superior to fallOff.
  66253. * Default value is 0.0075
  66254. */
  66255. area: number;
  66256. /**
  66257. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66258. * Must not be equal to area and inferior to area.
  66259. * Default value is 0.000001
  66260. */
  66261. fallOff: number;
  66262. /**
  66263. * The base color of the SSAO post-process
  66264. * The final result is "base + ssao" between [0, 1]
  66265. */
  66266. base: number;
  66267. private _scene;
  66268. private _depthTexture;
  66269. private _randomTexture;
  66270. private _originalColorPostProcess;
  66271. private _ssaoPostProcess;
  66272. private _blurHPostProcess;
  66273. private _blurVPostProcess;
  66274. private _ssaoCombinePostProcess;
  66275. private _firstUpdate;
  66276. /**
  66277. * Gets active scene
  66278. */
  66279. get scene(): Scene;
  66280. /**
  66281. * @constructor
  66282. * @param name - The rendering pipeline name
  66283. * @param scene - The scene linked to this pipeline
  66284. * @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 }
  66285. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66286. */
  66287. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66288. /**
  66289. * Get the class name
  66290. * @returns "SSAORenderingPipeline"
  66291. */
  66292. getClassName(): string;
  66293. /**
  66294. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66295. */
  66296. dispose(disableDepthRender?: boolean): void;
  66297. private _createBlurPostProcess;
  66298. /** @hidden */
  66299. _rebuild(): void;
  66300. private _createSSAOPostProcess;
  66301. private _createSSAOCombinePostProcess;
  66302. private _createRandomTexture;
  66303. }
  66304. }
  66305. declare module BABYLON {
  66306. /** @hidden */
  66307. export var screenSpaceReflectionPixelShader: {
  66308. name: string;
  66309. shader: string;
  66310. };
  66311. }
  66312. declare module BABYLON {
  66313. /**
  66314. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66315. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66316. */
  66317. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66318. /**
  66319. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66320. */
  66321. threshold: number;
  66322. /**
  66323. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66324. */
  66325. strength: number;
  66326. /**
  66327. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66328. */
  66329. reflectionSpecularFalloffExponent: number;
  66330. /**
  66331. * 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]
  66332. */
  66333. step: number;
  66334. /**
  66335. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66336. */
  66337. roughnessFactor: number;
  66338. private _geometryBufferRenderer;
  66339. private _enableSmoothReflections;
  66340. private _reflectionSamples;
  66341. private _smoothSteps;
  66342. /**
  66343. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66344. * @param name The name of the effect.
  66345. * @param scene The scene containing the objects to calculate reflections.
  66346. * @param options The required width/height ratio to downsize to before computing the render pass.
  66347. * @param camera The camera to apply the render pass to.
  66348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66349. * @param engine The engine which the post process will be applied. (default: current engine)
  66350. * @param reusable If the post process can be reused on the same frame. (default: false)
  66351. * @param textureType Type of textures used when performing the post process. (default: 0)
  66352. * @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)
  66353. */
  66354. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66355. /**
  66356. * Gets wether or not smoothing reflections is enabled.
  66357. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66358. */
  66359. get enableSmoothReflections(): boolean;
  66360. /**
  66361. * Sets wether or not smoothing reflections is enabled.
  66362. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66363. */
  66364. set enableSmoothReflections(enabled: boolean);
  66365. /**
  66366. * Gets the number of samples taken while computing reflections. More samples count is high,
  66367. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66368. */
  66369. get reflectionSamples(): number;
  66370. /**
  66371. * Sets the number of samples taken while computing reflections. More samples count is high,
  66372. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66373. */
  66374. set reflectionSamples(samples: number);
  66375. /**
  66376. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66377. * more the post-process will require GPU power and can generate a drop in FPS.
  66378. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66379. */
  66380. get smoothSteps(): number;
  66381. set smoothSteps(steps: number);
  66382. private _updateEffectDefines;
  66383. }
  66384. }
  66385. declare module BABYLON {
  66386. /** @hidden */
  66387. export var standardPixelShader: {
  66388. name: string;
  66389. shader: string;
  66390. };
  66391. }
  66392. declare module BABYLON {
  66393. /**
  66394. * Standard rendering pipeline
  66395. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66396. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66397. */
  66398. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66399. /**
  66400. * Public members
  66401. */
  66402. /**
  66403. * Post-process which contains the original scene color before the pipeline applies all the effects
  66404. */
  66405. originalPostProcess: Nullable<PostProcess>;
  66406. /**
  66407. * Post-process used to down scale an image x4
  66408. */
  66409. downSampleX4PostProcess: Nullable<PostProcess>;
  66410. /**
  66411. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66412. */
  66413. brightPassPostProcess: Nullable<PostProcess>;
  66414. /**
  66415. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66416. */
  66417. blurHPostProcesses: PostProcess[];
  66418. /**
  66419. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66420. */
  66421. blurVPostProcesses: PostProcess[];
  66422. /**
  66423. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66424. */
  66425. textureAdderPostProcess: Nullable<PostProcess>;
  66426. /**
  66427. * Post-process used to create volumetric lighting effect
  66428. */
  66429. volumetricLightPostProcess: Nullable<PostProcess>;
  66430. /**
  66431. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66432. */
  66433. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66434. /**
  66435. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66436. */
  66437. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66438. /**
  66439. * Post-process used to merge the volumetric light effect and the real scene color
  66440. */
  66441. volumetricLightMergePostProces: Nullable<PostProcess>;
  66442. /**
  66443. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66444. */
  66445. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66446. /**
  66447. * Base post-process used to calculate the average luminance of the final image for HDR
  66448. */
  66449. luminancePostProcess: Nullable<PostProcess>;
  66450. /**
  66451. * Post-processes used to create down sample post-processes in order to get
  66452. * the average luminance of the final image for HDR
  66453. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66454. */
  66455. luminanceDownSamplePostProcesses: PostProcess[];
  66456. /**
  66457. * Post-process used to create a HDR effect (light adaptation)
  66458. */
  66459. hdrPostProcess: Nullable<PostProcess>;
  66460. /**
  66461. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66462. */
  66463. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66464. /**
  66465. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66466. */
  66467. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66468. /**
  66469. * Post-process used to merge the final HDR post-process and the real scene color
  66470. */
  66471. hdrFinalPostProcess: Nullable<PostProcess>;
  66472. /**
  66473. * Post-process used to create a lens flare effect
  66474. */
  66475. lensFlarePostProcess: Nullable<PostProcess>;
  66476. /**
  66477. * Post-process that merges the result of the lens flare post-process and the real scene color
  66478. */
  66479. lensFlareComposePostProcess: Nullable<PostProcess>;
  66480. /**
  66481. * Post-process used to create a motion blur effect
  66482. */
  66483. motionBlurPostProcess: Nullable<PostProcess>;
  66484. /**
  66485. * Post-process used to create a depth of field effect
  66486. */
  66487. depthOfFieldPostProcess: Nullable<PostProcess>;
  66488. /**
  66489. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66490. */
  66491. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66492. /**
  66493. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66494. */
  66495. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66496. /**
  66497. * Represents the brightness threshold in order to configure the illuminated surfaces
  66498. */
  66499. brightThreshold: number;
  66500. /**
  66501. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66502. */
  66503. blurWidth: number;
  66504. /**
  66505. * Sets if the blur for highlighted surfaces must be only horizontal
  66506. */
  66507. horizontalBlur: boolean;
  66508. /**
  66509. * Gets the overall exposure used by the pipeline
  66510. */
  66511. get exposure(): number;
  66512. /**
  66513. * Sets the overall exposure used by the pipeline
  66514. */
  66515. set exposure(value: number);
  66516. /**
  66517. * Texture used typically to simulate "dirty" on camera lens
  66518. */
  66519. lensTexture: Nullable<Texture>;
  66520. /**
  66521. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66522. */
  66523. volumetricLightCoefficient: number;
  66524. /**
  66525. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66526. */
  66527. volumetricLightPower: number;
  66528. /**
  66529. * Used the set the blur intensity to smooth the volumetric lights
  66530. */
  66531. volumetricLightBlurScale: number;
  66532. /**
  66533. * Light (spot or directional) used to generate the volumetric lights rays
  66534. * The source light must have a shadow generate so the pipeline can get its
  66535. * depth map
  66536. */
  66537. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66538. /**
  66539. * For eye adaptation, represents the minimum luminance the eye can see
  66540. */
  66541. hdrMinimumLuminance: number;
  66542. /**
  66543. * For eye adaptation, represents the decrease luminance speed
  66544. */
  66545. hdrDecreaseRate: number;
  66546. /**
  66547. * For eye adaptation, represents the increase luminance speed
  66548. */
  66549. hdrIncreaseRate: number;
  66550. /**
  66551. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66552. */
  66553. get hdrAutoExposure(): boolean;
  66554. /**
  66555. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66556. */
  66557. set hdrAutoExposure(value: boolean);
  66558. /**
  66559. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66560. */
  66561. lensColorTexture: Nullable<Texture>;
  66562. /**
  66563. * The overall strengh for the lens flare effect
  66564. */
  66565. lensFlareStrength: number;
  66566. /**
  66567. * Dispersion coefficient for lens flare ghosts
  66568. */
  66569. lensFlareGhostDispersal: number;
  66570. /**
  66571. * Main lens flare halo width
  66572. */
  66573. lensFlareHaloWidth: number;
  66574. /**
  66575. * Based on the lens distortion effect, defines how much the lens flare result
  66576. * is distorted
  66577. */
  66578. lensFlareDistortionStrength: number;
  66579. /**
  66580. * Configures the blur intensity used for for lens flare (halo)
  66581. */
  66582. lensFlareBlurWidth: number;
  66583. /**
  66584. * Lens star texture must be used to simulate rays on the flares and is available
  66585. * in the documentation
  66586. */
  66587. lensStarTexture: Nullable<Texture>;
  66588. /**
  66589. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66590. * flare effect by taking account of the dirt texture
  66591. */
  66592. lensFlareDirtTexture: Nullable<Texture>;
  66593. /**
  66594. * Represents the focal length for the depth of field effect
  66595. */
  66596. depthOfFieldDistance: number;
  66597. /**
  66598. * Represents the blur intensity for the blurred part of the depth of field effect
  66599. */
  66600. depthOfFieldBlurWidth: number;
  66601. /**
  66602. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66603. */
  66604. get motionStrength(): number;
  66605. /**
  66606. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66607. */
  66608. set motionStrength(strength: number);
  66609. /**
  66610. * Gets wether or not the motion blur post-process is object based or screen based.
  66611. */
  66612. get objectBasedMotionBlur(): boolean;
  66613. /**
  66614. * Sets wether or not the motion blur post-process should be object based or screen based
  66615. */
  66616. set objectBasedMotionBlur(value: boolean);
  66617. /**
  66618. * List of animations for the pipeline (IAnimatable implementation)
  66619. */
  66620. animations: Animation[];
  66621. /**
  66622. * Private members
  66623. */
  66624. private _scene;
  66625. private _currentDepthOfFieldSource;
  66626. private _basePostProcess;
  66627. private _fixedExposure;
  66628. private _currentExposure;
  66629. private _hdrAutoExposure;
  66630. private _hdrCurrentLuminance;
  66631. private _motionStrength;
  66632. private _isObjectBasedMotionBlur;
  66633. private _floatTextureType;
  66634. private _camerasToBeAttached;
  66635. private _ratio;
  66636. private _bloomEnabled;
  66637. private _depthOfFieldEnabled;
  66638. private _vlsEnabled;
  66639. private _lensFlareEnabled;
  66640. private _hdrEnabled;
  66641. private _motionBlurEnabled;
  66642. private _fxaaEnabled;
  66643. private _screenSpaceReflectionsEnabled;
  66644. private _motionBlurSamples;
  66645. private _volumetricLightStepsCount;
  66646. private _samples;
  66647. /**
  66648. * @ignore
  66649. * Specifies if the bloom pipeline is enabled
  66650. */
  66651. get BloomEnabled(): boolean;
  66652. set BloomEnabled(enabled: boolean);
  66653. /**
  66654. * @ignore
  66655. * Specifies if the depth of field pipeline is enabed
  66656. */
  66657. get DepthOfFieldEnabled(): boolean;
  66658. set DepthOfFieldEnabled(enabled: boolean);
  66659. /**
  66660. * @ignore
  66661. * Specifies if the lens flare pipeline is enabed
  66662. */
  66663. get LensFlareEnabled(): boolean;
  66664. set LensFlareEnabled(enabled: boolean);
  66665. /**
  66666. * @ignore
  66667. * Specifies if the HDR pipeline is enabled
  66668. */
  66669. get HDREnabled(): boolean;
  66670. set HDREnabled(enabled: boolean);
  66671. /**
  66672. * @ignore
  66673. * Specifies if the volumetric lights scattering effect is enabled
  66674. */
  66675. get VLSEnabled(): boolean;
  66676. set VLSEnabled(enabled: boolean);
  66677. /**
  66678. * @ignore
  66679. * Specifies if the motion blur effect is enabled
  66680. */
  66681. get MotionBlurEnabled(): boolean;
  66682. set MotionBlurEnabled(enabled: boolean);
  66683. /**
  66684. * Specifies if anti-aliasing is enabled
  66685. */
  66686. get fxaaEnabled(): boolean;
  66687. set fxaaEnabled(enabled: boolean);
  66688. /**
  66689. * Specifies if screen space reflections are enabled.
  66690. */
  66691. get screenSpaceReflectionsEnabled(): boolean;
  66692. set screenSpaceReflectionsEnabled(enabled: boolean);
  66693. /**
  66694. * Specifies the number of steps used to calculate the volumetric lights
  66695. * Typically in interval [50, 200]
  66696. */
  66697. get volumetricLightStepsCount(): number;
  66698. set volumetricLightStepsCount(count: number);
  66699. /**
  66700. * Specifies the number of samples used for the motion blur effect
  66701. * Typically in interval [16, 64]
  66702. */
  66703. get motionBlurSamples(): number;
  66704. set motionBlurSamples(samples: number);
  66705. /**
  66706. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66707. */
  66708. get samples(): number;
  66709. set samples(sampleCount: number);
  66710. /**
  66711. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66712. * @constructor
  66713. * @param name The rendering pipeline name
  66714. * @param scene The scene linked to this pipeline
  66715. * @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)
  66716. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66717. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66718. */
  66719. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66720. private _buildPipeline;
  66721. private _createDownSampleX4PostProcess;
  66722. private _createBrightPassPostProcess;
  66723. private _createBlurPostProcesses;
  66724. private _createTextureAdderPostProcess;
  66725. private _createVolumetricLightPostProcess;
  66726. private _createLuminancePostProcesses;
  66727. private _createHdrPostProcess;
  66728. private _createLensFlarePostProcess;
  66729. private _createDepthOfFieldPostProcess;
  66730. private _createMotionBlurPostProcess;
  66731. private _getDepthTexture;
  66732. private _disposePostProcesses;
  66733. /**
  66734. * Dispose of the pipeline and stop all post processes
  66735. */
  66736. dispose(): void;
  66737. /**
  66738. * Serialize the rendering pipeline (Used when exporting)
  66739. * @returns the serialized object
  66740. */
  66741. serialize(): any;
  66742. /**
  66743. * Parse the serialized pipeline
  66744. * @param source Source pipeline.
  66745. * @param scene The scene to load the pipeline to.
  66746. * @param rootUrl The URL of the serialized pipeline.
  66747. * @returns An instantiated pipeline from the serialized object.
  66748. */
  66749. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66750. /**
  66751. * Luminance steps
  66752. */
  66753. static LuminanceSteps: number;
  66754. }
  66755. }
  66756. declare module BABYLON {
  66757. /** @hidden */
  66758. export var tonemapPixelShader: {
  66759. name: string;
  66760. shader: string;
  66761. };
  66762. }
  66763. declare module BABYLON {
  66764. /** Defines operator used for tonemapping */
  66765. export enum TonemappingOperator {
  66766. /** Hable */
  66767. Hable = 0,
  66768. /** Reinhard */
  66769. Reinhard = 1,
  66770. /** HejiDawson */
  66771. HejiDawson = 2,
  66772. /** Photographic */
  66773. Photographic = 3
  66774. }
  66775. /**
  66776. * Defines a post process to apply tone mapping
  66777. */
  66778. export class TonemapPostProcess extends PostProcess {
  66779. private _operator;
  66780. /** Defines the required exposure adjustement */
  66781. exposureAdjustment: number;
  66782. /**
  66783. * Creates a new TonemapPostProcess
  66784. * @param name defines the name of the postprocess
  66785. * @param _operator defines the operator to use
  66786. * @param exposureAdjustment defines the required exposure adjustement
  66787. * @param camera defines the camera to use (can be null)
  66788. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66789. * @param engine defines the hosting engine (can be ignore if camera is set)
  66790. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66791. */
  66792. constructor(name: string, _operator: TonemappingOperator,
  66793. /** Defines the required exposure adjustement */
  66794. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66795. }
  66796. }
  66797. declare module BABYLON {
  66798. /** @hidden */
  66799. export var volumetricLightScatteringPixelShader: {
  66800. name: string;
  66801. shader: string;
  66802. };
  66803. }
  66804. declare module BABYLON {
  66805. /** @hidden */
  66806. export var volumetricLightScatteringPassVertexShader: {
  66807. name: string;
  66808. shader: string;
  66809. };
  66810. }
  66811. declare module BABYLON {
  66812. /** @hidden */
  66813. export var volumetricLightScatteringPassPixelShader: {
  66814. name: string;
  66815. shader: string;
  66816. };
  66817. }
  66818. declare module BABYLON {
  66819. /**
  66820. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66821. */
  66822. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66823. private _volumetricLightScatteringPass;
  66824. private _volumetricLightScatteringRTT;
  66825. private _viewPort;
  66826. private _screenCoordinates;
  66827. private _cachedDefines;
  66828. /**
  66829. * If not undefined, the mesh position is computed from the attached node position
  66830. */
  66831. attachedNode: {
  66832. position: Vector3;
  66833. };
  66834. /**
  66835. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66836. */
  66837. customMeshPosition: Vector3;
  66838. /**
  66839. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66840. */
  66841. useCustomMeshPosition: boolean;
  66842. /**
  66843. * If the post-process should inverse the light scattering direction
  66844. */
  66845. invert: boolean;
  66846. /**
  66847. * The internal mesh used by the post-process
  66848. */
  66849. mesh: Mesh;
  66850. /**
  66851. * @hidden
  66852. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66853. */
  66854. get useDiffuseColor(): boolean;
  66855. set useDiffuseColor(useDiffuseColor: boolean);
  66856. /**
  66857. * Array containing the excluded meshes not rendered in the internal pass
  66858. */
  66859. excludedMeshes: AbstractMesh[];
  66860. /**
  66861. * Controls the overall intensity of the post-process
  66862. */
  66863. exposure: number;
  66864. /**
  66865. * Dissipates each sample's contribution in range [0, 1]
  66866. */
  66867. decay: number;
  66868. /**
  66869. * Controls the overall intensity of each sample
  66870. */
  66871. weight: number;
  66872. /**
  66873. * Controls the density of each sample
  66874. */
  66875. density: number;
  66876. /**
  66877. * @constructor
  66878. * @param name The post-process name
  66879. * @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)
  66880. * @param camera The camera that the post-process will be attached to
  66881. * @param mesh The mesh used to create the light scattering
  66882. * @param samples The post-process quality, default 100
  66883. * @param samplingModeThe post-process filtering mode
  66884. * @param engine The babylon engine
  66885. * @param reusable If the post-process is reusable
  66886. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66887. */
  66888. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66889. /**
  66890. * Returns the string "VolumetricLightScatteringPostProcess"
  66891. * @returns "VolumetricLightScatteringPostProcess"
  66892. */
  66893. getClassName(): string;
  66894. private _isReady;
  66895. /**
  66896. * Sets the new light position for light scattering effect
  66897. * @param position The new custom light position
  66898. */
  66899. setCustomMeshPosition(position: Vector3): void;
  66900. /**
  66901. * Returns the light position for light scattering effect
  66902. * @return Vector3 The custom light position
  66903. */
  66904. getCustomMeshPosition(): Vector3;
  66905. /**
  66906. * Disposes the internal assets and detaches the post-process from the camera
  66907. */
  66908. dispose(camera: Camera): void;
  66909. /**
  66910. * Returns the render target texture used by the post-process
  66911. * @return the render target texture used by the post-process
  66912. */
  66913. getPass(): RenderTargetTexture;
  66914. private _meshExcluded;
  66915. private _createPass;
  66916. private _updateMeshScreenCoordinates;
  66917. /**
  66918. * Creates a default mesh for the Volumeric Light Scattering post-process
  66919. * @param name The mesh name
  66920. * @param scene The scene where to create the mesh
  66921. * @return the default mesh
  66922. */
  66923. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66924. }
  66925. }
  66926. declare module BABYLON {
  66927. interface Scene {
  66928. /** @hidden (Backing field) */
  66929. _boundingBoxRenderer: BoundingBoxRenderer;
  66930. /** @hidden (Backing field) */
  66931. _forceShowBoundingBoxes: boolean;
  66932. /**
  66933. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66934. */
  66935. forceShowBoundingBoxes: boolean;
  66936. /**
  66937. * Gets the bounding box renderer associated with the scene
  66938. * @returns a BoundingBoxRenderer
  66939. */
  66940. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66941. }
  66942. interface AbstractMesh {
  66943. /** @hidden (Backing field) */
  66944. _showBoundingBox: boolean;
  66945. /**
  66946. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66947. */
  66948. showBoundingBox: boolean;
  66949. }
  66950. /**
  66951. * Component responsible of rendering the bounding box of the meshes in a scene.
  66952. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66953. */
  66954. export class BoundingBoxRenderer implements ISceneComponent {
  66955. /**
  66956. * The component name helpfull to identify the component in the list of scene components.
  66957. */
  66958. readonly name: string;
  66959. /**
  66960. * The scene the component belongs to.
  66961. */
  66962. scene: Scene;
  66963. /**
  66964. * Color of the bounding box lines placed in front of an object
  66965. */
  66966. frontColor: Color3;
  66967. /**
  66968. * Color of the bounding box lines placed behind an object
  66969. */
  66970. backColor: Color3;
  66971. /**
  66972. * Defines if the renderer should show the back lines or not
  66973. */
  66974. showBackLines: boolean;
  66975. /**
  66976. * @hidden
  66977. */
  66978. renderList: SmartArray<BoundingBox>;
  66979. private _colorShader;
  66980. private _vertexBuffers;
  66981. private _indexBuffer;
  66982. private _fillIndexBuffer;
  66983. private _fillIndexData;
  66984. /**
  66985. * Instantiates a new bounding box renderer in a scene.
  66986. * @param scene the scene the renderer renders in
  66987. */
  66988. constructor(scene: Scene);
  66989. /**
  66990. * Registers the component in a given scene
  66991. */
  66992. register(): void;
  66993. private _evaluateSubMesh;
  66994. private _activeMesh;
  66995. private _prepareRessources;
  66996. private _createIndexBuffer;
  66997. /**
  66998. * Rebuilds the elements related to this component in case of
  66999. * context lost for instance.
  67000. */
  67001. rebuild(): void;
  67002. /**
  67003. * @hidden
  67004. */
  67005. reset(): void;
  67006. /**
  67007. * Render the bounding boxes of a specific rendering group
  67008. * @param renderingGroupId defines the rendering group to render
  67009. */
  67010. render(renderingGroupId: number): void;
  67011. /**
  67012. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67013. * @param mesh Define the mesh to render the occlusion bounding box for
  67014. */
  67015. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67016. /**
  67017. * Dispose and release the resources attached to this renderer.
  67018. */
  67019. dispose(): void;
  67020. }
  67021. }
  67022. declare module BABYLON {
  67023. interface Scene {
  67024. /** @hidden (Backing field) */
  67025. _depthRenderer: {
  67026. [id: string]: DepthRenderer;
  67027. };
  67028. /**
  67029. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67030. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67031. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67032. * @returns the created depth renderer
  67033. */
  67034. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67035. /**
  67036. * Disables a depth renderer for a given camera
  67037. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67038. */
  67039. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67040. }
  67041. /**
  67042. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67043. * in several rendering techniques.
  67044. */
  67045. export class DepthRendererSceneComponent implements ISceneComponent {
  67046. /**
  67047. * The component name helpfull to identify the component in the list of scene components.
  67048. */
  67049. readonly name: string;
  67050. /**
  67051. * The scene the component belongs to.
  67052. */
  67053. scene: Scene;
  67054. /**
  67055. * Creates a new instance of the component for the given scene
  67056. * @param scene Defines the scene to register the component in
  67057. */
  67058. constructor(scene: Scene);
  67059. /**
  67060. * Registers the component in a given scene
  67061. */
  67062. register(): void;
  67063. /**
  67064. * Rebuilds the elements related to this component in case of
  67065. * context lost for instance.
  67066. */
  67067. rebuild(): void;
  67068. /**
  67069. * Disposes the component and the associated ressources
  67070. */
  67071. dispose(): void;
  67072. private _gatherRenderTargets;
  67073. private _gatherActiveCameraRenderTargets;
  67074. }
  67075. }
  67076. declare module BABYLON {
  67077. /** @hidden */
  67078. export var outlinePixelShader: {
  67079. name: string;
  67080. shader: string;
  67081. };
  67082. }
  67083. declare module BABYLON {
  67084. /** @hidden */
  67085. export var outlineVertexShader: {
  67086. name: string;
  67087. shader: string;
  67088. };
  67089. }
  67090. declare module BABYLON {
  67091. interface Scene {
  67092. /** @hidden */
  67093. _outlineRenderer: OutlineRenderer;
  67094. /**
  67095. * Gets the outline renderer associated with the scene
  67096. * @returns a OutlineRenderer
  67097. */
  67098. getOutlineRenderer(): OutlineRenderer;
  67099. }
  67100. interface AbstractMesh {
  67101. /** @hidden (Backing field) */
  67102. _renderOutline: boolean;
  67103. /**
  67104. * Gets or sets a boolean indicating if the outline must be rendered as well
  67105. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67106. */
  67107. renderOutline: boolean;
  67108. /** @hidden (Backing field) */
  67109. _renderOverlay: boolean;
  67110. /**
  67111. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67112. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67113. */
  67114. renderOverlay: boolean;
  67115. }
  67116. /**
  67117. * This class is responsible to draw bothe outline/overlay of meshes.
  67118. * It should not be used directly but through the available method on mesh.
  67119. */
  67120. export class OutlineRenderer implements ISceneComponent {
  67121. /**
  67122. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67123. */
  67124. private static _StencilReference;
  67125. /**
  67126. * The name of the component. Each component must have a unique name.
  67127. */
  67128. name: string;
  67129. /**
  67130. * The scene the component belongs to.
  67131. */
  67132. scene: Scene;
  67133. /**
  67134. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67135. */
  67136. zOffset: number;
  67137. private _engine;
  67138. private _effect;
  67139. private _cachedDefines;
  67140. private _savedDepthWrite;
  67141. /**
  67142. * Instantiates a new outline renderer. (There could be only one per scene).
  67143. * @param scene Defines the scene it belongs to
  67144. */
  67145. constructor(scene: Scene);
  67146. /**
  67147. * Register the component to one instance of a scene.
  67148. */
  67149. register(): void;
  67150. /**
  67151. * Rebuilds the elements related to this component in case of
  67152. * context lost for instance.
  67153. */
  67154. rebuild(): void;
  67155. /**
  67156. * Disposes the component and the associated ressources.
  67157. */
  67158. dispose(): void;
  67159. /**
  67160. * Renders the outline in the canvas.
  67161. * @param subMesh Defines the sumesh to render
  67162. * @param batch Defines the batch of meshes in case of instances
  67163. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67164. */
  67165. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67166. /**
  67167. * Returns whether or not the outline renderer is ready for a given submesh.
  67168. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67169. * @param subMesh Defines the submesh to check readyness for
  67170. * @param useInstances Defines wheter wee are trying to render instances or not
  67171. * @returns true if ready otherwise false
  67172. */
  67173. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67174. private _beforeRenderingMesh;
  67175. private _afterRenderingMesh;
  67176. }
  67177. }
  67178. declare module BABYLON {
  67179. /**
  67180. * Defines the basic options interface of a Sprite Frame Source Size.
  67181. */
  67182. export interface ISpriteJSONSpriteSourceSize {
  67183. /**
  67184. * number of the original width of the Frame
  67185. */
  67186. w: number;
  67187. /**
  67188. * number of the original height of the Frame
  67189. */
  67190. h: number;
  67191. }
  67192. /**
  67193. * Defines the basic options interface of a Sprite Frame Data.
  67194. */
  67195. export interface ISpriteJSONSpriteFrameData {
  67196. /**
  67197. * number of the x offset of the Frame
  67198. */
  67199. x: number;
  67200. /**
  67201. * number of the y offset of the Frame
  67202. */
  67203. y: number;
  67204. /**
  67205. * number of the width of the Frame
  67206. */
  67207. w: number;
  67208. /**
  67209. * number of the height of the Frame
  67210. */
  67211. h: number;
  67212. }
  67213. /**
  67214. * Defines the basic options interface of a JSON Sprite.
  67215. */
  67216. export interface ISpriteJSONSprite {
  67217. /**
  67218. * string name of the Frame
  67219. */
  67220. filename: string;
  67221. /**
  67222. * ISpriteJSONSpriteFrame basic object of the frame data
  67223. */
  67224. frame: ISpriteJSONSpriteFrameData;
  67225. /**
  67226. * boolean to flag is the frame was rotated.
  67227. */
  67228. rotated: boolean;
  67229. /**
  67230. * boolean to flag is the frame was trimmed.
  67231. */
  67232. trimmed: boolean;
  67233. /**
  67234. * ISpriteJSONSpriteFrame basic object of the source data
  67235. */
  67236. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67237. /**
  67238. * ISpriteJSONSpriteFrame basic object of the source data
  67239. */
  67240. sourceSize: ISpriteJSONSpriteSourceSize;
  67241. }
  67242. /**
  67243. * Defines the basic options interface of a JSON atlas.
  67244. */
  67245. export interface ISpriteJSONAtlas {
  67246. /**
  67247. * Array of objects that contain the frame data.
  67248. */
  67249. frames: Array<ISpriteJSONSprite>;
  67250. /**
  67251. * object basic object containing the sprite meta data.
  67252. */
  67253. meta?: object;
  67254. }
  67255. }
  67256. declare module BABYLON {
  67257. /** @hidden */
  67258. export var spriteMapPixelShader: {
  67259. name: string;
  67260. shader: string;
  67261. };
  67262. }
  67263. declare module BABYLON {
  67264. /** @hidden */
  67265. export var spriteMapVertexShader: {
  67266. name: string;
  67267. shader: string;
  67268. };
  67269. }
  67270. declare module BABYLON {
  67271. /**
  67272. * Defines the basic options interface of a SpriteMap
  67273. */
  67274. export interface ISpriteMapOptions {
  67275. /**
  67276. * Vector2 of the number of cells in the grid.
  67277. */
  67278. stageSize?: Vector2;
  67279. /**
  67280. * Vector2 of the size of the output plane in World Units.
  67281. */
  67282. outputSize?: Vector2;
  67283. /**
  67284. * Vector3 of the position of the output plane in World Units.
  67285. */
  67286. outputPosition?: Vector3;
  67287. /**
  67288. * Vector3 of the rotation of the output plane.
  67289. */
  67290. outputRotation?: Vector3;
  67291. /**
  67292. * number of layers that the system will reserve in resources.
  67293. */
  67294. layerCount?: number;
  67295. /**
  67296. * number of max animation frames a single cell will reserve in resources.
  67297. */
  67298. maxAnimationFrames?: number;
  67299. /**
  67300. * number cell index of the base tile when the system compiles.
  67301. */
  67302. baseTile?: number;
  67303. /**
  67304. * boolean flip the sprite after its been repositioned by the framing data.
  67305. */
  67306. flipU?: boolean;
  67307. /**
  67308. * Vector3 scalar of the global RGB values of the SpriteMap.
  67309. */
  67310. colorMultiply?: Vector3;
  67311. }
  67312. /**
  67313. * Defines the IDisposable interface in order to be cleanable from resources.
  67314. */
  67315. export interface ISpriteMap extends IDisposable {
  67316. /**
  67317. * String name of the SpriteMap.
  67318. */
  67319. name: string;
  67320. /**
  67321. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67322. */
  67323. atlasJSON: ISpriteJSONAtlas;
  67324. /**
  67325. * Texture of the SpriteMap.
  67326. */
  67327. spriteSheet: Texture;
  67328. /**
  67329. * The parameters to initialize the SpriteMap with.
  67330. */
  67331. options: ISpriteMapOptions;
  67332. }
  67333. /**
  67334. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67335. */
  67336. export class SpriteMap implements ISpriteMap {
  67337. /** The Name of the spriteMap */
  67338. name: string;
  67339. /** The JSON file with the frame and meta data */
  67340. atlasJSON: ISpriteJSONAtlas;
  67341. /** The systems Sprite Sheet Texture */
  67342. spriteSheet: Texture;
  67343. /** Arguments passed with the Constructor */
  67344. options: ISpriteMapOptions;
  67345. /** Public Sprite Storage array, parsed from atlasJSON */
  67346. sprites: Array<ISpriteJSONSprite>;
  67347. /** Returns the Number of Sprites in the System */
  67348. get spriteCount(): number;
  67349. /** Returns the Position of Output Plane*/
  67350. get position(): Vector3;
  67351. /** Returns the Position of Output Plane*/
  67352. set position(v: Vector3);
  67353. /** Returns the Rotation of Output Plane*/
  67354. get rotation(): Vector3;
  67355. /** Returns the Rotation of Output Plane*/
  67356. set rotation(v: Vector3);
  67357. /** Sets the AnimationMap*/
  67358. get animationMap(): RawTexture;
  67359. /** Sets the AnimationMap*/
  67360. set animationMap(v: RawTexture);
  67361. /** Scene that the SpriteMap was created in */
  67362. private _scene;
  67363. /** Texture Buffer of Float32 that holds tile frame data*/
  67364. private _frameMap;
  67365. /** Texture Buffers of Float32 that holds tileMap data*/
  67366. private _tileMaps;
  67367. /** Texture Buffer of Float32 that holds Animation Data*/
  67368. private _animationMap;
  67369. /** Custom ShaderMaterial Central to the System*/
  67370. private _material;
  67371. /** Custom ShaderMaterial Central to the System*/
  67372. private _output;
  67373. /** Systems Time Ticker*/
  67374. private _time;
  67375. /**
  67376. * Creates a new SpriteMap
  67377. * @param name defines the SpriteMaps Name
  67378. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67379. * @param spriteSheet is the Texture that the Sprites are on.
  67380. * @param options a basic deployment configuration
  67381. * @param scene The Scene that the map is deployed on
  67382. */
  67383. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67384. /**
  67385. * Returns tileID location
  67386. * @returns Vector2 the cell position ID
  67387. */
  67388. getTileID(): Vector2;
  67389. /**
  67390. * Gets the UV location of the mouse over the SpriteMap.
  67391. * @returns Vector2 the UV position of the mouse interaction
  67392. */
  67393. getMousePosition(): Vector2;
  67394. /**
  67395. * Creates the "frame" texture Buffer
  67396. * -------------------------------------
  67397. * Structure of frames
  67398. * "filename": "Falling-Water-2.png",
  67399. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67400. * "rotated": true,
  67401. * "trimmed": true,
  67402. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67403. * "sourceSize": {"w":32,"h":32}
  67404. * @returns RawTexture of the frameMap
  67405. */
  67406. private _createFrameBuffer;
  67407. /**
  67408. * Creates the tileMap texture Buffer
  67409. * @param buffer normally and array of numbers, or a false to generate from scratch
  67410. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67411. * @returns RawTexture of the tileMap
  67412. */
  67413. private _createTileBuffer;
  67414. /**
  67415. * Modifies the data of the tileMaps
  67416. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67417. * @param pos is the iVector2 Coordinates of the Tile
  67418. * @param tile The SpriteIndex of the new Tile
  67419. */
  67420. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67421. /**
  67422. * Creates the animationMap texture Buffer
  67423. * @param buffer normally and array of numbers, or a false to generate from scratch
  67424. * @returns RawTexture of the animationMap
  67425. */
  67426. private _createTileAnimationBuffer;
  67427. /**
  67428. * Modifies the data of the animationMap
  67429. * @param cellID is the Index of the Sprite
  67430. * @param _frame is the target Animation frame
  67431. * @param toCell is the Target Index of the next frame of the animation
  67432. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67433. * @param speed is a global scalar of the time variable on the map.
  67434. */
  67435. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67436. /**
  67437. * Exports the .tilemaps file
  67438. */
  67439. saveTileMaps(): void;
  67440. /**
  67441. * Imports the .tilemaps file
  67442. * @param url of the .tilemaps file
  67443. */
  67444. loadTileMaps(url: string): void;
  67445. /**
  67446. * Release associated resources
  67447. */
  67448. dispose(): void;
  67449. }
  67450. }
  67451. declare module BABYLON {
  67452. /**
  67453. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67454. * @see http://doc.babylonjs.com/babylon101/sprites
  67455. */
  67456. export class SpritePackedManager extends SpriteManager {
  67457. /** defines the packed manager's name */
  67458. name: string;
  67459. /**
  67460. * Creates a new sprite manager from a packed sprite sheet
  67461. * @param name defines the manager's name
  67462. * @param imgUrl defines the sprite sheet url
  67463. * @param capacity defines the maximum allowed number of sprites
  67464. * @param scene defines the hosting scene
  67465. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67466. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67467. * @param samplingMode defines the smapling mode to use with spritesheet
  67468. * @param fromPacked set to true; do not alter
  67469. */
  67470. constructor(
  67471. /** defines the packed manager's name */
  67472. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67473. }
  67474. }
  67475. declare module BABYLON {
  67476. /**
  67477. * Defines the list of states available for a task inside a AssetsManager
  67478. */
  67479. export enum AssetTaskState {
  67480. /**
  67481. * Initialization
  67482. */
  67483. INIT = 0,
  67484. /**
  67485. * Running
  67486. */
  67487. RUNNING = 1,
  67488. /**
  67489. * Done
  67490. */
  67491. DONE = 2,
  67492. /**
  67493. * Error
  67494. */
  67495. ERROR = 3
  67496. }
  67497. /**
  67498. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67499. */
  67500. export abstract class AbstractAssetTask {
  67501. /**
  67502. * Task name
  67503. */ name: string;
  67504. /**
  67505. * Callback called when the task is successful
  67506. */
  67507. onSuccess: (task: any) => void;
  67508. /**
  67509. * Callback called when the task is not successful
  67510. */
  67511. onError: (task: any, message?: string, exception?: any) => void;
  67512. /**
  67513. * Creates a new AssetsManager
  67514. * @param name defines the name of the task
  67515. */
  67516. constructor(
  67517. /**
  67518. * Task name
  67519. */ name: string);
  67520. private _isCompleted;
  67521. private _taskState;
  67522. private _errorObject;
  67523. /**
  67524. * Get if the task is completed
  67525. */
  67526. get isCompleted(): boolean;
  67527. /**
  67528. * Gets the current state of the task
  67529. */
  67530. get taskState(): AssetTaskState;
  67531. /**
  67532. * Gets the current error object (if task is in error)
  67533. */
  67534. get errorObject(): {
  67535. message?: string;
  67536. exception?: any;
  67537. };
  67538. /**
  67539. * Internal only
  67540. * @hidden
  67541. */
  67542. _setErrorObject(message?: string, exception?: any): void;
  67543. /**
  67544. * Execute the current task
  67545. * @param scene defines the scene where you want your assets to be loaded
  67546. * @param onSuccess is a callback called when the task is successfully executed
  67547. * @param onError is a callback called if an error occurs
  67548. */
  67549. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67550. /**
  67551. * Execute the current task
  67552. * @param scene defines the scene where you want your assets to be loaded
  67553. * @param onSuccess is a callback called when the task is successfully executed
  67554. * @param onError is a callback called if an error occurs
  67555. */
  67556. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67557. /**
  67558. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67559. * This can be used with failed tasks that have the reason for failure fixed.
  67560. */
  67561. reset(): void;
  67562. private onErrorCallback;
  67563. private onDoneCallback;
  67564. }
  67565. /**
  67566. * Define the interface used by progress events raised during assets loading
  67567. */
  67568. export interface IAssetsProgressEvent {
  67569. /**
  67570. * Defines the number of remaining tasks to process
  67571. */
  67572. remainingCount: number;
  67573. /**
  67574. * Defines the total number of tasks
  67575. */
  67576. totalCount: number;
  67577. /**
  67578. * Defines the task that was just processed
  67579. */
  67580. task: AbstractAssetTask;
  67581. }
  67582. /**
  67583. * Class used to share progress information about assets loading
  67584. */
  67585. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67586. /**
  67587. * Defines the number of remaining tasks to process
  67588. */
  67589. remainingCount: number;
  67590. /**
  67591. * Defines the total number of tasks
  67592. */
  67593. totalCount: number;
  67594. /**
  67595. * Defines the task that was just processed
  67596. */
  67597. task: AbstractAssetTask;
  67598. /**
  67599. * Creates a AssetsProgressEvent
  67600. * @param remainingCount defines the number of remaining tasks to process
  67601. * @param totalCount defines the total number of tasks
  67602. * @param task defines the task that was just processed
  67603. */
  67604. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67605. }
  67606. /**
  67607. * Define a task used by AssetsManager to load meshes
  67608. */
  67609. export class MeshAssetTask extends AbstractAssetTask {
  67610. /**
  67611. * Defines the name of the task
  67612. */
  67613. name: string;
  67614. /**
  67615. * Defines the list of mesh's names you want to load
  67616. */
  67617. meshesNames: any;
  67618. /**
  67619. * Defines the root url to use as a base to load your meshes and associated resources
  67620. */
  67621. rootUrl: string;
  67622. /**
  67623. * Defines the filename of the scene to load from
  67624. */
  67625. sceneFilename: string;
  67626. /**
  67627. * Gets the list of loaded meshes
  67628. */
  67629. loadedMeshes: Array<AbstractMesh>;
  67630. /**
  67631. * Gets the list of loaded particle systems
  67632. */
  67633. loadedParticleSystems: Array<IParticleSystem>;
  67634. /**
  67635. * Gets the list of loaded skeletons
  67636. */
  67637. loadedSkeletons: Array<Skeleton>;
  67638. /**
  67639. * Gets the list of loaded animation groups
  67640. */
  67641. loadedAnimationGroups: Array<AnimationGroup>;
  67642. /**
  67643. * Callback called when the task is successful
  67644. */
  67645. onSuccess: (task: MeshAssetTask) => void;
  67646. /**
  67647. * Callback called when the task is successful
  67648. */
  67649. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67650. /**
  67651. * Creates a new MeshAssetTask
  67652. * @param name defines the name of the task
  67653. * @param meshesNames defines the list of mesh's names you want to load
  67654. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67655. * @param sceneFilename defines the filename of the scene to load from
  67656. */
  67657. constructor(
  67658. /**
  67659. * Defines the name of the task
  67660. */
  67661. name: string,
  67662. /**
  67663. * Defines the list of mesh's names you want to load
  67664. */
  67665. meshesNames: any,
  67666. /**
  67667. * Defines the root url to use as a base to load your meshes and associated resources
  67668. */
  67669. rootUrl: string,
  67670. /**
  67671. * Defines the filename of the scene to load from
  67672. */
  67673. sceneFilename: string);
  67674. /**
  67675. * Execute the current task
  67676. * @param scene defines the scene where you want your assets to be loaded
  67677. * @param onSuccess is a callback called when the task is successfully executed
  67678. * @param onError is a callback called if an error occurs
  67679. */
  67680. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67681. }
  67682. /**
  67683. * Define a task used by AssetsManager to load text content
  67684. */
  67685. export class TextFileAssetTask extends AbstractAssetTask {
  67686. /**
  67687. * Defines the name of the task
  67688. */
  67689. name: string;
  67690. /**
  67691. * Defines the location of the file to load
  67692. */
  67693. url: string;
  67694. /**
  67695. * Gets the loaded text string
  67696. */
  67697. text: string;
  67698. /**
  67699. * Callback called when the task is successful
  67700. */
  67701. onSuccess: (task: TextFileAssetTask) => void;
  67702. /**
  67703. * Callback called when the task is successful
  67704. */
  67705. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67706. /**
  67707. * Creates a new TextFileAssetTask object
  67708. * @param name defines the name of the task
  67709. * @param url defines the location of the file to load
  67710. */
  67711. constructor(
  67712. /**
  67713. * Defines the name of the task
  67714. */
  67715. name: string,
  67716. /**
  67717. * Defines the location of the file to load
  67718. */
  67719. url: string);
  67720. /**
  67721. * Execute the current task
  67722. * @param scene defines the scene where you want your assets to be loaded
  67723. * @param onSuccess is a callback called when the task is successfully executed
  67724. * @param onError is a callback called if an error occurs
  67725. */
  67726. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67727. }
  67728. /**
  67729. * Define a task used by AssetsManager to load binary data
  67730. */
  67731. export class BinaryFileAssetTask extends AbstractAssetTask {
  67732. /**
  67733. * Defines the name of the task
  67734. */
  67735. name: string;
  67736. /**
  67737. * Defines the location of the file to load
  67738. */
  67739. url: string;
  67740. /**
  67741. * Gets the lodaded data (as an array buffer)
  67742. */
  67743. data: ArrayBuffer;
  67744. /**
  67745. * Callback called when the task is successful
  67746. */
  67747. onSuccess: (task: BinaryFileAssetTask) => void;
  67748. /**
  67749. * Callback called when the task is successful
  67750. */
  67751. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67752. /**
  67753. * Creates a new BinaryFileAssetTask object
  67754. * @param name defines the name of the new task
  67755. * @param url defines the location of the file to load
  67756. */
  67757. constructor(
  67758. /**
  67759. * Defines the name of the task
  67760. */
  67761. name: string,
  67762. /**
  67763. * Defines the location of the file to load
  67764. */
  67765. url: string);
  67766. /**
  67767. * Execute the current task
  67768. * @param scene defines the scene where you want your assets to be loaded
  67769. * @param onSuccess is a callback called when the task is successfully executed
  67770. * @param onError is a callback called if an error occurs
  67771. */
  67772. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67773. }
  67774. /**
  67775. * Define a task used by AssetsManager to load images
  67776. */
  67777. export class ImageAssetTask extends AbstractAssetTask {
  67778. /**
  67779. * Defines the name of the task
  67780. */
  67781. name: string;
  67782. /**
  67783. * Defines the location of the image to load
  67784. */
  67785. url: string;
  67786. /**
  67787. * Gets the loaded images
  67788. */
  67789. image: HTMLImageElement;
  67790. /**
  67791. * Callback called when the task is successful
  67792. */
  67793. onSuccess: (task: ImageAssetTask) => void;
  67794. /**
  67795. * Callback called when the task is successful
  67796. */
  67797. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67798. /**
  67799. * Creates a new ImageAssetTask
  67800. * @param name defines the name of the task
  67801. * @param url defines the location of the image to load
  67802. */
  67803. constructor(
  67804. /**
  67805. * Defines the name of the task
  67806. */
  67807. name: string,
  67808. /**
  67809. * Defines the location of the image to load
  67810. */
  67811. url: string);
  67812. /**
  67813. * Execute the current task
  67814. * @param scene defines the scene where you want your assets to be loaded
  67815. * @param onSuccess is a callback called when the task is successfully executed
  67816. * @param onError is a callback called if an error occurs
  67817. */
  67818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67819. }
  67820. /**
  67821. * Defines the interface used by texture loading tasks
  67822. */
  67823. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67824. /**
  67825. * Gets the loaded texture
  67826. */
  67827. texture: TEX;
  67828. }
  67829. /**
  67830. * Define a task used by AssetsManager to load 2D textures
  67831. */
  67832. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67833. /**
  67834. * Defines the name of the task
  67835. */
  67836. name: string;
  67837. /**
  67838. * Defines the location of the file to load
  67839. */
  67840. url: string;
  67841. /**
  67842. * Defines if mipmap should not be generated (default is false)
  67843. */
  67844. noMipmap?: boolean | undefined;
  67845. /**
  67846. * Defines if texture must be inverted on Y axis (default is false)
  67847. */
  67848. invertY?: boolean | undefined;
  67849. /**
  67850. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67851. */
  67852. samplingMode: number;
  67853. /**
  67854. * Gets the loaded texture
  67855. */
  67856. texture: Texture;
  67857. /**
  67858. * Callback called when the task is successful
  67859. */
  67860. onSuccess: (task: TextureAssetTask) => void;
  67861. /**
  67862. * Callback called when the task is successful
  67863. */
  67864. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67865. /**
  67866. * Creates a new TextureAssetTask object
  67867. * @param name defines the name of the task
  67868. * @param url defines the location of the file to load
  67869. * @param noMipmap defines if mipmap should not be generated (default is false)
  67870. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67871. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67872. */
  67873. constructor(
  67874. /**
  67875. * Defines the name of the task
  67876. */
  67877. name: string,
  67878. /**
  67879. * Defines the location of the file to load
  67880. */
  67881. url: string,
  67882. /**
  67883. * Defines if mipmap should not be generated (default is false)
  67884. */
  67885. noMipmap?: boolean | undefined,
  67886. /**
  67887. * Defines if texture must be inverted on Y axis (default is false)
  67888. */
  67889. invertY?: boolean | undefined,
  67890. /**
  67891. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67892. */
  67893. samplingMode?: number);
  67894. /**
  67895. * Execute the current task
  67896. * @param scene defines the scene where you want your assets to be loaded
  67897. * @param onSuccess is a callback called when the task is successfully executed
  67898. * @param onError is a callback called if an error occurs
  67899. */
  67900. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67901. }
  67902. /**
  67903. * Define a task used by AssetsManager to load cube textures
  67904. */
  67905. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67906. /**
  67907. * Defines the name of the task
  67908. */
  67909. name: string;
  67910. /**
  67911. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67912. */
  67913. url: string;
  67914. /**
  67915. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67916. */
  67917. extensions?: string[] | undefined;
  67918. /**
  67919. * Defines if mipmaps should not be generated (default is false)
  67920. */
  67921. noMipmap?: boolean | undefined;
  67922. /**
  67923. * Defines the explicit list of files (undefined by default)
  67924. */
  67925. files?: string[] | undefined;
  67926. /**
  67927. * Gets the loaded texture
  67928. */
  67929. texture: CubeTexture;
  67930. /**
  67931. * Callback called when the task is successful
  67932. */
  67933. onSuccess: (task: CubeTextureAssetTask) => void;
  67934. /**
  67935. * Callback called when the task is successful
  67936. */
  67937. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67938. /**
  67939. * Creates a new CubeTextureAssetTask
  67940. * @param name defines the name of the task
  67941. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67942. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67943. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67944. * @param files defines the explicit list of files (undefined by default)
  67945. */
  67946. constructor(
  67947. /**
  67948. * Defines the name of the task
  67949. */
  67950. name: string,
  67951. /**
  67952. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67953. */
  67954. url: string,
  67955. /**
  67956. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67957. */
  67958. extensions?: string[] | undefined,
  67959. /**
  67960. * Defines if mipmaps should not be generated (default is false)
  67961. */
  67962. noMipmap?: boolean | undefined,
  67963. /**
  67964. * Defines the explicit list of files (undefined by default)
  67965. */
  67966. files?: string[] | undefined);
  67967. /**
  67968. * Execute the current task
  67969. * @param scene defines the scene where you want your assets to be loaded
  67970. * @param onSuccess is a callback called when the task is successfully executed
  67971. * @param onError is a callback called if an error occurs
  67972. */
  67973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67974. }
  67975. /**
  67976. * Define a task used by AssetsManager to load HDR cube textures
  67977. */
  67978. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67979. /**
  67980. * Defines the name of the task
  67981. */
  67982. name: string;
  67983. /**
  67984. * Defines the location of the file to load
  67985. */
  67986. url: string;
  67987. /**
  67988. * Defines the desired size (the more it increases the longer the generation will be)
  67989. */
  67990. size: number;
  67991. /**
  67992. * Defines if mipmaps should not be generated (default is false)
  67993. */
  67994. noMipmap: boolean;
  67995. /**
  67996. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67997. */
  67998. generateHarmonics: boolean;
  67999. /**
  68000. * 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)
  68001. */
  68002. gammaSpace: boolean;
  68003. /**
  68004. * Internal Use Only
  68005. */
  68006. reserved: boolean;
  68007. /**
  68008. * Gets the loaded texture
  68009. */
  68010. texture: HDRCubeTexture;
  68011. /**
  68012. * Callback called when the task is successful
  68013. */
  68014. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68015. /**
  68016. * Callback called when the task is successful
  68017. */
  68018. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68019. /**
  68020. * Creates a new HDRCubeTextureAssetTask object
  68021. * @param name defines the name of the task
  68022. * @param url defines the location of the file to load
  68023. * @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.
  68024. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68025. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68026. * @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)
  68027. * @param reserved Internal use only
  68028. */
  68029. constructor(
  68030. /**
  68031. * Defines the name of the task
  68032. */
  68033. name: string,
  68034. /**
  68035. * Defines the location of the file to load
  68036. */
  68037. url: string,
  68038. /**
  68039. * Defines the desired size (the more it increases the longer the generation will be)
  68040. */
  68041. size: number,
  68042. /**
  68043. * Defines if mipmaps should not be generated (default is false)
  68044. */
  68045. noMipmap?: boolean,
  68046. /**
  68047. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68048. */
  68049. generateHarmonics?: boolean,
  68050. /**
  68051. * 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)
  68052. */
  68053. gammaSpace?: boolean,
  68054. /**
  68055. * Internal Use Only
  68056. */
  68057. reserved?: boolean);
  68058. /**
  68059. * Execute the current task
  68060. * @param scene defines the scene where you want your assets to be loaded
  68061. * @param onSuccess is a callback called when the task is successfully executed
  68062. * @param onError is a callback called if an error occurs
  68063. */
  68064. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68065. }
  68066. /**
  68067. * Define a task used by AssetsManager to load Equirectangular cube textures
  68068. */
  68069. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  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. * Defines the desired size (the more it increases the longer the generation will be)
  68080. */
  68081. size: number;
  68082. /**
  68083. * Defines if mipmaps should not be generated (default is false)
  68084. */
  68085. noMipmap: boolean;
  68086. /**
  68087. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68088. * but the standard material would require them in Gamma space) (default is true)
  68089. */
  68090. gammaSpace: boolean;
  68091. /**
  68092. * Gets the loaded texture
  68093. */
  68094. texture: EquiRectangularCubeTexture;
  68095. /**
  68096. * Callback called when the task is successful
  68097. */
  68098. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68099. /**
  68100. * Callback called when the task is successful
  68101. */
  68102. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68103. /**
  68104. * Creates a new EquiRectangularCubeTextureAssetTask object
  68105. * @param name defines the name of the task
  68106. * @param url defines the location of the file to load
  68107. * @param size defines the desired size (the more it increases the longer the generation will be)
  68108. * If the size is omitted this implies you are using a preprocessed cubemap.
  68109. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68110. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68111. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68112. * (default is true)
  68113. */
  68114. constructor(
  68115. /**
  68116. * Defines the name of the task
  68117. */
  68118. name: string,
  68119. /**
  68120. * Defines the location of the file to load
  68121. */
  68122. url: string,
  68123. /**
  68124. * Defines the desired size (the more it increases the longer the generation will be)
  68125. */
  68126. size: number,
  68127. /**
  68128. * Defines if mipmaps should not be generated (default is false)
  68129. */
  68130. noMipmap?: boolean,
  68131. /**
  68132. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68133. * but the standard material would require them in Gamma space) (default is true)
  68134. */
  68135. gammaSpace?: boolean);
  68136. /**
  68137. * Execute the current task
  68138. * @param scene defines the scene where you want your assets to be loaded
  68139. * @param onSuccess is a callback called when the task is successfully executed
  68140. * @param onError is a callback called if an error occurs
  68141. */
  68142. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68143. }
  68144. /**
  68145. * This class can be used to easily import assets into a scene
  68146. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68147. */
  68148. export class AssetsManager {
  68149. private _scene;
  68150. private _isLoading;
  68151. protected _tasks: AbstractAssetTask[];
  68152. protected _waitingTasksCount: number;
  68153. protected _totalTasksCount: number;
  68154. /**
  68155. * Callback called when all tasks are processed
  68156. */
  68157. onFinish: (tasks: AbstractAssetTask[]) => void;
  68158. /**
  68159. * Callback called when a task is successful
  68160. */
  68161. onTaskSuccess: (task: AbstractAssetTask) => void;
  68162. /**
  68163. * Callback called when a task had an error
  68164. */
  68165. onTaskError: (task: AbstractAssetTask) => void;
  68166. /**
  68167. * Callback called when a task is done (whatever the result is)
  68168. */
  68169. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68170. /**
  68171. * Observable called when all tasks are processed
  68172. */
  68173. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68174. /**
  68175. * Observable called when a task had an error
  68176. */
  68177. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68178. /**
  68179. * Observable called when all tasks were executed
  68180. */
  68181. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68182. /**
  68183. * Observable called when a task is done (whatever the result is)
  68184. */
  68185. onProgressObservable: Observable<IAssetsProgressEvent>;
  68186. /**
  68187. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68189. */
  68190. useDefaultLoadingScreen: boolean;
  68191. /**
  68192. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68193. * when all assets have been downloaded.
  68194. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68195. */
  68196. autoHideLoadingUI: boolean;
  68197. /**
  68198. * Creates a new AssetsManager
  68199. * @param scene defines the scene to work on
  68200. */
  68201. constructor(scene: Scene);
  68202. /**
  68203. * Add a MeshAssetTask to the list of active tasks
  68204. * @param taskName defines the name of the new task
  68205. * @param meshesNames defines the name of meshes to load
  68206. * @param rootUrl defines the root url to use to locate files
  68207. * @param sceneFilename defines the filename of the scene file
  68208. * @returns a new MeshAssetTask object
  68209. */
  68210. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68211. /**
  68212. * Add a TextFileAssetTask to the list of active tasks
  68213. * @param taskName defines the name of the new task
  68214. * @param url defines the url of the file to load
  68215. * @returns a new TextFileAssetTask object
  68216. */
  68217. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68218. /**
  68219. * Add a BinaryFileAssetTask to the list of active tasks
  68220. * @param taskName defines the name of the new task
  68221. * @param url defines the url of the file to load
  68222. * @returns a new BinaryFileAssetTask object
  68223. */
  68224. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68225. /**
  68226. * Add a ImageAssetTask to the list of active tasks
  68227. * @param taskName defines the name of the new task
  68228. * @param url defines the url of the file to load
  68229. * @returns a new ImageAssetTask object
  68230. */
  68231. addImageTask(taskName: string, url: string): ImageAssetTask;
  68232. /**
  68233. * Add a TextureAssetTask to the list of active tasks
  68234. * @param taskName defines the name of the new task
  68235. * @param url defines the url of the file to load
  68236. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68237. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68238. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68239. * @returns a new TextureAssetTask object
  68240. */
  68241. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68242. /**
  68243. * Add a CubeTextureAssetTask to the list of active tasks
  68244. * @param taskName defines the name of the new task
  68245. * @param url defines the url of the file to load
  68246. * @param extensions defines the extension to use to load the cube map (can be null)
  68247. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68248. * @param files defines the list of files to load (can be null)
  68249. * @returns a new CubeTextureAssetTask object
  68250. */
  68251. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68252. /**
  68253. *
  68254. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68255. * @param taskName defines the name of the new task
  68256. * @param url defines the url of the file to load
  68257. * @param size defines the size you want for the cubemap (can be null)
  68258. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68259. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68260. * @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)
  68261. * @param reserved Internal use only
  68262. * @returns a new HDRCubeTextureAssetTask object
  68263. */
  68264. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68265. /**
  68266. *
  68267. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68268. * @param taskName defines the name of the new task
  68269. * @param url defines the url of the file to load
  68270. * @param size defines the size you want for the cubemap (can be null)
  68271. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68272. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68273. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68274. * @returns a new EquiRectangularCubeTextureAssetTask object
  68275. */
  68276. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68277. /**
  68278. * Remove a task from the assets manager.
  68279. * @param task the task to remove
  68280. */
  68281. removeTask(task: AbstractAssetTask): void;
  68282. private _decreaseWaitingTasksCount;
  68283. private _runTask;
  68284. /**
  68285. * Reset the AssetsManager and remove all tasks
  68286. * @return the current instance of the AssetsManager
  68287. */
  68288. reset(): AssetsManager;
  68289. /**
  68290. * Start the loading process
  68291. * @return the current instance of the AssetsManager
  68292. */
  68293. load(): AssetsManager;
  68294. /**
  68295. * Start the loading process as an async operation
  68296. * @return a promise returning the list of failed tasks
  68297. */
  68298. loadAsync(): Promise<void>;
  68299. }
  68300. }
  68301. declare module BABYLON {
  68302. /**
  68303. * Wrapper class for promise with external resolve and reject.
  68304. */
  68305. export class Deferred<T> {
  68306. /**
  68307. * The promise associated with this deferred object.
  68308. */
  68309. readonly promise: Promise<T>;
  68310. private _resolve;
  68311. private _reject;
  68312. /**
  68313. * The resolve method of the promise associated with this deferred object.
  68314. */
  68315. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68316. /**
  68317. * The reject method of the promise associated with this deferred object.
  68318. */
  68319. get reject(): (reason?: any) => void;
  68320. /**
  68321. * Constructor for this deferred object.
  68322. */
  68323. constructor();
  68324. }
  68325. }
  68326. declare module BABYLON {
  68327. /**
  68328. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68329. */
  68330. export class MeshExploder {
  68331. private _centerMesh;
  68332. private _meshes;
  68333. private _meshesOrigins;
  68334. private _toCenterVectors;
  68335. private _scaledDirection;
  68336. private _newPosition;
  68337. private _centerPosition;
  68338. /**
  68339. * Explodes meshes from a center mesh.
  68340. * @param meshes The meshes to explode.
  68341. * @param centerMesh The mesh to be center of explosion.
  68342. */
  68343. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68344. private _setCenterMesh;
  68345. /**
  68346. * Get class name
  68347. * @returns "MeshExploder"
  68348. */
  68349. getClassName(): string;
  68350. /**
  68351. * "Exploded meshes"
  68352. * @returns Array of meshes with the centerMesh at index 0.
  68353. */
  68354. getMeshes(): Array<Mesh>;
  68355. /**
  68356. * Explodes meshes giving a specific direction
  68357. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68358. */
  68359. explode(direction?: number): void;
  68360. }
  68361. }
  68362. declare module BABYLON {
  68363. /**
  68364. * Class used to help managing file picking and drag'n'drop
  68365. */
  68366. export class FilesInput {
  68367. /**
  68368. * List of files ready to be loaded
  68369. */
  68370. static get FilesToLoad(): {
  68371. [key: string]: File;
  68372. };
  68373. /**
  68374. * Callback called when a file is processed
  68375. */
  68376. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68377. private _engine;
  68378. private _currentScene;
  68379. private _sceneLoadedCallback;
  68380. private _progressCallback;
  68381. private _additionalRenderLoopLogicCallback;
  68382. private _textureLoadingCallback;
  68383. private _startingProcessingFilesCallback;
  68384. private _onReloadCallback;
  68385. private _errorCallback;
  68386. private _elementToMonitor;
  68387. private _sceneFileToLoad;
  68388. private _filesToLoad;
  68389. /**
  68390. * Creates a new FilesInput
  68391. * @param engine defines the rendering engine
  68392. * @param scene defines the hosting scene
  68393. * @param sceneLoadedCallback callback called when scene is loaded
  68394. * @param progressCallback callback called to track progress
  68395. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68396. * @param textureLoadingCallback callback called when a texture is loading
  68397. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68398. * @param onReloadCallback callback called when a reload is requested
  68399. * @param errorCallback callback call if an error occurs
  68400. */
  68401. 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);
  68402. private _dragEnterHandler;
  68403. private _dragOverHandler;
  68404. private _dropHandler;
  68405. /**
  68406. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68407. * @param elementToMonitor defines the DOM element to track
  68408. */
  68409. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68410. /**
  68411. * Release all associated resources
  68412. */
  68413. dispose(): void;
  68414. private renderFunction;
  68415. private drag;
  68416. private drop;
  68417. private _traverseFolder;
  68418. private _processFiles;
  68419. /**
  68420. * Load files from a drop event
  68421. * @param event defines the drop event to use as source
  68422. */
  68423. loadFiles(event: any): void;
  68424. private _processReload;
  68425. /**
  68426. * Reload the current scene from the loaded files
  68427. */
  68428. reload(): void;
  68429. }
  68430. }
  68431. declare module BABYLON {
  68432. /**
  68433. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68435. */
  68436. export class SceneOptimization {
  68437. /**
  68438. * Defines the priority of this optimization (0 by default which means first in the list)
  68439. */
  68440. priority: number;
  68441. /**
  68442. * Gets a string describing the action executed by the current optimization
  68443. * @returns description string
  68444. */
  68445. getDescription(): string;
  68446. /**
  68447. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68448. * @param scene defines the current scene where to apply this optimization
  68449. * @param optimizer defines the current optimizer
  68450. * @returns true if everything that can be done was applied
  68451. */
  68452. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68453. /**
  68454. * Creates the SceneOptimization object
  68455. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68456. * @param desc defines the description associated with the optimization
  68457. */
  68458. constructor(
  68459. /**
  68460. * Defines the priority of this optimization (0 by default which means first in the list)
  68461. */
  68462. priority?: number);
  68463. }
  68464. /**
  68465. * Defines an optimization used to reduce the size of render target textures
  68466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68467. */
  68468. export class TextureOptimization extends SceneOptimization {
  68469. /**
  68470. * Defines the priority of this optimization (0 by default which means first in the list)
  68471. */
  68472. priority: number;
  68473. /**
  68474. * 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
  68475. */
  68476. maximumSize: number;
  68477. /**
  68478. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68479. */
  68480. step: number;
  68481. /**
  68482. * Gets a string describing the action executed by the current optimization
  68483. * @returns description string
  68484. */
  68485. getDescription(): string;
  68486. /**
  68487. * Creates the TextureOptimization object
  68488. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68489. * @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
  68490. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68491. */
  68492. constructor(
  68493. /**
  68494. * Defines the priority of this optimization (0 by default which means first in the list)
  68495. */
  68496. priority?: number,
  68497. /**
  68498. * 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
  68499. */
  68500. maximumSize?: number,
  68501. /**
  68502. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68503. */
  68504. step?: number);
  68505. /**
  68506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68507. * @param scene defines the current scene where to apply this optimization
  68508. * @param optimizer defines the current optimizer
  68509. * @returns true if everything that can be done was applied
  68510. */
  68511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68512. }
  68513. /**
  68514. * Defines an optimization used to increase or decrease the rendering resolution
  68515. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68516. */
  68517. export class HardwareScalingOptimization extends SceneOptimization {
  68518. /**
  68519. * Defines the priority of this optimization (0 by default which means first in the list)
  68520. */
  68521. priority: number;
  68522. /**
  68523. * Defines the maximum scale to use (2 by default)
  68524. */
  68525. maximumScale: number;
  68526. /**
  68527. * Defines the step to use between two passes (0.5 by default)
  68528. */
  68529. step: number;
  68530. private _currentScale;
  68531. private _directionOffset;
  68532. /**
  68533. * Gets a string describing the action executed by the current optimization
  68534. * @return description string
  68535. */
  68536. getDescription(): string;
  68537. /**
  68538. * Creates the HardwareScalingOptimization object
  68539. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68540. * @param maximumScale defines the maximum scale to use (2 by default)
  68541. * @param step defines the step to use between two passes (0.5 by default)
  68542. */
  68543. constructor(
  68544. /**
  68545. * Defines the priority of this optimization (0 by default which means first in the list)
  68546. */
  68547. priority?: number,
  68548. /**
  68549. * Defines the maximum scale to use (2 by default)
  68550. */
  68551. maximumScale?: number,
  68552. /**
  68553. * Defines the step to use between two passes (0.5 by default)
  68554. */
  68555. step?: number);
  68556. /**
  68557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68558. * @param scene defines the current scene where to apply this optimization
  68559. * @param optimizer defines the current optimizer
  68560. * @returns true if everything that can be done was applied
  68561. */
  68562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68563. }
  68564. /**
  68565. * Defines an optimization used to remove shadows
  68566. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68567. */
  68568. export class ShadowsOptimization extends SceneOptimization {
  68569. /**
  68570. * Gets a string describing the action executed by the current optimization
  68571. * @return description string
  68572. */
  68573. getDescription(): string;
  68574. /**
  68575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68576. * @param scene defines the current scene where to apply this optimization
  68577. * @param optimizer defines the current optimizer
  68578. * @returns true if everything that can be done was applied
  68579. */
  68580. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68581. }
  68582. /**
  68583. * Defines an optimization used to turn post-processes off
  68584. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68585. */
  68586. export class PostProcessesOptimization extends SceneOptimization {
  68587. /**
  68588. * Gets a string describing the action executed by the current optimization
  68589. * @return description string
  68590. */
  68591. getDescription(): string;
  68592. /**
  68593. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68594. * @param scene defines the current scene where to apply this optimization
  68595. * @param optimizer defines the current optimizer
  68596. * @returns true if everything that can be done was applied
  68597. */
  68598. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68599. }
  68600. /**
  68601. * Defines an optimization used to turn lens flares off
  68602. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68603. */
  68604. export class LensFlaresOptimization extends SceneOptimization {
  68605. /**
  68606. * Gets a string describing the action executed by the current optimization
  68607. * @return description string
  68608. */
  68609. getDescription(): string;
  68610. /**
  68611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68612. * @param scene defines the current scene where to apply this optimization
  68613. * @param optimizer defines the current optimizer
  68614. * @returns true if everything that can be done was applied
  68615. */
  68616. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68617. }
  68618. /**
  68619. * Defines an optimization based on user defined callback.
  68620. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68621. */
  68622. export class CustomOptimization extends SceneOptimization {
  68623. /**
  68624. * Callback called to apply the custom optimization.
  68625. */
  68626. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68627. /**
  68628. * Callback called to get custom description
  68629. */
  68630. onGetDescription: () => string;
  68631. /**
  68632. * Gets a string describing the action executed by the current optimization
  68633. * @returns description string
  68634. */
  68635. getDescription(): string;
  68636. /**
  68637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68638. * @param scene defines the current scene where to apply this optimization
  68639. * @param optimizer defines the current optimizer
  68640. * @returns true if everything that can be done was applied
  68641. */
  68642. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68643. }
  68644. /**
  68645. * Defines an optimization used to turn particles off
  68646. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68647. */
  68648. export class ParticlesOptimization extends SceneOptimization {
  68649. /**
  68650. * Gets a string describing the action executed by the current optimization
  68651. * @return description string
  68652. */
  68653. getDescription(): string;
  68654. /**
  68655. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68656. * @param scene defines the current scene where to apply this optimization
  68657. * @param optimizer defines the current optimizer
  68658. * @returns true if everything that can be done was applied
  68659. */
  68660. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68661. }
  68662. /**
  68663. * Defines an optimization used to turn render targets off
  68664. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68665. */
  68666. export class RenderTargetsOptimization extends SceneOptimization {
  68667. /**
  68668. * Gets a string describing the action executed by the current optimization
  68669. * @return description string
  68670. */
  68671. getDescription(): string;
  68672. /**
  68673. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68674. * @param scene defines the current scene where to apply this optimization
  68675. * @param optimizer defines the current optimizer
  68676. * @returns true if everything that can be done was applied
  68677. */
  68678. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68679. }
  68680. /**
  68681. * Defines an optimization used to merge meshes with compatible materials
  68682. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68683. */
  68684. export class MergeMeshesOptimization extends SceneOptimization {
  68685. private static _UpdateSelectionTree;
  68686. /**
  68687. * Gets or sets a boolean which defines if optimization octree has to be updated
  68688. */
  68689. static get UpdateSelectionTree(): boolean;
  68690. /**
  68691. * Gets or sets a boolean which defines if optimization octree has to be updated
  68692. */
  68693. static set UpdateSelectionTree(value: boolean);
  68694. /**
  68695. * Gets a string describing the action executed by the current optimization
  68696. * @return description string
  68697. */
  68698. getDescription(): string;
  68699. private _canBeMerged;
  68700. /**
  68701. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68702. * @param scene defines the current scene where to apply this optimization
  68703. * @param optimizer defines the current optimizer
  68704. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68705. * @returns true if everything that can be done was applied
  68706. */
  68707. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68708. }
  68709. /**
  68710. * Defines a list of options used by SceneOptimizer
  68711. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68712. */
  68713. export class SceneOptimizerOptions {
  68714. /**
  68715. * Defines the target frame rate to reach (60 by default)
  68716. */
  68717. targetFrameRate: number;
  68718. /**
  68719. * Defines the interval between two checkes (2000ms by default)
  68720. */
  68721. trackerDuration: number;
  68722. /**
  68723. * Gets the list of optimizations to apply
  68724. */
  68725. optimizations: SceneOptimization[];
  68726. /**
  68727. * Creates a new list of options used by SceneOptimizer
  68728. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68729. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68730. */
  68731. constructor(
  68732. /**
  68733. * Defines the target frame rate to reach (60 by default)
  68734. */
  68735. targetFrameRate?: number,
  68736. /**
  68737. * Defines the interval between two checkes (2000ms by default)
  68738. */
  68739. trackerDuration?: number);
  68740. /**
  68741. * Add a new optimization
  68742. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68743. * @returns the current SceneOptimizerOptions
  68744. */
  68745. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68746. /**
  68747. * Add a new custom optimization
  68748. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68749. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68750. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68751. * @returns the current SceneOptimizerOptions
  68752. */
  68753. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68754. /**
  68755. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68756. * @param targetFrameRate defines the target frame rate (60 by default)
  68757. * @returns a SceneOptimizerOptions object
  68758. */
  68759. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68760. /**
  68761. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68762. * @param targetFrameRate defines the target frame rate (60 by default)
  68763. * @returns a SceneOptimizerOptions object
  68764. */
  68765. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68766. /**
  68767. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68768. * @param targetFrameRate defines the target frame rate (60 by default)
  68769. * @returns a SceneOptimizerOptions object
  68770. */
  68771. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68772. }
  68773. /**
  68774. * Class used to run optimizations in order to reach a target frame rate
  68775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68776. */
  68777. export class SceneOptimizer implements IDisposable {
  68778. private _isRunning;
  68779. private _options;
  68780. private _scene;
  68781. private _currentPriorityLevel;
  68782. private _targetFrameRate;
  68783. private _trackerDuration;
  68784. private _currentFrameRate;
  68785. private _sceneDisposeObserver;
  68786. private _improvementMode;
  68787. /**
  68788. * Defines an observable called when the optimizer reaches the target frame rate
  68789. */
  68790. onSuccessObservable: Observable<SceneOptimizer>;
  68791. /**
  68792. * Defines an observable called when the optimizer enables an optimization
  68793. */
  68794. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68795. /**
  68796. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68797. */
  68798. onFailureObservable: Observable<SceneOptimizer>;
  68799. /**
  68800. * Gets a boolean indicating if the optimizer is in improvement mode
  68801. */
  68802. get isInImprovementMode(): boolean;
  68803. /**
  68804. * Gets the current priority level (0 at start)
  68805. */
  68806. get currentPriorityLevel(): number;
  68807. /**
  68808. * Gets the current frame rate checked by the SceneOptimizer
  68809. */
  68810. get currentFrameRate(): number;
  68811. /**
  68812. * Gets or sets the current target frame rate (60 by default)
  68813. */
  68814. get targetFrameRate(): number;
  68815. /**
  68816. * Gets or sets the current target frame rate (60 by default)
  68817. */
  68818. set targetFrameRate(value: number);
  68819. /**
  68820. * Gets or sets the current interval between two checks (every 2000ms by default)
  68821. */
  68822. get trackerDuration(): number;
  68823. /**
  68824. * Gets or sets the current interval between two checks (every 2000ms by default)
  68825. */
  68826. set trackerDuration(value: number);
  68827. /**
  68828. * Gets the list of active optimizations
  68829. */
  68830. get optimizations(): SceneOptimization[];
  68831. /**
  68832. * Creates a new SceneOptimizer
  68833. * @param scene defines the scene to work on
  68834. * @param options defines the options to use with the SceneOptimizer
  68835. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68836. * @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)
  68837. */
  68838. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68839. /**
  68840. * Stops the current optimizer
  68841. */
  68842. stop(): void;
  68843. /**
  68844. * Reset the optimizer to initial step (current priority level = 0)
  68845. */
  68846. reset(): void;
  68847. /**
  68848. * Start the optimizer. By default it will try to reach a specific framerate
  68849. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68850. */
  68851. start(): void;
  68852. private _checkCurrentState;
  68853. /**
  68854. * Release all resources
  68855. */
  68856. dispose(): void;
  68857. /**
  68858. * Helper function to create a SceneOptimizer with one single line of code
  68859. * @param scene defines the scene to work on
  68860. * @param options defines the options to use with the SceneOptimizer
  68861. * @param onSuccess defines a callback to call on success
  68862. * @param onFailure defines a callback to call on failure
  68863. * @returns the new SceneOptimizer object
  68864. */
  68865. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68866. }
  68867. }
  68868. declare module BABYLON {
  68869. /**
  68870. * Class used to serialize a scene into a string
  68871. */
  68872. export class SceneSerializer {
  68873. /**
  68874. * Clear cache used by a previous serialization
  68875. */
  68876. static ClearCache(): void;
  68877. /**
  68878. * Serialize a scene into a JSON compatible object
  68879. * @param scene defines the scene to serialize
  68880. * @returns a JSON compatible object
  68881. */
  68882. static Serialize(scene: Scene): any;
  68883. /**
  68884. * Serialize a mesh into a JSON compatible object
  68885. * @param toSerialize defines the mesh to serialize
  68886. * @param withParents defines if parents must be serialized as well
  68887. * @param withChildren defines if children must be serialized as well
  68888. * @returns a JSON compatible object
  68889. */
  68890. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68891. }
  68892. }
  68893. declare module BABYLON {
  68894. /**
  68895. * Class used to host texture specific utilities
  68896. */
  68897. export class TextureTools {
  68898. /**
  68899. * Uses the GPU to create a copy texture rescaled at a given size
  68900. * @param texture Texture to copy from
  68901. * @param width defines the desired width
  68902. * @param height defines the desired height
  68903. * @param useBilinearMode defines if bilinear mode has to be used
  68904. * @return the generated texture
  68905. */
  68906. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68907. }
  68908. }
  68909. declare module BABYLON {
  68910. /**
  68911. * This represents the different options available for the video capture.
  68912. */
  68913. export interface VideoRecorderOptions {
  68914. /** Defines the mime type of the video. */
  68915. mimeType: string;
  68916. /** Defines the FPS the video should be recorded at. */
  68917. fps: number;
  68918. /** Defines the chunk size for the recording data. */
  68919. recordChunckSize: number;
  68920. /** The audio tracks to attach to the recording. */
  68921. audioTracks?: MediaStreamTrack[];
  68922. }
  68923. /**
  68924. * This can help with recording videos from BabylonJS.
  68925. * This is based on the available WebRTC functionalities of the browser.
  68926. *
  68927. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68928. */
  68929. export class VideoRecorder {
  68930. private static readonly _defaultOptions;
  68931. /**
  68932. * Returns whether or not the VideoRecorder is available in your browser.
  68933. * @param engine Defines the Babylon Engine.
  68934. * @returns true if supported otherwise false.
  68935. */
  68936. static IsSupported(engine: Engine): boolean;
  68937. private readonly _options;
  68938. private _canvas;
  68939. private _mediaRecorder;
  68940. private _recordedChunks;
  68941. private _fileName;
  68942. private _resolve;
  68943. private _reject;
  68944. /**
  68945. * True when a recording is already in progress.
  68946. */
  68947. get isRecording(): boolean;
  68948. /**
  68949. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68950. * @param engine Defines the BabylonJS Engine you wish to record.
  68951. * @param options Defines options that can be used to customize the capture.
  68952. */
  68953. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68954. /**
  68955. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68956. */
  68957. stopRecording(): void;
  68958. /**
  68959. * Starts recording the canvas for a max duration specified in parameters.
  68960. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68961. * If null no automatic download will start and you can rely on the promise to get the data back.
  68962. * @param maxDuration Defines the maximum recording time in seconds.
  68963. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68964. * @return A promise callback at the end of the recording with the video data in Blob.
  68965. */
  68966. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68967. /**
  68968. * Releases internal resources used during the recording.
  68969. */
  68970. dispose(): void;
  68971. private _handleDataAvailable;
  68972. private _handleError;
  68973. private _handleStop;
  68974. }
  68975. }
  68976. declare module BABYLON {
  68977. /**
  68978. * Class containing a set of static utilities functions for screenshots
  68979. */
  68980. export class ScreenshotTools {
  68981. /**
  68982. * Captures a screenshot of the current rendering
  68983. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68984. * @param engine defines the rendering engine
  68985. * @param camera defines the source camera
  68986. * @param size This parameter can be set to a single number or to an object with the
  68987. * following (optional) properties: precision, width, height. If a single number is passed,
  68988. * it will be used for both width and height. If an object is passed, the screenshot size
  68989. * will be derived from the parameters. The precision property is a multiplier allowing
  68990. * rendering at a higher or lower resolution
  68991. * @param successCallback defines the callback receives a single parameter which contains the
  68992. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68993. * src parameter of an <img> to display it
  68994. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68995. * Check your browser for supported MIME types
  68996. */
  68997. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68998. /**
  68999. * Captures a screenshot of the current rendering
  69000. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69001. * @param engine defines the rendering engine
  69002. * @param camera defines the source camera
  69003. * @param size This parameter can be set to a single number or to an object with the
  69004. * following (optional) properties: precision, width, height. If a single number is passed,
  69005. * it will be used for both width and height. If an object is passed, the screenshot size
  69006. * will be derived from the parameters. The precision property is a multiplier allowing
  69007. * rendering at a higher or lower resolution
  69008. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69009. * Check your browser for supported MIME types
  69010. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69011. * to the src parameter of an <img> to display it
  69012. */
  69013. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69014. /**
  69015. * Generates an image screenshot from the specified camera.
  69016. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69017. * @param engine The engine to use for rendering
  69018. * @param camera The camera to use for rendering
  69019. * @param size This parameter can be set to a single number or to an object with the
  69020. * following (optional) properties: precision, width, height. If a single number is passed,
  69021. * it will be used for both width and height. If an object is passed, the screenshot size
  69022. * will be derived from the parameters. The precision property is a multiplier allowing
  69023. * rendering at a higher or lower resolution
  69024. * @param successCallback The callback receives a single parameter which contains the
  69025. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69026. * src parameter of an <img> to display it
  69027. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69028. * Check your browser for supported MIME types
  69029. * @param samples Texture samples (default: 1)
  69030. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69031. * @param fileName A name for for the downloaded file.
  69032. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69033. */
  69034. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69035. /**
  69036. * Generates an image screenshot from the specified camera.
  69037. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69038. * @param engine The engine to use for rendering
  69039. * @param camera The camera to use for rendering
  69040. * @param size This parameter can be set to a single number or to an object with the
  69041. * following (optional) properties: precision, width, height. If a single number is passed,
  69042. * it will be used for both width and height. If an object is passed, the screenshot size
  69043. * will be derived from the parameters. The precision property is a multiplier allowing
  69044. * rendering at a higher or lower resolution
  69045. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69046. * Check your browser for supported MIME types
  69047. * @param samples Texture samples (default: 1)
  69048. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69049. * @param fileName A name for for the downloaded file.
  69050. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69051. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69052. * to the src parameter of an <img> to display it
  69053. */
  69054. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69055. /**
  69056. * Gets height and width for screenshot size
  69057. * @private
  69058. */
  69059. private static _getScreenshotSize;
  69060. }
  69061. }
  69062. declare module BABYLON {
  69063. /**
  69064. * Interface for a data buffer
  69065. */
  69066. export interface IDataBuffer {
  69067. /**
  69068. * Reads bytes from the data buffer.
  69069. * @param byteOffset The byte offset to read
  69070. * @param byteLength The byte length to read
  69071. * @returns A promise that resolves when the bytes are read
  69072. */
  69073. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69074. /**
  69075. * The byte length of the buffer.
  69076. */
  69077. readonly byteLength: number;
  69078. }
  69079. /**
  69080. * Utility class for reading from a data buffer
  69081. */
  69082. export class DataReader {
  69083. /**
  69084. * The data buffer associated with this data reader.
  69085. */
  69086. readonly buffer: IDataBuffer;
  69087. /**
  69088. * The current byte offset from the beginning of the data buffer.
  69089. */
  69090. byteOffset: number;
  69091. private _dataView;
  69092. private _dataByteOffset;
  69093. /**
  69094. * Constructor
  69095. * @param buffer The buffer to read
  69096. */
  69097. constructor(buffer: IDataBuffer);
  69098. /**
  69099. * Loads the given byte length.
  69100. * @param byteLength The byte length to load
  69101. * @returns A promise that resolves when the load is complete
  69102. */
  69103. loadAsync(byteLength: number): Promise<void>;
  69104. /**
  69105. * Read a unsigned 32-bit integer from the currently loaded data range.
  69106. * @returns The 32-bit integer read
  69107. */
  69108. readUint32(): number;
  69109. /**
  69110. * Read a byte array from the currently loaded data range.
  69111. * @param byteLength The byte length to read
  69112. * @returns The byte array read
  69113. */
  69114. readUint8Array(byteLength: number): Uint8Array;
  69115. /**
  69116. * Read a string from the currently loaded data range.
  69117. * @param byteLength The byte length to read
  69118. * @returns The string read
  69119. */
  69120. readString(byteLength: number): string;
  69121. /**
  69122. * Skips the given byte length the currently loaded data range.
  69123. * @param byteLength The byte length to skip
  69124. */
  69125. skipBytes(byteLength: number): void;
  69126. }
  69127. }
  69128. declare module BABYLON {
  69129. /**
  69130. * Class for storing data to local storage if available or in-memory storage otherwise
  69131. */
  69132. export class DataStorage {
  69133. private static _Storage;
  69134. private static _GetStorage;
  69135. /**
  69136. * Reads a string from the data storage
  69137. * @param key The key to read
  69138. * @param defaultValue The value if the key doesn't exist
  69139. * @returns The string value
  69140. */
  69141. static ReadString(key: string, defaultValue: string): string;
  69142. /**
  69143. * Writes a string to the data storage
  69144. * @param key The key to write
  69145. * @param value The value to write
  69146. */
  69147. static WriteString(key: string, value: string): void;
  69148. /**
  69149. * Reads a boolean from the data storage
  69150. * @param key The key to read
  69151. * @param defaultValue The value if the key doesn't exist
  69152. * @returns The boolean value
  69153. */
  69154. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69155. /**
  69156. * Writes a boolean to the data storage
  69157. * @param key The key to write
  69158. * @param value The value to write
  69159. */
  69160. static WriteBoolean(key: string, value: boolean): void;
  69161. /**
  69162. * Reads a number from the data storage
  69163. * @param key The key to read
  69164. * @param defaultValue The value if the key doesn't exist
  69165. * @returns The number value
  69166. */
  69167. static ReadNumber(key: string, defaultValue: number): number;
  69168. /**
  69169. * Writes a number to the data storage
  69170. * @param key The key to write
  69171. * @param value The value to write
  69172. */
  69173. static WriteNumber(key: string, value: number): void;
  69174. }
  69175. }
  69176. declare module BABYLON {
  69177. /**
  69178. * Options used for hit testing
  69179. */
  69180. export interface IWebXRLegacyHitTestOptions {
  69181. /**
  69182. * Only test when user interacted with the scene. Default - hit test every frame
  69183. */
  69184. testOnPointerDownOnly?: boolean;
  69185. /**
  69186. * The node to use to transform the local results to world coordinates
  69187. */
  69188. worldParentNode?: TransformNode;
  69189. }
  69190. /**
  69191. * Interface defining the babylon result of raycasting/hit-test
  69192. */
  69193. export interface IWebXRLegacyHitResult {
  69194. /**
  69195. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69196. */
  69197. transformationMatrix: Matrix;
  69198. /**
  69199. * The native hit test result
  69200. */
  69201. xrHitResult: XRHitResult | XRHitTestResult;
  69202. }
  69203. /**
  69204. * The currently-working hit-test module.
  69205. * Hit test (or Ray-casting) is used to interact with the real world.
  69206. * For further information read here - https://github.com/immersive-web/hit-test
  69207. */
  69208. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69209. /**
  69210. * options to use when constructing this feature
  69211. */
  69212. readonly options: IWebXRLegacyHitTestOptions;
  69213. private _direction;
  69214. private _mat;
  69215. private _onSelectEnabled;
  69216. private _origin;
  69217. /**
  69218. * The module's name
  69219. */
  69220. static readonly Name: string;
  69221. /**
  69222. * The (Babylon) version of this module.
  69223. * This is an integer representing the implementation version.
  69224. * This number does not correspond to the WebXR specs version
  69225. */
  69226. static readonly Version: number;
  69227. /**
  69228. * Populated with the last native XR Hit Results
  69229. */
  69230. lastNativeXRHitResults: XRHitResult[];
  69231. /**
  69232. * Triggered when new babylon (transformed) hit test results are available
  69233. */
  69234. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69235. /**
  69236. * Creates a new instance of the (legacy version) hit test feature
  69237. * @param _xrSessionManager an instance of WebXRSessionManager
  69238. * @param options options to use when constructing this feature
  69239. */
  69240. constructor(_xrSessionManager: WebXRSessionManager,
  69241. /**
  69242. * options to use when constructing this feature
  69243. */
  69244. options?: IWebXRLegacyHitTestOptions);
  69245. /**
  69246. * execute a hit test with an XR Ray
  69247. *
  69248. * @param xrSession a native xrSession that will execute this hit test
  69249. * @param xrRay the ray (position and direction) to use for ray-casting
  69250. * @param referenceSpace native XR reference space to use for the hit-test
  69251. * @param filter filter function that will filter the results
  69252. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69253. */
  69254. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69255. /**
  69256. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69257. * @param event the (select) event to use to select with
  69258. * @param referenceSpace the reference space to use for this hit test
  69259. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69260. */
  69261. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69262. /**
  69263. * attach this feature
  69264. * Will usually be called by the features manager
  69265. *
  69266. * @returns true if successful.
  69267. */
  69268. attach(): boolean;
  69269. /**
  69270. * detach this feature.
  69271. * Will usually be called by the features manager
  69272. *
  69273. * @returns true if successful.
  69274. */
  69275. detach(): boolean;
  69276. /**
  69277. * Dispose this feature and all of the resources attached
  69278. */
  69279. dispose(): void;
  69280. protected _onXRFrame(frame: XRFrame): void;
  69281. private _onHitTestResults;
  69282. private _onSelect;
  69283. }
  69284. }
  69285. declare module BABYLON {
  69286. /**
  69287. * Options used in the plane detector module
  69288. */
  69289. export interface IWebXRPlaneDetectorOptions {
  69290. /**
  69291. * The node to use to transform the local results to world coordinates
  69292. */
  69293. worldParentNode?: TransformNode;
  69294. }
  69295. /**
  69296. * A babylon interface for a WebXR plane.
  69297. * A Plane is actually a polygon, built from N points in space
  69298. *
  69299. * Supported in chrome 79, not supported in canary 81 ATM
  69300. */
  69301. export interface IWebXRPlane {
  69302. /**
  69303. * a babylon-assigned ID for this polygon
  69304. */
  69305. id: number;
  69306. /**
  69307. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69308. */
  69309. polygonDefinition: Array<Vector3>;
  69310. /**
  69311. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69312. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69313. */
  69314. transformationMatrix: Matrix;
  69315. /**
  69316. * the native xr-plane object
  69317. */
  69318. xrPlane: XRPlane;
  69319. }
  69320. /**
  69321. * The plane detector is used to detect planes in the real world when in AR
  69322. * For more information see https://github.com/immersive-web/real-world-geometry/
  69323. */
  69324. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69325. private _options;
  69326. private _detectedPlanes;
  69327. private _enabled;
  69328. private _lastFrameDetected;
  69329. /**
  69330. * The module's name
  69331. */
  69332. static readonly Name: string;
  69333. /**
  69334. * The (Babylon) version of this module.
  69335. * This is an integer representing the implementation version.
  69336. * This number does not correspond to the WebXR specs version
  69337. */
  69338. static readonly Version: number;
  69339. /**
  69340. * Observers registered here will be executed when a new plane was added to the session
  69341. */
  69342. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69343. /**
  69344. * Observers registered here will be executed when a plane is no longer detected in the session
  69345. */
  69346. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69347. /**
  69348. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69349. * This can execute N times every frame
  69350. */
  69351. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69352. /**
  69353. * construct a new Plane Detector
  69354. * @param _xrSessionManager an instance of xr Session manager
  69355. * @param _options configuration to use when constructing this feature
  69356. */
  69357. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69358. /**
  69359. * Dispose this feature and all of the resources attached
  69360. */
  69361. dispose(): void;
  69362. protected _onXRFrame(frame: XRFrame): void;
  69363. private _init;
  69364. private _updatePlaneWithXRPlane;
  69365. /**
  69366. * avoiding using Array.find for global support.
  69367. * @param xrPlane the plane to find in the array
  69368. */
  69369. private findIndexInPlaneArray;
  69370. }
  69371. }
  69372. declare module BABYLON {
  69373. /**
  69374. * Configuration options of the anchor system
  69375. */
  69376. export interface IWebXRAnchorSystemOptions {
  69377. /**
  69378. * Should a new anchor be added every time a select event is triggered
  69379. */
  69380. addAnchorOnSelect?: boolean;
  69381. /**
  69382. * should the anchor system use plane detection.
  69383. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69384. */
  69385. usePlaneDetection?: boolean;
  69386. /**
  69387. * a node that will be used to convert local to world coordinates
  69388. */
  69389. worldParentNode?: TransformNode;
  69390. }
  69391. /**
  69392. * A babylon container for an XR Anchor
  69393. */
  69394. export interface IWebXRAnchor {
  69395. /**
  69396. * A babylon-assigned ID for this anchor
  69397. */
  69398. id: number;
  69399. /**
  69400. * Transformation matrix to apply to an object attached to this anchor
  69401. */
  69402. transformationMatrix: Matrix;
  69403. /**
  69404. * The native anchor object
  69405. */
  69406. xrAnchor: XRAnchor;
  69407. }
  69408. /**
  69409. * An implementation of the anchor system of WebXR.
  69410. * Note that the current documented implementation is not available in any browser. Future implementations
  69411. * will use the frame to create an anchor and not the session or a detected plane
  69412. * For further information see https://github.com/immersive-web/anchors/
  69413. */
  69414. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69415. private _options;
  69416. private _enabled;
  69417. private _hitTestModule;
  69418. private _lastFrameDetected;
  69419. private _onSelect;
  69420. private _planeDetector;
  69421. private _trackedAnchors;
  69422. /**
  69423. * The module's name
  69424. */
  69425. static readonly Name: string;
  69426. /**
  69427. * The (Babylon) version of this module.
  69428. * This is an integer representing the implementation version.
  69429. * This number does not correspond to the WebXR specs version
  69430. */
  69431. static readonly Version: number;
  69432. /**
  69433. * Observers registered here will be executed when a new anchor was added to the session
  69434. */
  69435. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69436. /**
  69437. * Observers registered here will be executed when an anchor was removed from the session
  69438. */
  69439. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69440. /**
  69441. * Observers registered here will be executed when an existing anchor updates
  69442. * This can execute N times every frame
  69443. */
  69444. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69445. /**
  69446. * constructs a new anchor system
  69447. * @param _xrSessionManager an instance of WebXRSessionManager
  69448. * @param _options configuration object for this feature
  69449. */
  69450. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69451. /**
  69452. * Add anchor at a specific XR point.
  69453. *
  69454. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69455. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69456. * @returns a promise the fulfills when the anchor was created
  69457. */
  69458. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69459. /**
  69460. * attach this feature
  69461. * Will usually be called by the features manager
  69462. *
  69463. * @returns true if successful.
  69464. */
  69465. attach(): boolean;
  69466. /**
  69467. * detach this feature.
  69468. * Will usually be called by the features manager
  69469. *
  69470. * @returns true if successful.
  69471. */
  69472. detach(): boolean;
  69473. /**
  69474. * Dispose this feature and all of the resources attached
  69475. */
  69476. dispose(): void;
  69477. /**
  69478. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69479. * @param hitTestModule the hit-test module to use.
  69480. */
  69481. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69482. /**
  69483. * set the plane detector to use in order to create anchors from frames
  69484. * @param planeDetector the plane-detector module to use
  69485. * @param enable enable plane-anchors. default is true
  69486. */
  69487. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69488. protected _onXRFrame(frame: XRFrame): void;
  69489. /**
  69490. * avoiding using Array.find for global support.
  69491. * @param xrAnchor the plane to find in the array
  69492. */
  69493. private _findIndexInAnchorArray;
  69494. private _updateAnchorWithXRFrame;
  69495. }
  69496. }
  69497. declare module BABYLON {
  69498. /**
  69499. * Options interface for the background remover plugin
  69500. */
  69501. export interface IWebXRBackgroundRemoverOptions {
  69502. /**
  69503. * Further background meshes to disable when entering AR
  69504. */
  69505. backgroundMeshes?: AbstractMesh[];
  69506. /**
  69507. * flags to configure the removal of the environment helper.
  69508. * If not set, the entire background will be removed. If set, flags should be set as well.
  69509. */
  69510. environmentHelperRemovalFlags?: {
  69511. /**
  69512. * Should the skybox be removed (default false)
  69513. */
  69514. skyBox?: boolean;
  69515. /**
  69516. * Should the ground be removed (default false)
  69517. */
  69518. ground?: boolean;
  69519. };
  69520. /**
  69521. * don't disable the environment helper
  69522. */
  69523. ignoreEnvironmentHelper?: boolean;
  69524. }
  69525. /**
  69526. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69527. */
  69528. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69529. /**
  69530. * read-only options to be used in this module
  69531. */
  69532. readonly options: IWebXRBackgroundRemoverOptions;
  69533. /**
  69534. * The module's name
  69535. */
  69536. static readonly Name: string;
  69537. /**
  69538. * The (Babylon) version of this module.
  69539. * This is an integer representing the implementation version.
  69540. * This number does not correspond to the WebXR specs version
  69541. */
  69542. static readonly Version: number;
  69543. /**
  69544. * registered observers will be triggered when the background state changes
  69545. */
  69546. onBackgroundStateChangedObservable: Observable<boolean>;
  69547. /**
  69548. * constructs a new background remover module
  69549. * @param _xrSessionManager the session manager for this module
  69550. * @param options read-only options to be used in this module
  69551. */
  69552. constructor(_xrSessionManager: WebXRSessionManager,
  69553. /**
  69554. * read-only options to be used in this module
  69555. */
  69556. options?: IWebXRBackgroundRemoverOptions);
  69557. /**
  69558. * attach this feature
  69559. * Will usually be called by the features manager
  69560. *
  69561. * @returns true if successful.
  69562. */
  69563. attach(): boolean;
  69564. /**
  69565. * detach this feature.
  69566. * Will usually be called by the features manager
  69567. *
  69568. * @returns true if successful.
  69569. */
  69570. detach(): boolean;
  69571. /**
  69572. * Dispose this feature and all of the resources attached
  69573. */
  69574. dispose(): void;
  69575. protected _onXRFrame(_xrFrame: XRFrame): void;
  69576. private _setBackgroundState;
  69577. }
  69578. }
  69579. declare module BABYLON {
  69580. /**
  69581. * Options for the controller physics feature
  69582. */
  69583. export class IWebXRControllerPhysicsOptions {
  69584. /**
  69585. * Should the headset get its own impostor
  69586. */
  69587. enableHeadsetImpostor?: boolean;
  69588. /**
  69589. * Optional parameters for the headset impostor
  69590. */
  69591. headsetImpostorParams?: {
  69592. /**
  69593. * The type of impostor to create. Default is sphere
  69594. */
  69595. impostorType: number;
  69596. /**
  69597. * the size of the impostor. Defaults to 10cm
  69598. */
  69599. impostorSize?: number | {
  69600. width: number;
  69601. height: number;
  69602. depth: number;
  69603. };
  69604. /**
  69605. * Friction definitions
  69606. */
  69607. friction?: number;
  69608. /**
  69609. * Restitution
  69610. */
  69611. restitution?: number;
  69612. };
  69613. /**
  69614. * The physics properties of the future impostors
  69615. */
  69616. physicsProperties?: {
  69617. /**
  69618. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69619. * Note that this requires a physics engine that supports mesh impostors!
  69620. */
  69621. useControllerMesh?: boolean;
  69622. /**
  69623. * The type of impostor to create. Default is sphere
  69624. */
  69625. impostorType?: number;
  69626. /**
  69627. * the size of the impostor. Defaults to 10cm
  69628. */
  69629. impostorSize?: number | {
  69630. width: number;
  69631. height: number;
  69632. depth: number;
  69633. };
  69634. /**
  69635. * Friction definitions
  69636. */
  69637. friction?: number;
  69638. /**
  69639. * Restitution
  69640. */
  69641. restitution?: number;
  69642. };
  69643. /**
  69644. * the xr input to use with this pointer selection
  69645. */
  69646. xrInput: WebXRInput;
  69647. }
  69648. /**
  69649. * Add physics impostor to your webxr controllers,
  69650. * including naive calculation of their linear and angular velocity
  69651. */
  69652. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69653. private readonly _options;
  69654. private _attachController;
  69655. private _controllers;
  69656. private _debugMode;
  69657. private _delta;
  69658. private _headsetImpostor?;
  69659. private _headsetMesh?;
  69660. private _lastTimestamp;
  69661. private _tmpQuaternion;
  69662. private _tmpVector;
  69663. /**
  69664. * The module's name
  69665. */
  69666. static readonly Name: string;
  69667. /**
  69668. * The (Babylon) version of this module.
  69669. * This is an integer representing the implementation version.
  69670. * This number does not correspond to the webxr specs version
  69671. */
  69672. static readonly Version: number;
  69673. /**
  69674. * Construct a new Controller Physics Feature
  69675. * @param _xrSessionManager the corresponding xr session manager
  69676. * @param _options options to create this feature with
  69677. */
  69678. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69679. /**
  69680. * @hidden
  69681. * enable debugging - will show console outputs and the impostor mesh
  69682. */
  69683. _enablePhysicsDebug(): void;
  69684. /**
  69685. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69686. * @param xrController the controller to add
  69687. */
  69688. addController(xrController: WebXRInputSource): void;
  69689. /**
  69690. * attach this feature
  69691. * Will usually be called by the features manager
  69692. *
  69693. * @returns true if successful.
  69694. */
  69695. attach(): boolean;
  69696. /**
  69697. * detach this feature.
  69698. * Will usually be called by the features manager
  69699. *
  69700. * @returns true if successful.
  69701. */
  69702. detach(): boolean;
  69703. /**
  69704. * Get the headset impostor, if enabled
  69705. * @returns the impostor
  69706. */
  69707. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69708. /**
  69709. * Get the physics impostor of a specific controller.
  69710. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69711. * @param controller the controller or the controller id of which to get the impostor
  69712. * @returns the impostor or null
  69713. */
  69714. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69715. /**
  69716. * Update the physics properties provided in the constructor
  69717. * @param newProperties the new properties object
  69718. */
  69719. setPhysicsProperties(newProperties: {
  69720. impostorType?: number;
  69721. impostorSize?: number | {
  69722. width: number;
  69723. height: number;
  69724. depth: number;
  69725. };
  69726. friction?: number;
  69727. restitution?: number;
  69728. }): void;
  69729. protected _onXRFrame(_xrFrame: any): void;
  69730. private _detachController;
  69731. }
  69732. }
  69733. declare module BABYLON {
  69734. /**
  69735. * Options used for hit testing (version 2)
  69736. */
  69737. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  69738. /**
  69739. * Do not create a permanent hit test. Will usually be used when only
  69740. * transient inputs are needed.
  69741. */
  69742. disablePermanentHitTest?: boolean;
  69743. /**
  69744. * Enable transient (for example touch-based) hit test inspections
  69745. */
  69746. enableTransientHitTest?: boolean;
  69747. /**
  69748. * Offset ray for the permanent hit test
  69749. */
  69750. offsetRay?: Vector3;
  69751. /**
  69752. * Offset ray for the transient hit test
  69753. */
  69754. transientOffsetRay?: Vector3;
  69755. /**
  69756. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  69757. */
  69758. useReferenceSpace?: boolean;
  69759. }
  69760. /**
  69761. * Interface defining the babylon result of hit-test
  69762. */
  69763. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  69764. /**
  69765. * The input source that generated this hit test (if transient)
  69766. */
  69767. inputSource?: XRInputSource;
  69768. /**
  69769. * Is this a transient hit test
  69770. */
  69771. isTransient?: boolean;
  69772. /**
  69773. * Position of the hit test result
  69774. */
  69775. position: Vector3;
  69776. /**
  69777. * Rotation of the hit test result
  69778. */
  69779. rotationQuaternion: Quaternion;
  69780. }
  69781. /**
  69782. * The currently-working hit-test module.
  69783. * Hit test (or Ray-casting) is used to interact with the real world.
  69784. * For further information read here - https://github.com/immersive-web/hit-test
  69785. *
  69786. * Tested on chrome (mobile) 80.
  69787. */
  69788. export class WebXRHitTest extends WebXRAbstractFeature {
  69789. /**
  69790. * options to use when constructing this feature
  69791. */
  69792. readonly options: IWebXRHitTestOptions;
  69793. private _tmpMat;
  69794. private _tmpPos;
  69795. private _tmpQuat;
  69796. private _transientXrHitTestSource;
  69797. private _xrHitTestSource;
  69798. private initHitTestSource;
  69799. /**
  69800. * The module's name
  69801. */
  69802. static readonly Name: string;
  69803. /**
  69804. * The (Babylon) version of this module.
  69805. * This is an integer representing the implementation version.
  69806. * This number does not correspond to the WebXR specs version
  69807. */
  69808. static readonly Version: number;
  69809. /**
  69810. * When set to true, each hit test will have its own position/rotation objects
  69811. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  69812. * the developers will clone them or copy them as they see fit.
  69813. */
  69814. autoCloneTransformation: boolean;
  69815. /**
  69816. * Populated with the last native XR Hit Results
  69817. */
  69818. lastNativeXRHitResults: XRHitResult[];
  69819. /**
  69820. * Triggered when new babylon (transformed) hit test results are available
  69821. */
  69822. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  69823. /**
  69824. * Use this to temporarily pause hit test checks.
  69825. */
  69826. paused: boolean;
  69827. /**
  69828. * Creates a new instance of the hit test feature
  69829. * @param _xrSessionManager an instance of WebXRSessionManager
  69830. * @param options options to use when constructing this feature
  69831. */
  69832. constructor(_xrSessionManager: WebXRSessionManager,
  69833. /**
  69834. * options to use when constructing this feature
  69835. */
  69836. options?: IWebXRHitTestOptions);
  69837. /**
  69838. * attach this feature
  69839. * Will usually be called by the features manager
  69840. *
  69841. * @returns true if successful.
  69842. */
  69843. attach(): boolean;
  69844. /**
  69845. * detach this feature.
  69846. * Will usually be called by the features manager
  69847. *
  69848. * @returns true if successful.
  69849. */
  69850. detach(): boolean;
  69851. /**
  69852. * Dispose this feature and all of the resources attached
  69853. */
  69854. dispose(): void;
  69855. protected _onXRFrame(frame: XRFrame): void;
  69856. private _processWebXRHitTestResult;
  69857. }
  69858. }
  69859. declare module BABYLON {
  69860. /**
  69861. * The motion controller class for all microsoft mixed reality controllers
  69862. */
  69863. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69864. protected readonly _mapping: {
  69865. defaultButton: {
  69866. "valueNodeName": string;
  69867. "unpressedNodeName": string;
  69868. "pressedNodeName": string;
  69869. };
  69870. defaultAxis: {
  69871. "valueNodeName": string;
  69872. "minNodeName": string;
  69873. "maxNodeName": string;
  69874. };
  69875. buttons: {
  69876. "xr-standard-trigger": {
  69877. "rootNodeName": string;
  69878. "componentProperty": string;
  69879. "states": string[];
  69880. };
  69881. "xr-standard-squeeze": {
  69882. "rootNodeName": string;
  69883. "componentProperty": string;
  69884. "states": string[];
  69885. };
  69886. "xr-standard-touchpad": {
  69887. "rootNodeName": string;
  69888. "labelAnchorNodeName": string;
  69889. "touchPointNodeName": string;
  69890. };
  69891. "xr-standard-thumbstick": {
  69892. "rootNodeName": string;
  69893. "componentProperty": string;
  69894. "states": string[];
  69895. };
  69896. };
  69897. axes: {
  69898. "xr-standard-touchpad": {
  69899. "x-axis": {
  69900. "rootNodeName": string;
  69901. };
  69902. "y-axis": {
  69903. "rootNodeName": string;
  69904. };
  69905. };
  69906. "xr-standard-thumbstick": {
  69907. "x-axis": {
  69908. "rootNodeName": string;
  69909. };
  69910. "y-axis": {
  69911. "rootNodeName": string;
  69912. };
  69913. };
  69914. };
  69915. };
  69916. /**
  69917. * The base url used to load the left and right controller models
  69918. */
  69919. static MODEL_BASE_URL: string;
  69920. /**
  69921. * The name of the left controller model file
  69922. */
  69923. static MODEL_LEFT_FILENAME: string;
  69924. /**
  69925. * The name of the right controller model file
  69926. */
  69927. static MODEL_RIGHT_FILENAME: string;
  69928. profileId: string;
  69929. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69930. protected _getFilenameAndPath(): {
  69931. filename: string;
  69932. path: string;
  69933. };
  69934. protected _getModelLoadingConstraints(): boolean;
  69935. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69936. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69937. protected _updateModel(): void;
  69938. }
  69939. }
  69940. declare module BABYLON {
  69941. /**
  69942. * The motion controller class for oculus touch (quest, rift).
  69943. * This class supports legacy mapping as well the standard xr mapping
  69944. */
  69945. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69946. private _forceLegacyControllers;
  69947. private _modelRootNode;
  69948. /**
  69949. * The base url used to load the left and right controller models
  69950. */
  69951. static MODEL_BASE_URL: string;
  69952. /**
  69953. * The name of the left controller model file
  69954. */
  69955. static MODEL_LEFT_FILENAME: string;
  69956. /**
  69957. * The name of the right controller model file
  69958. */
  69959. static MODEL_RIGHT_FILENAME: string;
  69960. /**
  69961. * Base Url for the Quest controller model.
  69962. */
  69963. static QUEST_MODEL_BASE_URL: string;
  69964. profileId: string;
  69965. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69966. protected _getFilenameAndPath(): {
  69967. filename: string;
  69968. path: string;
  69969. };
  69970. protected _getModelLoadingConstraints(): boolean;
  69971. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69972. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69973. protected _updateModel(): void;
  69974. /**
  69975. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69976. * between the touch and touch 2.
  69977. */
  69978. private _isQuest;
  69979. }
  69980. }
  69981. declare module BABYLON {
  69982. /**
  69983. * The motion controller class for the standard HTC-Vive controllers
  69984. */
  69985. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69986. private _modelRootNode;
  69987. /**
  69988. * The base url used to load the left and right controller models
  69989. */
  69990. static MODEL_BASE_URL: string;
  69991. /**
  69992. * File name for the controller model.
  69993. */
  69994. static MODEL_FILENAME: string;
  69995. profileId: string;
  69996. /**
  69997. * Create a new Vive motion controller object
  69998. * @param scene the scene to use to create this controller
  69999. * @param gamepadObject the corresponding gamepad object
  70000. * @param handness the handness of the controller
  70001. */
  70002. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70003. protected _getFilenameAndPath(): {
  70004. filename: string;
  70005. path: string;
  70006. };
  70007. protected _getModelLoadingConstraints(): boolean;
  70008. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70009. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70010. protected _updateModel(): void;
  70011. }
  70012. }
  70013. declare module BABYLON {
  70014. /**
  70015. * A cursor which tracks a point on a path
  70016. */
  70017. export class PathCursor {
  70018. private path;
  70019. /**
  70020. * Stores path cursor callbacks for when an onchange event is triggered
  70021. */
  70022. private _onchange;
  70023. /**
  70024. * The value of the path cursor
  70025. */
  70026. value: number;
  70027. /**
  70028. * The animation array of the path cursor
  70029. */
  70030. animations: Animation[];
  70031. /**
  70032. * Initializes the path cursor
  70033. * @param path The path to track
  70034. */
  70035. constructor(path: Path2);
  70036. /**
  70037. * Gets the cursor point on the path
  70038. * @returns A point on the path cursor at the cursor location
  70039. */
  70040. getPoint(): Vector3;
  70041. /**
  70042. * Moves the cursor ahead by the step amount
  70043. * @param step The amount to move the cursor forward
  70044. * @returns This path cursor
  70045. */
  70046. moveAhead(step?: number): PathCursor;
  70047. /**
  70048. * Moves the cursor behind by the step amount
  70049. * @param step The amount to move the cursor back
  70050. * @returns This path cursor
  70051. */
  70052. moveBack(step?: number): PathCursor;
  70053. /**
  70054. * Moves the cursor by the step amount
  70055. * If the step amount is greater than one, an exception is thrown
  70056. * @param step The amount to move the cursor
  70057. * @returns This path cursor
  70058. */
  70059. move(step: number): PathCursor;
  70060. /**
  70061. * Ensures that the value is limited between zero and one
  70062. * @returns This path cursor
  70063. */
  70064. private ensureLimits;
  70065. /**
  70066. * Runs onchange callbacks on change (used by the animation engine)
  70067. * @returns This path cursor
  70068. */
  70069. private raiseOnChange;
  70070. /**
  70071. * Executes a function on change
  70072. * @param f A path cursor onchange callback
  70073. * @returns This path cursor
  70074. */
  70075. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70076. }
  70077. }
  70078. declare module BABYLON {
  70079. /** @hidden */
  70080. export var blurPixelShader: {
  70081. name: string;
  70082. shader: string;
  70083. };
  70084. }
  70085. declare module BABYLON {
  70086. /** @hidden */
  70087. export var pointCloudVertexDeclaration: {
  70088. name: string;
  70089. shader: string;
  70090. };
  70091. }
  70092. // Mixins
  70093. interface Window {
  70094. mozIndexedDB: IDBFactory;
  70095. webkitIndexedDB: IDBFactory;
  70096. msIndexedDB: IDBFactory;
  70097. webkitURL: typeof URL;
  70098. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70099. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70100. WebGLRenderingContext: WebGLRenderingContext;
  70101. MSGesture: MSGesture;
  70102. CANNON: any;
  70103. AudioContext: AudioContext;
  70104. webkitAudioContext: AudioContext;
  70105. PointerEvent: any;
  70106. Math: Math;
  70107. Uint8Array: Uint8ArrayConstructor;
  70108. Float32Array: Float32ArrayConstructor;
  70109. mozURL: typeof URL;
  70110. msURL: typeof URL;
  70111. VRFrameData: any; // WebVR, from specs 1.1
  70112. DracoDecoderModule: any;
  70113. setImmediate(handler: (...args: any[]) => void): number;
  70114. }
  70115. interface HTMLCanvasElement {
  70116. requestPointerLock(): void;
  70117. msRequestPointerLock?(): void;
  70118. mozRequestPointerLock?(): void;
  70119. webkitRequestPointerLock?(): void;
  70120. /** Track wether a record is in progress */
  70121. isRecording: boolean;
  70122. /** Capture Stream method defined by some browsers */
  70123. captureStream(fps?: number): MediaStream;
  70124. }
  70125. interface CanvasRenderingContext2D {
  70126. msImageSmoothingEnabled: boolean;
  70127. }
  70128. interface MouseEvent {
  70129. mozMovementX: number;
  70130. mozMovementY: number;
  70131. webkitMovementX: number;
  70132. webkitMovementY: number;
  70133. msMovementX: number;
  70134. msMovementY: number;
  70135. }
  70136. interface Navigator {
  70137. mozGetVRDevices: (any: any) => any;
  70138. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70139. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70140. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70141. webkitGetGamepads(): Gamepad[];
  70142. msGetGamepads(): Gamepad[];
  70143. webkitGamepads(): Gamepad[];
  70144. }
  70145. interface HTMLVideoElement {
  70146. mozSrcObject: any;
  70147. }
  70148. interface Math {
  70149. fround(x: number): number;
  70150. imul(a: number, b: number): number;
  70151. }
  70152. interface WebGLRenderingContext {
  70153. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70154. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70155. vertexAttribDivisor(index: number, divisor: number): void;
  70156. createVertexArray(): any;
  70157. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70158. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70159. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70160. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70161. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70162. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70163. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70164. // Queries
  70165. createQuery(): WebGLQuery;
  70166. deleteQuery(query: WebGLQuery): void;
  70167. beginQuery(target: number, query: WebGLQuery): void;
  70168. endQuery(target: number): void;
  70169. getQueryParameter(query: WebGLQuery, pname: number): any;
  70170. getQuery(target: number, pname: number): any;
  70171. MAX_SAMPLES: number;
  70172. RGBA8: number;
  70173. READ_FRAMEBUFFER: number;
  70174. DRAW_FRAMEBUFFER: number;
  70175. UNIFORM_BUFFER: number;
  70176. HALF_FLOAT_OES: number;
  70177. RGBA16F: number;
  70178. RGBA32F: number;
  70179. R32F: number;
  70180. RG32F: number;
  70181. RGB32F: number;
  70182. R16F: number;
  70183. RG16F: number;
  70184. RGB16F: number;
  70185. RED: number;
  70186. RG: number;
  70187. R8: number;
  70188. RG8: number;
  70189. UNSIGNED_INT_24_8: number;
  70190. DEPTH24_STENCIL8: number;
  70191. MIN: number;
  70192. MAX: number;
  70193. /* Multiple Render Targets */
  70194. drawBuffers(buffers: number[]): void;
  70195. readBuffer(src: number): void;
  70196. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70197. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70198. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70199. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70200. // Occlusion Query
  70201. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70202. ANY_SAMPLES_PASSED: number;
  70203. QUERY_RESULT_AVAILABLE: number;
  70204. QUERY_RESULT: number;
  70205. }
  70206. interface WebGLProgram {
  70207. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70208. }
  70209. interface EXT_disjoint_timer_query {
  70210. QUERY_COUNTER_BITS_EXT: number;
  70211. TIME_ELAPSED_EXT: number;
  70212. TIMESTAMP_EXT: number;
  70213. GPU_DISJOINT_EXT: number;
  70214. QUERY_RESULT_EXT: number;
  70215. QUERY_RESULT_AVAILABLE_EXT: number;
  70216. queryCounterEXT(query: WebGLQuery, target: number): void;
  70217. createQueryEXT(): WebGLQuery;
  70218. beginQueryEXT(target: number, query: WebGLQuery): void;
  70219. endQueryEXT(target: number): void;
  70220. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70221. deleteQueryEXT(query: WebGLQuery): void;
  70222. }
  70223. interface WebGLUniformLocation {
  70224. _currentState: any;
  70225. }
  70226. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70227. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70228. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70229. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70230. interface WebGLRenderingContext {
  70231. readonly RASTERIZER_DISCARD: number;
  70232. readonly DEPTH_COMPONENT24: number;
  70233. readonly TEXTURE_3D: number;
  70234. readonly TEXTURE_2D_ARRAY: number;
  70235. readonly TEXTURE_COMPARE_FUNC: number;
  70236. readonly TEXTURE_COMPARE_MODE: number;
  70237. readonly COMPARE_REF_TO_TEXTURE: number;
  70238. readonly TEXTURE_WRAP_R: number;
  70239. readonly HALF_FLOAT: number;
  70240. readonly RGB8: number;
  70241. readonly RED_INTEGER: number;
  70242. readonly RG_INTEGER: number;
  70243. readonly RGB_INTEGER: number;
  70244. readonly RGBA_INTEGER: number;
  70245. readonly R8_SNORM: number;
  70246. readonly RG8_SNORM: number;
  70247. readonly RGB8_SNORM: number;
  70248. readonly RGBA8_SNORM: number;
  70249. readonly R8I: number;
  70250. readonly RG8I: number;
  70251. readonly RGB8I: number;
  70252. readonly RGBA8I: number;
  70253. readonly R8UI: number;
  70254. readonly RG8UI: number;
  70255. readonly RGB8UI: number;
  70256. readonly RGBA8UI: number;
  70257. readonly R16I: number;
  70258. readonly RG16I: number;
  70259. readonly RGB16I: number;
  70260. readonly RGBA16I: number;
  70261. readonly R16UI: number;
  70262. readonly RG16UI: number;
  70263. readonly RGB16UI: number;
  70264. readonly RGBA16UI: number;
  70265. readonly R32I: number;
  70266. readonly RG32I: number;
  70267. readonly RGB32I: number;
  70268. readonly RGBA32I: number;
  70269. readonly R32UI: number;
  70270. readonly RG32UI: number;
  70271. readonly RGB32UI: number;
  70272. readonly RGBA32UI: number;
  70273. readonly RGB10_A2UI: number;
  70274. readonly R11F_G11F_B10F: number;
  70275. readonly RGB9_E5: number;
  70276. readonly RGB10_A2: number;
  70277. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70278. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70279. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70280. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70281. readonly DEPTH_COMPONENT32F: number;
  70282. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70283. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70284. 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;
  70285. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70286. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70287. readonly TRANSFORM_FEEDBACK: number;
  70288. readonly INTERLEAVED_ATTRIBS: number;
  70289. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70290. createTransformFeedback(): WebGLTransformFeedback;
  70291. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70292. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70293. beginTransformFeedback(primitiveMode: number): void;
  70294. endTransformFeedback(): void;
  70295. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70296. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70297. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70298. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70299. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70300. }
  70301. interface ImageBitmap {
  70302. readonly width: number;
  70303. readonly height: number;
  70304. close(): void;
  70305. }
  70306. interface WebGLQuery extends WebGLObject {
  70307. }
  70308. declare var WebGLQuery: {
  70309. prototype: WebGLQuery;
  70310. new(): WebGLQuery;
  70311. };
  70312. interface WebGLSampler extends WebGLObject {
  70313. }
  70314. declare var WebGLSampler: {
  70315. prototype: WebGLSampler;
  70316. new(): WebGLSampler;
  70317. };
  70318. interface WebGLSync extends WebGLObject {
  70319. }
  70320. declare var WebGLSync: {
  70321. prototype: WebGLSync;
  70322. new(): WebGLSync;
  70323. };
  70324. interface WebGLTransformFeedback extends WebGLObject {
  70325. }
  70326. declare var WebGLTransformFeedback: {
  70327. prototype: WebGLTransformFeedback;
  70328. new(): WebGLTransformFeedback;
  70329. };
  70330. interface WebGLVertexArrayObject extends WebGLObject {
  70331. }
  70332. declare var WebGLVertexArrayObject: {
  70333. prototype: WebGLVertexArrayObject;
  70334. new(): WebGLVertexArrayObject;
  70335. };
  70336. // Type definitions for WebVR API
  70337. // Project: https://w3c.github.io/webvr/
  70338. // Definitions by: six a <https://github.com/lostfictions>
  70339. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70340. interface VRDisplay extends EventTarget {
  70341. /**
  70342. * Dictionary of capabilities describing the VRDisplay.
  70343. */
  70344. readonly capabilities: VRDisplayCapabilities;
  70345. /**
  70346. * z-depth defining the far plane of the eye view frustum
  70347. * enables mapping of values in the render target depth
  70348. * attachment to scene coordinates. Initially set to 10000.0.
  70349. */
  70350. depthFar: number;
  70351. /**
  70352. * z-depth defining the near plane of the eye view frustum
  70353. * enables mapping of values in the render target depth
  70354. * attachment to scene coordinates. Initially set to 0.01.
  70355. */
  70356. depthNear: number;
  70357. /**
  70358. * An identifier for this distinct VRDisplay. Used as an
  70359. * association point in the Gamepad API.
  70360. */
  70361. readonly displayId: number;
  70362. /**
  70363. * A display name, a user-readable name identifying it.
  70364. */
  70365. readonly displayName: string;
  70366. readonly isConnected: boolean;
  70367. readonly isPresenting: boolean;
  70368. /**
  70369. * If this VRDisplay supports room-scale experiences, the optional
  70370. * stage attribute contains details on the room-scale parameters.
  70371. */
  70372. readonly stageParameters: VRStageParameters | null;
  70373. /**
  70374. * Passing the value returned by `requestAnimationFrame` to
  70375. * `cancelAnimationFrame` will unregister the callback.
  70376. * @param handle Define the hanle of the request to cancel
  70377. */
  70378. cancelAnimationFrame(handle: number): void;
  70379. /**
  70380. * Stops presenting to the VRDisplay.
  70381. * @returns a promise to know when it stopped
  70382. */
  70383. exitPresent(): Promise<void>;
  70384. /**
  70385. * Return the current VREyeParameters for the given eye.
  70386. * @param whichEye Define the eye we want the parameter for
  70387. * @returns the eye parameters
  70388. */
  70389. getEyeParameters(whichEye: string): VREyeParameters;
  70390. /**
  70391. * Populates the passed VRFrameData with the information required to render
  70392. * the current frame.
  70393. * @param frameData Define the data structure to populate
  70394. * @returns true if ok otherwise false
  70395. */
  70396. getFrameData(frameData: VRFrameData): boolean;
  70397. /**
  70398. * Get the layers currently being presented.
  70399. * @returns the list of VR layers
  70400. */
  70401. getLayers(): VRLayer[];
  70402. /**
  70403. * Return a VRPose containing the future predicted pose of the VRDisplay
  70404. * when the current frame will be presented. The value returned will not
  70405. * change until JavaScript has returned control to the browser.
  70406. *
  70407. * The VRPose will contain the position, orientation, velocity,
  70408. * and acceleration of each of these properties.
  70409. * @returns the pose object
  70410. */
  70411. getPose(): VRPose;
  70412. /**
  70413. * Return the current instantaneous pose of the VRDisplay, with no
  70414. * prediction applied.
  70415. * @returns the current instantaneous pose
  70416. */
  70417. getImmediatePose(): VRPose;
  70418. /**
  70419. * The callback passed to `requestAnimationFrame` will be called
  70420. * any time a new frame should be rendered. When the VRDisplay is
  70421. * presenting the callback will be called at the native refresh
  70422. * rate of the HMD. When not presenting this function acts
  70423. * identically to how window.requestAnimationFrame acts. Content should
  70424. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70425. * asynchronously from other displays and at differing refresh rates.
  70426. * @param callback Define the eaction to run next frame
  70427. * @returns the request handle it
  70428. */
  70429. requestAnimationFrame(callback: FrameRequestCallback): number;
  70430. /**
  70431. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70432. * Repeat calls while already presenting will update the VRLayers being displayed.
  70433. * @param layers Define the list of layer to present
  70434. * @returns a promise to know when the request has been fulfilled
  70435. */
  70436. requestPresent(layers: VRLayer[]): Promise<void>;
  70437. /**
  70438. * Reset the pose for this display, treating its current position and
  70439. * orientation as the "origin/zero" values. VRPose.position,
  70440. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70441. * updated when calling resetPose(). This should be called in only
  70442. * sitting-space experiences.
  70443. */
  70444. resetPose(): void;
  70445. /**
  70446. * The VRLayer provided to the VRDisplay will be captured and presented
  70447. * in the HMD. Calling this function has the same effect on the source
  70448. * canvas as any other operation that uses its source image, and canvases
  70449. * created without preserveDrawingBuffer set to true will be cleared.
  70450. * @param pose Define the pose to submit
  70451. */
  70452. submitFrame(pose?: VRPose): void;
  70453. }
  70454. declare var VRDisplay: {
  70455. prototype: VRDisplay;
  70456. new(): VRDisplay;
  70457. };
  70458. interface VRLayer {
  70459. leftBounds?: number[] | Float32Array | null;
  70460. rightBounds?: number[] | Float32Array | null;
  70461. source?: HTMLCanvasElement | null;
  70462. }
  70463. interface VRDisplayCapabilities {
  70464. readonly canPresent: boolean;
  70465. readonly hasExternalDisplay: boolean;
  70466. readonly hasOrientation: boolean;
  70467. readonly hasPosition: boolean;
  70468. readonly maxLayers: number;
  70469. }
  70470. interface VREyeParameters {
  70471. /** @deprecated */
  70472. readonly fieldOfView: VRFieldOfView;
  70473. readonly offset: Float32Array;
  70474. readonly renderHeight: number;
  70475. readonly renderWidth: number;
  70476. }
  70477. interface VRFieldOfView {
  70478. readonly downDegrees: number;
  70479. readonly leftDegrees: number;
  70480. readonly rightDegrees: number;
  70481. readonly upDegrees: number;
  70482. }
  70483. interface VRFrameData {
  70484. readonly leftProjectionMatrix: Float32Array;
  70485. readonly leftViewMatrix: Float32Array;
  70486. readonly pose: VRPose;
  70487. readonly rightProjectionMatrix: Float32Array;
  70488. readonly rightViewMatrix: Float32Array;
  70489. readonly timestamp: number;
  70490. }
  70491. interface VRPose {
  70492. readonly angularAcceleration: Float32Array | null;
  70493. readonly angularVelocity: Float32Array | null;
  70494. readonly linearAcceleration: Float32Array | null;
  70495. readonly linearVelocity: Float32Array | null;
  70496. readonly orientation: Float32Array | null;
  70497. readonly position: Float32Array | null;
  70498. readonly timestamp: number;
  70499. }
  70500. interface VRStageParameters {
  70501. sittingToStandingTransform?: Float32Array;
  70502. sizeX?: number;
  70503. sizeY?: number;
  70504. }
  70505. interface Navigator {
  70506. getVRDisplays(): Promise<VRDisplay[]>;
  70507. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70508. }
  70509. interface Window {
  70510. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70511. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70512. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70513. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70514. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70515. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70516. }
  70517. interface Gamepad {
  70518. readonly displayId: number;
  70519. }
  70520. type XRSessionMode =
  70521. | "inline"
  70522. | "immersive-vr"
  70523. | "immersive-ar";
  70524. type XRReferenceSpaceType =
  70525. | "viewer"
  70526. | "local"
  70527. | "local-floor"
  70528. | "bounded-floor"
  70529. | "unbounded";
  70530. type XREnvironmentBlendMode =
  70531. | "opaque"
  70532. | "additive"
  70533. | "alpha-blend";
  70534. type XRVisibilityState =
  70535. | "visible"
  70536. | "visible-blurred"
  70537. | "hidden";
  70538. type XRHandedness =
  70539. | "none"
  70540. | "left"
  70541. | "right";
  70542. type XRTargetRayMode =
  70543. | "gaze"
  70544. | "tracked-pointer"
  70545. | "screen";
  70546. type XREye =
  70547. | "none"
  70548. | "left"
  70549. | "right";
  70550. interface XRSpace extends EventTarget {
  70551. }
  70552. interface XRRenderState {
  70553. depthNear?: number;
  70554. depthFar?: number;
  70555. inlineVerticalFieldOfView?: number;
  70556. baseLayer?: XRWebGLLayer;
  70557. }
  70558. interface XRInputSource {
  70559. handedness: XRHandedness;
  70560. targetRayMode: XRTargetRayMode;
  70561. targetRaySpace: XRSpace;
  70562. gripSpace: XRSpace | undefined;
  70563. gamepad: Gamepad | undefined;
  70564. profiles: Array<string>;
  70565. }
  70566. interface XRSessionInit {
  70567. optionalFeatures?: XRReferenceSpaceType[];
  70568. requiredFeatures?: XRReferenceSpaceType[];
  70569. }
  70570. interface XRSession extends XRAnchorCreator {
  70571. addEventListener: Function;
  70572. removeEventListener: Function;
  70573. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70574. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70575. requestAnimationFrame: Function;
  70576. end(): Promise<void>;
  70577. renderState: XRRenderState;
  70578. inputSources: Array<XRInputSource>;
  70579. // hit test
  70580. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70581. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70582. // legacy AR hit test
  70583. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70584. // legacy plane detection
  70585. updateWorldTrackingState(options: {
  70586. planeDetectionState?: { enabled: boolean; }
  70587. }): void;
  70588. }
  70589. interface XRReferenceSpace extends XRSpace {
  70590. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70591. onreset: any;
  70592. }
  70593. type XRPlaneSet = Set<XRPlane>;
  70594. type XRAnchorSet = Set<XRAnchor>;
  70595. interface XRFrame {
  70596. session: XRSession;
  70597. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70598. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70599. // AR
  70600. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70601. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70602. // Anchors
  70603. trackedAnchors?: XRAnchorSet;
  70604. // Planes
  70605. worldInformation: {
  70606. detectedPlanes?: XRPlaneSet;
  70607. };
  70608. }
  70609. interface XRViewerPose extends XRPose {
  70610. views: Array<XRView>;
  70611. }
  70612. interface XRPose {
  70613. transform: XRRigidTransform;
  70614. emulatedPosition: boolean;
  70615. }
  70616. interface XRWebGLLayerOptions {
  70617. antialias?: boolean;
  70618. depth?: boolean;
  70619. stencil?: boolean;
  70620. alpha?: boolean;
  70621. multiview?: boolean;
  70622. framebufferScaleFactor?: number;
  70623. }
  70624. declare var XRWebGLLayer: {
  70625. prototype: XRWebGLLayer;
  70626. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70627. };
  70628. interface XRWebGLLayer {
  70629. framebuffer: WebGLFramebuffer;
  70630. framebufferWidth: number;
  70631. framebufferHeight: number;
  70632. getViewport: Function;
  70633. }
  70634. declare class XRRigidTransform {
  70635. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70636. position: DOMPointReadOnly;
  70637. orientation: DOMPointReadOnly;
  70638. matrix: Float32Array;
  70639. inverse: XRRigidTransform;
  70640. }
  70641. interface XRView {
  70642. eye: XREye;
  70643. projectionMatrix: Float32Array;
  70644. transform: XRRigidTransform;
  70645. }
  70646. interface XRInputSourceChangeEvent {
  70647. session: XRSession;
  70648. removed: Array<XRInputSource>;
  70649. added: Array<XRInputSource>;
  70650. }
  70651. interface XRInputSourceEvent extends Event {
  70652. readonly frame: XRFrame;
  70653. readonly inputSource: XRInputSource;
  70654. }
  70655. // Experimental(er) features
  70656. declare class XRRay {
  70657. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70658. origin: DOMPointReadOnly;
  70659. direction: DOMPointReadOnly;
  70660. matrix: Float32Array;
  70661. }
  70662. declare enum XRHitTestTrackableType {
  70663. "point",
  70664. "plane"
  70665. }
  70666. interface XRHitResult {
  70667. hitMatrix: Float32Array;
  70668. }
  70669. interface XRTransientInputHitTestResult {
  70670. readonly inputSource: XRInputSource;
  70671. readonly results: Array<XRHitTestResult>;
  70672. }
  70673. interface XRHitTestResult {
  70674. getPose(baseSpace: XRSpace): XRPose | undefined;
  70675. }
  70676. interface XRHitTestSource {
  70677. cancel(): void;
  70678. }
  70679. interface XRTransientInputHitTestSource {
  70680. cancel(): void;
  70681. }
  70682. interface XRHitTestOptionsInit {
  70683. space: XRSpace;
  70684. entityTypes?: Array<XRHitTestTrackableType>;
  70685. offsetRay?: XRRay;
  70686. }
  70687. interface XRTransientInputHitTestOptionsInit {
  70688. profile: string;
  70689. entityTypes?: Array<XRHitTestTrackableType>;
  70690. offsetRay?: XRRay;
  70691. }
  70692. interface XRAnchor {
  70693. // remove?
  70694. id?: string;
  70695. anchorSpace: XRSpace;
  70696. lastChangedTime: number;
  70697. detach(): void;
  70698. }
  70699. interface XRPlane extends XRAnchorCreator {
  70700. orientation: "Horizontal" | "Vertical";
  70701. planeSpace: XRSpace;
  70702. polygon: Array<DOMPointReadOnly>;
  70703. lastChangedTime: number;
  70704. }
  70705. interface XRAnchorCreator {
  70706. // AR Anchors
  70707. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70708. }
  70709. /**
  70710. * @ignore
  70711. */
  70712. declare module BABYLON.GLTF2.Exporter {
  70713. }
  70714. /**
  70715. * @ignore
  70716. */
  70717. declare module BABYLON.GLTF1 {
  70718. }
  70719. declare module BABYLON.GUI {
  70720. /**
  70721. * Class used to specific a value and its associated unit
  70722. */
  70723. export class ValueAndUnit {
  70724. /** defines the unit to store */
  70725. unit: number;
  70726. /** defines a boolean indicating if the value can be negative */
  70727. negativeValueAllowed: boolean;
  70728. private _value;
  70729. private _originalUnit;
  70730. /**
  70731. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70732. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70733. */
  70734. ignoreAdaptiveScaling: boolean;
  70735. /**
  70736. * Creates a new ValueAndUnit
  70737. * @param value defines the value to store
  70738. * @param unit defines the unit to store
  70739. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70740. */
  70741. constructor(value: number,
  70742. /** defines the unit to store */
  70743. unit?: number,
  70744. /** defines a boolean indicating if the value can be negative */
  70745. negativeValueAllowed?: boolean);
  70746. /** Gets a boolean indicating if the value is a percentage */
  70747. get isPercentage(): boolean;
  70748. /** Gets a boolean indicating if the value is store as pixel */
  70749. get isPixel(): boolean;
  70750. /** Gets direct internal value */
  70751. get internalValue(): number;
  70752. /**
  70753. * Gets value as pixel
  70754. * @param host defines the root host
  70755. * @param refValue defines the reference value for percentages
  70756. * @returns the value as pixel
  70757. */
  70758. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70759. /**
  70760. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70761. * @param value defines the value to store
  70762. * @param unit defines the unit to store
  70763. * @returns the current ValueAndUnit
  70764. */
  70765. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70766. /**
  70767. * Gets the value accordingly to its unit
  70768. * @param host defines the root host
  70769. * @returns the value
  70770. */
  70771. getValue(host: AdvancedDynamicTexture): number;
  70772. /**
  70773. * Gets a string representation of the value
  70774. * @param host defines the root host
  70775. * @param decimals defines an optional number of decimals to display
  70776. * @returns a string
  70777. */
  70778. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70779. /**
  70780. * Store a value parsed from a string
  70781. * @param source defines the source string
  70782. * @returns true if the value was successfully parsed
  70783. */
  70784. fromString(source: string | number): boolean;
  70785. private static _Regex;
  70786. private static _UNITMODE_PERCENTAGE;
  70787. private static _UNITMODE_PIXEL;
  70788. /** UNITMODE_PERCENTAGE */
  70789. static get UNITMODE_PERCENTAGE(): number;
  70790. /** UNITMODE_PIXEL */
  70791. static get UNITMODE_PIXEL(): number;
  70792. }
  70793. }
  70794. declare module BABYLON.GUI {
  70795. /**
  70796. * Define a style used by control to automatically setup properties based on a template.
  70797. * Only support font related properties so far
  70798. */
  70799. export class Style implements BABYLON.IDisposable {
  70800. private _fontFamily;
  70801. private _fontStyle;
  70802. private _fontWeight;
  70803. /** @hidden */
  70804. _host: AdvancedDynamicTexture;
  70805. /** @hidden */
  70806. _fontSize: ValueAndUnit;
  70807. /**
  70808. * BABYLON.Observable raised when the style values are changed
  70809. */
  70810. onChangedObservable: BABYLON.Observable<Style>;
  70811. /**
  70812. * Creates a new style object
  70813. * @param host defines the AdvancedDynamicTexture which hosts this style
  70814. */
  70815. constructor(host: AdvancedDynamicTexture);
  70816. /**
  70817. * Gets or sets the font size
  70818. */
  70819. get fontSize(): string | number;
  70820. set fontSize(value: string | number);
  70821. /**
  70822. * Gets or sets the font family
  70823. */
  70824. get fontFamily(): string;
  70825. set fontFamily(value: string);
  70826. /**
  70827. * Gets or sets the font style
  70828. */
  70829. get fontStyle(): string;
  70830. set fontStyle(value: string);
  70831. /** Gets or sets font weight */
  70832. get fontWeight(): string;
  70833. set fontWeight(value: string);
  70834. /** Dispose all associated resources */
  70835. dispose(): void;
  70836. }
  70837. }
  70838. declare module BABYLON.GUI {
  70839. /**
  70840. * Class used to transport BABYLON.Vector2 information for pointer events
  70841. */
  70842. export class Vector2WithInfo extends BABYLON.Vector2 {
  70843. /** defines the current mouse button index */
  70844. buttonIndex: number;
  70845. /**
  70846. * Creates a new Vector2WithInfo
  70847. * @param source defines the vector2 data to transport
  70848. * @param buttonIndex defines the current mouse button index
  70849. */
  70850. constructor(source: BABYLON.Vector2,
  70851. /** defines the current mouse button index */
  70852. buttonIndex?: number);
  70853. }
  70854. /** Class used to provide 2D matrix features */
  70855. export class Matrix2D {
  70856. /** Gets the internal array of 6 floats used to store matrix data */
  70857. m: Float32Array;
  70858. /**
  70859. * Creates a new matrix
  70860. * @param m00 defines value for (0, 0)
  70861. * @param m01 defines value for (0, 1)
  70862. * @param m10 defines value for (1, 0)
  70863. * @param m11 defines value for (1, 1)
  70864. * @param m20 defines value for (2, 0)
  70865. * @param m21 defines value for (2, 1)
  70866. */
  70867. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70868. /**
  70869. * Fills the matrix from direct values
  70870. * @param m00 defines value for (0, 0)
  70871. * @param m01 defines value for (0, 1)
  70872. * @param m10 defines value for (1, 0)
  70873. * @param m11 defines value for (1, 1)
  70874. * @param m20 defines value for (2, 0)
  70875. * @param m21 defines value for (2, 1)
  70876. * @returns the current modified matrix
  70877. */
  70878. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70879. /**
  70880. * Gets matrix determinant
  70881. * @returns the determinant
  70882. */
  70883. determinant(): number;
  70884. /**
  70885. * Inverses the matrix and stores it in a target matrix
  70886. * @param result defines the target matrix
  70887. * @returns the current matrix
  70888. */
  70889. invertToRef(result: Matrix2D): Matrix2D;
  70890. /**
  70891. * Multiplies the current matrix with another one
  70892. * @param other defines the second operand
  70893. * @param result defines the target matrix
  70894. * @returns the current matrix
  70895. */
  70896. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70897. /**
  70898. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70899. * @param x defines the x coordinate to transform
  70900. * @param y defines the x coordinate to transform
  70901. * @param result defines the target vector2
  70902. * @returns the current matrix
  70903. */
  70904. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70905. /**
  70906. * Creates an identity matrix
  70907. * @returns a new matrix
  70908. */
  70909. static Identity(): Matrix2D;
  70910. /**
  70911. * Creates a translation matrix and stores it in a target matrix
  70912. * @param x defines the x coordinate of the translation
  70913. * @param y defines the y coordinate of the translation
  70914. * @param result defines the target matrix
  70915. */
  70916. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70917. /**
  70918. * Creates a scaling matrix and stores it in a target matrix
  70919. * @param x defines the x coordinate of the scaling
  70920. * @param y defines the y coordinate of the scaling
  70921. * @param result defines the target matrix
  70922. */
  70923. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70924. /**
  70925. * Creates a rotation matrix and stores it in a target matrix
  70926. * @param angle defines the rotation angle
  70927. * @param result defines the target matrix
  70928. */
  70929. static RotationToRef(angle: number, result: Matrix2D): void;
  70930. private static _TempPreTranslationMatrix;
  70931. private static _TempPostTranslationMatrix;
  70932. private static _TempRotationMatrix;
  70933. private static _TempScalingMatrix;
  70934. private static _TempCompose0;
  70935. private static _TempCompose1;
  70936. private static _TempCompose2;
  70937. /**
  70938. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70939. * @param tx defines the x coordinate of the translation
  70940. * @param ty defines the y coordinate of the translation
  70941. * @param angle defines the rotation angle
  70942. * @param scaleX defines the x coordinate of the scaling
  70943. * @param scaleY defines the y coordinate of the scaling
  70944. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70945. * @param result defines the target matrix
  70946. */
  70947. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70948. }
  70949. }
  70950. declare module BABYLON.GUI {
  70951. /**
  70952. * Class used to store 2D control sizes
  70953. */
  70954. export class Measure {
  70955. /** defines left coordinate */
  70956. left: number;
  70957. /** defines top coordinate */
  70958. top: number;
  70959. /** defines width dimension */
  70960. width: number;
  70961. /** defines height dimension */
  70962. height: number;
  70963. /**
  70964. * Creates a new measure
  70965. * @param left defines left coordinate
  70966. * @param top defines top coordinate
  70967. * @param width defines width dimension
  70968. * @param height defines height dimension
  70969. */
  70970. constructor(
  70971. /** defines left coordinate */
  70972. left: number,
  70973. /** defines top coordinate */
  70974. top: number,
  70975. /** defines width dimension */
  70976. width: number,
  70977. /** defines height dimension */
  70978. height: number);
  70979. /**
  70980. * Copy from another measure
  70981. * @param other defines the other measure to copy from
  70982. */
  70983. copyFrom(other: Measure): void;
  70984. /**
  70985. * Copy from a group of 4 floats
  70986. * @param left defines left coordinate
  70987. * @param top defines top coordinate
  70988. * @param width defines width dimension
  70989. * @param height defines height dimension
  70990. */
  70991. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70992. /**
  70993. * Computes the axis aligned bounding box measure for two given measures
  70994. * @param a Input measure
  70995. * @param b Input measure
  70996. * @param result the resulting bounding measure
  70997. */
  70998. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70999. /**
  71000. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71001. * @param transform the matrix to transform the measure before computing the AABB
  71002. * @param result the resulting AABB
  71003. */
  71004. transformToRef(transform: Matrix2D, result: Measure): void;
  71005. /**
  71006. * Check equality between this measure and another one
  71007. * @param other defines the other measures
  71008. * @returns true if both measures are equals
  71009. */
  71010. isEqualsTo(other: Measure): boolean;
  71011. /**
  71012. * Creates an empty measure
  71013. * @returns a new measure
  71014. */
  71015. static Empty(): Measure;
  71016. }
  71017. }
  71018. declare module BABYLON.GUI {
  71019. /**
  71020. * Interface used to define a control that can receive focus
  71021. */
  71022. export interface IFocusableControl {
  71023. /**
  71024. * Function called when the control receives the focus
  71025. */
  71026. onFocus(): void;
  71027. /**
  71028. * Function called when the control loses the focus
  71029. */
  71030. onBlur(): void;
  71031. /**
  71032. * Function called to let the control handle keyboard events
  71033. * @param evt defines the current keyboard event
  71034. */
  71035. processKeyboard(evt: KeyboardEvent): void;
  71036. /**
  71037. * Function called to get the list of controls that should not steal the focus from this control
  71038. * @returns an array of controls
  71039. */
  71040. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71041. }
  71042. /**
  71043. * Class used to create texture to support 2D GUI elements
  71044. * @see http://doc.babylonjs.com/how_to/gui
  71045. */
  71046. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71047. private _isDirty;
  71048. private _renderObserver;
  71049. private _resizeObserver;
  71050. private _preKeyboardObserver;
  71051. private _pointerMoveObserver;
  71052. private _pointerObserver;
  71053. private _canvasPointerOutObserver;
  71054. private _background;
  71055. /** @hidden */
  71056. _rootContainer: Container;
  71057. /** @hidden */
  71058. _lastPickedControl: Control;
  71059. /** @hidden */
  71060. _lastControlOver: {
  71061. [pointerId: number]: Control;
  71062. };
  71063. /** @hidden */
  71064. _lastControlDown: {
  71065. [pointerId: number]: Control;
  71066. };
  71067. /** @hidden */
  71068. _capturingControl: {
  71069. [pointerId: number]: Control;
  71070. };
  71071. /** @hidden */
  71072. _shouldBlockPointer: boolean;
  71073. /** @hidden */
  71074. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71075. /** @hidden */
  71076. _linkedControls: Control[];
  71077. private _isFullscreen;
  71078. private _fullscreenViewport;
  71079. private _idealWidth;
  71080. private _idealHeight;
  71081. private _useSmallestIdeal;
  71082. private _renderAtIdealSize;
  71083. private _focusedControl;
  71084. private _blockNextFocusCheck;
  71085. private _renderScale;
  71086. private _rootElement;
  71087. private _cursorChanged;
  71088. private _defaultMousePointerId;
  71089. /** @hidden */
  71090. _numLayoutCalls: number;
  71091. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71092. get numLayoutCalls(): number;
  71093. /** @hidden */
  71094. _numRenderCalls: number;
  71095. /** Gets the number of render calls made the last time the ADT has been rendered */
  71096. get numRenderCalls(): number;
  71097. /**
  71098. * Define type to string to ensure compatibility across browsers
  71099. * Safari doesn't support DataTransfer constructor
  71100. */
  71101. private _clipboardData;
  71102. /**
  71103. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71104. */
  71105. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71106. /**
  71107. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71108. */
  71109. onControlPickedObservable: BABYLON.Observable<Control>;
  71110. /**
  71111. * BABYLON.Observable event triggered before layout is evaluated
  71112. */
  71113. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71114. /**
  71115. * BABYLON.Observable event triggered after the layout was evaluated
  71116. */
  71117. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71118. /**
  71119. * BABYLON.Observable event triggered before the texture is rendered
  71120. */
  71121. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71122. /**
  71123. * BABYLON.Observable event triggered after the texture was rendered
  71124. */
  71125. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71126. /**
  71127. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71128. */
  71129. premulAlpha: boolean;
  71130. /**
  71131. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71132. * Useful when you want more antialiasing
  71133. */
  71134. get renderScale(): number;
  71135. set renderScale(value: number);
  71136. /** Gets or sets the background color */
  71137. get background(): string;
  71138. set background(value: string);
  71139. /**
  71140. * Gets or sets the ideal width used to design controls.
  71141. * The GUI will then rescale everything accordingly
  71142. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71143. */
  71144. get idealWidth(): number;
  71145. set idealWidth(value: number);
  71146. /**
  71147. * Gets or sets the ideal height used to design controls.
  71148. * The GUI will then rescale everything accordingly
  71149. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71150. */
  71151. get idealHeight(): number;
  71152. set idealHeight(value: number);
  71153. /**
  71154. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71155. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71156. */
  71157. get useSmallestIdeal(): boolean;
  71158. set useSmallestIdeal(value: boolean);
  71159. /**
  71160. * Gets or sets a boolean indicating if adaptive scaling must be used
  71161. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71162. */
  71163. get renderAtIdealSize(): boolean;
  71164. set renderAtIdealSize(value: boolean);
  71165. /**
  71166. * Gets the ratio used when in "ideal mode"
  71167. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71168. * */
  71169. get idealRatio(): number;
  71170. /**
  71171. * Gets the underlying layer used to render the texture when in fullscreen mode
  71172. */
  71173. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71174. /**
  71175. * Gets the root container control
  71176. */
  71177. get rootContainer(): Container;
  71178. /**
  71179. * Returns an array containing the root container.
  71180. * This is mostly used to let the Inspector introspects the ADT
  71181. * @returns an array containing the rootContainer
  71182. */
  71183. getChildren(): Array<Container>;
  71184. /**
  71185. * Will return all controls that are inside this texture
  71186. * @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
  71187. * @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
  71188. * @return all child controls
  71189. */
  71190. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71191. /**
  71192. * Gets or sets the current focused control
  71193. */
  71194. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71195. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71196. /**
  71197. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71198. */
  71199. get isForeground(): boolean;
  71200. set isForeground(value: boolean);
  71201. /**
  71202. * Gets or set information about clipboardData
  71203. */
  71204. get clipboardData(): string;
  71205. set clipboardData(value: string);
  71206. /**
  71207. * Creates a new AdvancedDynamicTexture
  71208. * @param name defines the name of the texture
  71209. * @param width defines the width of the texture
  71210. * @param height defines the height of the texture
  71211. * @param scene defines the hosting scene
  71212. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71213. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71214. */
  71215. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71216. /**
  71217. * Get the current class name of the texture useful for serialization or dynamic coding.
  71218. * @returns "AdvancedDynamicTexture"
  71219. */
  71220. getClassName(): string;
  71221. /**
  71222. * Function used to execute a function on all controls
  71223. * @param func defines the function to execute
  71224. * @param container defines the container where controls belong. If null the root container will be used
  71225. */
  71226. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71227. private _useInvalidateRectOptimization;
  71228. /**
  71229. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71230. */
  71231. get useInvalidateRectOptimization(): boolean;
  71232. set useInvalidateRectOptimization(value: boolean);
  71233. private _invalidatedRectangle;
  71234. /**
  71235. * Invalidates a rectangle area on the gui texture
  71236. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71237. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71238. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71239. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71240. */
  71241. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71242. /**
  71243. * Marks the texture as dirty forcing a complete update
  71244. */
  71245. markAsDirty(): void;
  71246. /**
  71247. * Helper function used to create a new style
  71248. * @returns a new style
  71249. * @see http://doc.babylonjs.com/how_to/gui#styles
  71250. */
  71251. createStyle(): Style;
  71252. /**
  71253. * Adds a new control to the root container
  71254. * @param control defines the control to add
  71255. * @returns the current texture
  71256. */
  71257. addControl(control: Control): AdvancedDynamicTexture;
  71258. /**
  71259. * Removes a control from the root container
  71260. * @param control defines the control to remove
  71261. * @returns the current texture
  71262. */
  71263. removeControl(control: Control): AdvancedDynamicTexture;
  71264. /**
  71265. * Release all resources
  71266. */
  71267. dispose(): void;
  71268. private _onResize;
  71269. /** @hidden */
  71270. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71271. /**
  71272. * Get screen coordinates for a vector3
  71273. * @param position defines the position to project
  71274. * @param worldMatrix defines the world matrix to use
  71275. * @returns the projected position
  71276. */
  71277. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71278. private _checkUpdate;
  71279. private _clearMeasure;
  71280. private _render;
  71281. /** @hidden */
  71282. _changeCursor(cursor: string): void;
  71283. /** @hidden */
  71284. _registerLastControlDown(control: Control, pointerId: number): void;
  71285. private _doPicking;
  71286. /** @hidden */
  71287. _cleanControlAfterRemovalFromList(list: {
  71288. [pointerId: number]: Control;
  71289. }, control: Control): void;
  71290. /** @hidden */
  71291. _cleanControlAfterRemoval(control: Control): void;
  71292. /** Attach to all scene events required to support pointer events */
  71293. attach(): void;
  71294. /** @hidden */
  71295. private onClipboardCopy;
  71296. /** @hidden */
  71297. private onClipboardCut;
  71298. /** @hidden */
  71299. private onClipboardPaste;
  71300. /**
  71301. * Register the clipboard Events onto the canvas
  71302. */
  71303. registerClipboardEvents(): void;
  71304. /**
  71305. * Unregister the clipboard Events from the canvas
  71306. */
  71307. unRegisterClipboardEvents(): void;
  71308. /**
  71309. * Connect the texture to a hosting mesh to enable interactions
  71310. * @param mesh defines the mesh to attach to
  71311. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71312. */
  71313. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71314. /**
  71315. * Move the focus to a specific control
  71316. * @param control defines the control which will receive the focus
  71317. */
  71318. moveFocusToControl(control: IFocusableControl): void;
  71319. private _manageFocus;
  71320. private _attachToOnPointerOut;
  71321. /**
  71322. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71323. * @param mesh defines the mesh which will receive the texture
  71324. * @param width defines the texture width (1024 by default)
  71325. * @param height defines the texture height (1024 by default)
  71326. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71327. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71328. * @returns a new AdvancedDynamicTexture
  71329. */
  71330. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71331. /**
  71332. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71333. * In this mode the texture will rely on a layer for its rendering.
  71334. * This allows it to be treated like any other layer.
  71335. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71336. * LayerMask is set through advancedTexture.layer.layerMask
  71337. * @param name defines name for the texture
  71338. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71339. * @param scene defines the hsoting scene
  71340. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71341. * @returns a new AdvancedDynamicTexture
  71342. */
  71343. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71344. }
  71345. }
  71346. declare module BABYLON.GUI {
  71347. /**
  71348. * Root class used for all 2D controls
  71349. * @see http://doc.babylonjs.com/how_to/gui#controls
  71350. */
  71351. export class Control {
  71352. /** defines the name of the control */
  71353. name?: string | undefined;
  71354. /**
  71355. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71356. */
  71357. static AllowAlphaInheritance: boolean;
  71358. private _alpha;
  71359. private _alphaSet;
  71360. private _zIndex;
  71361. /** @hidden */
  71362. _host: AdvancedDynamicTexture;
  71363. /** Gets or sets the control parent */
  71364. parent: BABYLON.Nullable<Container>;
  71365. /** @hidden */
  71366. _currentMeasure: Measure;
  71367. private _fontFamily;
  71368. private _fontStyle;
  71369. private _fontWeight;
  71370. private _fontSize;
  71371. private _font;
  71372. /** @hidden */
  71373. _width: ValueAndUnit;
  71374. /** @hidden */
  71375. _height: ValueAndUnit;
  71376. /** @hidden */
  71377. protected _fontOffset: {
  71378. ascent: number;
  71379. height: number;
  71380. descent: number;
  71381. };
  71382. private _color;
  71383. private _style;
  71384. private _styleObserver;
  71385. /** @hidden */
  71386. protected _horizontalAlignment: number;
  71387. /** @hidden */
  71388. protected _verticalAlignment: number;
  71389. /** @hidden */
  71390. protected _isDirty: boolean;
  71391. /** @hidden */
  71392. protected _wasDirty: boolean;
  71393. /** @hidden */
  71394. _tempParentMeasure: Measure;
  71395. /** @hidden */
  71396. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71397. /** @hidden */
  71398. protected _cachedParentMeasure: Measure;
  71399. private _paddingLeft;
  71400. private _paddingRight;
  71401. private _paddingTop;
  71402. private _paddingBottom;
  71403. /** @hidden */
  71404. _left: ValueAndUnit;
  71405. /** @hidden */
  71406. _top: ValueAndUnit;
  71407. private _scaleX;
  71408. private _scaleY;
  71409. private _rotation;
  71410. private _transformCenterX;
  71411. private _transformCenterY;
  71412. /** @hidden */
  71413. _transformMatrix: Matrix2D;
  71414. /** @hidden */
  71415. protected _invertTransformMatrix: Matrix2D;
  71416. /** @hidden */
  71417. protected _transformedPosition: BABYLON.Vector2;
  71418. private _isMatrixDirty;
  71419. private _cachedOffsetX;
  71420. private _cachedOffsetY;
  71421. private _isVisible;
  71422. private _isHighlighted;
  71423. /** @hidden */
  71424. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71425. private _fontSet;
  71426. private _dummyVector2;
  71427. private _downCount;
  71428. private _enterCount;
  71429. private _doNotRender;
  71430. private _downPointerIds;
  71431. protected _isEnabled: boolean;
  71432. protected _disabledColor: string;
  71433. protected _disabledColorItem: string;
  71434. /** @hidden */
  71435. protected _rebuildLayout: boolean;
  71436. /** @hidden */
  71437. _customData: any;
  71438. /** @hidden */
  71439. _isClipped: boolean;
  71440. /** @hidden */
  71441. _automaticSize: boolean;
  71442. /** @hidden */
  71443. _tag: any;
  71444. /**
  71445. * 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
  71446. */
  71447. uniqueId: number;
  71448. /**
  71449. * Gets or sets an object used to store user defined information for the node
  71450. */
  71451. metadata: any;
  71452. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71453. isHitTestVisible: boolean;
  71454. /** Gets or sets a boolean indicating if the control can block pointer events */
  71455. isPointerBlocker: boolean;
  71456. /** Gets or sets a boolean indicating if the control can be focusable */
  71457. isFocusInvisible: boolean;
  71458. /**
  71459. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71460. * 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
  71461. */
  71462. clipChildren: boolean;
  71463. /**
  71464. * Gets or sets a boolean indicating that control content must be clipped
  71465. * 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
  71466. */
  71467. clipContent: boolean;
  71468. /**
  71469. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71470. */
  71471. useBitmapCache: boolean;
  71472. private _cacheData;
  71473. private _shadowOffsetX;
  71474. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71475. get shadowOffsetX(): number;
  71476. set shadowOffsetX(value: number);
  71477. private _shadowOffsetY;
  71478. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71479. get shadowOffsetY(): number;
  71480. set shadowOffsetY(value: number);
  71481. private _shadowBlur;
  71482. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71483. get shadowBlur(): number;
  71484. set shadowBlur(value: number);
  71485. private _shadowColor;
  71486. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71487. get shadowColor(): string;
  71488. set shadowColor(value: string);
  71489. /** Gets or sets the cursor to use when the control is hovered */
  71490. hoverCursor: string;
  71491. /** @hidden */
  71492. protected _linkOffsetX: ValueAndUnit;
  71493. /** @hidden */
  71494. protected _linkOffsetY: ValueAndUnit;
  71495. /** Gets the control type name */
  71496. get typeName(): string;
  71497. /**
  71498. * Get the current class name of the control.
  71499. * @returns current class name
  71500. */
  71501. getClassName(): string;
  71502. /**
  71503. * An event triggered when pointer wheel is scrolled
  71504. */
  71505. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71506. /**
  71507. * An event triggered when the pointer move over the control.
  71508. */
  71509. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71510. /**
  71511. * An event triggered when the pointer move out of the control.
  71512. */
  71513. onPointerOutObservable: BABYLON.Observable<Control>;
  71514. /**
  71515. * An event triggered when the pointer taps the control
  71516. */
  71517. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71518. /**
  71519. * An event triggered when pointer up
  71520. */
  71521. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71522. /**
  71523. * An event triggered when a control is clicked on
  71524. */
  71525. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71526. /**
  71527. * An event triggered when pointer enters the control
  71528. */
  71529. onPointerEnterObservable: BABYLON.Observable<Control>;
  71530. /**
  71531. * An event triggered when the control is marked as dirty
  71532. */
  71533. onDirtyObservable: BABYLON.Observable<Control>;
  71534. /**
  71535. * An event triggered before drawing the control
  71536. */
  71537. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71538. /**
  71539. * An event triggered after the control was drawn
  71540. */
  71541. onAfterDrawObservable: BABYLON.Observable<Control>;
  71542. /**
  71543. * Get the hosting AdvancedDynamicTexture
  71544. */
  71545. get host(): AdvancedDynamicTexture;
  71546. /** Gets or set information about font offsets (used to render and align text) */
  71547. get fontOffset(): {
  71548. ascent: number;
  71549. height: number;
  71550. descent: number;
  71551. };
  71552. set fontOffset(offset: {
  71553. ascent: number;
  71554. height: number;
  71555. descent: number;
  71556. });
  71557. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71558. get alpha(): number;
  71559. set alpha(value: number);
  71560. /**
  71561. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71562. */
  71563. get isHighlighted(): boolean;
  71564. set isHighlighted(value: boolean);
  71565. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71566. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71567. */
  71568. get scaleX(): number;
  71569. set scaleX(value: number);
  71570. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71571. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71572. */
  71573. get scaleY(): number;
  71574. set scaleY(value: number);
  71575. /** Gets or sets the rotation angle (0 by default)
  71576. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71577. */
  71578. get rotation(): number;
  71579. set rotation(value: number);
  71580. /** Gets or sets the transformation center on Y axis (0 by default)
  71581. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71582. */
  71583. get transformCenterY(): number;
  71584. set transformCenterY(value: number);
  71585. /** Gets or sets the transformation center on X axis (0 by default)
  71586. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71587. */
  71588. get transformCenterX(): number;
  71589. set transformCenterX(value: number);
  71590. /**
  71591. * Gets or sets the horizontal alignment
  71592. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71593. */
  71594. get horizontalAlignment(): number;
  71595. set horizontalAlignment(value: number);
  71596. /**
  71597. * Gets or sets the vertical alignment
  71598. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71599. */
  71600. get verticalAlignment(): number;
  71601. set verticalAlignment(value: number);
  71602. /**
  71603. * Gets or sets control width
  71604. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71605. */
  71606. get width(): string | number;
  71607. set width(value: string | number);
  71608. /**
  71609. * Gets or sets the control width in pixel
  71610. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71611. */
  71612. get widthInPixels(): number;
  71613. set widthInPixels(value: number);
  71614. /**
  71615. * Gets or sets control height
  71616. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71617. */
  71618. get height(): string | number;
  71619. set height(value: string | number);
  71620. /**
  71621. * Gets or sets control height in pixel
  71622. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71623. */
  71624. get heightInPixels(): number;
  71625. set heightInPixels(value: number);
  71626. /** Gets or set font family */
  71627. get fontFamily(): string;
  71628. set fontFamily(value: string);
  71629. /** Gets or sets font style */
  71630. get fontStyle(): string;
  71631. set fontStyle(value: string);
  71632. /** Gets or sets font weight */
  71633. get fontWeight(): string;
  71634. set fontWeight(value: string);
  71635. /**
  71636. * Gets or sets style
  71637. * @see http://doc.babylonjs.com/how_to/gui#styles
  71638. */
  71639. get style(): BABYLON.Nullable<Style>;
  71640. set style(value: BABYLON.Nullable<Style>);
  71641. /** @hidden */
  71642. get _isFontSizeInPercentage(): boolean;
  71643. /** Gets or sets font size in pixels */
  71644. get fontSizeInPixels(): number;
  71645. set fontSizeInPixels(value: number);
  71646. /** Gets or sets font size */
  71647. get fontSize(): string | number;
  71648. set fontSize(value: string | number);
  71649. /** Gets or sets foreground color */
  71650. get color(): string;
  71651. set color(value: string);
  71652. /** Gets or sets z index which is used to reorder controls on the z axis */
  71653. get zIndex(): number;
  71654. set zIndex(value: number);
  71655. /** Gets or sets a boolean indicating if the control can be rendered */
  71656. get notRenderable(): boolean;
  71657. set notRenderable(value: boolean);
  71658. /** Gets or sets a boolean indicating if the control is visible */
  71659. get isVisible(): boolean;
  71660. set isVisible(value: boolean);
  71661. /** Gets a boolean indicating that the control needs to update its rendering */
  71662. get isDirty(): boolean;
  71663. /**
  71664. * Gets the current linked mesh (or null if none)
  71665. */
  71666. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71667. /**
  71668. * Gets or sets a value indicating the padding to use on the left of the control
  71669. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71670. */
  71671. get paddingLeft(): string | number;
  71672. set paddingLeft(value: string | number);
  71673. /**
  71674. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71675. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71676. */
  71677. get paddingLeftInPixels(): number;
  71678. set paddingLeftInPixels(value: number);
  71679. /**
  71680. * Gets or sets a value indicating the padding to use on the right of the control
  71681. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71682. */
  71683. get paddingRight(): string | number;
  71684. set paddingRight(value: string | number);
  71685. /**
  71686. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71687. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71688. */
  71689. get paddingRightInPixels(): number;
  71690. set paddingRightInPixels(value: number);
  71691. /**
  71692. * Gets or sets a value indicating the padding to use on the top of the control
  71693. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71694. */
  71695. get paddingTop(): string | number;
  71696. set paddingTop(value: string | number);
  71697. /**
  71698. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71699. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71700. */
  71701. get paddingTopInPixels(): number;
  71702. set paddingTopInPixels(value: number);
  71703. /**
  71704. * Gets or sets a value indicating the padding to use on the bottom of the control
  71705. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71706. */
  71707. get paddingBottom(): string | number;
  71708. set paddingBottom(value: string | number);
  71709. /**
  71710. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71711. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71712. */
  71713. get paddingBottomInPixels(): number;
  71714. set paddingBottomInPixels(value: number);
  71715. /**
  71716. * Gets or sets a value indicating the left coordinate of the control
  71717. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71718. */
  71719. get left(): string | number;
  71720. set left(value: string | number);
  71721. /**
  71722. * Gets or sets a value indicating the left coordinate in pixels of the control
  71723. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71724. */
  71725. get leftInPixels(): number;
  71726. set leftInPixels(value: number);
  71727. /**
  71728. * Gets or sets a value indicating the top coordinate of the control
  71729. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71730. */
  71731. get top(): string | number;
  71732. set top(value: string | number);
  71733. /**
  71734. * Gets or sets a value indicating the top coordinate in pixels of the control
  71735. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71736. */
  71737. get topInPixels(): number;
  71738. set topInPixels(value: number);
  71739. /**
  71740. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71741. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71742. */
  71743. get linkOffsetX(): string | number;
  71744. set linkOffsetX(value: string | number);
  71745. /**
  71746. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71747. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71748. */
  71749. get linkOffsetXInPixels(): number;
  71750. set linkOffsetXInPixels(value: number);
  71751. /**
  71752. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71753. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71754. */
  71755. get linkOffsetY(): string | number;
  71756. set linkOffsetY(value: string | number);
  71757. /**
  71758. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71759. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71760. */
  71761. get linkOffsetYInPixels(): number;
  71762. set linkOffsetYInPixels(value: number);
  71763. /** Gets the center coordinate on X axis */
  71764. get centerX(): number;
  71765. /** Gets the center coordinate on Y axis */
  71766. get centerY(): number;
  71767. /** Gets or sets if control is Enabled*/
  71768. get isEnabled(): boolean;
  71769. set isEnabled(value: boolean);
  71770. /** Gets or sets background color of control if it's disabled*/
  71771. get disabledColor(): string;
  71772. set disabledColor(value: string);
  71773. /** Gets or sets front color of control if it's disabled*/
  71774. get disabledColorItem(): string;
  71775. set disabledColorItem(value: string);
  71776. /**
  71777. * Creates a new control
  71778. * @param name defines the name of the control
  71779. */
  71780. constructor(
  71781. /** defines the name of the control */
  71782. name?: string | undefined);
  71783. /** @hidden */
  71784. protected _getTypeName(): string;
  71785. /**
  71786. * Gets the first ascendant in the hierarchy of the given type
  71787. * @param className defines the required type
  71788. * @returns the ascendant or null if not found
  71789. */
  71790. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71791. /** @hidden */
  71792. _resetFontCache(): void;
  71793. /**
  71794. * Determines if a container is an ascendant of the current control
  71795. * @param container defines the container to look for
  71796. * @returns true if the container is one of the ascendant of the control
  71797. */
  71798. isAscendant(container: Control): boolean;
  71799. /**
  71800. * Gets coordinates in local control space
  71801. * @param globalCoordinates defines the coordinates to transform
  71802. * @returns the new coordinates in local space
  71803. */
  71804. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71805. /**
  71806. * Gets coordinates in local control space
  71807. * @param globalCoordinates defines the coordinates to transform
  71808. * @param result defines the target vector2 where to store the result
  71809. * @returns the current control
  71810. */
  71811. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71812. /**
  71813. * Gets coordinates in parent local control space
  71814. * @param globalCoordinates defines the coordinates to transform
  71815. * @returns the new coordinates in parent local space
  71816. */
  71817. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71818. /**
  71819. * Move the current control to a vector3 position projected onto the screen.
  71820. * @param position defines the target position
  71821. * @param scene defines the hosting scene
  71822. */
  71823. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71824. /**
  71825. * Will store all controls that have this control as ascendant in a given array
  71826. * @param results defines the array where to store the descendants
  71827. * @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
  71828. * @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
  71829. */
  71830. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71831. /**
  71832. * Will return all controls that have this control as ascendant
  71833. * @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
  71834. * @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
  71835. * @return all child controls
  71836. */
  71837. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71838. /**
  71839. * Link current control with a target mesh
  71840. * @param mesh defines the mesh to link with
  71841. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71842. */
  71843. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71844. /** @hidden */
  71845. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71846. /** @hidden */
  71847. _offsetLeft(offset: number): void;
  71848. /** @hidden */
  71849. _offsetTop(offset: number): void;
  71850. /** @hidden */
  71851. _markMatrixAsDirty(): void;
  71852. /** @hidden */
  71853. _flagDescendantsAsMatrixDirty(): void;
  71854. /** @hidden */
  71855. _intersectsRect(rect: Measure): boolean;
  71856. /** @hidden */
  71857. protected invalidateRect(): void;
  71858. /** @hidden */
  71859. _markAsDirty(force?: boolean): void;
  71860. /** @hidden */
  71861. _markAllAsDirty(): void;
  71862. /** @hidden */
  71863. _link(host: AdvancedDynamicTexture): void;
  71864. /** @hidden */
  71865. protected _transform(context?: CanvasRenderingContext2D): void;
  71866. /** @hidden */
  71867. _renderHighlight(context: CanvasRenderingContext2D): void;
  71868. /** @hidden */
  71869. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71870. /** @hidden */
  71871. protected _applyStates(context: CanvasRenderingContext2D): void;
  71872. /** @hidden */
  71873. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71874. /** @hidden */
  71875. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71876. protected _evaluateClippingState(parentMeasure: Measure): void;
  71877. /** @hidden */
  71878. _measure(): void;
  71879. /** @hidden */
  71880. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71881. /** @hidden */
  71882. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71883. /** @hidden */
  71884. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71885. /** @hidden */
  71886. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71887. private static _ClipMeasure;
  71888. private _tmpMeasureA;
  71889. private _clip;
  71890. /** @hidden */
  71891. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71892. /** @hidden */
  71893. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71894. /**
  71895. * Tests if a given coordinates belong to the current control
  71896. * @param x defines x coordinate to test
  71897. * @param y defines y coordinate to test
  71898. * @returns true if the coordinates are inside the control
  71899. */
  71900. contains(x: number, y: number): boolean;
  71901. /** @hidden */
  71902. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71903. /** @hidden */
  71904. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71905. /** @hidden */
  71906. _onPointerEnter(target: Control): boolean;
  71907. /** @hidden */
  71908. _onPointerOut(target: Control, force?: boolean): void;
  71909. /** @hidden */
  71910. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71911. /** @hidden */
  71912. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71913. /** @hidden */
  71914. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71915. /** @hidden */
  71916. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  71917. /** @hidden */
  71918. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  71919. private _prepareFont;
  71920. /** Releases associated resources */
  71921. dispose(): void;
  71922. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71923. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71924. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71925. private static _VERTICAL_ALIGNMENT_TOP;
  71926. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71927. private static _VERTICAL_ALIGNMENT_CENTER;
  71928. /** HORIZONTAL_ALIGNMENT_LEFT */
  71929. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71930. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71931. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71932. /** HORIZONTAL_ALIGNMENT_CENTER */
  71933. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71934. /** VERTICAL_ALIGNMENT_TOP */
  71935. static get VERTICAL_ALIGNMENT_TOP(): number;
  71936. /** VERTICAL_ALIGNMENT_BOTTOM */
  71937. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71938. /** VERTICAL_ALIGNMENT_CENTER */
  71939. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71940. private static _FontHeightSizes;
  71941. /** @hidden */
  71942. static _GetFontOffset(font: string): {
  71943. ascent: number;
  71944. height: number;
  71945. descent: number;
  71946. };
  71947. /**
  71948. * Creates a stack panel that can be used to render headers
  71949. * @param control defines the control to associate with the header
  71950. * @param text defines the text of the header
  71951. * @param size defines the size of the header
  71952. * @param options defines options used to configure the header
  71953. * @returns a new StackPanel
  71954. * @ignore
  71955. * @hidden
  71956. */
  71957. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71958. isHorizontal: boolean;
  71959. controlFirst: boolean;
  71960. }) => any;
  71961. /** @hidden */
  71962. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71963. }
  71964. }
  71965. declare module BABYLON.GUI {
  71966. /**
  71967. * Root class for 2D containers
  71968. * @see http://doc.babylonjs.com/how_to/gui#containers
  71969. */
  71970. export class Container extends Control {
  71971. name?: string | undefined;
  71972. /** @hidden */
  71973. _children: Control[];
  71974. /** @hidden */
  71975. protected _measureForChildren: Measure;
  71976. /** @hidden */
  71977. protected _background: string;
  71978. /** @hidden */
  71979. protected _adaptWidthToChildren: boolean;
  71980. /** @hidden */
  71981. protected _adaptHeightToChildren: boolean;
  71982. /**
  71983. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71984. */
  71985. logLayoutCycleErrors: boolean;
  71986. /**
  71987. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71988. */
  71989. maxLayoutCycle: number;
  71990. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71991. get adaptHeightToChildren(): boolean;
  71992. set adaptHeightToChildren(value: boolean);
  71993. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71994. get adaptWidthToChildren(): boolean;
  71995. set adaptWidthToChildren(value: boolean);
  71996. /** Gets or sets background color */
  71997. get background(): string;
  71998. set background(value: string);
  71999. /** Gets the list of children */
  72000. get children(): Control[];
  72001. /**
  72002. * Creates a new Container
  72003. * @param name defines the name of the container
  72004. */
  72005. constructor(name?: string | undefined);
  72006. protected _getTypeName(): string;
  72007. _flagDescendantsAsMatrixDirty(): void;
  72008. /**
  72009. * Gets a child using its name
  72010. * @param name defines the child name to look for
  72011. * @returns the child control if found
  72012. */
  72013. getChildByName(name: string): BABYLON.Nullable<Control>;
  72014. /**
  72015. * Gets a child using its type and its name
  72016. * @param name defines the child name to look for
  72017. * @param type defines the child type to look for
  72018. * @returns the child control if found
  72019. */
  72020. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72021. /**
  72022. * Search for a specific control in children
  72023. * @param control defines the control to look for
  72024. * @returns true if the control is in child list
  72025. */
  72026. containsControl(control: Control): boolean;
  72027. /**
  72028. * Adds a new control to the current container
  72029. * @param control defines the control to add
  72030. * @returns the current container
  72031. */
  72032. addControl(control: BABYLON.Nullable<Control>): Container;
  72033. /**
  72034. * Removes all controls from the current container
  72035. * @returns the current container
  72036. */
  72037. clearControls(): Container;
  72038. /**
  72039. * Removes a control from the current container
  72040. * @param control defines the control to remove
  72041. * @returns the current container
  72042. */
  72043. removeControl(control: Control): Container;
  72044. /** @hidden */
  72045. _reOrderControl(control: Control): void;
  72046. /** @hidden */
  72047. _offsetLeft(offset: number): void;
  72048. /** @hidden */
  72049. _offsetTop(offset: number): void;
  72050. /** @hidden */
  72051. _markAllAsDirty(): void;
  72052. /** @hidden */
  72053. protected _localDraw(context: CanvasRenderingContext2D): void;
  72054. /** @hidden */
  72055. _link(host: AdvancedDynamicTexture): void;
  72056. /** @hidden */
  72057. protected _beforeLayout(): void;
  72058. /** @hidden */
  72059. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72060. /** @hidden */
  72061. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72062. protected _postMeasure(): void;
  72063. /** @hidden */
  72064. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72065. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72066. /** @hidden */
  72067. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72068. /** @hidden */
  72069. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72070. /** Releases associated resources */
  72071. dispose(): void;
  72072. }
  72073. }
  72074. declare module BABYLON.GUI {
  72075. /** Class used to create rectangle container */
  72076. export class Rectangle extends Container {
  72077. name?: string | undefined;
  72078. private _thickness;
  72079. private _cornerRadius;
  72080. /** Gets or sets border thickness */
  72081. get thickness(): number;
  72082. set thickness(value: number);
  72083. /** Gets or sets the corner radius angle */
  72084. get cornerRadius(): number;
  72085. set cornerRadius(value: number);
  72086. /**
  72087. * Creates a new Rectangle
  72088. * @param name defines the control name
  72089. */
  72090. constructor(name?: string | undefined);
  72091. protected _getTypeName(): string;
  72092. protected _localDraw(context: CanvasRenderingContext2D): void;
  72093. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72094. private _drawRoundedRect;
  72095. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72096. }
  72097. }
  72098. declare module BABYLON.GUI {
  72099. /**
  72100. * Enum that determines the text-wrapping mode to use.
  72101. */
  72102. export enum TextWrapping {
  72103. /**
  72104. * Clip the text when it's larger than Control.width; this is the default mode.
  72105. */
  72106. Clip = 0,
  72107. /**
  72108. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72109. */
  72110. WordWrap = 1,
  72111. /**
  72112. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72113. */
  72114. Ellipsis = 2
  72115. }
  72116. /**
  72117. * Class used to create text block control
  72118. */
  72119. export class TextBlock extends Control {
  72120. /**
  72121. * Defines the name of the control
  72122. */
  72123. name?: string | undefined;
  72124. private _text;
  72125. private _textWrapping;
  72126. private _textHorizontalAlignment;
  72127. private _textVerticalAlignment;
  72128. private _lines;
  72129. private _resizeToFit;
  72130. private _lineSpacing;
  72131. private _outlineWidth;
  72132. private _outlineColor;
  72133. /**
  72134. * An event triggered after the text is changed
  72135. */
  72136. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72137. /**
  72138. * An event triggered after the text was broken up into lines
  72139. */
  72140. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72141. /**
  72142. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72143. */
  72144. get lines(): any[];
  72145. /**
  72146. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72147. */
  72148. get resizeToFit(): boolean;
  72149. /**
  72150. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72151. */
  72152. set resizeToFit(value: boolean);
  72153. /**
  72154. * Gets or sets a boolean indicating if text must be wrapped
  72155. */
  72156. get textWrapping(): TextWrapping | boolean;
  72157. /**
  72158. * Gets or sets a boolean indicating if text must be wrapped
  72159. */
  72160. set textWrapping(value: TextWrapping | boolean);
  72161. /**
  72162. * Gets or sets text to display
  72163. */
  72164. get text(): string;
  72165. /**
  72166. * Gets or sets text to display
  72167. */
  72168. set text(value: string);
  72169. /**
  72170. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72171. */
  72172. get textHorizontalAlignment(): number;
  72173. /**
  72174. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72175. */
  72176. set textHorizontalAlignment(value: number);
  72177. /**
  72178. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72179. */
  72180. get textVerticalAlignment(): number;
  72181. /**
  72182. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72183. */
  72184. set textVerticalAlignment(value: number);
  72185. /**
  72186. * Gets or sets line spacing value
  72187. */
  72188. set lineSpacing(value: string | number);
  72189. /**
  72190. * Gets or sets line spacing value
  72191. */
  72192. get lineSpacing(): string | number;
  72193. /**
  72194. * Gets or sets outlineWidth of the text to display
  72195. */
  72196. get outlineWidth(): number;
  72197. /**
  72198. * Gets or sets outlineWidth of the text to display
  72199. */
  72200. set outlineWidth(value: number);
  72201. /**
  72202. * Gets or sets outlineColor of the text to display
  72203. */
  72204. get outlineColor(): string;
  72205. /**
  72206. * Gets or sets outlineColor of the text to display
  72207. */
  72208. set outlineColor(value: string);
  72209. /**
  72210. * Creates a new TextBlock object
  72211. * @param name defines the name of the control
  72212. * @param text defines the text to display (emptry string by default)
  72213. */
  72214. constructor(
  72215. /**
  72216. * Defines the name of the control
  72217. */
  72218. name?: string | undefined, text?: string);
  72219. protected _getTypeName(): string;
  72220. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72221. private _drawText;
  72222. /** @hidden */
  72223. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72224. protected _applyStates(context: CanvasRenderingContext2D): void;
  72225. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72226. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72227. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72228. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72229. protected _renderLines(context: CanvasRenderingContext2D): void;
  72230. /**
  72231. * Given a width constraint applied on the text block, find the expected height
  72232. * @returns expected height
  72233. */
  72234. computeExpectedHeight(): number;
  72235. dispose(): void;
  72236. }
  72237. }
  72238. declare module BABYLON.GUI {
  72239. /**
  72240. * Class used to create 2D images
  72241. */
  72242. export class Image extends Control {
  72243. name?: string | undefined;
  72244. private _workingCanvas;
  72245. private _domImage;
  72246. private _imageWidth;
  72247. private _imageHeight;
  72248. private _loaded;
  72249. private _stretch;
  72250. private _source;
  72251. private _autoScale;
  72252. private _sourceLeft;
  72253. private _sourceTop;
  72254. private _sourceWidth;
  72255. private _sourceHeight;
  72256. private _svgAttributesComputationCompleted;
  72257. private _isSVG;
  72258. private _cellWidth;
  72259. private _cellHeight;
  72260. private _cellId;
  72261. private _populateNinePatchSlicesFromImage;
  72262. private _sliceLeft;
  72263. private _sliceRight;
  72264. private _sliceTop;
  72265. private _sliceBottom;
  72266. private _detectPointerOnOpaqueOnly;
  72267. /**
  72268. * BABYLON.Observable notified when the content is loaded
  72269. */
  72270. onImageLoadedObservable: BABYLON.Observable<Image>;
  72271. /**
  72272. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72273. */
  72274. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72275. /**
  72276. * Gets a boolean indicating that the content is loaded
  72277. */
  72278. get isLoaded(): boolean;
  72279. /**
  72280. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72281. */
  72282. get populateNinePatchSlicesFromImage(): boolean;
  72283. set populateNinePatchSlicesFromImage(value: boolean);
  72284. /**
  72285. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72286. * Beware using this as this will comsume more memory as the image has to be stored twice
  72287. */
  72288. get detectPointerOnOpaqueOnly(): boolean;
  72289. set detectPointerOnOpaqueOnly(value: boolean);
  72290. /**
  72291. * Gets or sets the left value for slicing (9-patch)
  72292. */
  72293. get sliceLeft(): number;
  72294. set sliceLeft(value: number);
  72295. /**
  72296. * Gets or sets the right value for slicing (9-patch)
  72297. */
  72298. get sliceRight(): number;
  72299. set sliceRight(value: number);
  72300. /**
  72301. * Gets or sets the top value for slicing (9-patch)
  72302. */
  72303. get sliceTop(): number;
  72304. set sliceTop(value: number);
  72305. /**
  72306. * Gets or sets the bottom value for slicing (9-patch)
  72307. */
  72308. get sliceBottom(): number;
  72309. set sliceBottom(value: number);
  72310. /**
  72311. * Gets or sets the left coordinate in the source image
  72312. */
  72313. get sourceLeft(): number;
  72314. set sourceLeft(value: number);
  72315. /**
  72316. * Gets or sets the top coordinate in the source image
  72317. */
  72318. get sourceTop(): number;
  72319. set sourceTop(value: number);
  72320. /**
  72321. * Gets or sets the width to capture in the source image
  72322. */
  72323. get sourceWidth(): number;
  72324. set sourceWidth(value: number);
  72325. /**
  72326. * Gets or sets the height to capture in the source image
  72327. */
  72328. get sourceHeight(): number;
  72329. set sourceHeight(value: number);
  72330. /** Indicates if the format of the image is SVG */
  72331. get isSVG(): boolean;
  72332. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72333. get svgAttributesComputationCompleted(): boolean;
  72334. /**
  72335. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72336. * @see http://doc.babylonjs.com/how_to/gui#image
  72337. */
  72338. get autoScale(): boolean;
  72339. set autoScale(value: boolean);
  72340. /** Gets or sets the streching mode used by the image */
  72341. get stretch(): number;
  72342. set stretch(value: number);
  72343. /** @hidden */
  72344. _rotate90(n: number, preserveProperties?: boolean): Image;
  72345. private _handleRotationForSVGImage;
  72346. private _rotate90SourceProperties;
  72347. /**
  72348. * Gets or sets the internal DOM image used to render the control
  72349. */
  72350. set domImage(value: HTMLImageElement);
  72351. get domImage(): HTMLImageElement;
  72352. private _onImageLoaded;
  72353. private _extractNinePatchSliceDataFromImage;
  72354. /**
  72355. * Gets or sets image source url
  72356. */
  72357. set source(value: BABYLON.Nullable<string>);
  72358. /**
  72359. * Checks for svg document with icon id present
  72360. */
  72361. private _svgCheck;
  72362. /**
  72363. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72364. * given external svg file and icon id
  72365. */
  72366. private _getSVGAttribs;
  72367. /**
  72368. * Gets or sets the cell width to use when animation sheet is enabled
  72369. * @see http://doc.babylonjs.com/how_to/gui#image
  72370. */
  72371. get cellWidth(): number;
  72372. set cellWidth(value: number);
  72373. /**
  72374. * Gets or sets the cell height to use when animation sheet is enabled
  72375. * @see http://doc.babylonjs.com/how_to/gui#image
  72376. */
  72377. get cellHeight(): number;
  72378. set cellHeight(value: number);
  72379. /**
  72380. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72381. * @see http://doc.babylonjs.com/how_to/gui#image
  72382. */
  72383. get cellId(): number;
  72384. set cellId(value: number);
  72385. /**
  72386. * Creates a new Image
  72387. * @param name defines the control name
  72388. * @param url defines the image url
  72389. */
  72390. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72391. /**
  72392. * Tests if a given coordinates belong to the current control
  72393. * @param x defines x coordinate to test
  72394. * @param y defines y coordinate to test
  72395. * @returns true if the coordinates are inside the control
  72396. */
  72397. contains(x: number, y: number): boolean;
  72398. protected _getTypeName(): string;
  72399. /** Force the control to synchronize with its content */
  72400. synchronizeSizeWithContent(): void;
  72401. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72402. private _prepareWorkingCanvasForOpaqueDetection;
  72403. private _drawImage;
  72404. _draw(context: CanvasRenderingContext2D): void;
  72405. private _renderCornerPatch;
  72406. private _renderNinePatch;
  72407. dispose(): void;
  72408. /** STRETCH_NONE */
  72409. static readonly STRETCH_NONE: number;
  72410. /** STRETCH_FILL */
  72411. static readonly STRETCH_FILL: number;
  72412. /** STRETCH_UNIFORM */
  72413. static readonly STRETCH_UNIFORM: number;
  72414. /** STRETCH_EXTEND */
  72415. static readonly STRETCH_EXTEND: number;
  72416. /** NINE_PATCH */
  72417. static readonly STRETCH_NINE_PATCH: number;
  72418. }
  72419. }
  72420. declare module BABYLON.GUI {
  72421. /**
  72422. * Class used to create 2D buttons
  72423. */
  72424. export class Button extends Rectangle {
  72425. name?: string | undefined;
  72426. /**
  72427. * Function called to generate a pointer enter animation
  72428. */
  72429. pointerEnterAnimation: () => void;
  72430. /**
  72431. * Function called to generate a pointer out animation
  72432. */
  72433. pointerOutAnimation: () => void;
  72434. /**
  72435. * Function called to generate a pointer down animation
  72436. */
  72437. pointerDownAnimation: () => void;
  72438. /**
  72439. * Function called to generate a pointer up animation
  72440. */
  72441. pointerUpAnimation: () => void;
  72442. /**
  72443. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72444. */
  72445. delegatePickingToChildren: boolean;
  72446. private _image;
  72447. /**
  72448. * Returns the image part of the button (if any)
  72449. */
  72450. get image(): BABYLON.Nullable<Image>;
  72451. private _textBlock;
  72452. /**
  72453. * Returns the image part of the button (if any)
  72454. */
  72455. get textBlock(): BABYLON.Nullable<TextBlock>;
  72456. /**
  72457. * Creates a new Button
  72458. * @param name defines the name of the button
  72459. */
  72460. constructor(name?: string | undefined);
  72461. protected _getTypeName(): string;
  72462. /** @hidden */
  72463. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72464. /** @hidden */
  72465. _onPointerEnter(target: Control): boolean;
  72466. /** @hidden */
  72467. _onPointerOut(target: Control, force?: boolean): void;
  72468. /** @hidden */
  72469. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72470. /** @hidden */
  72471. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72472. /**
  72473. * Creates a new button made with an image and a text
  72474. * @param name defines the name of the button
  72475. * @param text defines the text of the button
  72476. * @param imageUrl defines the url of the image
  72477. * @returns a new Button
  72478. */
  72479. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72480. /**
  72481. * Creates a new button made with an image
  72482. * @param name defines the name of the button
  72483. * @param imageUrl defines the url of the image
  72484. * @returns a new Button
  72485. */
  72486. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72487. /**
  72488. * Creates a new button made with a text
  72489. * @param name defines the name of the button
  72490. * @param text defines the text of the button
  72491. * @returns a new Button
  72492. */
  72493. static CreateSimpleButton(name: string, text: string): Button;
  72494. /**
  72495. * Creates a new button made with an image and a centered text
  72496. * @param name defines the name of the button
  72497. * @param text defines the text of the button
  72498. * @param imageUrl defines the url of the image
  72499. * @returns a new Button
  72500. */
  72501. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72502. }
  72503. }
  72504. declare module BABYLON.GUI {
  72505. /**
  72506. * Class used to create a 2D stack panel container
  72507. */
  72508. export class StackPanel extends Container {
  72509. name?: string | undefined;
  72510. private _isVertical;
  72511. private _manualWidth;
  72512. private _manualHeight;
  72513. private _doNotTrackManualChanges;
  72514. /**
  72515. * Gets or sets a boolean indicating that layou warnings should be ignored
  72516. */
  72517. ignoreLayoutWarnings: boolean;
  72518. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72519. get isVertical(): boolean;
  72520. set isVertical(value: boolean);
  72521. /**
  72522. * Gets or sets panel width.
  72523. * This value should not be set when in horizontal mode as it will be computed automatically
  72524. */
  72525. set width(value: string | number);
  72526. get width(): string | number;
  72527. /**
  72528. * Gets or sets panel height.
  72529. * This value should not be set when in vertical mode as it will be computed automatically
  72530. */
  72531. set height(value: string | number);
  72532. get height(): string | number;
  72533. /**
  72534. * Creates a new StackPanel
  72535. * @param name defines control name
  72536. */
  72537. constructor(name?: string | undefined);
  72538. protected _getTypeName(): string;
  72539. /** @hidden */
  72540. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72541. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72542. protected _postMeasure(): void;
  72543. }
  72544. }
  72545. declare module BABYLON.GUI {
  72546. /**
  72547. * Class used to represent a 2D checkbox
  72548. */
  72549. export class Checkbox extends Control {
  72550. name?: string | undefined;
  72551. private _isChecked;
  72552. private _background;
  72553. private _checkSizeRatio;
  72554. private _thickness;
  72555. /** Gets or sets border thickness */
  72556. get thickness(): number;
  72557. set thickness(value: number);
  72558. /**
  72559. * BABYLON.Observable raised when isChecked property changes
  72560. */
  72561. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72562. /** Gets or sets a value indicating the ratio between overall size and check size */
  72563. get checkSizeRatio(): number;
  72564. set checkSizeRatio(value: number);
  72565. /** Gets or sets background color */
  72566. get background(): string;
  72567. set background(value: string);
  72568. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72569. get isChecked(): boolean;
  72570. set isChecked(value: boolean);
  72571. /**
  72572. * Creates a new CheckBox
  72573. * @param name defines the control name
  72574. */
  72575. constructor(name?: string | undefined);
  72576. protected _getTypeName(): string;
  72577. /** @hidden */
  72578. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72579. /** @hidden */
  72580. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72581. /**
  72582. * Utility function to easily create a checkbox with a header
  72583. * @param title defines the label to use for the header
  72584. * @param onValueChanged defines the callback to call when value changes
  72585. * @returns a StackPanel containing the checkbox and a textBlock
  72586. */
  72587. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72588. }
  72589. }
  72590. declare module BABYLON.GUI {
  72591. /**
  72592. * Class used to store key control properties
  72593. */
  72594. export class KeyPropertySet {
  72595. /** Width */
  72596. width?: string;
  72597. /** Height */
  72598. height?: string;
  72599. /** Left padding */
  72600. paddingLeft?: string;
  72601. /** Right padding */
  72602. paddingRight?: string;
  72603. /** Top padding */
  72604. paddingTop?: string;
  72605. /** Bottom padding */
  72606. paddingBottom?: string;
  72607. /** Foreground color */
  72608. color?: string;
  72609. /** Background color */
  72610. background?: string;
  72611. }
  72612. /**
  72613. * Class used to create virtual keyboard
  72614. */
  72615. export class VirtualKeyboard extends StackPanel {
  72616. /** BABYLON.Observable raised when a key is pressed */
  72617. onKeyPressObservable: BABYLON.Observable<string>;
  72618. /** Gets or sets default key button width */
  72619. defaultButtonWidth: string;
  72620. /** Gets or sets default key button height */
  72621. defaultButtonHeight: string;
  72622. /** Gets or sets default key button left padding */
  72623. defaultButtonPaddingLeft: string;
  72624. /** Gets or sets default key button right padding */
  72625. defaultButtonPaddingRight: string;
  72626. /** Gets or sets default key button top padding */
  72627. defaultButtonPaddingTop: string;
  72628. /** Gets or sets default key button bottom padding */
  72629. defaultButtonPaddingBottom: string;
  72630. /** Gets or sets default key button foreground color */
  72631. defaultButtonColor: string;
  72632. /** Gets or sets default key button background color */
  72633. defaultButtonBackground: string;
  72634. /** Gets or sets shift button foreground color */
  72635. shiftButtonColor: string;
  72636. /** Gets or sets shift button thickness*/
  72637. selectedShiftThickness: number;
  72638. /** Gets shift key state */
  72639. shiftState: number;
  72640. protected _getTypeName(): string;
  72641. private _createKey;
  72642. /**
  72643. * Adds a new row of keys
  72644. * @param keys defines the list of keys to add
  72645. * @param propertySets defines the associated property sets
  72646. */
  72647. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72648. /**
  72649. * Set the shift key to a specific state
  72650. * @param shiftState defines the new shift state
  72651. */
  72652. applyShiftState(shiftState: number): void;
  72653. private _currentlyConnectedInputText;
  72654. private _connectedInputTexts;
  72655. private _onKeyPressObserver;
  72656. /** Gets the input text control currently attached to the keyboard */
  72657. get connectedInputText(): BABYLON.Nullable<InputText>;
  72658. /**
  72659. * Connects the keyboard with an input text control
  72660. *
  72661. * @param input defines the target control
  72662. */
  72663. connect(input: InputText): void;
  72664. /**
  72665. * Disconnects the keyboard from connected InputText controls
  72666. *
  72667. * @param input optionally defines a target control, otherwise all are disconnected
  72668. */
  72669. disconnect(input?: InputText): void;
  72670. private _removeConnectedInputObservables;
  72671. /**
  72672. * Release all resources
  72673. */
  72674. dispose(): void;
  72675. /**
  72676. * Creates a new keyboard using a default layout
  72677. *
  72678. * @param name defines control name
  72679. * @returns a new VirtualKeyboard
  72680. */
  72681. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72682. }
  72683. }
  72684. declare module BABYLON.GUI {
  72685. /**
  72686. * Class used to create input text control
  72687. */
  72688. export class InputText extends Control implements IFocusableControl {
  72689. name?: string | undefined;
  72690. private _text;
  72691. private _placeholderText;
  72692. private _background;
  72693. private _focusedBackground;
  72694. private _focusedColor;
  72695. private _placeholderColor;
  72696. private _thickness;
  72697. private _margin;
  72698. private _autoStretchWidth;
  72699. private _maxWidth;
  72700. private _isFocused;
  72701. private _blinkTimeout;
  72702. private _blinkIsEven;
  72703. private _cursorOffset;
  72704. private _scrollLeft;
  72705. private _textWidth;
  72706. private _clickedCoordinate;
  72707. private _deadKey;
  72708. private _addKey;
  72709. private _currentKey;
  72710. private _isTextHighlightOn;
  72711. private _textHighlightColor;
  72712. private _highligherOpacity;
  72713. private _highlightedText;
  72714. private _startHighlightIndex;
  72715. private _endHighlightIndex;
  72716. private _cursorIndex;
  72717. private _onFocusSelectAll;
  72718. private _isPointerDown;
  72719. private _onClipboardObserver;
  72720. private _onPointerDblTapObserver;
  72721. /** @hidden */
  72722. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72723. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72724. promptMessage: string;
  72725. /** Force disable prompt on mobile device */
  72726. disableMobilePrompt: boolean;
  72727. /** BABYLON.Observable raised when the text changes */
  72728. onTextChangedObservable: BABYLON.Observable<InputText>;
  72729. /** BABYLON.Observable raised just before an entered character is to be added */
  72730. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72731. /** BABYLON.Observable raised when the control gets the focus */
  72732. onFocusObservable: BABYLON.Observable<InputText>;
  72733. /** BABYLON.Observable raised when the control loses the focus */
  72734. onBlurObservable: BABYLON.Observable<InputText>;
  72735. /**Observable raised when the text is highlighted */
  72736. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72737. /**Observable raised when copy event is triggered */
  72738. onTextCopyObservable: BABYLON.Observable<InputText>;
  72739. /** BABYLON.Observable raised when cut event is triggered */
  72740. onTextCutObservable: BABYLON.Observable<InputText>;
  72741. /** BABYLON.Observable raised when paste event is triggered */
  72742. onTextPasteObservable: BABYLON.Observable<InputText>;
  72743. /** BABYLON.Observable raised when a key event was processed */
  72744. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72745. /** Gets or sets the maximum width allowed by the control */
  72746. get maxWidth(): string | number;
  72747. /** Gets the maximum width allowed by the control in pixels */
  72748. get maxWidthInPixels(): number;
  72749. set maxWidth(value: string | number);
  72750. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72751. get highligherOpacity(): number;
  72752. set highligherOpacity(value: number);
  72753. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72754. get onFocusSelectAll(): boolean;
  72755. set onFocusSelectAll(value: boolean);
  72756. /** Gets or sets the text hightlight color */
  72757. get textHighlightColor(): string;
  72758. set textHighlightColor(value: string);
  72759. /** Gets or sets control margin */
  72760. get margin(): string;
  72761. /** Gets control margin in pixels */
  72762. get marginInPixels(): number;
  72763. set margin(value: string);
  72764. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72765. get autoStretchWidth(): boolean;
  72766. set autoStretchWidth(value: boolean);
  72767. /** Gets or sets border thickness */
  72768. get thickness(): number;
  72769. set thickness(value: number);
  72770. /** Gets or sets the background color when focused */
  72771. get focusedBackground(): string;
  72772. set focusedBackground(value: string);
  72773. /** Gets or sets the background color when focused */
  72774. get focusedColor(): string;
  72775. set focusedColor(value: string);
  72776. /** Gets or sets the background color */
  72777. get background(): string;
  72778. set background(value: string);
  72779. /** Gets or sets the placeholder color */
  72780. get placeholderColor(): string;
  72781. set placeholderColor(value: string);
  72782. /** Gets or sets the text displayed when the control is empty */
  72783. get placeholderText(): string;
  72784. set placeholderText(value: string);
  72785. /** Gets or sets the dead key flag */
  72786. get deadKey(): boolean;
  72787. set deadKey(flag: boolean);
  72788. /** Gets or sets the highlight text */
  72789. get highlightedText(): string;
  72790. set highlightedText(text: string);
  72791. /** Gets or sets if the current key should be added */
  72792. get addKey(): boolean;
  72793. set addKey(flag: boolean);
  72794. /** Gets or sets the value of the current key being entered */
  72795. get currentKey(): string;
  72796. set currentKey(key: string);
  72797. /** Gets or sets the text displayed in the control */
  72798. get text(): string;
  72799. set text(value: string);
  72800. /** Gets or sets control width */
  72801. get width(): string | number;
  72802. set width(value: string | number);
  72803. /**
  72804. * Creates a new InputText
  72805. * @param name defines the control name
  72806. * @param text defines the text of the control
  72807. */
  72808. constructor(name?: string | undefined, text?: string);
  72809. /** @hidden */
  72810. onBlur(): void;
  72811. /** @hidden */
  72812. onFocus(): void;
  72813. protected _getTypeName(): string;
  72814. /**
  72815. * Function called to get the list of controls that should not steal the focus from this control
  72816. * @returns an array of controls
  72817. */
  72818. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72819. /** @hidden */
  72820. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72821. /** @hidden */
  72822. private _updateValueFromCursorIndex;
  72823. /** @hidden */
  72824. private _processDblClick;
  72825. /** @hidden */
  72826. private _selectAllText;
  72827. /**
  72828. * Handles the keyboard event
  72829. * @param evt Defines the KeyboardEvent
  72830. */
  72831. processKeyboard(evt: KeyboardEvent): void;
  72832. /** @hidden */
  72833. private _onCopyText;
  72834. /** @hidden */
  72835. private _onCutText;
  72836. /** @hidden */
  72837. private _onPasteText;
  72838. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72839. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72840. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72841. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72842. protected _beforeRenderText(text: string): string;
  72843. dispose(): void;
  72844. }
  72845. }
  72846. declare module BABYLON.GUI {
  72847. /**
  72848. * Class used to create a 2D grid container
  72849. */
  72850. export class Grid extends Container {
  72851. name?: string | undefined;
  72852. private _rowDefinitions;
  72853. private _columnDefinitions;
  72854. private _cells;
  72855. private _childControls;
  72856. /**
  72857. * Gets the number of columns
  72858. */
  72859. get columnCount(): number;
  72860. /**
  72861. * Gets the number of rows
  72862. */
  72863. get rowCount(): number;
  72864. /** Gets the list of children */
  72865. get children(): Control[];
  72866. /** Gets the list of cells (e.g. the containers) */
  72867. get cells(): {
  72868. [key: string]: Container;
  72869. };
  72870. /**
  72871. * Gets the definition of a specific row
  72872. * @param index defines the index of the row
  72873. * @returns the row definition
  72874. */
  72875. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72876. /**
  72877. * Gets the definition of a specific column
  72878. * @param index defines the index of the column
  72879. * @returns the column definition
  72880. */
  72881. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72882. /**
  72883. * Adds a new row to the grid
  72884. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72885. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72886. * @returns the current grid
  72887. */
  72888. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72889. /**
  72890. * Adds a new column to the grid
  72891. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72892. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72893. * @returns the current grid
  72894. */
  72895. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72896. /**
  72897. * Update a row definition
  72898. * @param index defines the index of the row to update
  72899. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72900. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72901. * @returns the current grid
  72902. */
  72903. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72904. /**
  72905. * Update a column definition
  72906. * @param index defines the index of the column to update
  72907. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72908. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72909. * @returns the current grid
  72910. */
  72911. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72912. /**
  72913. * Gets the list of children stored in a specific cell
  72914. * @param row defines the row to check
  72915. * @param column defines the column to check
  72916. * @returns the list of controls
  72917. */
  72918. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72919. /**
  72920. * Gets a string representing the child cell info (row x column)
  72921. * @param child defines the control to get info from
  72922. * @returns a string containing the child cell info (row x column)
  72923. */
  72924. getChildCellInfo(child: Control): string;
  72925. private _removeCell;
  72926. private _offsetCell;
  72927. /**
  72928. * Remove a column definition at specified index
  72929. * @param index defines the index of the column to remove
  72930. * @returns the current grid
  72931. */
  72932. removeColumnDefinition(index: number): Grid;
  72933. /**
  72934. * Remove a row definition at specified index
  72935. * @param index defines the index of the row to remove
  72936. * @returns the current grid
  72937. */
  72938. removeRowDefinition(index: number): Grid;
  72939. /**
  72940. * Adds a new control to the current grid
  72941. * @param control defines the control to add
  72942. * @param row defines the row where to add the control (0 by default)
  72943. * @param column defines the column where to add the control (0 by default)
  72944. * @returns the current grid
  72945. */
  72946. addControl(control: Control, row?: number, column?: number): Grid;
  72947. /**
  72948. * Removes a control from the current container
  72949. * @param control defines the control to remove
  72950. * @returns the current container
  72951. */
  72952. removeControl(control: Control): Container;
  72953. /**
  72954. * Creates a new Grid
  72955. * @param name defines control name
  72956. */
  72957. constructor(name?: string | undefined);
  72958. protected _getTypeName(): string;
  72959. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72960. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72961. _flagDescendantsAsMatrixDirty(): void;
  72962. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72963. /** Releases associated resources */
  72964. dispose(): void;
  72965. }
  72966. }
  72967. declare module BABYLON.GUI {
  72968. /** Class used to create color pickers */
  72969. export class ColorPicker extends Control {
  72970. name?: string | undefined;
  72971. private static _Epsilon;
  72972. private _colorWheelCanvas;
  72973. private _value;
  72974. private _tmpColor;
  72975. private _pointerStartedOnSquare;
  72976. private _pointerStartedOnWheel;
  72977. private _squareLeft;
  72978. private _squareTop;
  72979. private _squareSize;
  72980. private _h;
  72981. private _s;
  72982. private _v;
  72983. private _lastPointerDownID;
  72984. /**
  72985. * BABYLON.Observable raised when the value changes
  72986. */
  72987. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72988. /** Gets or sets the color of the color picker */
  72989. get value(): BABYLON.Color3;
  72990. set value(value: BABYLON.Color3);
  72991. /**
  72992. * Gets or sets control width
  72993. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72994. */
  72995. get width(): string | number;
  72996. set width(value: string | number);
  72997. /**
  72998. * Gets or sets control height
  72999. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73000. */
  73001. get height(): string | number;
  73002. /** Gets or sets control height */
  73003. set height(value: string | number);
  73004. /** Gets or sets control size */
  73005. get size(): string | number;
  73006. set size(value: string | number);
  73007. /**
  73008. * Creates a new ColorPicker
  73009. * @param name defines the control name
  73010. */
  73011. constructor(name?: string | undefined);
  73012. protected _getTypeName(): string;
  73013. /** @hidden */
  73014. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73015. private _updateSquareProps;
  73016. private _drawGradientSquare;
  73017. private _drawCircle;
  73018. private _createColorWheelCanvas;
  73019. /** @hidden */
  73020. _draw(context: CanvasRenderingContext2D): void;
  73021. private _pointerIsDown;
  73022. private _updateValueFromPointer;
  73023. private _isPointOnSquare;
  73024. private _isPointOnWheel;
  73025. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73026. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73027. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73028. /**
  73029. * This function expands the color picker by creating a color picker dialog with manual
  73030. * color value input and the ability to save colors into an array to be used later in
  73031. * subsequent launches of the dialogue.
  73032. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73033. * @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.
  73034. * @returns picked color as a hex string and the saved colors array as hex strings.
  73035. */
  73036. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73037. pickerWidth?: string;
  73038. pickerHeight?: string;
  73039. headerHeight?: string;
  73040. lastColor?: string;
  73041. swatchLimit?: number;
  73042. numSwatchesPerLine?: number;
  73043. savedColors?: Array<string>;
  73044. }): Promise<{
  73045. savedColors?: string[];
  73046. pickedColor: string;
  73047. }>;
  73048. }
  73049. }
  73050. declare module BABYLON.GUI {
  73051. /** Class used to create 2D ellipse containers */
  73052. export class Ellipse extends Container {
  73053. name?: string | undefined;
  73054. private _thickness;
  73055. /** Gets or sets border thickness */
  73056. get thickness(): number;
  73057. set thickness(value: number);
  73058. /**
  73059. * Creates a new Ellipse
  73060. * @param name defines the control name
  73061. */
  73062. constructor(name?: string | undefined);
  73063. protected _getTypeName(): string;
  73064. protected _localDraw(context: CanvasRenderingContext2D): void;
  73065. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73066. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73067. }
  73068. }
  73069. declare module BABYLON.GUI {
  73070. /**
  73071. * Class used to create a password control
  73072. */
  73073. export class InputPassword extends InputText {
  73074. protected _beforeRenderText(text: string): string;
  73075. }
  73076. }
  73077. declare module BABYLON.GUI {
  73078. /** Class used to render 2D lines */
  73079. export class Line extends Control {
  73080. name?: string | undefined;
  73081. private _lineWidth;
  73082. private _x1;
  73083. private _y1;
  73084. private _x2;
  73085. private _y2;
  73086. private _dash;
  73087. private _connectedControl;
  73088. private _connectedControlDirtyObserver;
  73089. /** Gets or sets the dash pattern */
  73090. get dash(): Array<number>;
  73091. set dash(value: Array<number>);
  73092. /** Gets or sets the control connected with the line end */
  73093. get connectedControl(): Control;
  73094. set connectedControl(value: Control);
  73095. /** Gets or sets start coordinates on X axis */
  73096. get x1(): string | number;
  73097. set x1(value: string | number);
  73098. /** Gets or sets start coordinates on Y axis */
  73099. get y1(): string | number;
  73100. set y1(value: string | number);
  73101. /** Gets or sets end coordinates on X axis */
  73102. get x2(): string | number;
  73103. set x2(value: string | number);
  73104. /** Gets or sets end coordinates on Y axis */
  73105. get y2(): string | number;
  73106. set y2(value: string | number);
  73107. /** Gets or sets line width */
  73108. get lineWidth(): number;
  73109. set lineWidth(value: number);
  73110. /** Gets or sets horizontal alignment */
  73111. set horizontalAlignment(value: number);
  73112. /** Gets or sets vertical alignment */
  73113. set verticalAlignment(value: number);
  73114. private get _effectiveX2();
  73115. private get _effectiveY2();
  73116. /**
  73117. * Creates a new Line
  73118. * @param name defines the control name
  73119. */
  73120. constructor(name?: string | undefined);
  73121. protected _getTypeName(): string;
  73122. _draw(context: CanvasRenderingContext2D): void;
  73123. _measure(): void;
  73124. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73125. /**
  73126. * Move one end of the line given 3D cartesian coordinates.
  73127. * @param position Targeted world position
  73128. * @param scene BABYLON.Scene
  73129. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73130. */
  73131. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73132. /**
  73133. * Move one end of the line to a position in screen absolute space.
  73134. * @param projectedPosition Position in screen absolute space (X, Y)
  73135. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73136. */
  73137. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73138. }
  73139. }
  73140. declare module BABYLON.GUI {
  73141. /**
  73142. * Class used to store a point for a MultiLine object.
  73143. * The point can be pure 2D coordinates, a mesh or a control
  73144. */
  73145. export class MultiLinePoint {
  73146. private _multiLine;
  73147. private _x;
  73148. private _y;
  73149. private _control;
  73150. private _mesh;
  73151. private _controlObserver;
  73152. private _meshObserver;
  73153. /** @hidden */
  73154. _point: BABYLON.Vector2;
  73155. /**
  73156. * Creates a new MultiLinePoint
  73157. * @param multiLine defines the source MultiLine object
  73158. */
  73159. constructor(multiLine: MultiLine);
  73160. /** Gets or sets x coordinate */
  73161. get x(): string | number;
  73162. set x(value: string | number);
  73163. /** Gets or sets y coordinate */
  73164. get y(): string | number;
  73165. set y(value: string | number);
  73166. /** Gets or sets the control associated with this point */
  73167. get control(): BABYLON.Nullable<Control>;
  73168. set control(value: BABYLON.Nullable<Control>);
  73169. /** Gets or sets the mesh associated with this point */
  73170. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73171. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73172. /** Resets links */
  73173. resetLinks(): void;
  73174. /**
  73175. * Gets a translation vector
  73176. * @returns the translation vector
  73177. */
  73178. translate(): BABYLON.Vector2;
  73179. private _translatePoint;
  73180. /** Release associated resources */
  73181. dispose(): void;
  73182. }
  73183. }
  73184. declare module BABYLON.GUI {
  73185. /**
  73186. * Class used to create multi line control
  73187. */
  73188. export class MultiLine extends Control {
  73189. name?: string | undefined;
  73190. private _lineWidth;
  73191. private _dash;
  73192. private _points;
  73193. private _minX;
  73194. private _minY;
  73195. private _maxX;
  73196. private _maxY;
  73197. /**
  73198. * Creates a new MultiLine
  73199. * @param name defines the control name
  73200. */
  73201. constructor(name?: string | undefined);
  73202. /** Gets or sets dash pattern */
  73203. get dash(): Array<number>;
  73204. set dash(value: Array<number>);
  73205. /**
  73206. * Gets point stored at specified index
  73207. * @param index defines the index to look for
  73208. * @returns the requested point if found
  73209. */
  73210. getAt(index: number): MultiLinePoint;
  73211. /** Function called when a point is updated */
  73212. onPointUpdate: () => void;
  73213. /**
  73214. * Adds new points to the point collection
  73215. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73216. * @returns the list of created MultiLinePoint
  73217. */
  73218. add(...items: (AbstractMesh | Control | {
  73219. x: string | number;
  73220. y: string | number;
  73221. })[]): MultiLinePoint[];
  73222. /**
  73223. * Adds a new point to the point collection
  73224. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73225. * @returns the created MultiLinePoint
  73226. */
  73227. push(item?: (AbstractMesh | Control | {
  73228. x: string | number;
  73229. y: string | number;
  73230. })): MultiLinePoint;
  73231. /**
  73232. * Remove a specific value or point from the active point collection
  73233. * @param value defines the value or point to remove
  73234. */
  73235. remove(value: number | MultiLinePoint): void;
  73236. /**
  73237. * Resets this object to initial state (no point)
  73238. */
  73239. reset(): void;
  73240. /**
  73241. * Resets all links
  73242. */
  73243. resetLinks(): void;
  73244. /** Gets or sets line width */
  73245. get lineWidth(): number;
  73246. set lineWidth(value: number);
  73247. set horizontalAlignment(value: number);
  73248. set verticalAlignment(value: number);
  73249. protected _getTypeName(): string;
  73250. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73251. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73252. _measure(): void;
  73253. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73254. dispose(): void;
  73255. }
  73256. }
  73257. declare module BABYLON.GUI {
  73258. /**
  73259. * Class used to create radio button controls
  73260. */
  73261. export class RadioButton extends Control {
  73262. name?: string | undefined;
  73263. private _isChecked;
  73264. private _background;
  73265. private _checkSizeRatio;
  73266. private _thickness;
  73267. /** Gets or sets border thickness */
  73268. get thickness(): number;
  73269. set thickness(value: number);
  73270. /** Gets or sets group name */
  73271. group: string;
  73272. /** BABYLON.Observable raised when isChecked is changed */
  73273. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73274. /** Gets or sets a value indicating the ratio between overall size and check size */
  73275. get checkSizeRatio(): number;
  73276. set checkSizeRatio(value: number);
  73277. /** Gets or sets background color */
  73278. get background(): string;
  73279. set background(value: string);
  73280. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73281. get isChecked(): boolean;
  73282. set isChecked(value: boolean);
  73283. /**
  73284. * Creates a new RadioButton
  73285. * @param name defines the control name
  73286. */
  73287. constructor(name?: string | undefined);
  73288. protected _getTypeName(): string;
  73289. _draw(context: CanvasRenderingContext2D): void;
  73290. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73291. /**
  73292. * Utility function to easily create a radio button with a header
  73293. * @param title defines the label to use for the header
  73294. * @param group defines the group to use for the radio button
  73295. * @param isChecked defines the initial state of the radio button
  73296. * @param onValueChanged defines the callback to call when value changes
  73297. * @returns a StackPanel containing the radio button and a textBlock
  73298. */
  73299. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73300. }
  73301. }
  73302. declare module BABYLON.GUI {
  73303. /**
  73304. * Class used to create slider controls
  73305. */
  73306. export class BaseSlider extends Control {
  73307. name?: string | undefined;
  73308. protected _thumbWidth: ValueAndUnit;
  73309. private _minimum;
  73310. private _maximum;
  73311. private _value;
  73312. private _isVertical;
  73313. protected _barOffset: ValueAndUnit;
  73314. private _isThumbClamped;
  73315. protected _displayThumb: boolean;
  73316. private _step;
  73317. private _lastPointerDownID;
  73318. protected _effectiveBarOffset: number;
  73319. protected _renderLeft: number;
  73320. protected _renderTop: number;
  73321. protected _renderWidth: number;
  73322. protected _renderHeight: number;
  73323. protected _backgroundBoxLength: number;
  73324. protected _backgroundBoxThickness: number;
  73325. protected _effectiveThumbThickness: number;
  73326. /** BABYLON.Observable raised when the sldier value changes */
  73327. onValueChangedObservable: BABYLON.Observable<number>;
  73328. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73329. get displayThumb(): boolean;
  73330. set displayThumb(value: boolean);
  73331. /** Gets or sets a step to apply to values (0 by default) */
  73332. get step(): number;
  73333. set step(value: number);
  73334. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73335. get barOffset(): string | number;
  73336. /** Gets main bar offset in pixels*/
  73337. get barOffsetInPixels(): number;
  73338. set barOffset(value: string | number);
  73339. /** Gets or sets thumb width */
  73340. get thumbWidth(): string | number;
  73341. /** Gets thumb width in pixels */
  73342. get thumbWidthInPixels(): number;
  73343. set thumbWidth(value: string | number);
  73344. /** Gets or sets minimum value */
  73345. get minimum(): number;
  73346. set minimum(value: number);
  73347. /** Gets or sets maximum value */
  73348. get maximum(): number;
  73349. set maximum(value: number);
  73350. /** Gets or sets current value */
  73351. get value(): number;
  73352. set value(value: number);
  73353. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73354. get isVertical(): boolean;
  73355. set isVertical(value: boolean);
  73356. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73357. get isThumbClamped(): boolean;
  73358. set isThumbClamped(value: boolean);
  73359. /**
  73360. * Creates a new BaseSlider
  73361. * @param name defines the control name
  73362. */
  73363. constructor(name?: string | undefined);
  73364. protected _getTypeName(): string;
  73365. protected _getThumbPosition(): number;
  73366. protected _getThumbThickness(type: string): number;
  73367. protected _prepareRenderingData(type: string): void;
  73368. private _pointerIsDown;
  73369. /** @hidden */
  73370. protected _updateValueFromPointer(x: number, y: number): void;
  73371. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73372. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73373. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73374. }
  73375. }
  73376. declare module BABYLON.GUI {
  73377. /**
  73378. * Class used to create slider controls
  73379. */
  73380. export class Slider extends BaseSlider {
  73381. name?: string | undefined;
  73382. private _background;
  73383. private _borderColor;
  73384. private _isThumbCircle;
  73385. protected _displayValueBar: boolean;
  73386. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73387. get displayValueBar(): boolean;
  73388. set displayValueBar(value: boolean);
  73389. /** Gets or sets border color */
  73390. get borderColor(): string;
  73391. set borderColor(value: string);
  73392. /** Gets or sets background color */
  73393. get background(): string;
  73394. set background(value: string);
  73395. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73396. get isThumbCircle(): boolean;
  73397. set isThumbCircle(value: boolean);
  73398. /**
  73399. * Creates a new Slider
  73400. * @param name defines the control name
  73401. */
  73402. constructor(name?: string | undefined);
  73403. protected _getTypeName(): string;
  73404. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73405. }
  73406. }
  73407. declare module BABYLON.GUI {
  73408. /** Class used to create a RadioGroup
  73409. * which contains groups of radio buttons
  73410. */
  73411. export class SelectorGroup {
  73412. /** name of SelectorGroup */
  73413. name: string;
  73414. private _groupPanel;
  73415. private _selectors;
  73416. private _groupHeader;
  73417. /**
  73418. * Creates a new SelectorGroup
  73419. * @param name of group, used as a group heading
  73420. */
  73421. constructor(
  73422. /** name of SelectorGroup */
  73423. name: string);
  73424. /** Gets the groupPanel of the SelectorGroup */
  73425. get groupPanel(): StackPanel;
  73426. /** Gets the selectors array */
  73427. get selectors(): StackPanel[];
  73428. /** Gets and sets the group header */
  73429. get header(): string;
  73430. set header(label: string);
  73431. /** @hidden */
  73432. private _addGroupHeader;
  73433. /** @hidden*/
  73434. _getSelector(selectorNb: number): StackPanel | undefined;
  73435. /** Removes the selector at the given position
  73436. * @param selectorNb the position of the selector within the group
  73437. */
  73438. removeSelector(selectorNb: number): void;
  73439. }
  73440. /** Class used to create a CheckboxGroup
  73441. * which contains groups of checkbox buttons
  73442. */
  73443. export class CheckboxGroup extends SelectorGroup {
  73444. /** Adds a checkbox as a control
  73445. * @param text is the label for the selector
  73446. * @param func is the function called when the Selector is checked
  73447. * @param checked is true when Selector is checked
  73448. */
  73449. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73450. /** @hidden */
  73451. _setSelectorLabel(selectorNb: number, label: string): void;
  73452. /** @hidden */
  73453. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73454. /** @hidden */
  73455. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73456. /** @hidden */
  73457. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73458. }
  73459. /** Class used to create a RadioGroup
  73460. * which contains groups of radio buttons
  73461. */
  73462. export class RadioGroup extends SelectorGroup {
  73463. private _selectNb;
  73464. /** Adds a radio button as a control
  73465. * @param label is the label for the selector
  73466. * @param func is the function called when the Selector is checked
  73467. * @param checked is true when Selector is checked
  73468. */
  73469. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73470. /** @hidden */
  73471. _setSelectorLabel(selectorNb: number, label: string): void;
  73472. /** @hidden */
  73473. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73474. /** @hidden */
  73475. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73476. /** @hidden */
  73477. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73478. }
  73479. /** Class used to create a SliderGroup
  73480. * which contains groups of slider buttons
  73481. */
  73482. export class SliderGroup extends SelectorGroup {
  73483. /**
  73484. * Adds a slider to the SelectorGroup
  73485. * @param label is the label for the SliderBar
  73486. * @param func is the function called when the Slider moves
  73487. * @param unit is a string describing the units used, eg degrees or metres
  73488. * @param min is the minimum value for the Slider
  73489. * @param max is the maximum value for the Slider
  73490. * @param value is the start value for the Slider between min and max
  73491. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73492. */
  73493. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73494. /** @hidden */
  73495. _setSelectorLabel(selectorNb: number, label: string): void;
  73496. /** @hidden */
  73497. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73498. /** @hidden */
  73499. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73500. /** @hidden */
  73501. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73502. }
  73503. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73504. * @see http://doc.babylonjs.com/how_to/selector
  73505. */
  73506. export class SelectionPanel extends Rectangle {
  73507. /** name of SelectionPanel */
  73508. name: string;
  73509. /** an array of SelectionGroups */
  73510. groups: SelectorGroup[];
  73511. private _panel;
  73512. private _buttonColor;
  73513. private _buttonBackground;
  73514. private _headerColor;
  73515. private _barColor;
  73516. private _barHeight;
  73517. private _spacerHeight;
  73518. private _labelColor;
  73519. private _groups;
  73520. private _bars;
  73521. /**
  73522. * Creates a new SelectionPanel
  73523. * @param name of SelectionPanel
  73524. * @param groups is an array of SelectionGroups
  73525. */
  73526. constructor(
  73527. /** name of SelectionPanel */
  73528. name: string,
  73529. /** an array of SelectionGroups */
  73530. groups?: SelectorGroup[]);
  73531. protected _getTypeName(): string;
  73532. /** Gets or sets the headerColor */
  73533. get headerColor(): string;
  73534. set headerColor(color: string);
  73535. private _setHeaderColor;
  73536. /** Gets or sets the button color */
  73537. get buttonColor(): string;
  73538. set buttonColor(color: string);
  73539. private _setbuttonColor;
  73540. /** Gets or sets the label color */
  73541. get labelColor(): string;
  73542. set labelColor(color: string);
  73543. private _setLabelColor;
  73544. /** Gets or sets the button background */
  73545. get buttonBackground(): string;
  73546. set buttonBackground(color: string);
  73547. private _setButtonBackground;
  73548. /** Gets or sets the color of separator bar */
  73549. get barColor(): string;
  73550. set barColor(color: string);
  73551. private _setBarColor;
  73552. /** Gets or sets the height of separator bar */
  73553. get barHeight(): string;
  73554. set barHeight(value: string);
  73555. private _setBarHeight;
  73556. /** Gets or sets the height of spacers*/
  73557. get spacerHeight(): string;
  73558. set spacerHeight(value: string);
  73559. private _setSpacerHeight;
  73560. /** Adds a bar between groups */
  73561. private _addSpacer;
  73562. /** Add a group to the selection panel
  73563. * @param group is the selector group to add
  73564. */
  73565. addGroup(group: SelectorGroup): void;
  73566. /** Remove the group from the given position
  73567. * @param groupNb is the position of the group in the list
  73568. */
  73569. removeGroup(groupNb: number): void;
  73570. /** Change a group header label
  73571. * @param label is the new group header label
  73572. * @param groupNb is the number of the group to relabel
  73573. * */
  73574. setHeaderName(label: string, groupNb: number): void;
  73575. /** Change selector label to the one given
  73576. * @param label is the new selector label
  73577. * @param groupNb is the number of the groupcontaining the selector
  73578. * @param selectorNb is the number of the selector within a group to relabel
  73579. * */
  73580. relabel(label: string, groupNb: number, selectorNb: number): void;
  73581. /** For a given group position remove the selector at the given position
  73582. * @param groupNb is the number of the group to remove the selector from
  73583. * @param selectorNb is the number of the selector within the group
  73584. */
  73585. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73586. /** For a given group position of correct type add a checkbox button
  73587. * @param groupNb is the number of the group to remove the selector from
  73588. * @param label is the label for the selector
  73589. * @param func is the function called when the Selector is checked
  73590. * @param checked is true when Selector is checked
  73591. */
  73592. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73593. /** For a given group position of correct type add a radio button
  73594. * @param groupNb is the number of the group to remove the selector from
  73595. * @param label is the label for the selector
  73596. * @param func is the function called when the Selector is checked
  73597. * @param checked is true when Selector is checked
  73598. */
  73599. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73600. /**
  73601. * For a given slider group add a slider
  73602. * @param groupNb is the number of the group to add the slider to
  73603. * @param label is the label for the Slider
  73604. * @param func is the function called when the Slider moves
  73605. * @param unit is a string describing the units used, eg degrees or metres
  73606. * @param min is the minimum value for the Slider
  73607. * @param max is the maximum value for the Slider
  73608. * @param value is the start value for the Slider between min and max
  73609. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73610. */
  73611. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73612. }
  73613. }
  73614. declare module BABYLON.GUI {
  73615. /**
  73616. * Class used to hold a the container for ScrollViewer
  73617. * @hidden
  73618. */
  73619. export class _ScrollViewerWindow extends Container {
  73620. parentClientWidth: number;
  73621. parentClientHeight: number;
  73622. private _freezeControls;
  73623. private _parentMeasure;
  73624. private _oldLeft;
  73625. private _oldTop;
  73626. get freezeControls(): boolean;
  73627. set freezeControls(value: boolean);
  73628. private _bucketWidth;
  73629. private _bucketHeight;
  73630. private _buckets;
  73631. private _bucketLen;
  73632. get bucketWidth(): number;
  73633. get bucketHeight(): number;
  73634. setBucketSizes(width: number, height: number): void;
  73635. private _useBuckets;
  73636. private _makeBuckets;
  73637. private _dispatchInBuckets;
  73638. private _updateMeasures;
  73639. private _updateChildrenMeasures;
  73640. private _restoreMeasures;
  73641. /**
  73642. * Creates a new ScrollViewerWindow
  73643. * @param name of ScrollViewerWindow
  73644. */
  73645. constructor(name?: string);
  73646. protected _getTypeName(): string;
  73647. /** @hidden */
  73648. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73649. /** @hidden */
  73650. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73651. private _scrollChildren;
  73652. private _scrollChildrenWithBuckets;
  73653. /** @hidden */
  73654. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73655. protected _postMeasure(): void;
  73656. }
  73657. }
  73658. declare module BABYLON.GUI {
  73659. /**
  73660. * Class used to create slider controls
  73661. */
  73662. export class ScrollBar extends BaseSlider {
  73663. name?: string | undefined;
  73664. private _background;
  73665. private _borderColor;
  73666. private _tempMeasure;
  73667. /** Gets or sets border color */
  73668. get borderColor(): string;
  73669. set borderColor(value: string);
  73670. /** Gets or sets background color */
  73671. get background(): string;
  73672. set background(value: string);
  73673. /**
  73674. * Creates a new Slider
  73675. * @param name defines the control name
  73676. */
  73677. constructor(name?: string | undefined);
  73678. protected _getTypeName(): string;
  73679. protected _getThumbThickness(): number;
  73680. _draw(context: CanvasRenderingContext2D): void;
  73681. private _first;
  73682. private _originX;
  73683. private _originY;
  73684. /** @hidden */
  73685. protected _updateValueFromPointer(x: number, y: number): void;
  73686. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73687. }
  73688. }
  73689. declare module BABYLON.GUI {
  73690. /**
  73691. * Class used to create slider controls
  73692. */
  73693. export class ImageScrollBar extends BaseSlider {
  73694. name?: string | undefined;
  73695. private _backgroundBaseImage;
  73696. private _backgroundImage;
  73697. private _thumbImage;
  73698. private _thumbBaseImage;
  73699. private _thumbLength;
  73700. private _thumbHeight;
  73701. private _barImageHeight;
  73702. private _tempMeasure;
  73703. /** Number of 90° rotation to apply on the images when in vertical mode */
  73704. num90RotationInVerticalMode: number;
  73705. /**
  73706. * Gets or sets the image used to render the background for horizontal bar
  73707. */
  73708. get backgroundImage(): Image;
  73709. set backgroundImage(value: Image);
  73710. /**
  73711. * Gets or sets the image used to render the thumb
  73712. */
  73713. get thumbImage(): Image;
  73714. set thumbImage(value: Image);
  73715. /**
  73716. * Gets or sets the length of the thumb
  73717. */
  73718. get thumbLength(): number;
  73719. set thumbLength(value: number);
  73720. /**
  73721. * Gets or sets the height of the thumb
  73722. */
  73723. get thumbHeight(): number;
  73724. set thumbHeight(value: number);
  73725. /**
  73726. * Gets or sets the height of the bar image
  73727. */
  73728. get barImageHeight(): number;
  73729. set barImageHeight(value: number);
  73730. /**
  73731. * Creates a new ImageScrollBar
  73732. * @param name defines the control name
  73733. */
  73734. constructor(name?: string | undefined);
  73735. protected _getTypeName(): string;
  73736. protected _getThumbThickness(): number;
  73737. _draw(context: CanvasRenderingContext2D): void;
  73738. private _first;
  73739. private _originX;
  73740. private _originY;
  73741. /** @hidden */
  73742. protected _updateValueFromPointer(x: number, y: number): void;
  73743. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73744. }
  73745. }
  73746. declare module BABYLON.GUI {
  73747. /**
  73748. * Class used to hold a viewer window and sliders in a grid
  73749. */
  73750. export class ScrollViewer extends Rectangle {
  73751. private _grid;
  73752. private _horizontalBarSpace;
  73753. private _verticalBarSpace;
  73754. private _dragSpace;
  73755. private _horizontalBar;
  73756. private _verticalBar;
  73757. private _barColor;
  73758. private _barBackground;
  73759. private _barImage;
  73760. private _horizontalBarImage;
  73761. private _verticalBarImage;
  73762. private _barBackgroundImage;
  73763. private _horizontalBarBackgroundImage;
  73764. private _verticalBarBackgroundImage;
  73765. private _barSize;
  73766. private _window;
  73767. private _pointerIsOver;
  73768. private _wheelPrecision;
  73769. private _onWheelObserver;
  73770. private _clientWidth;
  73771. private _clientHeight;
  73772. private _useImageBar;
  73773. private _thumbLength;
  73774. private _thumbHeight;
  73775. private _barImageHeight;
  73776. private _horizontalBarImageHeight;
  73777. private _verticalBarImageHeight;
  73778. /**
  73779. * Gets the horizontal scrollbar
  73780. */
  73781. get horizontalBar(): ScrollBar | ImageScrollBar;
  73782. /**
  73783. * Gets the vertical scrollbar
  73784. */
  73785. get verticalBar(): ScrollBar | ImageScrollBar;
  73786. /**
  73787. * Adds a new control to the current container
  73788. * @param control defines the control to add
  73789. * @returns the current container
  73790. */
  73791. addControl(control: BABYLON.Nullable<Control>): Container;
  73792. /**
  73793. * Removes a control from the current container
  73794. * @param control defines the control to remove
  73795. * @returns the current container
  73796. */
  73797. removeControl(control: Control): Container;
  73798. /** Gets the list of children */
  73799. get children(): Control[];
  73800. _flagDescendantsAsMatrixDirty(): void;
  73801. /**
  73802. * Freezes or unfreezes the controls in the window.
  73803. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73804. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73805. */
  73806. get freezeControls(): boolean;
  73807. set freezeControls(value: boolean);
  73808. /** Gets the bucket width */
  73809. get bucketWidth(): number;
  73810. /** Gets the bucket height */
  73811. get bucketHeight(): number;
  73812. /**
  73813. * Sets the bucket sizes.
  73814. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73815. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73816. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73817. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73818. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73819. * used), that's why it is not enabled by default.
  73820. * @param width width of the bucket
  73821. * @param height height of the bucket
  73822. */
  73823. setBucketSizes(width: number, height: number): void;
  73824. private _forceHorizontalBar;
  73825. private _forceVerticalBar;
  73826. /**
  73827. * Forces the horizontal scroll bar to be displayed
  73828. */
  73829. get forceHorizontalBar(): boolean;
  73830. set forceHorizontalBar(value: boolean);
  73831. /**
  73832. * Forces the vertical scroll bar to be displayed
  73833. */
  73834. get forceVerticalBar(): boolean;
  73835. set forceVerticalBar(value: boolean);
  73836. /**
  73837. * Creates a new ScrollViewer
  73838. * @param name of ScrollViewer
  73839. */
  73840. constructor(name?: string, isImageBased?: boolean);
  73841. /** Reset the scroll viewer window to initial size */
  73842. resetWindow(): void;
  73843. protected _getTypeName(): string;
  73844. private _buildClientSizes;
  73845. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73846. protected _postMeasure(): void;
  73847. /**
  73848. * Gets or sets the mouse wheel precision
  73849. * from 0 to 1 with a default value of 0.05
  73850. * */
  73851. get wheelPrecision(): number;
  73852. set wheelPrecision(value: number);
  73853. /** Gets or sets the scroll bar container background color */
  73854. get scrollBackground(): string;
  73855. set scrollBackground(color: string);
  73856. /** Gets or sets the bar color */
  73857. get barColor(): string;
  73858. set barColor(color: string);
  73859. /** Gets or sets the bar image */
  73860. get thumbImage(): Image;
  73861. set thumbImage(value: Image);
  73862. /** Gets or sets the horizontal bar image */
  73863. get horizontalThumbImage(): Image;
  73864. set horizontalThumbImage(value: Image);
  73865. /** Gets or sets the vertical bar image */
  73866. get verticalThumbImage(): Image;
  73867. set verticalThumbImage(value: Image);
  73868. /** Gets or sets the size of the bar */
  73869. get barSize(): number;
  73870. set barSize(value: number);
  73871. /** Gets or sets the length of the thumb */
  73872. get thumbLength(): number;
  73873. set thumbLength(value: number);
  73874. /** Gets or sets the height of the thumb */
  73875. get thumbHeight(): number;
  73876. set thumbHeight(value: number);
  73877. /** Gets or sets the height of the bar image */
  73878. get barImageHeight(): number;
  73879. set barImageHeight(value: number);
  73880. /** Gets or sets the height of the horizontal bar image */
  73881. get horizontalBarImageHeight(): number;
  73882. set horizontalBarImageHeight(value: number);
  73883. /** Gets or sets the height of the vertical bar image */
  73884. get verticalBarImageHeight(): number;
  73885. set verticalBarImageHeight(value: number);
  73886. /** Gets or sets the bar background */
  73887. get barBackground(): string;
  73888. set barBackground(color: string);
  73889. /** Gets or sets the bar background image */
  73890. get barImage(): Image;
  73891. set barImage(value: Image);
  73892. /** Gets or sets the horizontal bar background image */
  73893. get horizontalBarImage(): Image;
  73894. set horizontalBarImage(value: Image);
  73895. /** Gets or sets the vertical bar background image */
  73896. get verticalBarImage(): Image;
  73897. set verticalBarImage(value: Image);
  73898. private _setWindowPosition;
  73899. /** @hidden */
  73900. private _updateScroller;
  73901. _link(host: AdvancedDynamicTexture): void;
  73902. /** @hidden */
  73903. private _addBar;
  73904. /** @hidden */
  73905. private _attachWheel;
  73906. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73907. /** Releases associated resources */
  73908. dispose(): void;
  73909. }
  73910. }
  73911. declare module BABYLON.GUI {
  73912. /** Class used to render a grid */
  73913. export class DisplayGrid extends Control {
  73914. name?: string | undefined;
  73915. private _cellWidth;
  73916. private _cellHeight;
  73917. private _minorLineTickness;
  73918. private _minorLineColor;
  73919. private _majorLineTickness;
  73920. private _majorLineColor;
  73921. private _majorLineFrequency;
  73922. private _background;
  73923. private _displayMajorLines;
  73924. private _displayMinorLines;
  73925. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73926. get displayMinorLines(): boolean;
  73927. set displayMinorLines(value: boolean);
  73928. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73929. get displayMajorLines(): boolean;
  73930. set displayMajorLines(value: boolean);
  73931. /** Gets or sets background color (Black by default) */
  73932. get background(): string;
  73933. set background(value: string);
  73934. /** Gets or sets the width of each cell (20 by default) */
  73935. get cellWidth(): number;
  73936. set cellWidth(value: number);
  73937. /** Gets or sets the height of each cell (20 by default) */
  73938. get cellHeight(): number;
  73939. set cellHeight(value: number);
  73940. /** Gets or sets the tickness of minor lines (1 by default) */
  73941. get minorLineTickness(): number;
  73942. set minorLineTickness(value: number);
  73943. /** Gets or sets the color of minor lines (DarkGray by default) */
  73944. get minorLineColor(): string;
  73945. set minorLineColor(value: string);
  73946. /** Gets or sets the tickness of major lines (2 by default) */
  73947. get majorLineTickness(): number;
  73948. set majorLineTickness(value: number);
  73949. /** Gets or sets the color of major lines (White by default) */
  73950. get majorLineColor(): string;
  73951. set majorLineColor(value: string);
  73952. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73953. get majorLineFrequency(): number;
  73954. set majorLineFrequency(value: number);
  73955. /**
  73956. * Creates a new GridDisplayRectangle
  73957. * @param name defines the control name
  73958. */
  73959. constructor(name?: string | undefined);
  73960. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73961. protected _getTypeName(): string;
  73962. }
  73963. }
  73964. declare module BABYLON.GUI {
  73965. /**
  73966. * Class used to create slider controls based on images
  73967. */
  73968. export class ImageBasedSlider extends BaseSlider {
  73969. name?: string | undefined;
  73970. private _backgroundImage;
  73971. private _thumbImage;
  73972. private _valueBarImage;
  73973. private _tempMeasure;
  73974. get displayThumb(): boolean;
  73975. set displayThumb(value: boolean);
  73976. /**
  73977. * Gets or sets the image used to render the background
  73978. */
  73979. get backgroundImage(): Image;
  73980. set backgroundImage(value: Image);
  73981. /**
  73982. * Gets or sets the image used to render the value bar
  73983. */
  73984. get valueBarImage(): Image;
  73985. set valueBarImage(value: Image);
  73986. /**
  73987. * Gets or sets the image used to render the thumb
  73988. */
  73989. get thumbImage(): Image;
  73990. set thumbImage(value: Image);
  73991. /**
  73992. * Creates a new ImageBasedSlider
  73993. * @param name defines the control name
  73994. */
  73995. constructor(name?: string | undefined);
  73996. protected _getTypeName(): string;
  73997. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73998. }
  73999. }
  74000. declare module BABYLON.GUI {
  74001. /**
  74002. * Forcing an export so that this code will execute
  74003. * @hidden
  74004. */
  74005. const name = "Statics";
  74006. }
  74007. declare module BABYLON.GUI {
  74008. /**
  74009. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74010. */
  74011. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74012. /**
  74013. * Define the instrumented AdvancedDynamicTexture.
  74014. */
  74015. texture: AdvancedDynamicTexture;
  74016. private _captureRenderTime;
  74017. private _renderTime;
  74018. private _captureLayoutTime;
  74019. private _layoutTime;
  74020. private _onBeginRenderObserver;
  74021. private _onEndRenderObserver;
  74022. private _onBeginLayoutObserver;
  74023. private _onEndLayoutObserver;
  74024. /**
  74025. * Gets the perf counter used to capture render time
  74026. */
  74027. get renderTimeCounter(): BABYLON.PerfCounter;
  74028. /**
  74029. * Gets the perf counter used to capture layout time
  74030. */
  74031. get layoutTimeCounter(): BABYLON.PerfCounter;
  74032. /**
  74033. * Enable or disable the render time capture
  74034. */
  74035. get captureRenderTime(): boolean;
  74036. set captureRenderTime(value: boolean);
  74037. /**
  74038. * Enable or disable the layout time capture
  74039. */
  74040. get captureLayoutTime(): boolean;
  74041. set captureLayoutTime(value: boolean);
  74042. /**
  74043. * Instantiates a new advanced dynamic texture instrumentation.
  74044. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74045. * @param texture Defines the AdvancedDynamicTexture to instrument
  74046. */
  74047. constructor(
  74048. /**
  74049. * Define the instrumented AdvancedDynamicTexture.
  74050. */
  74051. texture: AdvancedDynamicTexture);
  74052. /**
  74053. * Dispose and release associated resources.
  74054. */
  74055. dispose(): void;
  74056. }
  74057. }
  74058. declare module BABYLON.GUI {
  74059. /**
  74060. * Class used to load GUI via XML.
  74061. */
  74062. export class XmlLoader {
  74063. private _nodes;
  74064. private _nodeTypes;
  74065. private _isLoaded;
  74066. private _objectAttributes;
  74067. private _parentClass;
  74068. /**
  74069. * Create a new xml loader
  74070. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74071. */
  74072. constructor(parentClass?: null);
  74073. private _getChainElement;
  74074. private _getClassAttribute;
  74075. private _createGuiElement;
  74076. private _parseGrid;
  74077. private _parseElement;
  74078. private _prepareSourceElement;
  74079. private _parseElementsFromSource;
  74080. private _parseXml;
  74081. /**
  74082. * Gets if the loading has finished.
  74083. * @returns whether the loading has finished or not
  74084. */
  74085. isLoaded(): boolean;
  74086. /**
  74087. * Gets a loaded node / control by id.
  74088. * @param id the Controls id set in the xml
  74089. * @returns element of type Control
  74090. */
  74091. getNodeById(id: string): any;
  74092. /**
  74093. * Gets all loaded nodes / controls
  74094. * @returns Array of controls
  74095. */
  74096. getNodes(): any;
  74097. /**
  74098. * Initiates the xml layout loading
  74099. * @param xmlFile defines the xml layout to load
  74100. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74101. * @param callback defines the callback called on layout load.
  74102. */
  74103. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74104. }
  74105. }
  74106. declare module BABYLON.GUI {
  74107. /**
  74108. * Class used to create containers for controls
  74109. */
  74110. export class Container3D extends Control3D {
  74111. private _blockLayout;
  74112. /**
  74113. * Gets the list of child controls
  74114. */
  74115. protected _children: Control3D[];
  74116. /**
  74117. * Gets the list of child controls
  74118. */
  74119. get children(): Array<Control3D>;
  74120. /**
  74121. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74122. * This is helpful to optimize layout operation when adding multiple children in a row
  74123. */
  74124. get blockLayout(): boolean;
  74125. set blockLayout(value: boolean);
  74126. /**
  74127. * Creates a new container
  74128. * @param name defines the container name
  74129. */
  74130. constructor(name?: string);
  74131. /**
  74132. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74133. * @returns the current container
  74134. */
  74135. updateLayout(): Container3D;
  74136. /**
  74137. * Gets a boolean indicating if the given control is in the children of this control
  74138. * @param control defines the control to check
  74139. * @returns true if the control is in the child list
  74140. */
  74141. containsControl(control: Control3D): boolean;
  74142. /**
  74143. * Adds a control to the children of this control
  74144. * @param control defines the control to add
  74145. * @returns the current container
  74146. */
  74147. addControl(control: Control3D): Container3D;
  74148. /**
  74149. * This function will be called everytime a new control is added
  74150. */
  74151. protected _arrangeChildren(): void;
  74152. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74153. /**
  74154. * Removes a control from the children of this control
  74155. * @param control defines the control to remove
  74156. * @returns the current container
  74157. */
  74158. removeControl(control: Control3D): Container3D;
  74159. protected _getTypeName(): string;
  74160. /**
  74161. * Releases all associated resources
  74162. */
  74163. dispose(): void;
  74164. /** Control rotation will remain unchanged */
  74165. static readonly UNSET_ORIENTATION: number;
  74166. /** Control will rotate to make it look at sphere central axis */
  74167. static readonly FACEORIGIN_ORIENTATION: number;
  74168. /** Control will rotate to make it look back at sphere central axis */
  74169. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74170. /** Control will rotate to look at z axis (0, 0, 1) */
  74171. static readonly FACEFORWARD_ORIENTATION: number;
  74172. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74173. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74174. }
  74175. }
  74176. declare module BABYLON.GUI {
  74177. /**
  74178. * Class used to manage 3D user interface
  74179. * @see http://doc.babylonjs.com/how_to/gui3d
  74180. */
  74181. export class GUI3DManager implements BABYLON.IDisposable {
  74182. private _scene;
  74183. private _sceneDisposeObserver;
  74184. private _utilityLayer;
  74185. private _rootContainer;
  74186. private _pointerObserver;
  74187. private _pointerOutObserver;
  74188. /** @hidden */
  74189. _lastPickedControl: Control3D;
  74190. /** @hidden */
  74191. _lastControlOver: {
  74192. [pointerId: number]: Control3D;
  74193. };
  74194. /** @hidden */
  74195. _lastControlDown: {
  74196. [pointerId: number]: Control3D;
  74197. };
  74198. /**
  74199. * BABYLON.Observable raised when the point picked by the pointer events changed
  74200. */
  74201. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74202. /** @hidden */
  74203. _sharedMaterials: {
  74204. [key: string]: BABYLON.Material;
  74205. };
  74206. /** Gets the hosting scene */
  74207. get scene(): BABYLON.Scene;
  74208. /** Gets associated utility layer */
  74209. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74210. /**
  74211. * Creates a new GUI3DManager
  74212. * @param scene
  74213. */
  74214. constructor(scene?: BABYLON.Scene);
  74215. private _handlePointerOut;
  74216. private _doPicking;
  74217. /**
  74218. * Gets the root container
  74219. */
  74220. get rootContainer(): Container3D;
  74221. /**
  74222. * Gets a boolean indicating if the given control is in the root child list
  74223. * @param control defines the control to check
  74224. * @returns true if the control is in the root child list
  74225. */
  74226. containsControl(control: Control3D): boolean;
  74227. /**
  74228. * Adds a control to the root child list
  74229. * @param control defines the control to add
  74230. * @returns the current manager
  74231. */
  74232. addControl(control: Control3D): GUI3DManager;
  74233. /**
  74234. * Removes a control from the root child list
  74235. * @param control defines the control to remove
  74236. * @returns the current container
  74237. */
  74238. removeControl(control: Control3D): GUI3DManager;
  74239. /**
  74240. * Releases all associated resources
  74241. */
  74242. dispose(): void;
  74243. }
  74244. }
  74245. declare module BABYLON.GUI {
  74246. /**
  74247. * Class used to transport BABYLON.Vector3 information for pointer events
  74248. */
  74249. export class Vector3WithInfo extends BABYLON.Vector3 {
  74250. /** defines the current mouse button index */
  74251. buttonIndex: number;
  74252. /**
  74253. * Creates a new Vector3WithInfo
  74254. * @param source defines the vector3 data to transport
  74255. * @param buttonIndex defines the current mouse button index
  74256. */
  74257. constructor(source: BABYLON.Vector3,
  74258. /** defines the current mouse button index */
  74259. buttonIndex?: number);
  74260. }
  74261. }
  74262. declare module BABYLON.GUI {
  74263. /**
  74264. * Class used as base class for controls
  74265. */
  74266. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74267. /** Defines the control name */
  74268. name?: string | undefined;
  74269. /** @hidden */
  74270. _host: GUI3DManager;
  74271. private _node;
  74272. private _downCount;
  74273. private _enterCount;
  74274. private _downPointerIds;
  74275. private _isVisible;
  74276. /** Gets or sets the control position in world space */
  74277. get position(): BABYLON.Vector3;
  74278. set position(value: BABYLON.Vector3);
  74279. /** Gets or sets the control scaling in world space */
  74280. get scaling(): BABYLON.Vector3;
  74281. set scaling(value: BABYLON.Vector3);
  74282. /** Callback used to start pointer enter animation */
  74283. pointerEnterAnimation: () => void;
  74284. /** Callback used to start pointer out animation */
  74285. pointerOutAnimation: () => void;
  74286. /** Callback used to start pointer down animation */
  74287. pointerDownAnimation: () => void;
  74288. /** Callback used to start pointer up animation */
  74289. pointerUpAnimation: () => void;
  74290. /**
  74291. * An event triggered when the pointer move over the control
  74292. */
  74293. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74294. /**
  74295. * An event triggered when the pointer move out of the control
  74296. */
  74297. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74298. /**
  74299. * An event triggered when the pointer taps the control
  74300. */
  74301. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74302. /**
  74303. * An event triggered when pointer is up
  74304. */
  74305. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74306. /**
  74307. * An event triggered when a control is clicked on (with a mouse)
  74308. */
  74309. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74310. /**
  74311. * An event triggered when pointer enters the control
  74312. */
  74313. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74314. /**
  74315. * Gets or sets the parent container
  74316. */
  74317. parent: BABYLON.Nullable<Container3D>;
  74318. private _behaviors;
  74319. /**
  74320. * Gets the list of attached behaviors
  74321. * @see http://doc.babylonjs.com/features/behaviour
  74322. */
  74323. get behaviors(): BABYLON.Behavior<Control3D>[];
  74324. /**
  74325. * Attach a behavior to the control
  74326. * @see http://doc.babylonjs.com/features/behaviour
  74327. * @param behavior defines the behavior to attach
  74328. * @returns the current control
  74329. */
  74330. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74331. /**
  74332. * Remove an attached behavior
  74333. * @see http://doc.babylonjs.com/features/behaviour
  74334. * @param behavior defines the behavior to attach
  74335. * @returns the current control
  74336. */
  74337. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74338. /**
  74339. * Gets an attached behavior by name
  74340. * @param name defines the name of the behavior to look for
  74341. * @see http://doc.babylonjs.com/features/behaviour
  74342. * @returns null if behavior was not found else the requested behavior
  74343. */
  74344. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74345. /** Gets or sets a boolean indicating if the control is visible */
  74346. get isVisible(): boolean;
  74347. set isVisible(value: boolean);
  74348. /**
  74349. * Creates a new control
  74350. * @param name defines the control name
  74351. */
  74352. constructor(
  74353. /** Defines the control name */
  74354. name?: string | undefined);
  74355. /**
  74356. * Gets a string representing the class name
  74357. */
  74358. get typeName(): string;
  74359. /**
  74360. * Get the current class name of the control.
  74361. * @returns current class name
  74362. */
  74363. getClassName(): string;
  74364. protected _getTypeName(): string;
  74365. /**
  74366. * Gets the transform node used by this control
  74367. */
  74368. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74369. /**
  74370. * Gets the mesh used to render this control
  74371. */
  74372. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74373. /**
  74374. * Link the control as child of the given node
  74375. * @param node defines the node to link to. Use null to unlink the control
  74376. * @returns the current control
  74377. */
  74378. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74379. /** @hidden **/
  74380. _prepareNode(scene: BABYLON.Scene): void;
  74381. /**
  74382. * Node creation.
  74383. * Can be overriden by children
  74384. * @param scene defines the scene where the node must be attached
  74385. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74386. */
  74387. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74388. /**
  74389. * Affect a material to the given mesh
  74390. * @param mesh defines the mesh which will represent the control
  74391. */
  74392. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74393. /** @hidden */
  74394. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74395. /** @hidden */
  74396. _onPointerEnter(target: Control3D): boolean;
  74397. /** @hidden */
  74398. _onPointerOut(target: Control3D): void;
  74399. /** @hidden */
  74400. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74401. /** @hidden */
  74402. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74403. /** @hidden */
  74404. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74405. /** @hidden */
  74406. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74407. /** @hidden */
  74408. _disposeNode(): void;
  74409. /**
  74410. * Releases all associated resources
  74411. */
  74412. dispose(): void;
  74413. }
  74414. }
  74415. declare module BABYLON.GUI {
  74416. /**
  74417. * Class used as a root to all buttons
  74418. */
  74419. export class AbstractButton3D extends Control3D {
  74420. /**
  74421. * Creates a new button
  74422. * @param name defines the control name
  74423. */
  74424. constructor(name?: string);
  74425. protected _getTypeName(): string;
  74426. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74427. }
  74428. }
  74429. declare module BABYLON.GUI {
  74430. /**
  74431. * Class used to create a button in 3D
  74432. */
  74433. export class Button3D extends AbstractButton3D {
  74434. /** @hidden */
  74435. protected _currentMaterial: BABYLON.Material;
  74436. private _facadeTexture;
  74437. private _content;
  74438. private _contentResolution;
  74439. private _contentScaleRatio;
  74440. /**
  74441. * Gets or sets the texture resolution used to render content (512 by default)
  74442. */
  74443. get contentResolution(): BABYLON.int;
  74444. set contentResolution(value: BABYLON.int);
  74445. /**
  74446. * Gets or sets the texture scale ratio used to render content (2 by default)
  74447. */
  74448. get contentScaleRatio(): number;
  74449. set contentScaleRatio(value: number);
  74450. protected _disposeFacadeTexture(): void;
  74451. protected _resetContent(): void;
  74452. /**
  74453. * Creates a new button
  74454. * @param name defines the control name
  74455. */
  74456. constructor(name?: string);
  74457. /**
  74458. * Gets or sets the GUI 2D content used to display the button's facade
  74459. */
  74460. get content(): Control;
  74461. set content(value: Control);
  74462. /**
  74463. * Apply the facade texture (created from the content property).
  74464. * This function can be overloaded by child classes
  74465. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74466. */
  74467. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74468. protected _getTypeName(): string;
  74469. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74470. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74471. /**
  74472. * Releases all associated resources
  74473. */
  74474. dispose(): void;
  74475. }
  74476. }
  74477. declare module BABYLON.GUI {
  74478. /**
  74479. * Abstract class used to create a container panel deployed on the surface of a volume
  74480. */
  74481. export abstract class VolumeBasedPanel extends Container3D {
  74482. private _columns;
  74483. private _rows;
  74484. private _rowThenColum;
  74485. private _orientation;
  74486. protected _cellWidth: number;
  74487. protected _cellHeight: number;
  74488. /**
  74489. * Gets or sets the distance between elements
  74490. */
  74491. margin: number;
  74492. /**
  74493. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74494. * | Value | Type | Description |
  74495. * | ----- | ----------------------------------- | ----------- |
  74496. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74497. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74498. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74499. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74500. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74501. */
  74502. get orientation(): number;
  74503. set orientation(value: number);
  74504. /**
  74505. * Gets or sets the number of columns requested (10 by default).
  74506. * The panel will automatically compute the number of rows based on number of child controls.
  74507. */
  74508. get columns(): BABYLON.int;
  74509. set columns(value: BABYLON.int);
  74510. /**
  74511. * Gets or sets a the number of rows requested.
  74512. * The panel will automatically compute the number of columns based on number of child controls.
  74513. */
  74514. get rows(): BABYLON.int;
  74515. set rows(value: BABYLON.int);
  74516. /**
  74517. * Creates new VolumeBasedPanel
  74518. */
  74519. constructor();
  74520. protected _arrangeChildren(): void;
  74521. /** Child classes must implement this function to provide correct control positioning */
  74522. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74523. /** Child classes can implement this function to provide additional processing */
  74524. protected _finalProcessing(): void;
  74525. }
  74526. }
  74527. declare module BABYLON.GUI {
  74528. /**
  74529. * Class used to create a container panel deployed on the surface of a cylinder
  74530. */
  74531. export class CylinderPanel extends VolumeBasedPanel {
  74532. private _radius;
  74533. /**
  74534. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74535. */
  74536. get radius(): BABYLON.float;
  74537. set radius(value: BABYLON.float);
  74538. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74539. private _cylindricalMapping;
  74540. }
  74541. }
  74542. declare module BABYLON.GUI {
  74543. /** @hidden */
  74544. export var fluentVertexShader: {
  74545. name: string;
  74546. shader: string;
  74547. };
  74548. }
  74549. declare module BABYLON.GUI {
  74550. /** @hidden */
  74551. export var fluentPixelShader: {
  74552. name: string;
  74553. shader: string;
  74554. };
  74555. }
  74556. declare module BABYLON.GUI {
  74557. /** @hidden */
  74558. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74559. INNERGLOW: boolean;
  74560. BORDER: boolean;
  74561. HOVERLIGHT: boolean;
  74562. TEXTURE: boolean;
  74563. constructor();
  74564. }
  74565. /**
  74566. * Class used to render controls with fluent desgin
  74567. */
  74568. export class FluentMaterial extends BABYLON.PushMaterial {
  74569. /**
  74570. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74571. */
  74572. innerGlowColorIntensity: number;
  74573. /**
  74574. * Gets or sets the inner glow color (white by default)
  74575. */
  74576. innerGlowColor: BABYLON.Color3;
  74577. /**
  74578. * Gets or sets alpha value (default is 1.0)
  74579. */
  74580. alpha: number;
  74581. /**
  74582. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74583. */
  74584. albedoColor: BABYLON.Color3;
  74585. /**
  74586. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74587. */
  74588. renderBorders: boolean;
  74589. /**
  74590. * Gets or sets border width (default is 0.5)
  74591. */
  74592. borderWidth: number;
  74593. /**
  74594. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74595. */
  74596. edgeSmoothingValue: number;
  74597. /**
  74598. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74599. */
  74600. borderMinValue: number;
  74601. /**
  74602. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74603. */
  74604. renderHoverLight: boolean;
  74605. /**
  74606. * Gets or sets the radius used to render the hover light (default is 1.0)
  74607. */
  74608. hoverRadius: number;
  74609. /**
  74610. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74611. */
  74612. hoverColor: BABYLON.Color4;
  74613. /**
  74614. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74615. */
  74616. hoverPosition: BABYLON.Vector3;
  74617. private _albedoTexture;
  74618. /** Gets or sets the texture to use for albedo color */
  74619. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74620. /**
  74621. * Creates a new Fluent material
  74622. * @param name defines the name of the material
  74623. * @param scene defines the hosting scene
  74624. */
  74625. constructor(name: string, scene: BABYLON.Scene);
  74626. needAlphaBlending(): boolean;
  74627. needAlphaTesting(): boolean;
  74628. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74629. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74630. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74631. getActiveTextures(): BABYLON.BaseTexture[];
  74632. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74633. dispose(forceDisposeEffect?: boolean): void;
  74634. clone(name: string): FluentMaterial;
  74635. serialize(): any;
  74636. getClassName(): string;
  74637. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74638. }
  74639. }
  74640. declare module BABYLON.GUI {
  74641. /**
  74642. * Class used to create a holographic button in 3D
  74643. */
  74644. export class HolographicButton extends Button3D {
  74645. private _backPlate;
  74646. private _textPlate;
  74647. private _frontPlate;
  74648. private _text;
  74649. private _imageUrl;
  74650. private _shareMaterials;
  74651. private _frontMaterial;
  74652. private _backMaterial;
  74653. private _plateMaterial;
  74654. private _pickedPointObserver;
  74655. private _tooltipFade;
  74656. private _tooltipTextBlock;
  74657. private _tooltipTexture;
  74658. private _tooltipMesh;
  74659. private _tooltipHoverObserver;
  74660. private _tooltipOutObserver;
  74661. private _disposeTooltip;
  74662. /**
  74663. * Rendering ground id of all the mesh in the button
  74664. */
  74665. set renderingGroupId(id: number);
  74666. get renderingGroupId(): number;
  74667. /**
  74668. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74669. */
  74670. set tooltipText(text: BABYLON.Nullable<string>);
  74671. get tooltipText(): BABYLON.Nullable<string>;
  74672. /**
  74673. * Gets or sets text for the button
  74674. */
  74675. get text(): string;
  74676. set text(value: string);
  74677. /**
  74678. * Gets or sets the image url for the button
  74679. */
  74680. get imageUrl(): string;
  74681. set imageUrl(value: string);
  74682. /**
  74683. * Gets the back material used by this button
  74684. */
  74685. get backMaterial(): FluentMaterial;
  74686. /**
  74687. * Gets the front material used by this button
  74688. */
  74689. get frontMaterial(): FluentMaterial;
  74690. /**
  74691. * Gets the plate material used by this button
  74692. */
  74693. get plateMaterial(): BABYLON.StandardMaterial;
  74694. /**
  74695. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74696. */
  74697. get shareMaterials(): boolean;
  74698. /**
  74699. * Creates a new button
  74700. * @param name defines the control name
  74701. */
  74702. constructor(name?: string, shareMaterials?: boolean);
  74703. protected _getTypeName(): string;
  74704. private _rebuildContent;
  74705. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74706. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74707. private _createBackMaterial;
  74708. private _createFrontMaterial;
  74709. private _createPlateMaterial;
  74710. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74711. /**
  74712. * Releases all associated resources
  74713. */
  74714. dispose(): void;
  74715. }
  74716. }
  74717. declare module BABYLON.GUI {
  74718. /**
  74719. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74720. */
  74721. export class MeshButton3D extends Button3D {
  74722. /** @hidden */
  74723. protected _currentMesh: BABYLON.Mesh;
  74724. /**
  74725. * Creates a new 3D button based on a mesh
  74726. * @param mesh mesh to become a 3D button
  74727. * @param name defines the control name
  74728. */
  74729. constructor(mesh: BABYLON.Mesh, name?: string);
  74730. protected _getTypeName(): string;
  74731. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74732. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74733. }
  74734. }
  74735. declare module BABYLON.GUI {
  74736. /**
  74737. * Class used to create a container panel deployed on the surface of a plane
  74738. */
  74739. export class PlanePanel extends VolumeBasedPanel {
  74740. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74741. }
  74742. }
  74743. declare module BABYLON.GUI {
  74744. /**
  74745. * Class used to create a container panel where items get randomized planar mapping
  74746. */
  74747. export class ScatterPanel extends VolumeBasedPanel {
  74748. private _iteration;
  74749. /**
  74750. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74751. */
  74752. get iteration(): BABYLON.float;
  74753. set iteration(value: BABYLON.float);
  74754. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74755. private _scatterMapping;
  74756. protected _finalProcessing(): void;
  74757. }
  74758. }
  74759. declare module BABYLON.GUI {
  74760. /**
  74761. * Class used to create a container panel deployed on the surface of a sphere
  74762. */
  74763. export class SpherePanel extends VolumeBasedPanel {
  74764. private _radius;
  74765. /**
  74766. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74767. */
  74768. get radius(): BABYLON.float;
  74769. set radius(value: BABYLON.float);
  74770. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74771. private _sphericalMapping;
  74772. }
  74773. }
  74774. declare module BABYLON.GUI {
  74775. /**
  74776. * Class used to create a stack panel in 3D on XY plane
  74777. */
  74778. export class StackPanel3D extends Container3D {
  74779. private _isVertical;
  74780. /**
  74781. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74782. */
  74783. get isVertical(): boolean;
  74784. set isVertical(value: boolean);
  74785. /**
  74786. * Gets or sets the distance between elements
  74787. */
  74788. margin: number;
  74789. /**
  74790. * Creates new StackPanel
  74791. * @param isVertical
  74792. */
  74793. constructor(isVertical?: boolean);
  74794. protected _arrangeChildren(): void;
  74795. }
  74796. }
  74797. declare module BABYLON {
  74798. /**
  74799. * Configuration for glTF validation
  74800. */
  74801. export interface IGLTFValidationConfiguration {
  74802. /**
  74803. * The url of the glTF validator.
  74804. */
  74805. url: string;
  74806. }
  74807. /**
  74808. * glTF validation
  74809. */
  74810. export class GLTFValidation {
  74811. /**
  74812. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74813. */
  74814. static Configuration: IGLTFValidationConfiguration;
  74815. private static _LoadScriptPromise;
  74816. /**
  74817. * Validate a glTF asset using the glTF-Validator.
  74818. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74819. * @param rootUrl The root url for the glTF
  74820. * @param fileName The file name for the glTF
  74821. * @param getExternalResource The callback to get external resources for the glTF validator
  74822. * @returns A promise that resolves with the glTF validation results once complete
  74823. */
  74824. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74825. }
  74826. }
  74827. declare module BABYLON {
  74828. /**
  74829. * Mode that determines the coordinate system to use.
  74830. */
  74831. export enum GLTFLoaderCoordinateSystemMode {
  74832. /**
  74833. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74834. */
  74835. AUTO = 0,
  74836. /**
  74837. * Sets the useRightHandedSystem flag on the scene.
  74838. */
  74839. FORCE_RIGHT_HANDED = 1
  74840. }
  74841. /**
  74842. * Mode that determines what animations will start.
  74843. */
  74844. export enum GLTFLoaderAnimationStartMode {
  74845. /**
  74846. * No animation will start.
  74847. */
  74848. NONE = 0,
  74849. /**
  74850. * The first animation will start.
  74851. */
  74852. FIRST = 1,
  74853. /**
  74854. * All animations will start.
  74855. */
  74856. ALL = 2
  74857. }
  74858. /**
  74859. * Interface that contains the data for the glTF asset.
  74860. */
  74861. export interface IGLTFLoaderData {
  74862. /**
  74863. * The object that represents the glTF JSON.
  74864. */
  74865. json: Object;
  74866. /**
  74867. * The BIN chunk of a binary glTF.
  74868. */
  74869. bin: Nullable<IDataBuffer>;
  74870. }
  74871. /**
  74872. * Interface for extending the loader.
  74873. */
  74874. export interface IGLTFLoaderExtension {
  74875. /**
  74876. * The name of this extension.
  74877. */
  74878. readonly name: string;
  74879. /**
  74880. * Defines whether this extension is enabled.
  74881. */
  74882. enabled: boolean;
  74883. /**
  74884. * Defines the order of this extension.
  74885. * The loader sorts the extensions using these values when loading.
  74886. */
  74887. order?: number;
  74888. }
  74889. /**
  74890. * Loader state.
  74891. */
  74892. export enum GLTFLoaderState {
  74893. /**
  74894. * The asset is loading.
  74895. */
  74896. LOADING = 0,
  74897. /**
  74898. * The asset is ready for rendering.
  74899. */
  74900. READY = 1,
  74901. /**
  74902. * The asset is completely loaded.
  74903. */
  74904. COMPLETE = 2
  74905. }
  74906. /** @hidden */
  74907. export interface IImportMeshAsyncOutput {
  74908. meshes: AbstractMesh[];
  74909. particleSystems: IParticleSystem[];
  74910. skeletons: Skeleton[];
  74911. animationGroups: AnimationGroup[];
  74912. lights: Light[];
  74913. transformNodes: TransformNode[];
  74914. }
  74915. /** @hidden */
  74916. export interface IGLTFLoader extends IDisposable {
  74917. readonly state: Nullable<GLTFLoaderState>;
  74918. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74919. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74920. }
  74921. /**
  74922. * File loader for loading glTF files into a scene.
  74923. */
  74924. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74925. /** @hidden */
  74926. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74927. /** @hidden */
  74928. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74929. /**
  74930. * Raised when the asset has been parsed
  74931. */
  74932. onParsedObservable: Observable<IGLTFLoaderData>;
  74933. private _onParsedObserver;
  74934. /**
  74935. * Raised when the asset has been parsed
  74936. */
  74937. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74938. /**
  74939. * 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.
  74940. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74941. * Defaults to true.
  74942. * @hidden
  74943. */
  74944. static IncrementalLoading: boolean;
  74945. /**
  74946. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74947. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74948. * @hidden
  74949. */
  74950. static HomogeneousCoordinates: boolean;
  74951. /**
  74952. * The coordinate system mode. Defaults to AUTO.
  74953. */
  74954. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74955. /**
  74956. * The animation start mode. Defaults to FIRST.
  74957. */
  74958. animationStartMode: GLTFLoaderAnimationStartMode;
  74959. /**
  74960. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74961. */
  74962. compileMaterials: boolean;
  74963. /**
  74964. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74965. */
  74966. useClipPlane: boolean;
  74967. /**
  74968. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74969. */
  74970. compileShadowGenerators: boolean;
  74971. /**
  74972. * Defines if the Alpha blended materials are only applied as coverage.
  74973. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74974. * If true, no extra effects are applied to transparent pixels.
  74975. */
  74976. transparencyAsCoverage: boolean;
  74977. /**
  74978. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74979. * Enabling will disable offline support and glTF validator.
  74980. * Defaults to false.
  74981. */
  74982. useRangeRequests: boolean;
  74983. /**
  74984. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74985. */
  74986. createInstances: boolean;
  74987. /**
  74988. * Function called before loading a url referenced by the asset.
  74989. */
  74990. preprocessUrlAsync: (url: string) => Promise<string>;
  74991. /**
  74992. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74993. */
  74994. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74995. private _onMeshLoadedObserver;
  74996. /**
  74997. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74998. */
  74999. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75000. /**
  75001. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75002. */
  75003. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75004. private _onTextureLoadedObserver;
  75005. /**
  75006. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75007. */
  75008. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75009. /**
  75010. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75011. */
  75012. readonly onMaterialLoadedObservable: Observable<Material>;
  75013. private _onMaterialLoadedObserver;
  75014. /**
  75015. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75016. */
  75017. set onMaterialLoaded(callback: (material: Material) => void);
  75018. /**
  75019. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75020. */
  75021. readonly onCameraLoadedObservable: Observable<Camera>;
  75022. private _onCameraLoadedObserver;
  75023. /**
  75024. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75025. */
  75026. set onCameraLoaded(callback: (camera: Camera) => void);
  75027. /**
  75028. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75029. * For assets with LODs, raised when all of the LODs are complete.
  75030. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75031. */
  75032. readonly onCompleteObservable: Observable<void>;
  75033. private _onCompleteObserver;
  75034. /**
  75035. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75036. * For assets with LODs, raised when all of the LODs are complete.
  75037. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75038. */
  75039. set onComplete(callback: () => void);
  75040. /**
  75041. * Observable raised when an error occurs.
  75042. */
  75043. readonly onErrorObservable: Observable<any>;
  75044. private _onErrorObserver;
  75045. /**
  75046. * Callback raised when an error occurs.
  75047. */
  75048. set onError(callback: (reason: any) => void);
  75049. /**
  75050. * Observable raised after the loader is disposed.
  75051. */
  75052. readonly onDisposeObservable: Observable<void>;
  75053. private _onDisposeObserver;
  75054. /**
  75055. * Callback raised after the loader is disposed.
  75056. */
  75057. set onDispose(callback: () => void);
  75058. /**
  75059. * Observable raised after a loader extension is created.
  75060. * Set additional options for a loader extension in this event.
  75061. */
  75062. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75063. private _onExtensionLoadedObserver;
  75064. /**
  75065. * Callback raised after a loader extension is created.
  75066. */
  75067. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75068. /**
  75069. * Defines if the loader logging is enabled.
  75070. */
  75071. get loggingEnabled(): boolean;
  75072. set loggingEnabled(value: boolean);
  75073. /**
  75074. * Defines if the loader should capture performance counters.
  75075. */
  75076. get capturePerformanceCounters(): boolean;
  75077. set capturePerformanceCounters(value: boolean);
  75078. /**
  75079. * Defines if the loader should validate the asset.
  75080. */
  75081. validate: boolean;
  75082. /**
  75083. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75084. */
  75085. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75086. private _onValidatedObserver;
  75087. /**
  75088. * Callback raised after a loader extension is created.
  75089. */
  75090. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75091. private _loader;
  75092. /**
  75093. * Name of the loader ("gltf")
  75094. */
  75095. name: string;
  75096. /** @hidden */
  75097. extensions: ISceneLoaderPluginExtensions;
  75098. /**
  75099. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75100. */
  75101. dispose(): void;
  75102. /** @hidden */
  75103. _clear(): void;
  75104. /** @hidden */
  75105. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75106. /** @hidden */
  75107. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75108. /** @hidden */
  75109. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75110. meshes: AbstractMesh[];
  75111. particleSystems: IParticleSystem[];
  75112. skeletons: Skeleton[];
  75113. animationGroups: AnimationGroup[];
  75114. }>;
  75115. /** @hidden */
  75116. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75117. /** @hidden */
  75118. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75119. /** @hidden */
  75120. canDirectLoad(data: string): boolean;
  75121. /** @hidden */
  75122. directLoad(scene: Scene, data: string): any;
  75123. /**
  75124. * The callback that allows custom handling of the root url based on the response url.
  75125. * @param rootUrl the original root url
  75126. * @param responseURL the response url if available
  75127. * @returns the new root url
  75128. */
  75129. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75130. /** @hidden */
  75131. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75132. /**
  75133. * The loader state or null if the loader is not active.
  75134. */
  75135. get loaderState(): Nullable<GLTFLoaderState>;
  75136. /**
  75137. * Returns a promise that resolves when the asset is completely loaded.
  75138. * @returns a promise that resolves when the asset is completely loaded.
  75139. */
  75140. whenCompleteAsync(): Promise<void>;
  75141. private _validate;
  75142. private _getLoader;
  75143. private _parseJson;
  75144. private _unpackBinaryAsync;
  75145. private _unpackBinaryV1Async;
  75146. private _unpackBinaryV2Async;
  75147. private static _parseVersion;
  75148. private static _compareVersion;
  75149. private static readonly _logSpaces;
  75150. private _logIndentLevel;
  75151. private _loggingEnabled;
  75152. /** @hidden */
  75153. _log: (message: string) => void;
  75154. /** @hidden */
  75155. _logOpen(message: string): void;
  75156. /** @hidden */
  75157. _logClose(): void;
  75158. private _logEnabled;
  75159. private _logDisabled;
  75160. private _capturePerformanceCounters;
  75161. /** @hidden */
  75162. _startPerformanceCounter: (counterName: string) => void;
  75163. /** @hidden */
  75164. _endPerformanceCounter: (counterName: string) => void;
  75165. private _startPerformanceCounterEnabled;
  75166. private _startPerformanceCounterDisabled;
  75167. private _endPerformanceCounterEnabled;
  75168. private _endPerformanceCounterDisabled;
  75169. }
  75170. }
  75171. declare module BABYLON.GLTF1 {
  75172. /**
  75173. * Enums
  75174. * @hidden
  75175. */
  75176. export enum EComponentType {
  75177. BYTE = 5120,
  75178. UNSIGNED_BYTE = 5121,
  75179. SHORT = 5122,
  75180. UNSIGNED_SHORT = 5123,
  75181. FLOAT = 5126
  75182. }
  75183. /** @hidden */
  75184. export enum EShaderType {
  75185. FRAGMENT = 35632,
  75186. VERTEX = 35633
  75187. }
  75188. /** @hidden */
  75189. export enum EParameterType {
  75190. BYTE = 5120,
  75191. UNSIGNED_BYTE = 5121,
  75192. SHORT = 5122,
  75193. UNSIGNED_SHORT = 5123,
  75194. INT = 5124,
  75195. UNSIGNED_INT = 5125,
  75196. FLOAT = 5126,
  75197. FLOAT_VEC2 = 35664,
  75198. FLOAT_VEC3 = 35665,
  75199. FLOAT_VEC4 = 35666,
  75200. INT_VEC2 = 35667,
  75201. INT_VEC3 = 35668,
  75202. INT_VEC4 = 35669,
  75203. BOOL = 35670,
  75204. BOOL_VEC2 = 35671,
  75205. BOOL_VEC3 = 35672,
  75206. BOOL_VEC4 = 35673,
  75207. FLOAT_MAT2 = 35674,
  75208. FLOAT_MAT3 = 35675,
  75209. FLOAT_MAT4 = 35676,
  75210. SAMPLER_2D = 35678
  75211. }
  75212. /** @hidden */
  75213. export enum ETextureWrapMode {
  75214. CLAMP_TO_EDGE = 33071,
  75215. MIRRORED_REPEAT = 33648,
  75216. REPEAT = 10497
  75217. }
  75218. /** @hidden */
  75219. export enum ETextureFilterType {
  75220. NEAREST = 9728,
  75221. LINEAR = 9728,
  75222. NEAREST_MIPMAP_NEAREST = 9984,
  75223. LINEAR_MIPMAP_NEAREST = 9985,
  75224. NEAREST_MIPMAP_LINEAR = 9986,
  75225. LINEAR_MIPMAP_LINEAR = 9987
  75226. }
  75227. /** @hidden */
  75228. export enum ETextureFormat {
  75229. ALPHA = 6406,
  75230. RGB = 6407,
  75231. RGBA = 6408,
  75232. LUMINANCE = 6409,
  75233. LUMINANCE_ALPHA = 6410
  75234. }
  75235. /** @hidden */
  75236. export enum ECullingType {
  75237. FRONT = 1028,
  75238. BACK = 1029,
  75239. FRONT_AND_BACK = 1032
  75240. }
  75241. /** @hidden */
  75242. export enum EBlendingFunction {
  75243. ZERO = 0,
  75244. ONE = 1,
  75245. SRC_COLOR = 768,
  75246. ONE_MINUS_SRC_COLOR = 769,
  75247. DST_COLOR = 774,
  75248. ONE_MINUS_DST_COLOR = 775,
  75249. SRC_ALPHA = 770,
  75250. ONE_MINUS_SRC_ALPHA = 771,
  75251. DST_ALPHA = 772,
  75252. ONE_MINUS_DST_ALPHA = 773,
  75253. CONSTANT_COLOR = 32769,
  75254. ONE_MINUS_CONSTANT_COLOR = 32770,
  75255. CONSTANT_ALPHA = 32771,
  75256. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75257. SRC_ALPHA_SATURATE = 776
  75258. }
  75259. /** @hidden */
  75260. export interface IGLTFProperty {
  75261. extensions?: {
  75262. [key: string]: any;
  75263. };
  75264. extras?: Object;
  75265. }
  75266. /** @hidden */
  75267. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75268. name?: string;
  75269. }
  75270. /** @hidden */
  75271. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75272. bufferView: string;
  75273. byteOffset: number;
  75274. byteStride: number;
  75275. count: number;
  75276. type: string;
  75277. componentType: EComponentType;
  75278. max?: number[];
  75279. min?: number[];
  75280. name?: string;
  75281. }
  75282. /** @hidden */
  75283. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75284. buffer: string;
  75285. byteOffset: number;
  75286. byteLength: number;
  75287. byteStride: number;
  75288. target?: number;
  75289. }
  75290. /** @hidden */
  75291. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75292. uri: string;
  75293. byteLength?: number;
  75294. type?: string;
  75295. }
  75296. /** @hidden */
  75297. export interface IGLTFShader extends IGLTFChildRootProperty {
  75298. uri: string;
  75299. type: EShaderType;
  75300. }
  75301. /** @hidden */
  75302. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75303. attributes: string[];
  75304. fragmentShader: string;
  75305. vertexShader: string;
  75306. }
  75307. /** @hidden */
  75308. export interface IGLTFTechniqueParameter {
  75309. type: number;
  75310. count?: number;
  75311. semantic?: string;
  75312. node?: string;
  75313. value?: number | boolean | string | Array<any>;
  75314. source?: string;
  75315. babylonValue?: any;
  75316. }
  75317. /** @hidden */
  75318. export interface IGLTFTechniqueCommonProfile {
  75319. lightingModel: string;
  75320. texcoordBindings: Object;
  75321. parameters?: Array<any>;
  75322. }
  75323. /** @hidden */
  75324. export interface IGLTFTechniqueStatesFunctions {
  75325. blendColor?: number[];
  75326. blendEquationSeparate?: number[];
  75327. blendFuncSeparate?: number[];
  75328. colorMask: boolean[];
  75329. cullFace: number[];
  75330. }
  75331. /** @hidden */
  75332. export interface IGLTFTechniqueStates {
  75333. enable: number[];
  75334. functions: IGLTFTechniqueStatesFunctions;
  75335. }
  75336. /** @hidden */
  75337. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75338. parameters: {
  75339. [key: string]: IGLTFTechniqueParameter;
  75340. };
  75341. program: string;
  75342. attributes: {
  75343. [key: string]: string;
  75344. };
  75345. uniforms: {
  75346. [key: string]: string;
  75347. };
  75348. states: IGLTFTechniqueStates;
  75349. }
  75350. /** @hidden */
  75351. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75352. technique?: string;
  75353. values: string[];
  75354. }
  75355. /** @hidden */
  75356. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75357. attributes: {
  75358. [key: string]: string;
  75359. };
  75360. indices: string;
  75361. material: string;
  75362. mode?: number;
  75363. }
  75364. /** @hidden */
  75365. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75366. primitives: IGLTFMeshPrimitive[];
  75367. }
  75368. /** @hidden */
  75369. export interface IGLTFImage extends IGLTFChildRootProperty {
  75370. uri: string;
  75371. }
  75372. /** @hidden */
  75373. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75374. magFilter?: number;
  75375. minFilter?: number;
  75376. wrapS?: number;
  75377. wrapT?: number;
  75378. }
  75379. /** @hidden */
  75380. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75381. sampler: string;
  75382. source: string;
  75383. format?: ETextureFormat;
  75384. internalFormat?: ETextureFormat;
  75385. target?: number;
  75386. type?: number;
  75387. babylonTexture?: Texture;
  75388. }
  75389. /** @hidden */
  75390. export interface IGLTFAmbienLight {
  75391. color?: number[];
  75392. }
  75393. /** @hidden */
  75394. export interface IGLTFDirectionalLight {
  75395. color?: number[];
  75396. }
  75397. /** @hidden */
  75398. export interface IGLTFPointLight {
  75399. color?: number[];
  75400. constantAttenuation?: number;
  75401. linearAttenuation?: number;
  75402. quadraticAttenuation?: number;
  75403. }
  75404. /** @hidden */
  75405. export interface IGLTFSpotLight {
  75406. color?: number[];
  75407. constantAttenuation?: number;
  75408. fallOfAngle?: number;
  75409. fallOffExponent?: number;
  75410. linearAttenuation?: number;
  75411. quadraticAttenuation?: number;
  75412. }
  75413. /** @hidden */
  75414. export interface IGLTFLight extends IGLTFChildRootProperty {
  75415. type: string;
  75416. }
  75417. /** @hidden */
  75418. export interface IGLTFCameraOrthographic {
  75419. xmag: number;
  75420. ymag: number;
  75421. zfar: number;
  75422. znear: number;
  75423. }
  75424. /** @hidden */
  75425. export interface IGLTFCameraPerspective {
  75426. aspectRatio: number;
  75427. yfov: number;
  75428. zfar: number;
  75429. znear: number;
  75430. }
  75431. /** @hidden */
  75432. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75433. type: string;
  75434. }
  75435. /** @hidden */
  75436. export interface IGLTFAnimationChannelTarget {
  75437. id: string;
  75438. path: string;
  75439. }
  75440. /** @hidden */
  75441. export interface IGLTFAnimationChannel {
  75442. sampler: string;
  75443. target: IGLTFAnimationChannelTarget;
  75444. }
  75445. /** @hidden */
  75446. export interface IGLTFAnimationSampler {
  75447. input: string;
  75448. output: string;
  75449. interpolation?: string;
  75450. }
  75451. /** @hidden */
  75452. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75453. channels?: IGLTFAnimationChannel[];
  75454. parameters?: {
  75455. [key: string]: string;
  75456. };
  75457. samplers?: {
  75458. [key: string]: IGLTFAnimationSampler;
  75459. };
  75460. }
  75461. /** @hidden */
  75462. export interface IGLTFNodeInstanceSkin {
  75463. skeletons: string[];
  75464. skin: string;
  75465. meshes: string[];
  75466. }
  75467. /** @hidden */
  75468. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75469. bindShapeMatrix: number[];
  75470. inverseBindMatrices: string;
  75471. jointNames: string[];
  75472. babylonSkeleton?: Skeleton;
  75473. }
  75474. /** @hidden */
  75475. export interface IGLTFNode extends IGLTFChildRootProperty {
  75476. camera?: string;
  75477. children: string[];
  75478. skin?: string;
  75479. jointName?: string;
  75480. light?: string;
  75481. matrix: number[];
  75482. mesh?: string;
  75483. meshes?: string[];
  75484. rotation?: number[];
  75485. scale?: number[];
  75486. translation?: number[];
  75487. babylonNode?: Node;
  75488. }
  75489. /** @hidden */
  75490. export interface IGLTFScene extends IGLTFChildRootProperty {
  75491. nodes: string[];
  75492. }
  75493. /** @hidden */
  75494. export interface IGLTFRuntime {
  75495. extensions: {
  75496. [key: string]: any;
  75497. };
  75498. accessors: {
  75499. [key: string]: IGLTFAccessor;
  75500. };
  75501. buffers: {
  75502. [key: string]: IGLTFBuffer;
  75503. };
  75504. bufferViews: {
  75505. [key: string]: IGLTFBufferView;
  75506. };
  75507. meshes: {
  75508. [key: string]: IGLTFMesh;
  75509. };
  75510. lights: {
  75511. [key: string]: IGLTFLight;
  75512. };
  75513. cameras: {
  75514. [key: string]: IGLTFCamera;
  75515. };
  75516. nodes: {
  75517. [key: string]: IGLTFNode;
  75518. };
  75519. images: {
  75520. [key: string]: IGLTFImage;
  75521. };
  75522. textures: {
  75523. [key: string]: IGLTFTexture;
  75524. };
  75525. shaders: {
  75526. [key: string]: IGLTFShader;
  75527. };
  75528. programs: {
  75529. [key: string]: IGLTFProgram;
  75530. };
  75531. samplers: {
  75532. [key: string]: IGLTFSampler;
  75533. };
  75534. techniques: {
  75535. [key: string]: IGLTFTechnique;
  75536. };
  75537. materials: {
  75538. [key: string]: IGLTFMaterial;
  75539. };
  75540. animations: {
  75541. [key: string]: IGLTFAnimation;
  75542. };
  75543. skins: {
  75544. [key: string]: IGLTFSkins;
  75545. };
  75546. currentScene?: Object;
  75547. scenes: {
  75548. [key: string]: IGLTFScene;
  75549. };
  75550. extensionsUsed: string[];
  75551. extensionsRequired?: string[];
  75552. buffersCount: number;
  75553. shaderscount: number;
  75554. scene: Scene;
  75555. rootUrl: string;
  75556. loadedBufferCount: number;
  75557. loadedBufferViews: {
  75558. [name: string]: ArrayBufferView;
  75559. };
  75560. loadedShaderCount: number;
  75561. importOnlyMeshes: boolean;
  75562. importMeshesNames?: string[];
  75563. dummyNodes: Node[];
  75564. forAssetContainer: boolean;
  75565. }
  75566. /** @hidden */
  75567. export interface INodeToRoot {
  75568. bone: Bone;
  75569. node: IGLTFNode;
  75570. id: string;
  75571. }
  75572. /** @hidden */
  75573. export interface IJointNode {
  75574. node: IGLTFNode;
  75575. id: string;
  75576. }
  75577. }
  75578. declare module BABYLON.GLTF1 {
  75579. /**
  75580. * Utils functions for GLTF
  75581. * @hidden
  75582. */
  75583. export class GLTFUtils {
  75584. /**
  75585. * Sets the given "parameter" matrix
  75586. * @param scene: the Scene object
  75587. * @param source: the source node where to pick the matrix
  75588. * @param parameter: the GLTF technique parameter
  75589. * @param uniformName: the name of the shader's uniform
  75590. * @param shaderMaterial: the shader material
  75591. */
  75592. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75593. /**
  75594. * Sets the given "parameter" matrix
  75595. * @param shaderMaterial: the shader material
  75596. * @param uniform: the name of the shader's uniform
  75597. * @param value: the value of the uniform
  75598. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75599. */
  75600. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75601. /**
  75602. * Returns the wrap mode of the texture
  75603. * @param mode: the mode value
  75604. */
  75605. static GetWrapMode(mode: number): number;
  75606. /**
  75607. * Returns the byte stride giving an accessor
  75608. * @param accessor: the GLTF accessor objet
  75609. */
  75610. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75611. /**
  75612. * Returns the texture filter mode giving a mode value
  75613. * @param mode: the filter mode value
  75614. */
  75615. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75616. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75617. /**
  75618. * Returns a buffer from its accessor
  75619. * @param gltfRuntime: the GLTF runtime
  75620. * @param accessor: the GLTF accessor
  75621. */
  75622. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75623. /**
  75624. * Decodes a buffer view into a string
  75625. * @param view: the buffer view
  75626. */
  75627. static DecodeBufferToText(view: ArrayBufferView): string;
  75628. /**
  75629. * Returns the default material of gltf. Related to
  75630. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75631. * @param scene: the Babylon.js scene
  75632. */
  75633. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75634. private static _DefaultMaterial;
  75635. }
  75636. }
  75637. declare module BABYLON.GLTF1 {
  75638. /**
  75639. * Implementation of the base glTF spec
  75640. * @hidden
  75641. */
  75642. export class GLTFLoaderBase {
  75643. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75644. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75645. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75646. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75647. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75648. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75649. }
  75650. /**
  75651. * glTF V1 Loader
  75652. * @hidden
  75653. */
  75654. export class GLTFLoader implements IGLTFLoader {
  75655. static Extensions: {
  75656. [name: string]: GLTFLoaderExtension;
  75657. };
  75658. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75659. state: Nullable<GLTFLoaderState>;
  75660. dispose(): void;
  75661. private _importMeshAsync;
  75662. /**
  75663. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75664. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75665. * @param scene the scene the meshes should be added to
  75666. * @param forAssetContainer defines if the entities must be stored in the scene
  75667. * @param data gltf data containing information of the meshes in a loaded file
  75668. * @param rootUrl root url to load from
  75669. * @param onProgress event that fires when loading progress has occured
  75670. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75671. */
  75672. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75673. private _loadAsync;
  75674. /**
  75675. * Imports all objects from a loaded gltf file and adds them to the scene
  75676. * @param scene the scene the objects should be added to
  75677. * @param data gltf data containing information of the meshes in a loaded file
  75678. * @param rootUrl root url to load from
  75679. * @param onProgress event that fires when loading progress has occured
  75680. * @returns a promise which completes when objects have been loaded to the scene
  75681. */
  75682. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75683. private _loadShadersAsync;
  75684. private _loadBuffersAsync;
  75685. private _createNodes;
  75686. }
  75687. /** @hidden */
  75688. export abstract class GLTFLoaderExtension {
  75689. private _name;
  75690. constructor(name: string);
  75691. get name(): string;
  75692. /**
  75693. * Defines an override for loading the runtime
  75694. * Return true to stop further extensions from loading the runtime
  75695. */
  75696. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75697. /**
  75698. * Defines an onverride for creating gltf runtime
  75699. * Return true to stop further extensions from creating the runtime
  75700. */
  75701. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75702. /**
  75703. * Defines an override for loading buffers
  75704. * Return true to stop further extensions from loading this buffer
  75705. */
  75706. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75707. /**
  75708. * Defines an override for loading texture buffers
  75709. * Return true to stop further extensions from loading this texture data
  75710. */
  75711. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75712. /**
  75713. * Defines an override for creating textures
  75714. * Return true to stop further extensions from loading this texture
  75715. */
  75716. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75717. /**
  75718. * Defines an override for loading shader strings
  75719. * Return true to stop further extensions from loading this shader data
  75720. */
  75721. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75722. /**
  75723. * Defines an override for loading materials
  75724. * Return true to stop further extensions from loading this material
  75725. */
  75726. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75727. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75728. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75729. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75730. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75731. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75732. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75733. private static LoadTextureBufferAsync;
  75734. private static CreateTextureAsync;
  75735. private static ApplyExtensions;
  75736. }
  75737. }
  75738. declare module BABYLON.GLTF1 {
  75739. /** @hidden */
  75740. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75741. private _bin;
  75742. constructor();
  75743. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75744. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75745. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75746. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75747. }
  75748. }
  75749. declare module BABYLON.GLTF1 {
  75750. /** @hidden */
  75751. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75752. constructor();
  75753. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75754. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75755. private _loadTexture;
  75756. }
  75757. }
  75758. declare module BABYLON.GLTF2.Loader {
  75759. /**
  75760. * Loader interface with an index field.
  75761. */
  75762. export interface IArrayItem {
  75763. /**
  75764. * The index of this item in the array.
  75765. */
  75766. index: number;
  75767. }
  75768. /**
  75769. * Loader interface with additional members.
  75770. */
  75771. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75772. /** @hidden */
  75773. _data?: Promise<ArrayBufferView>;
  75774. /** @hidden */
  75775. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75776. }
  75777. /**
  75778. * Loader interface with additional members.
  75779. */
  75780. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75781. }
  75782. /** @hidden */
  75783. export interface _IAnimationSamplerData {
  75784. input: Float32Array;
  75785. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75786. output: Float32Array;
  75787. }
  75788. /**
  75789. * Loader interface with additional members.
  75790. */
  75791. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75792. /** @hidden */
  75793. _data?: Promise<_IAnimationSamplerData>;
  75794. }
  75795. /**
  75796. * Loader interface with additional members.
  75797. */
  75798. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75799. channels: IAnimationChannel[];
  75800. samplers: IAnimationSampler[];
  75801. /** @hidden */
  75802. _babylonAnimationGroup?: AnimationGroup;
  75803. }
  75804. /**
  75805. * Loader interface with additional members.
  75806. */
  75807. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75808. /** @hidden */
  75809. _data?: Promise<ArrayBufferView>;
  75810. }
  75811. /**
  75812. * Loader interface with additional members.
  75813. */
  75814. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75815. /** @hidden */
  75816. _data?: Promise<ArrayBufferView>;
  75817. /** @hidden */
  75818. _babylonBuffer?: Promise<Buffer>;
  75819. }
  75820. /**
  75821. * Loader interface with additional members.
  75822. */
  75823. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75824. }
  75825. /**
  75826. * Loader interface with additional members.
  75827. */
  75828. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75829. /** @hidden */
  75830. _data?: Promise<ArrayBufferView>;
  75831. }
  75832. /**
  75833. * Loader interface with additional members.
  75834. */
  75835. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75836. }
  75837. /**
  75838. * Loader interface with additional members.
  75839. */
  75840. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75841. }
  75842. /**
  75843. * Loader interface with additional members.
  75844. */
  75845. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75846. baseColorTexture?: ITextureInfo;
  75847. metallicRoughnessTexture?: ITextureInfo;
  75848. }
  75849. /**
  75850. * Loader interface with additional members.
  75851. */
  75852. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75853. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75854. normalTexture?: IMaterialNormalTextureInfo;
  75855. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75856. emissiveTexture?: ITextureInfo;
  75857. /** @hidden */
  75858. _data?: {
  75859. [babylonDrawMode: number]: {
  75860. babylonMaterial: Material;
  75861. babylonMeshes: AbstractMesh[];
  75862. promise: Promise<void>;
  75863. };
  75864. };
  75865. }
  75866. /**
  75867. * Loader interface with additional members.
  75868. */
  75869. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75870. primitives: IMeshPrimitive[];
  75871. }
  75872. /**
  75873. * Loader interface with additional members.
  75874. */
  75875. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75876. /** @hidden */
  75877. _instanceData?: {
  75878. babylonSourceMesh: Mesh;
  75879. promise: Promise<any>;
  75880. };
  75881. }
  75882. /**
  75883. * Loader interface with additional members.
  75884. */
  75885. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75886. /**
  75887. * The parent glTF node.
  75888. */
  75889. parent?: INode;
  75890. /** @hidden */
  75891. _babylonTransformNode?: TransformNode;
  75892. /** @hidden */
  75893. _primitiveBabylonMeshes?: AbstractMesh[];
  75894. /** @hidden */
  75895. _babylonBones?: Bone[];
  75896. /** @hidden */
  75897. _numMorphTargets?: number;
  75898. }
  75899. /** @hidden */
  75900. export interface _ISamplerData {
  75901. noMipMaps: boolean;
  75902. samplingMode: number;
  75903. wrapU: number;
  75904. wrapV: number;
  75905. }
  75906. /**
  75907. * Loader interface with additional members.
  75908. */
  75909. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75910. /** @hidden */
  75911. _data?: _ISamplerData;
  75912. }
  75913. /**
  75914. * Loader interface with additional members.
  75915. */
  75916. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75917. }
  75918. /**
  75919. * Loader interface with additional members.
  75920. */
  75921. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75922. /** @hidden */
  75923. _data?: {
  75924. babylonSkeleton: Skeleton;
  75925. promise: Promise<void>;
  75926. };
  75927. }
  75928. /**
  75929. * Loader interface with additional members.
  75930. */
  75931. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75932. }
  75933. /**
  75934. * Loader interface with additional members.
  75935. */
  75936. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75937. }
  75938. /**
  75939. * Loader interface with additional members.
  75940. */
  75941. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75942. accessors?: IAccessor[];
  75943. animations?: IAnimation[];
  75944. buffers?: IBuffer[];
  75945. bufferViews?: IBufferView[];
  75946. cameras?: ICamera[];
  75947. images?: IImage[];
  75948. materials?: IMaterial[];
  75949. meshes?: IMesh[];
  75950. nodes?: INode[];
  75951. samplers?: ISampler[];
  75952. scenes?: IScene[];
  75953. skins?: ISkin[];
  75954. textures?: ITexture[];
  75955. }
  75956. }
  75957. declare module BABYLON.GLTF2 {
  75958. /**
  75959. * Interface for a glTF loader extension.
  75960. */
  75961. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75962. /**
  75963. * Called after the loader state changes to LOADING.
  75964. */
  75965. onLoading?(): void;
  75966. /**
  75967. * Called after the loader state changes to READY.
  75968. */
  75969. onReady?(): void;
  75970. /**
  75971. * Define this method to modify the default behavior when loading scenes.
  75972. * @param context The context when loading the asset
  75973. * @param scene The glTF scene property
  75974. * @returns A promise that resolves when the load is complete or null if not handled
  75975. */
  75976. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75977. /**
  75978. * Define this method to modify the default behavior when loading nodes.
  75979. * @param context The context when loading the asset
  75980. * @param node The glTF node property
  75981. * @param assign A function called synchronously after parsing the glTF properties
  75982. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75983. */
  75984. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75985. /**
  75986. * Define this method to modify the default behavior when loading cameras.
  75987. * @param context The context when loading the asset
  75988. * @param camera The glTF camera property
  75989. * @param assign A function called synchronously after parsing the glTF properties
  75990. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75991. */
  75992. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75993. /**
  75994. * @hidden
  75995. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75996. * @param context The context when loading the asset
  75997. * @param primitive The glTF mesh primitive property
  75998. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75999. */
  76000. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76001. /**
  76002. * @hidden
  76003. * Define this method to modify the default behavior when loading data for mesh primitives.
  76004. * @param context The context when loading the asset
  76005. * @param name The mesh name when loading the asset
  76006. * @param node The glTF node when loading the asset
  76007. * @param mesh The glTF mesh when loading the asset
  76008. * @param primitive The glTF mesh primitive property
  76009. * @param assign A function called synchronously after parsing the glTF properties
  76010. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76011. */
  76012. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76013. /**
  76014. * @hidden
  76015. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76016. * @param context The context when loading the asset
  76017. * @param material The glTF material property
  76018. * @param assign A function called synchronously after parsing the glTF properties
  76019. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76020. */
  76021. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76022. /**
  76023. * Define this method to modify the default behavior when creating materials.
  76024. * @param context The context when loading the asset
  76025. * @param material The glTF material property
  76026. * @param babylonDrawMode The draw mode for the Babylon material
  76027. * @returns The Babylon material or null if not handled
  76028. */
  76029. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76030. /**
  76031. * Define this method to modify the default behavior when loading material properties.
  76032. * @param context The context when loading the asset
  76033. * @param material The glTF material property
  76034. * @param babylonMaterial The Babylon material
  76035. * @returns A promise that resolves when the load is complete or null if not handled
  76036. */
  76037. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76038. /**
  76039. * Define this method to modify the default behavior when loading texture infos.
  76040. * @param context The context when loading the asset
  76041. * @param textureInfo The glTF texture info property
  76042. * @param assign A function called synchronously after parsing the glTF properties
  76043. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76044. */
  76045. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76046. /**
  76047. * @hidden
  76048. * Define this method to modify the default behavior when loading textures.
  76049. * @param context The context when loading the asset
  76050. * @param texture The glTF texture property
  76051. * @param assign A function called synchronously after parsing the glTF properties
  76052. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76053. */
  76054. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76055. /**
  76056. * Define this method to modify the default behavior when loading animations.
  76057. * @param context The context when loading the asset
  76058. * @param animation The glTF animation property
  76059. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76060. */
  76061. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76062. /**
  76063. * @hidden
  76064. * Define this method to modify the default behavior when loading skins.
  76065. * @param context The context when loading the asset
  76066. * @param node The glTF node property
  76067. * @param skin The glTF skin property
  76068. * @returns A promise that resolves when the load is complete or null if not handled
  76069. */
  76070. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76071. /**
  76072. * @hidden
  76073. * Define this method to modify the default behavior when loading uris.
  76074. * @param context The context when loading the asset
  76075. * @param property The glTF property associated with the uri
  76076. * @param uri The uri to load
  76077. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76078. */
  76079. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76080. /**
  76081. * Define this method to modify the default behavior when loading buffer views.
  76082. * @param context The context when loading the asset
  76083. * @param bufferView The glTF buffer view property
  76084. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76085. */
  76086. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76087. /**
  76088. * Define this method to modify the default behavior when loading buffers.
  76089. * @param context The context when loading the asset
  76090. * @param buffer The glTF buffer property
  76091. * @param byteOffset The byte offset to load
  76092. * @param byteLength The byte length to load
  76093. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76094. */
  76095. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76096. }
  76097. }
  76098. declare module BABYLON.GLTF2 {
  76099. /**
  76100. * Helper class for working with arrays when loading the glTF asset
  76101. */
  76102. export class ArrayItem {
  76103. /**
  76104. * Gets an item from the given array.
  76105. * @param context The context when loading the asset
  76106. * @param array The array to get the item from
  76107. * @param index The index to the array
  76108. * @returns The array item
  76109. */
  76110. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76111. /**
  76112. * Assign an `index` field to each item of the given array.
  76113. * @param array The array of items
  76114. */
  76115. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76116. }
  76117. /**
  76118. * The glTF 2.0 loader
  76119. */
  76120. export class GLTFLoader implements IGLTFLoader {
  76121. /** @hidden */
  76122. _completePromises: Promise<any>[];
  76123. /** @hidden */
  76124. _forAssetContainer: boolean;
  76125. /** Storage */
  76126. _babylonLights: Light[];
  76127. private _disposed;
  76128. private _parent;
  76129. private _state;
  76130. private _extensions;
  76131. private _rootUrl;
  76132. private _fileName;
  76133. private _uniqueRootUrl;
  76134. private _gltf;
  76135. private _bin;
  76136. private _babylonScene;
  76137. private _rootBabylonMesh;
  76138. private _defaultBabylonMaterialData;
  76139. private _progressCallback?;
  76140. private _requests;
  76141. private static _RegisteredExtensions;
  76142. /**
  76143. * The default glTF sampler.
  76144. */
  76145. static readonly DefaultSampler: ISampler;
  76146. /**
  76147. * Registers a loader extension.
  76148. * @param name The name of the loader extension.
  76149. * @param factory The factory function that creates the loader extension.
  76150. */
  76151. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76152. /**
  76153. * Unregisters a loader extension.
  76154. * @param name The name of the loader extension.
  76155. * @returns A boolean indicating whether the extension has been unregistered
  76156. */
  76157. static UnregisterExtension(name: string): boolean;
  76158. /**
  76159. * The loader state.
  76160. */
  76161. get state(): Nullable<GLTFLoaderState>;
  76162. /**
  76163. * The object that represents the glTF JSON.
  76164. */
  76165. get gltf(): IGLTF;
  76166. /**
  76167. * The BIN chunk of a binary glTF.
  76168. */
  76169. get bin(): Nullable<IDataBuffer>;
  76170. /**
  76171. * The parent file loader.
  76172. */
  76173. get parent(): GLTFFileLoader;
  76174. /**
  76175. * The Babylon scene when loading the asset.
  76176. */
  76177. get babylonScene(): Scene;
  76178. /**
  76179. * The root Babylon mesh when loading the asset.
  76180. */
  76181. get rootBabylonMesh(): Mesh;
  76182. /** @hidden */
  76183. constructor(parent: GLTFFileLoader);
  76184. /** @hidden */
  76185. dispose(): void;
  76186. /** @hidden */
  76187. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76188. /** @hidden */
  76189. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76190. private _loadAsync;
  76191. private _loadData;
  76192. private _setupData;
  76193. private _loadExtensions;
  76194. private _checkExtensions;
  76195. private _setState;
  76196. private _createRootNode;
  76197. /**
  76198. * Loads a glTF scene.
  76199. * @param context The context when loading the asset
  76200. * @param scene The glTF scene property
  76201. * @returns A promise that resolves when the load is complete
  76202. */
  76203. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76204. private _forEachPrimitive;
  76205. private _getMeshes;
  76206. private _getTransformNodes;
  76207. private _getSkeletons;
  76208. private _getAnimationGroups;
  76209. private _startAnimations;
  76210. /**
  76211. * Loads a glTF node.
  76212. * @param context The context when loading the asset
  76213. * @param node The glTF node property
  76214. * @param assign A function called synchronously after parsing the glTF properties
  76215. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76216. */
  76217. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76218. private _loadMeshAsync;
  76219. /**
  76220. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76221. * @param context The context when loading the asset
  76222. * @param name The mesh name when loading the asset
  76223. * @param node The glTF node when loading the asset
  76224. * @param mesh The glTF mesh when loading the asset
  76225. * @param primitive The glTF mesh primitive property
  76226. * @param assign A function called synchronously after parsing the glTF properties
  76227. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76228. */
  76229. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76230. private _loadVertexDataAsync;
  76231. private _createMorphTargets;
  76232. private _loadMorphTargetsAsync;
  76233. private _loadMorphTargetVertexDataAsync;
  76234. private static _LoadTransform;
  76235. private _loadSkinAsync;
  76236. private _loadBones;
  76237. private _loadBone;
  76238. private _loadSkinInverseBindMatricesDataAsync;
  76239. private _updateBoneMatrices;
  76240. private _getNodeMatrix;
  76241. /**
  76242. * Loads a glTF camera.
  76243. * @param context The context when loading the asset
  76244. * @param camera The glTF camera property
  76245. * @param assign A function called synchronously after parsing the glTF properties
  76246. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76247. */
  76248. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76249. private _loadAnimationsAsync;
  76250. /**
  76251. * Loads a glTF animation.
  76252. * @param context The context when loading the asset
  76253. * @param animation The glTF animation property
  76254. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76255. */
  76256. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76257. /**
  76258. * @hidden Loads a glTF animation channel.
  76259. * @param context The context when loading the asset
  76260. * @param animationContext The context of the animation when loading the asset
  76261. * @param animation The glTF animation property
  76262. * @param channel The glTF animation channel property
  76263. * @param babylonAnimationGroup The babylon animation group property
  76264. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76265. * @returns A void promise when the channel load is complete
  76266. */
  76267. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76268. private _loadAnimationSamplerAsync;
  76269. private _loadBufferAsync;
  76270. /**
  76271. * Loads a glTF buffer view.
  76272. * @param context The context when loading the asset
  76273. * @param bufferView The glTF buffer view property
  76274. * @returns A promise that resolves with the loaded data when the load is complete
  76275. */
  76276. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76277. private _loadAccessorAsync;
  76278. /** @hidden */
  76279. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76280. private _loadIndicesAccessorAsync;
  76281. private _loadVertexBufferViewAsync;
  76282. private _loadVertexAccessorAsync;
  76283. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76284. /** @hidden */
  76285. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76286. private _createDefaultMaterial;
  76287. /**
  76288. * Creates a Babylon material from a glTF material.
  76289. * @param context The context when loading the asset
  76290. * @param material The glTF material property
  76291. * @param babylonDrawMode The draw mode for the Babylon material
  76292. * @returns The Babylon material
  76293. */
  76294. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76295. /**
  76296. * Loads properties from a glTF material into a Babylon material.
  76297. * @param context The context when loading the asset
  76298. * @param material The glTF material property
  76299. * @param babylonMaterial The Babylon material
  76300. * @returns A promise that resolves when the load is complete
  76301. */
  76302. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76303. /**
  76304. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76305. * @param context The context when loading the asset
  76306. * @param material The glTF material property
  76307. * @param babylonMaterial The Babylon material
  76308. * @returns A promise that resolves when the load is complete
  76309. */
  76310. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76311. /**
  76312. * Loads the alpha properties from a glTF material into a Babylon material.
  76313. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76314. * @param context The context when loading the asset
  76315. * @param material The glTF material property
  76316. * @param babylonMaterial The Babylon material
  76317. */
  76318. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76319. /**
  76320. * Loads a glTF texture info.
  76321. * @param context The context when loading the asset
  76322. * @param textureInfo The glTF texture info property
  76323. * @param assign A function called synchronously after parsing the glTF properties
  76324. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76325. */
  76326. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76327. /** @hidden */
  76328. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76329. /** @hidden */
  76330. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76331. private _loadSampler;
  76332. /**
  76333. * Loads a glTF image.
  76334. * @param context The context when loading the asset
  76335. * @param image The glTF image property
  76336. * @returns A promise that resolves with the loaded data when the load is complete
  76337. */
  76338. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76339. /**
  76340. * Loads a glTF uri.
  76341. * @param context The context when loading the asset
  76342. * @param property The glTF property associated with the uri
  76343. * @param uri The base64 or relative uri
  76344. * @returns A promise that resolves with the loaded data when the load is complete
  76345. */
  76346. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76347. private _onProgress;
  76348. /**
  76349. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76350. * @param babylonObject the Babylon object with metadata
  76351. * @param pointer the JSON pointer
  76352. */
  76353. static AddPointerMetadata(babylonObject: {
  76354. metadata: any;
  76355. }, pointer: string): void;
  76356. private static _GetTextureWrapMode;
  76357. private static _GetTextureSamplingMode;
  76358. private static _GetTypedArrayConstructor;
  76359. private static _GetTypedArray;
  76360. private static _GetNumComponents;
  76361. private static _ValidateUri;
  76362. private static _GetDrawMode;
  76363. private _compileMaterialsAsync;
  76364. private _compileShadowGeneratorsAsync;
  76365. private _forEachExtensions;
  76366. private _applyExtensions;
  76367. private _extensionsOnLoading;
  76368. private _extensionsOnReady;
  76369. private _extensionsLoadSceneAsync;
  76370. private _extensionsLoadNodeAsync;
  76371. private _extensionsLoadCameraAsync;
  76372. private _extensionsLoadVertexDataAsync;
  76373. private _extensionsLoadMeshPrimitiveAsync;
  76374. private _extensionsLoadMaterialAsync;
  76375. private _extensionsCreateMaterial;
  76376. private _extensionsLoadMaterialPropertiesAsync;
  76377. private _extensionsLoadTextureInfoAsync;
  76378. private _extensionsLoadTextureAsync;
  76379. private _extensionsLoadAnimationAsync;
  76380. private _extensionsLoadSkinAsync;
  76381. private _extensionsLoadUriAsync;
  76382. private _extensionsLoadBufferViewAsync;
  76383. private _extensionsLoadBufferAsync;
  76384. /**
  76385. * Helper method called by a loader extension to load an glTF extension.
  76386. * @param context The context when loading the asset
  76387. * @param property The glTF property to load the extension from
  76388. * @param extensionName The name of the extension to load
  76389. * @param actionAsync The action to run
  76390. * @returns The promise returned by actionAsync or null if the extension does not exist
  76391. */
  76392. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76393. /**
  76394. * Helper method called by a loader extension to load a glTF extra.
  76395. * @param context The context when loading the asset
  76396. * @param property The glTF property to load the extra from
  76397. * @param extensionName The name of the extension to load
  76398. * @param actionAsync The action to run
  76399. * @returns The promise returned by actionAsync or null if the extra does not exist
  76400. */
  76401. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76402. /**
  76403. * Checks for presence of an extension.
  76404. * @param name The name of the extension to check
  76405. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76406. */
  76407. isExtensionUsed(name: string): boolean;
  76408. /**
  76409. * Increments the indentation level and logs a message.
  76410. * @param message The message to log
  76411. */
  76412. logOpen(message: string): void;
  76413. /**
  76414. * Decrements the indentation level.
  76415. */
  76416. logClose(): void;
  76417. /**
  76418. * Logs a message
  76419. * @param message The message to log
  76420. */
  76421. log(message: string): void;
  76422. /**
  76423. * Starts a performance counter.
  76424. * @param counterName The name of the performance counter
  76425. */
  76426. startPerformanceCounter(counterName: string): void;
  76427. /**
  76428. * Ends a performance counter.
  76429. * @param counterName The name of the performance counter
  76430. */
  76431. endPerformanceCounter(counterName: string): void;
  76432. }
  76433. }
  76434. declare module BABYLON.GLTF2.Loader.Extensions {
  76435. /**
  76436. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76437. */
  76438. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76439. /**
  76440. * The name of this extension.
  76441. */
  76442. readonly name: string;
  76443. /**
  76444. * Defines whether this extension is enabled.
  76445. */
  76446. enabled: boolean;
  76447. private _loader;
  76448. private _lights?;
  76449. /** @hidden */
  76450. constructor(loader: GLTFLoader);
  76451. /** @hidden */
  76452. dispose(): void;
  76453. /** @hidden */
  76454. onLoading(): void;
  76455. /** @hidden */
  76456. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76457. private _loadLightAsync;
  76458. }
  76459. }
  76460. declare module BABYLON.GLTF2.Loader.Extensions {
  76461. /**
  76462. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76463. */
  76464. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76465. /**
  76466. * The name of this extension.
  76467. */
  76468. readonly name: string;
  76469. /**
  76470. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76471. */
  76472. dracoCompression?: DracoCompression;
  76473. /**
  76474. * Defines whether this extension is enabled.
  76475. */
  76476. enabled: boolean;
  76477. private _loader;
  76478. /** @hidden */
  76479. constructor(loader: GLTFLoader);
  76480. /** @hidden */
  76481. dispose(): void;
  76482. /** @hidden */
  76483. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76484. }
  76485. }
  76486. declare module BABYLON.GLTF2.Loader.Extensions {
  76487. /**
  76488. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76489. */
  76490. export class KHR_lights implements IGLTFLoaderExtension {
  76491. /**
  76492. * The name of this extension.
  76493. */
  76494. readonly name: string;
  76495. /**
  76496. * Defines whether this extension is enabled.
  76497. */
  76498. enabled: boolean;
  76499. private _loader;
  76500. private _lights?;
  76501. /** @hidden */
  76502. constructor(loader: GLTFLoader);
  76503. /** @hidden */
  76504. dispose(): void;
  76505. /** @hidden */
  76506. onLoading(): void;
  76507. /** @hidden */
  76508. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76509. }
  76510. }
  76511. declare module BABYLON.GLTF2.Loader.Extensions {
  76512. /**
  76513. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76514. */
  76515. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76516. /**
  76517. * The name of this extension.
  76518. */
  76519. readonly name: string;
  76520. /**
  76521. * Defines whether this extension is enabled.
  76522. */
  76523. enabled: boolean;
  76524. /**
  76525. * Defines a number that determines the order the extensions are applied.
  76526. */
  76527. order: number;
  76528. private _loader;
  76529. /** @hidden */
  76530. constructor(loader: GLTFLoader);
  76531. /** @hidden */
  76532. dispose(): void;
  76533. /** @hidden */
  76534. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76535. private _loadSpecularGlossinessPropertiesAsync;
  76536. }
  76537. }
  76538. declare module BABYLON.GLTF2.Loader.Extensions {
  76539. /**
  76540. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76541. */
  76542. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76543. /**
  76544. * The name of this extension.
  76545. */
  76546. readonly name: string;
  76547. /**
  76548. * Defines whether this extension is enabled.
  76549. */
  76550. enabled: boolean;
  76551. /**
  76552. * Defines a number that determines the order the extensions are applied.
  76553. */
  76554. order: number;
  76555. private _loader;
  76556. /** @hidden */
  76557. constructor(loader: GLTFLoader);
  76558. /** @hidden */
  76559. dispose(): void;
  76560. /** @hidden */
  76561. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76562. private _loadUnlitPropertiesAsync;
  76563. }
  76564. }
  76565. declare module BABYLON.GLTF2.Loader.Extensions {
  76566. /**
  76567. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76568. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76569. * !!! Experimental Extension Subject to Changes !!!
  76570. */
  76571. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76572. /**
  76573. * The name of this extension.
  76574. */
  76575. readonly name: string;
  76576. /**
  76577. * Defines whether this extension is enabled.
  76578. */
  76579. enabled: boolean;
  76580. /**
  76581. * Defines a number that determines the order the extensions are applied.
  76582. */
  76583. order: number;
  76584. private _loader;
  76585. /** @hidden */
  76586. constructor(loader: GLTFLoader);
  76587. /** @hidden */
  76588. dispose(): void;
  76589. /** @hidden */
  76590. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76591. private _loadClearCoatPropertiesAsync;
  76592. }
  76593. }
  76594. declare module BABYLON.GLTF2.Loader.Extensions {
  76595. /**
  76596. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76597. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76598. * !!! Experimental Extension Subject to Changes !!!
  76599. */
  76600. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76601. /**
  76602. * The name of this extension.
  76603. */
  76604. readonly name: string;
  76605. /**
  76606. * Defines whether this extension is enabled.
  76607. */
  76608. enabled: boolean;
  76609. /**
  76610. * Defines a number that determines the order the extensions are applied.
  76611. */
  76612. order: number;
  76613. private _loader;
  76614. /** @hidden */
  76615. constructor(loader: GLTFLoader);
  76616. /** @hidden */
  76617. dispose(): void;
  76618. /** @hidden */
  76619. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76620. private _loadSheenPropertiesAsync;
  76621. }
  76622. }
  76623. declare module BABYLON.GLTF2.Loader.Extensions {
  76624. /**
  76625. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76626. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76627. * !!! Experimental Extension Subject to Changes !!!
  76628. */
  76629. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76630. /**
  76631. * The name of this extension.
  76632. */
  76633. readonly name: string;
  76634. /**
  76635. * Defines whether this extension is enabled.
  76636. */
  76637. enabled: boolean;
  76638. /**
  76639. * Defines a number that determines the order the extensions are applied.
  76640. */
  76641. order: number;
  76642. private _loader;
  76643. /** @hidden */
  76644. constructor(loader: GLTFLoader);
  76645. /** @hidden */
  76646. dispose(): void;
  76647. /** @hidden */
  76648. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76649. private _loadSpecularPropertiesAsync;
  76650. }
  76651. }
  76652. declare module BABYLON.GLTF2.Loader.Extensions {
  76653. /**
  76654. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76655. * [Playground Sample](//TODO)
  76656. * !!! Experimental Extension Subject to Changes !!!
  76657. */
  76658. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76659. /**
  76660. * The name of this extension.
  76661. */
  76662. readonly name: string;
  76663. /**
  76664. * Defines whether this extension is enabled.
  76665. */
  76666. enabled: boolean;
  76667. private _loader;
  76668. /** @hidden */
  76669. constructor(loader: GLTFLoader);
  76670. /** @hidden */
  76671. dispose(): void;
  76672. /** @hidden */
  76673. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76674. }
  76675. }
  76676. declare module BABYLON.GLTF2.Loader.Extensions {
  76677. /**
  76678. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76679. */
  76680. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76681. /**
  76682. * The name of this extension.
  76683. */
  76684. readonly name: string;
  76685. /**
  76686. * Defines whether this extension is enabled.
  76687. */
  76688. enabled: boolean;
  76689. /** @hidden */
  76690. constructor(loader: GLTFLoader);
  76691. /** @hidden */
  76692. dispose(): void;
  76693. }
  76694. }
  76695. declare module BABYLON.GLTF2.Loader.Extensions {
  76696. /**
  76697. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76698. * !!! Experimental Extension Subject to Changes !!!
  76699. */
  76700. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76701. /** The name of this extension. */
  76702. readonly name: string;
  76703. /** Defines whether this extension is enabled. */
  76704. enabled: boolean;
  76705. private _loader;
  76706. /** @hidden */
  76707. constructor(loader: GLTFLoader);
  76708. /** @hidden */
  76709. dispose(): void;
  76710. /** @hidden */
  76711. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76712. }
  76713. }
  76714. declare module BABYLON.GLTF2.Loader.Extensions {
  76715. /**
  76716. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  76717. */
  76718. export class KHR_texture_transform implements IGLTFLoaderExtension {
  76719. /**
  76720. * The name of this extension.
  76721. */
  76722. readonly name: string;
  76723. /**
  76724. * Defines whether this extension is enabled.
  76725. */
  76726. enabled: boolean;
  76727. private _loader;
  76728. /** @hidden */
  76729. constructor(loader: GLTFLoader);
  76730. /** @hidden */
  76731. dispose(): void;
  76732. /** @hidden */
  76733. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76734. }
  76735. }
  76736. declare module BABYLON.GLTF2.Loader.Extensions {
  76737. /**
  76738. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76739. */
  76740. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76741. /**
  76742. * The name of this extension.
  76743. */
  76744. readonly name: string;
  76745. /**
  76746. * Defines whether this extension is enabled.
  76747. */
  76748. enabled: boolean;
  76749. private _loader;
  76750. private _clips;
  76751. private _emitters;
  76752. /** @hidden */
  76753. constructor(loader: GLTFLoader);
  76754. /** @hidden */
  76755. dispose(): void;
  76756. /** @hidden */
  76757. onLoading(): void;
  76758. /** @hidden */
  76759. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76760. /** @hidden */
  76761. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76762. /** @hidden */
  76763. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76764. private _loadClipAsync;
  76765. private _loadEmitterAsync;
  76766. private _getEventAction;
  76767. private _loadAnimationEventAsync;
  76768. }
  76769. }
  76770. declare module BABYLON.GLTF2.Loader.Extensions {
  76771. /**
  76772. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76773. */
  76774. export class MSFT_lod implements IGLTFLoaderExtension {
  76775. /**
  76776. * The name of this extension.
  76777. */
  76778. readonly name: string;
  76779. /**
  76780. * Defines whether this extension is enabled.
  76781. */
  76782. enabled: boolean;
  76783. /**
  76784. * Defines a number that determines the order the extensions are applied.
  76785. */
  76786. order: number;
  76787. /**
  76788. * Maximum number of LODs to load, starting from the lowest LOD.
  76789. */
  76790. maxLODsToLoad: number;
  76791. /**
  76792. * Observable raised when all node LODs of one level are loaded.
  76793. * The event data is the index of the loaded LOD starting from zero.
  76794. * Dispose the loader to cancel the loading of the next level of LODs.
  76795. */
  76796. onNodeLODsLoadedObservable: Observable<number>;
  76797. /**
  76798. * Observable raised when all material LODs of one level are loaded.
  76799. * The event data is the index of the loaded LOD starting from zero.
  76800. * Dispose the loader to cancel the loading of the next level of LODs.
  76801. */
  76802. onMaterialLODsLoadedObservable: Observable<number>;
  76803. private _loader;
  76804. private _nodeIndexLOD;
  76805. private _nodeSignalLODs;
  76806. private _nodePromiseLODs;
  76807. private _materialIndexLOD;
  76808. private _materialSignalLODs;
  76809. private _materialPromiseLODs;
  76810. private _indexLOD;
  76811. private _bufferLODs;
  76812. /** @hidden */
  76813. constructor(loader: GLTFLoader);
  76814. /** @hidden */
  76815. dispose(): void;
  76816. /** @hidden */
  76817. onReady(): void;
  76818. /** @hidden */
  76819. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76820. /** @hidden */
  76821. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76822. /** @hidden */
  76823. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76824. /** @hidden */
  76825. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76826. /** @hidden */
  76827. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76828. private _loadBufferLOD;
  76829. /**
  76830. * Gets an array of LOD properties from lowest to highest.
  76831. */
  76832. private _getLODs;
  76833. private _disposeTransformNode;
  76834. private _disposeMaterials;
  76835. }
  76836. }
  76837. declare module BABYLON.GLTF2.Loader.Extensions {
  76838. /** @hidden */
  76839. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76840. readonly name: string;
  76841. enabled: boolean;
  76842. private _loader;
  76843. constructor(loader: GLTFLoader);
  76844. dispose(): void;
  76845. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76846. }
  76847. }
  76848. declare module BABYLON.GLTF2.Loader.Extensions {
  76849. /** @hidden */
  76850. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76851. readonly name: string;
  76852. enabled: boolean;
  76853. private _loader;
  76854. constructor(loader: GLTFLoader);
  76855. dispose(): void;
  76856. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76857. }
  76858. }
  76859. declare module BABYLON.GLTF2.Loader.Extensions {
  76860. /**
  76861. * Store glTF extras (if present) in BJS objects' metadata
  76862. */
  76863. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76864. /**
  76865. * The name of this extension.
  76866. */
  76867. readonly name: string;
  76868. /**
  76869. * Defines whether this extension is enabled.
  76870. */
  76871. enabled: boolean;
  76872. private _loader;
  76873. private _assignExtras;
  76874. /** @hidden */
  76875. constructor(loader: GLTFLoader);
  76876. /** @hidden */
  76877. dispose(): void;
  76878. /** @hidden */
  76879. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76880. /** @hidden */
  76881. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76882. /** @hidden */
  76883. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76884. }
  76885. }
  76886. declare module BABYLON {
  76887. /**
  76888. * Class reading and parsing the MTL file bundled with the obj file.
  76889. */
  76890. export class MTLFileLoader {
  76891. /**
  76892. * Invert Y-Axis of referenced textures on load
  76893. */
  76894. static INVERT_TEXTURE_Y: boolean;
  76895. /**
  76896. * All material loaded from the mtl will be set here
  76897. */
  76898. materials: StandardMaterial[];
  76899. /**
  76900. * This function will read the mtl file and create each material described inside
  76901. * This function could be improve by adding :
  76902. * -some component missing (Ni, Tf...)
  76903. * -including the specific options available
  76904. *
  76905. * @param scene defines the scene the material will be created in
  76906. * @param data defines the mtl data to parse
  76907. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76908. * @param forAssetContainer defines if the material should be registered in the scene
  76909. */
  76910. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76911. /**
  76912. * Gets the texture for the material.
  76913. *
  76914. * If the material is imported from input file,
  76915. * We sanitize the url to ensure it takes the textre from aside the material.
  76916. *
  76917. * @param rootUrl The root url to load from
  76918. * @param value The value stored in the mtl
  76919. * @return The Texture
  76920. */
  76921. private static _getTexture;
  76922. }
  76923. }
  76924. declare module BABYLON {
  76925. /**
  76926. * Options for loading OBJ/MTL files
  76927. */
  76928. type MeshLoadOptions = {
  76929. /**
  76930. * Defines if UVs are optimized by default during load.
  76931. */
  76932. OptimizeWithUV: boolean;
  76933. /**
  76934. * Defines custom scaling of UV coordinates of loaded meshes.
  76935. */
  76936. UVScaling: Vector2;
  76937. /**
  76938. * Invert model on y-axis (does a model scaling inversion)
  76939. */
  76940. InvertY: boolean;
  76941. /**
  76942. * Invert Y-Axis of referenced textures on load
  76943. */
  76944. InvertTextureY: boolean;
  76945. /**
  76946. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76947. */
  76948. ImportVertexColors: boolean;
  76949. /**
  76950. * Compute the normals for the model, even if normals are present in the file.
  76951. */
  76952. ComputeNormals: boolean;
  76953. /**
  76954. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76955. */
  76956. SkipMaterials: boolean;
  76957. /**
  76958. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76959. */
  76960. MaterialLoadingFailsSilently: boolean;
  76961. };
  76962. /**
  76963. * OBJ file type loader.
  76964. * This is a babylon scene loader plugin.
  76965. */
  76966. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76967. /**
  76968. * Defines if UVs are optimized by default during load.
  76969. */
  76970. static OPTIMIZE_WITH_UV: boolean;
  76971. /**
  76972. * Invert model on y-axis (does a model scaling inversion)
  76973. */
  76974. static INVERT_Y: boolean;
  76975. /**
  76976. * Invert Y-Axis of referenced textures on load
  76977. */
  76978. static get INVERT_TEXTURE_Y(): boolean;
  76979. static set INVERT_TEXTURE_Y(value: boolean);
  76980. /**
  76981. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76982. */
  76983. static IMPORT_VERTEX_COLORS: boolean;
  76984. /**
  76985. * Compute the normals for the model, even if normals are present in the file.
  76986. */
  76987. static COMPUTE_NORMALS: boolean;
  76988. /**
  76989. * Defines custom scaling of UV coordinates of loaded meshes.
  76990. */
  76991. static UV_SCALING: Vector2;
  76992. /**
  76993. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76994. */
  76995. static SKIP_MATERIALS: boolean;
  76996. /**
  76997. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76998. *
  76999. * Defaults to true for backwards compatibility.
  77000. */
  77001. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77002. /**
  77003. * Defines the name of the plugin.
  77004. */
  77005. name: string;
  77006. /**
  77007. * Defines the extension the plugin is able to load.
  77008. */
  77009. extensions: string;
  77010. /** @hidden */
  77011. obj: RegExp;
  77012. /** @hidden */
  77013. group: RegExp;
  77014. /** @hidden */
  77015. mtllib: RegExp;
  77016. /** @hidden */
  77017. usemtl: RegExp;
  77018. /** @hidden */
  77019. smooth: RegExp;
  77020. /** @hidden */
  77021. vertexPattern: RegExp;
  77022. /** @hidden */
  77023. normalPattern: RegExp;
  77024. /** @hidden */
  77025. uvPattern: RegExp;
  77026. /** @hidden */
  77027. facePattern1: RegExp;
  77028. /** @hidden */
  77029. facePattern2: RegExp;
  77030. /** @hidden */
  77031. facePattern3: RegExp;
  77032. /** @hidden */
  77033. facePattern4: RegExp;
  77034. /** @hidden */
  77035. facePattern5: RegExp;
  77036. private _forAssetContainer;
  77037. private _meshLoadOptions;
  77038. /**
  77039. * Creates loader for .OBJ files
  77040. *
  77041. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77042. */
  77043. constructor(meshLoadOptions?: MeshLoadOptions);
  77044. private static get currentMeshLoadOptions();
  77045. /**
  77046. * Calls synchronously the MTL file attached to this obj.
  77047. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77048. * Without this function materials are not displayed in the first frame (but displayed after).
  77049. * In consequence it is impossible to get material information in your HTML file
  77050. *
  77051. * @param url The URL of the MTL file
  77052. * @param rootUrl
  77053. * @param onSuccess Callback function to be called when the MTL file is loaded
  77054. * @private
  77055. */
  77056. private _loadMTL;
  77057. /**
  77058. * Instantiates a OBJ file loader plugin.
  77059. * @returns the created plugin
  77060. */
  77061. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77062. /**
  77063. * If the data string can be loaded directly.
  77064. *
  77065. * @param data string containing the file data
  77066. * @returns if the data can be loaded directly
  77067. */
  77068. canDirectLoad(data: string): boolean;
  77069. /**
  77070. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77071. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77072. * @param scene the scene the meshes should be added to
  77073. * @param data the OBJ data to load
  77074. * @param rootUrl root url to load from
  77075. * @param onProgress event that fires when loading progress has occured
  77076. * @param fileName Defines the name of the file to load
  77077. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77078. */
  77079. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77080. meshes: AbstractMesh[];
  77081. particleSystems: IParticleSystem[];
  77082. skeletons: Skeleton[];
  77083. animationGroups: AnimationGroup[];
  77084. }>;
  77085. /**
  77086. * Imports all objects from the loaded OBJ data and adds them to the scene
  77087. * @param scene the scene the objects should be added to
  77088. * @param data the OBJ data to load
  77089. * @param rootUrl root url to load from
  77090. * @param onProgress event that fires when loading progress has occured
  77091. * @param fileName Defines the name of the file to load
  77092. * @returns a promise which completes when objects have been loaded to the scene
  77093. */
  77094. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77095. /**
  77096. * Load into an asset container.
  77097. * @param scene The scene to load into
  77098. * @param data The data to import
  77099. * @param rootUrl The root url for scene and resources
  77100. * @param onProgress The callback when the load progresses
  77101. * @param fileName Defines the name of the file to load
  77102. * @returns The loaded asset container
  77103. */
  77104. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77105. /**
  77106. * Read the OBJ file and create an Array of meshes.
  77107. * Each mesh contains all information given by the OBJ and the MTL file.
  77108. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77109. *
  77110. * @param meshesNames
  77111. * @param scene Scene The scene where are displayed the data
  77112. * @param data String The content of the obj file
  77113. * @param rootUrl String The path to the folder
  77114. * @returns Array<AbstractMesh>
  77115. * @private
  77116. */
  77117. private _parseSolid;
  77118. }
  77119. }
  77120. declare module BABYLON {
  77121. /**
  77122. * STL file type loader.
  77123. * This is a babylon scene loader plugin.
  77124. */
  77125. export class STLFileLoader implements ISceneLoaderPlugin {
  77126. /** @hidden */
  77127. solidPattern: RegExp;
  77128. /** @hidden */
  77129. facetsPattern: RegExp;
  77130. /** @hidden */
  77131. normalPattern: RegExp;
  77132. /** @hidden */
  77133. vertexPattern: RegExp;
  77134. /**
  77135. * Defines the name of the plugin.
  77136. */
  77137. name: string;
  77138. /**
  77139. * Defines the extensions the stl loader is able to load.
  77140. * force data to come in as an ArrayBuffer
  77141. * we'll convert to string if it looks like it's an ASCII .stl
  77142. */
  77143. extensions: ISceneLoaderPluginExtensions;
  77144. /**
  77145. * Import meshes into a scene.
  77146. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77147. * @param scene The scene to import into
  77148. * @param data The data to import
  77149. * @param rootUrl The root url for scene and resources
  77150. * @param meshes The meshes array to import into
  77151. * @param particleSystems The particle systems array to import into
  77152. * @param skeletons The skeletons array to import into
  77153. * @param onError The callback when import fails
  77154. * @returns True if successful or false otherwise
  77155. */
  77156. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77157. /**
  77158. * Load into a scene.
  77159. * @param scene The scene to load into
  77160. * @param data The data to import
  77161. * @param rootUrl The root url for scene and resources
  77162. * @param onError The callback when import fails
  77163. * @returns true if successful or false otherwise
  77164. */
  77165. load(scene: Scene, data: any, rootUrl: string): boolean;
  77166. /**
  77167. * Load into an asset container.
  77168. * @param scene The scene to load into
  77169. * @param data The data to import
  77170. * @param rootUrl The root url for scene and resources
  77171. * @param onError The callback when import fails
  77172. * @returns The loaded asset container
  77173. */
  77174. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77175. private _isBinary;
  77176. private _parseBinary;
  77177. private _parseASCII;
  77178. }
  77179. }
  77180. declare module BABYLON {
  77181. /**
  77182. * Class for generating OBJ data from a Babylon scene.
  77183. */
  77184. export class OBJExport {
  77185. /**
  77186. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77187. * @param mesh defines the list of meshes to serialize
  77188. * @param materials defines if materials should be exported
  77189. * @param matlibname defines the name of the associated mtl file
  77190. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77191. * @returns the OBJ content
  77192. */
  77193. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77194. /**
  77195. * Exports the material(s) of a mesh in .MTL file format (text)
  77196. * @param mesh defines the mesh to extract the material from
  77197. * @returns the mtl content
  77198. */
  77199. static MTL(mesh: Mesh): string;
  77200. }
  77201. }
  77202. declare module BABYLON {
  77203. /** @hidden */
  77204. export var __IGLTFExporterExtension: number;
  77205. /**
  77206. * Interface for extending the exporter
  77207. * @hidden
  77208. */
  77209. export interface IGLTFExporterExtension {
  77210. /**
  77211. * The name of this extension
  77212. */
  77213. readonly name: string;
  77214. /**
  77215. * Defines whether this extension is enabled
  77216. */
  77217. enabled: boolean;
  77218. /**
  77219. * Defines whether this extension is required
  77220. */
  77221. required: boolean;
  77222. }
  77223. }
  77224. declare module BABYLON.GLTF2.Exporter {
  77225. /** @hidden */
  77226. export var __IGLTFExporterExtensionV2: number;
  77227. /**
  77228. * Interface for a glTF exporter extension
  77229. * @hidden
  77230. */
  77231. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77232. /**
  77233. * Define this method to modify the default behavior before exporting a texture
  77234. * @param context The context when loading the asset
  77235. * @param babylonTexture The Babylon.js texture
  77236. * @param mimeType The mime-type of the generated image
  77237. * @returns A promise that resolves with the exported texture
  77238. */
  77239. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77240. /**
  77241. * Define this method to get notified when a texture info is created
  77242. * @param context The context when loading the asset
  77243. * @param textureInfo The glTF texture info
  77244. * @param babylonTexture The Babylon.js texture
  77245. */
  77246. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77247. /**
  77248. * Define this method to modify the default behavior when exporting texture info
  77249. * @param context The context when loading the asset
  77250. * @param meshPrimitive glTF mesh primitive
  77251. * @param babylonSubMesh Babylon submesh
  77252. * @param binaryWriter glTF serializer binary writer instance
  77253. * @returns nullable IMeshPrimitive promise
  77254. */
  77255. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77256. /**
  77257. * Define this method to modify the default behavior when exporting a node
  77258. * @param context The context when exporting the node
  77259. * @param node glTF node
  77260. * @param babylonNode BabylonJS node
  77261. * @returns nullable INode promise
  77262. */
  77263. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77264. [key: number]: number;
  77265. }): Promise<Nullable<INode>>;
  77266. /**
  77267. * Define this method to modify the default behavior when exporting a material
  77268. * @param material glTF material
  77269. * @param babylonMaterial BabylonJS material
  77270. * @returns nullable IMaterial promise
  77271. */
  77272. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77273. /**
  77274. * Define this method to return additional textures to export from a material
  77275. * @param material glTF material
  77276. * @param babylonMaterial BabylonJS material
  77277. * @returns List of textures
  77278. */
  77279. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77280. /** Gets a boolean indicating that this extension was used */
  77281. wasUsed: boolean;
  77282. /** Gets a boolean indicating that this extension is required for the file to work */
  77283. required: boolean;
  77284. /**
  77285. * Called after the exporter state changes to EXPORTING
  77286. */
  77287. onExporting?(): void;
  77288. }
  77289. }
  77290. declare module BABYLON.GLTF2.Exporter {
  77291. /**
  77292. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77293. * @hidden
  77294. */
  77295. export class _GLTFMaterialExporter {
  77296. /**
  77297. * Represents the dielectric specular values for R, G and B
  77298. */
  77299. private static readonly _DielectricSpecular;
  77300. /**
  77301. * Allows the maximum specular power to be defined for material calculations
  77302. */
  77303. private static readonly _MaxSpecularPower;
  77304. /**
  77305. * Mapping to store textures
  77306. */
  77307. private _textureMap;
  77308. /**
  77309. * Numeric tolerance value
  77310. */
  77311. private static readonly _Epsilon;
  77312. /**
  77313. * Reference to the glTF Exporter
  77314. */
  77315. private _exporter;
  77316. constructor(exporter: _Exporter);
  77317. /**
  77318. * Specifies if two colors are approximately equal in value
  77319. * @param color1 first color to compare to
  77320. * @param color2 second color to compare to
  77321. * @param epsilon threshold value
  77322. */
  77323. private static FuzzyEquals;
  77324. /**
  77325. * Gets the materials from a Babylon scene and converts them to glTF materials
  77326. * @param scene babylonjs scene
  77327. * @param mimeType texture mime type
  77328. * @param images array of images
  77329. * @param textures array of textures
  77330. * @param materials array of materials
  77331. * @param imageData mapping of texture names to base64 textures
  77332. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77333. */
  77334. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77335. /**
  77336. * Makes a copy of the glTF material without the texture parameters
  77337. * @param originalMaterial original glTF material
  77338. * @returns glTF material without texture parameters
  77339. */
  77340. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77341. /**
  77342. * Specifies if the material has any texture parameters present
  77343. * @param material glTF Material
  77344. * @returns boolean specifying if texture parameters are present
  77345. */
  77346. _hasTexturesPresent(material: IMaterial): boolean;
  77347. /**
  77348. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77349. * @param babylonStandardMaterial
  77350. * @returns glTF Metallic Roughness Material representation
  77351. */
  77352. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77353. /**
  77354. * Computes the metallic factor
  77355. * @param diffuse diffused value
  77356. * @param specular specular value
  77357. * @param oneMinusSpecularStrength one minus the specular strength
  77358. * @returns metallic value
  77359. */
  77360. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77361. /**
  77362. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77363. * @param glTFMaterial glTF material
  77364. * @param babylonMaterial Babylon material
  77365. */
  77366. private static _SetAlphaMode;
  77367. /**
  77368. * Converts a Babylon Standard Material to a glTF Material
  77369. * @param babylonStandardMaterial BJS Standard Material
  77370. * @param mimeType mime type to use for the textures
  77371. * @param images array of glTF image interfaces
  77372. * @param textures array of glTF texture interfaces
  77373. * @param materials array of glTF material interfaces
  77374. * @param imageData map of image file name to data
  77375. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77376. */
  77377. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77378. private _finishMaterial;
  77379. /**
  77380. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77381. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77382. * @param mimeType mime type to use for the textures
  77383. * @param images array of glTF image interfaces
  77384. * @param textures array of glTF texture interfaces
  77385. * @param materials array of glTF material interfaces
  77386. * @param imageData map of image file name to data
  77387. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77388. */
  77389. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77390. /**
  77391. * Converts an image typed array buffer to a base64 image
  77392. * @param buffer typed array buffer
  77393. * @param width width of the image
  77394. * @param height height of the image
  77395. * @param mimeType mimetype of the image
  77396. * @returns base64 image string
  77397. */
  77398. private _createBase64FromCanvasAsync;
  77399. /**
  77400. * Generates a white texture based on the specified width and height
  77401. * @param width width of the texture in pixels
  77402. * @param height height of the texture in pixels
  77403. * @param scene babylonjs scene
  77404. * @returns white texture
  77405. */
  77406. private _createWhiteTexture;
  77407. /**
  77408. * 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
  77409. * @param texture1 first texture to resize
  77410. * @param texture2 second texture to resize
  77411. * @param scene babylonjs scene
  77412. * @returns resized textures or null
  77413. */
  77414. private _resizeTexturesToSameDimensions;
  77415. /**
  77416. * Converts an array of pixels to a Float32Array
  77417. * Throws an error if the pixel format is not supported
  77418. * @param pixels - array buffer containing pixel values
  77419. * @returns Float32 of pixels
  77420. */
  77421. private _convertPixelArrayToFloat32;
  77422. /**
  77423. * Convert Specular Glossiness Textures to Metallic Roughness
  77424. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77425. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77426. * @param diffuseTexture texture used to store diffuse information
  77427. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77428. * @param factors specular glossiness material factors
  77429. * @param mimeType the mime type to use for the texture
  77430. * @returns pbr metallic roughness interface or null
  77431. */
  77432. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77433. /**
  77434. * Converts specular glossiness material properties to metallic roughness
  77435. * @param specularGlossiness interface with specular glossiness material properties
  77436. * @returns interface with metallic roughness material properties
  77437. */
  77438. private _convertSpecularGlossinessToMetallicRoughness;
  77439. /**
  77440. * Calculates the surface reflectance, independent of lighting conditions
  77441. * @param color Color source to calculate brightness from
  77442. * @returns number representing the perceived brightness, or zero if color is undefined
  77443. */
  77444. private _getPerceivedBrightness;
  77445. /**
  77446. * Returns the maximum color component value
  77447. * @param color
  77448. * @returns maximum color component value, or zero if color is null or undefined
  77449. */
  77450. private _getMaxComponent;
  77451. /**
  77452. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77453. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77454. * @param mimeType mime type to use for the textures
  77455. * @param images array of glTF image interfaces
  77456. * @param textures array of glTF texture interfaces
  77457. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77458. * @param imageData map of image file name to data
  77459. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77460. * @returns glTF PBR Metallic Roughness factors
  77461. */
  77462. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77463. private _getGLTFTextureSampler;
  77464. private _getGLTFTextureWrapMode;
  77465. private _getGLTFTextureWrapModesSampler;
  77466. /**
  77467. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77468. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77469. * @param mimeType mime type to use for the textures
  77470. * @param images array of glTF image interfaces
  77471. * @param textures array of glTF texture interfaces
  77472. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77473. * @param imageData map of image file name to data
  77474. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77475. * @returns glTF PBR Metallic Roughness factors
  77476. */
  77477. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77478. /**
  77479. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77480. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77481. * @param mimeType mime type to use for the textures
  77482. * @param images array of glTF image interfaces
  77483. * @param textures array of glTF texture interfaces
  77484. * @param materials array of glTF material interfaces
  77485. * @param imageData map of image file name to data
  77486. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77487. */
  77488. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77489. private setMetallicRoughnessPbrMaterial;
  77490. private getPixelsFromTexture;
  77491. /**
  77492. * Extracts a texture from a Babylon texture into file data and glTF data
  77493. * @param babylonTexture Babylon texture to extract
  77494. * @param mimeType Mime Type of the babylonTexture
  77495. * @return glTF texture info, or null if the texture format is not supported
  77496. */
  77497. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77498. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77499. /**
  77500. * Builds a texture from base64 string
  77501. * @param base64Texture base64 texture string
  77502. * @param baseTextureName Name to use for the texture
  77503. * @param mimeType image mime type for the texture
  77504. * @param images array of images
  77505. * @param textures array of textures
  77506. * @param imageData map of image data
  77507. * @returns glTF texture info, or null if the texture format is not supported
  77508. */
  77509. private _getTextureInfoFromBase64;
  77510. }
  77511. }
  77512. declare module BABYLON {
  77513. /**
  77514. * Class for holding and downloading glTF file data
  77515. */
  77516. export class GLTFData {
  77517. /**
  77518. * Object which contains the file name as the key and its data as the value
  77519. */
  77520. glTFFiles: {
  77521. [fileName: string]: string | Blob;
  77522. };
  77523. /**
  77524. * Initializes the glTF file object
  77525. */
  77526. constructor();
  77527. /**
  77528. * Downloads the glTF data as files based on their names and data
  77529. */
  77530. downloadFiles(): void;
  77531. }
  77532. }
  77533. declare module BABYLON {
  77534. /**
  77535. * Holds a collection of exporter options and parameters
  77536. */
  77537. export interface IExportOptions {
  77538. /**
  77539. * Function which indicates whether a babylon node should be exported or not
  77540. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77541. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77542. */
  77543. shouldExportNode?(node: Node): boolean;
  77544. /**
  77545. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77546. * @param metadata source metadata to read from
  77547. * @returns the data to store to glTF node extras
  77548. */
  77549. metadataSelector?(metadata: any): any;
  77550. /**
  77551. * The sample rate to bake animation curves
  77552. */
  77553. animationSampleRate?: number;
  77554. /**
  77555. * Begin serialization without waiting for the scene to be ready
  77556. */
  77557. exportWithoutWaitingForScene?: boolean;
  77558. /**
  77559. * Indicates if coordinate system swapping root nodes should be included in export
  77560. */
  77561. includeCoordinateSystemConversionNodes?: boolean;
  77562. }
  77563. /**
  77564. * Class for generating glTF data from a Babylon scene.
  77565. */
  77566. export class GLTF2Export {
  77567. /**
  77568. * Exports the geometry of the scene to .gltf file format asynchronously
  77569. * @param scene Babylon scene with scene hierarchy information
  77570. * @param filePrefix File prefix to use when generating the glTF file
  77571. * @param options Exporter options
  77572. * @returns Returns an object with a .gltf file and associates texture names
  77573. * as keys and their data and paths as values
  77574. */
  77575. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77576. private static _PreExportAsync;
  77577. private static _PostExportAsync;
  77578. /**
  77579. * Exports the geometry of the scene to .glb file format asychronously
  77580. * @param scene Babylon scene with scene hierarchy information
  77581. * @param filePrefix File prefix to use when generating glb file
  77582. * @param options Exporter options
  77583. * @returns Returns an object with a .glb filename as key and data as value
  77584. */
  77585. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77586. }
  77587. }
  77588. declare module BABYLON.GLTF2.Exporter {
  77589. /**
  77590. * @hidden
  77591. */
  77592. export class _GLTFUtilities {
  77593. /**
  77594. * Creates a buffer view based on the supplied arguments
  77595. * @param bufferIndex index value of the specified buffer
  77596. * @param byteOffset byte offset value
  77597. * @param byteLength byte length of the bufferView
  77598. * @param byteStride byte distance between conequential elements
  77599. * @param name name of the buffer view
  77600. * @returns bufferView for glTF
  77601. */
  77602. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77603. /**
  77604. * Creates an accessor based on the supplied arguments
  77605. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77606. * @param name The name of the accessor
  77607. * @param type The type of the accessor
  77608. * @param componentType The datatype of components in the attribute
  77609. * @param count The number of attributes referenced by this accessor
  77610. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77611. * @param min Minimum value of each component in this attribute
  77612. * @param max Maximum value of each component in this attribute
  77613. * @returns accessor for glTF
  77614. */
  77615. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77616. /**
  77617. * Calculates the minimum and maximum values of an array of position floats
  77618. * @param positions Positions array of a mesh
  77619. * @param vertexStart Starting vertex offset to calculate min and max values
  77620. * @param vertexCount Number of vertices to check for min and max values
  77621. * @returns min number array and max number array
  77622. */
  77623. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77624. min: number[];
  77625. max: number[];
  77626. };
  77627. /**
  77628. * Converts a new right-handed Vector3
  77629. * @param vector vector3 array
  77630. * @returns right-handed Vector3
  77631. */
  77632. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77633. /**
  77634. * Converts a Vector3 to right-handed
  77635. * @param vector Vector3 to convert to right-handed
  77636. */
  77637. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77638. /**
  77639. * Converts a three element number array to right-handed
  77640. * @param vector number array to convert to right-handed
  77641. */
  77642. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77643. /**
  77644. * Converts a new right-handed Vector3
  77645. * @param vector vector3 array
  77646. * @returns right-handed Vector3
  77647. */
  77648. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77649. /**
  77650. * Converts a Vector3 to right-handed
  77651. * @param vector Vector3 to convert to right-handed
  77652. */
  77653. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77654. /**
  77655. * Converts a three element number array to right-handed
  77656. * @param vector number array to convert to right-handed
  77657. */
  77658. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77659. /**
  77660. * Converts a Vector4 to right-handed
  77661. * @param vector Vector4 to convert to right-handed
  77662. */
  77663. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77664. /**
  77665. * Converts a Vector4 to right-handed
  77666. * @param vector Vector4 to convert to right-handed
  77667. */
  77668. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77669. /**
  77670. * Converts a Quaternion to right-handed
  77671. * @param quaternion Source quaternion to convert to right-handed
  77672. */
  77673. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77674. /**
  77675. * Converts a Quaternion to right-handed
  77676. * @param quaternion Source quaternion to convert to right-handed
  77677. */
  77678. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77679. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77680. }
  77681. }
  77682. declare module BABYLON.GLTF2.Exporter {
  77683. /**
  77684. * Converts Babylon Scene into glTF 2.0.
  77685. * @hidden
  77686. */
  77687. export class _Exporter {
  77688. /**
  77689. * Stores the glTF to export
  77690. */
  77691. _glTF: IGLTF;
  77692. /**
  77693. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77694. */
  77695. _bufferViews: IBufferView[];
  77696. /**
  77697. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77698. */
  77699. _accessors: IAccessor[];
  77700. /**
  77701. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77702. */
  77703. _nodes: INode[];
  77704. /**
  77705. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77706. */
  77707. private _scenes;
  77708. /**
  77709. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  77710. */
  77711. private _meshes;
  77712. /**
  77713. * Stores all the generated material information, which represents the appearance of each primitive
  77714. */
  77715. _materials: IMaterial[];
  77716. _materialMap: {
  77717. [materialID: number]: number;
  77718. };
  77719. /**
  77720. * Stores all the generated texture information, which is referenced by glTF materials
  77721. */
  77722. _textures: ITexture[];
  77723. /**
  77724. * Stores all the generated image information, which is referenced by glTF textures
  77725. */
  77726. _images: IImage[];
  77727. /**
  77728. * Stores all the texture samplers
  77729. */
  77730. _samplers: ISampler[];
  77731. /**
  77732. * Stores all the generated animation samplers, which is referenced by glTF animations
  77733. */
  77734. /**
  77735. * Stores the animations for glTF models
  77736. */
  77737. private _animations;
  77738. /**
  77739. * Stores the total amount of bytes stored in the glTF buffer
  77740. */
  77741. private _totalByteLength;
  77742. /**
  77743. * Stores a reference to the Babylon scene containing the source geometry and material information
  77744. */
  77745. _babylonScene: Scene;
  77746. /**
  77747. * Stores a map of the image data, where the key is the file name and the value
  77748. * is the image data
  77749. */
  77750. _imageData: {
  77751. [fileName: string]: {
  77752. data: Uint8Array;
  77753. mimeType: ImageMimeType;
  77754. };
  77755. };
  77756. /**
  77757. * Stores a map of the unique id of a node to its index in the node array
  77758. */
  77759. _nodeMap: {
  77760. [key: number]: number;
  77761. };
  77762. /**
  77763. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77764. */
  77765. _convertToRightHandedSystem: boolean;
  77766. /**
  77767. * Specifies if a Babylon node should be converted to right-handed on export
  77768. */
  77769. _convertToRightHandedSystemMap: {
  77770. [nodeId: number]: boolean;
  77771. };
  77772. _includeCoordinateSystemConversionNodes: boolean;
  77773. /**
  77774. * Baked animation sample rate
  77775. */
  77776. private _animationSampleRate;
  77777. private _options;
  77778. private _localEngine;
  77779. _glTFMaterialExporter: _GLTFMaterialExporter;
  77780. private _extensions;
  77781. private static _ExtensionNames;
  77782. private static _ExtensionFactories;
  77783. private _applyExtension;
  77784. private _applyExtensions;
  77785. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77786. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77787. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77788. [key: number]: number;
  77789. }): Promise<Nullable<INode>>;
  77790. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77791. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77792. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77793. private _forEachExtensions;
  77794. private _extensionsOnExporting;
  77795. /**
  77796. * Load glTF serializer extensions
  77797. */
  77798. private _loadExtensions;
  77799. /**
  77800. * Creates a glTF Exporter instance, which can accept optional exporter options
  77801. * @param babylonScene Babylon scene object
  77802. * @param options Options to modify the behavior of the exporter
  77803. */
  77804. constructor(babylonScene: Scene, options?: IExportOptions);
  77805. dispose(): void;
  77806. /**
  77807. * Registers a glTF exporter extension
  77808. * @param name Name of the extension to export
  77809. * @param factory The factory function that creates the exporter extension
  77810. */
  77811. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77812. /**
  77813. * Un-registers an exporter extension
  77814. * @param name The name fo the exporter extension
  77815. * @returns A boolean indicating whether the extension has been un-registered
  77816. */
  77817. static UnregisterExtension(name: string): boolean;
  77818. /**
  77819. * Lazy load a local engine
  77820. */
  77821. _getLocalEngine(): Engine;
  77822. private reorderIndicesBasedOnPrimitiveMode;
  77823. /**
  77824. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77825. * clock-wise during export to glTF
  77826. * @param submesh BabylonJS submesh
  77827. * @param primitiveMode Primitive mode of the mesh
  77828. * @param sideOrientation the winding order of the submesh
  77829. * @param vertexBufferKind The type of vertex attribute
  77830. * @param meshAttributeArray The vertex attribute data
  77831. * @param byteOffset The offset to the binary data
  77832. * @param binaryWriter The binary data for the glTF file
  77833. * @param convertToRightHandedSystem Converts the values to right-handed
  77834. */
  77835. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77836. /**
  77837. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77838. * clock-wise during export to glTF
  77839. * @param submesh BabylonJS submesh
  77840. * @param primitiveMode Primitive mode of the mesh
  77841. * @param sideOrientation the winding order of the submesh
  77842. * @param vertexBufferKind The type of vertex attribute
  77843. * @param meshAttributeArray The vertex attribute data
  77844. * @param byteOffset The offset to the binary data
  77845. * @param binaryWriter The binary data for the glTF file
  77846. * @param convertToRightHandedSystem Converts the values to right-handed
  77847. */
  77848. private reorderTriangleFillMode;
  77849. /**
  77850. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77851. * clock-wise during export to glTF
  77852. * @param submesh BabylonJS submesh
  77853. * @param primitiveMode Primitive mode of the mesh
  77854. * @param sideOrientation the winding order of the submesh
  77855. * @param vertexBufferKind The type of vertex attribute
  77856. * @param meshAttributeArray The vertex attribute data
  77857. * @param byteOffset The offset to the binary data
  77858. * @param binaryWriter The binary data for the glTF file
  77859. * @param convertToRightHandedSystem Converts the values to right-handed
  77860. */
  77861. private reorderTriangleStripDrawMode;
  77862. /**
  77863. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77864. * clock-wise during export to glTF
  77865. * @param submesh BabylonJS submesh
  77866. * @param primitiveMode Primitive mode of the mesh
  77867. * @param sideOrientation the winding order of the submesh
  77868. * @param vertexBufferKind The type of vertex attribute
  77869. * @param meshAttributeArray The vertex attribute data
  77870. * @param byteOffset The offset to the binary data
  77871. * @param binaryWriter The binary data for the glTF file
  77872. * @param convertToRightHandedSystem Converts the values to right-handed
  77873. */
  77874. private reorderTriangleFanMode;
  77875. /**
  77876. * Writes the vertex attribute data to binary
  77877. * @param vertices The vertices to write to the binary writer
  77878. * @param byteOffset The offset into the binary writer to overwrite binary data
  77879. * @param vertexAttributeKind The vertex attribute type
  77880. * @param meshAttributeArray The vertex attribute data
  77881. * @param binaryWriter The writer containing the binary data
  77882. * @param convertToRightHandedSystem Converts the values to right-handed
  77883. */
  77884. private writeVertexAttributeData;
  77885. /**
  77886. * Writes mesh attribute data to a data buffer
  77887. * Returns the bytelength of the data
  77888. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77889. * @param meshAttributeArray Array containing the attribute data
  77890. * @param binaryWriter The buffer to write the binary data to
  77891. * @param indices Used to specify the order of the vertex data
  77892. * @param convertToRightHandedSystem Converts the values to right-handed
  77893. */
  77894. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77895. /**
  77896. * Generates glTF json data
  77897. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77898. * @param glTFPrefix Text to use when prefixing a glTF file
  77899. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77900. * @returns json data as string
  77901. */
  77902. private generateJSON;
  77903. /**
  77904. * Generates data for .gltf and .bin files based on the glTF prefix string
  77905. * @param glTFPrefix Text to use when prefixing a glTF file
  77906. * @param dispose Dispose the exporter
  77907. * @returns GLTFData with glTF file data
  77908. */
  77909. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77910. /**
  77911. * Creates a binary buffer for glTF
  77912. * @returns array buffer for binary data
  77913. */
  77914. private _generateBinaryAsync;
  77915. /**
  77916. * Pads the number to a multiple of 4
  77917. * @param num number to pad
  77918. * @returns padded number
  77919. */
  77920. private _getPadding;
  77921. /**
  77922. * @hidden
  77923. */
  77924. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77925. /**
  77926. * Sets the TRS for each node
  77927. * @param node glTF Node for storing the transformation data
  77928. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77929. * @param convertToRightHandedSystem Converts the values to right-handed
  77930. */
  77931. private setNodeTransformation;
  77932. private getVertexBufferFromMesh;
  77933. /**
  77934. * Creates a bufferview based on the vertices type for the Babylon mesh
  77935. * @param kind Indicates the type of vertices data
  77936. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77937. * @param binaryWriter The buffer to write the bufferview data to
  77938. * @param convertToRightHandedSystem Converts the values to right-handed
  77939. */
  77940. private createBufferViewKind;
  77941. /**
  77942. * The primitive mode of the Babylon mesh
  77943. * @param babylonMesh The BabylonJS mesh
  77944. */
  77945. private getMeshPrimitiveMode;
  77946. /**
  77947. * Sets the primitive mode of the glTF mesh primitive
  77948. * @param meshPrimitive glTF mesh primitive
  77949. * @param primitiveMode The primitive mode
  77950. */
  77951. private setPrimitiveMode;
  77952. /**
  77953. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77954. * @param meshPrimitive glTF mesh primitive
  77955. * @param attributeKind vertex attribute
  77956. * @returns boolean specifying if uv coordinates are present
  77957. */
  77958. private setAttributeKind;
  77959. /**
  77960. * Sets data for the primitive attributes of each submesh
  77961. * @param mesh glTF Mesh object to store the primitive attribute information
  77962. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77963. * @param binaryWriter Buffer to write the attribute data to
  77964. * @param convertToRightHandedSystem Converts the values to right-handed
  77965. */
  77966. private setPrimitiveAttributesAsync;
  77967. /**
  77968. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  77969. * @param node The node to check
  77970. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  77971. */
  77972. private isBabylonCoordinateSystemConvertingNode;
  77973. /**
  77974. * Creates a glTF scene based on the array of meshes
  77975. * Returns the the total byte offset
  77976. * @param babylonScene Babylon scene to get the mesh data from
  77977. * @param binaryWriter Buffer to write binary data to
  77978. */
  77979. private createSceneAsync;
  77980. /**
  77981. * Creates a mapping of Node unique id to node index and handles animations
  77982. * @param babylonScene Babylon Scene
  77983. * @param nodes Babylon transform nodes
  77984. * @param binaryWriter Buffer to write binary data to
  77985. * @returns Node mapping of unique id to index
  77986. */
  77987. private createNodeMapAndAnimationsAsync;
  77988. /**
  77989. * Creates a glTF node from a Babylon mesh
  77990. * @param babylonMesh Source Babylon mesh
  77991. * @param binaryWriter Buffer for storing geometry data
  77992. * @param convertToRightHandedSystem Converts the values to right-handed
  77993. * @param nodeMap Node mapping of unique id to glTF node index
  77994. * @returns glTF node
  77995. */
  77996. private createNodeAsync;
  77997. }
  77998. /**
  77999. * @hidden
  78000. *
  78001. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78002. */
  78003. export class _BinaryWriter {
  78004. /**
  78005. * Array buffer which stores all binary data
  78006. */
  78007. private _arrayBuffer;
  78008. /**
  78009. * View of the array buffer
  78010. */
  78011. private _dataView;
  78012. /**
  78013. * byte offset of data in array buffer
  78014. */
  78015. private _byteOffset;
  78016. /**
  78017. * Initialize binary writer with an initial byte length
  78018. * @param byteLength Initial byte length of the array buffer
  78019. */
  78020. constructor(byteLength: number);
  78021. /**
  78022. * Resize the array buffer to the specified byte length
  78023. * @param byteLength
  78024. */
  78025. private resizeBuffer;
  78026. /**
  78027. * Get an array buffer with the length of the byte offset
  78028. * @returns ArrayBuffer resized to the byte offset
  78029. */
  78030. getArrayBuffer(): ArrayBuffer;
  78031. /**
  78032. * Get the byte offset of the array buffer
  78033. * @returns byte offset
  78034. */
  78035. getByteOffset(): number;
  78036. /**
  78037. * Stores an UInt8 in the array buffer
  78038. * @param entry
  78039. * @param byteOffset If defined, specifies where to set the value as an offset.
  78040. */
  78041. setUInt8(entry: number, byteOffset?: number): void;
  78042. /**
  78043. * Gets an UInt32 in the array buffer
  78044. * @param entry
  78045. * @param byteOffset If defined, specifies where to set the value as an offset.
  78046. */
  78047. getUInt32(byteOffset: number): number;
  78048. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78049. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78050. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78051. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78052. /**
  78053. * Stores a Float32 in the array buffer
  78054. * @param entry
  78055. */
  78056. setFloat32(entry: number, byteOffset?: number): void;
  78057. /**
  78058. * Stores an UInt32 in the array buffer
  78059. * @param entry
  78060. * @param byteOffset If defined, specifies where to set the value as an offset.
  78061. */
  78062. setUInt32(entry: number, byteOffset?: number): void;
  78063. }
  78064. }
  78065. declare module BABYLON.GLTF2.Exporter {
  78066. /**
  78067. * @hidden
  78068. * Interface to store animation data.
  78069. */
  78070. export interface _IAnimationData {
  78071. /**
  78072. * Keyframe data.
  78073. */
  78074. inputs: number[];
  78075. /**
  78076. * Value data.
  78077. */
  78078. outputs: number[][];
  78079. /**
  78080. * Animation interpolation data.
  78081. */
  78082. samplerInterpolation: AnimationSamplerInterpolation;
  78083. /**
  78084. * Minimum keyframe value.
  78085. */
  78086. inputsMin: number;
  78087. /**
  78088. * Maximum keyframe value.
  78089. */
  78090. inputsMax: number;
  78091. }
  78092. /**
  78093. * @hidden
  78094. */
  78095. export interface _IAnimationInfo {
  78096. /**
  78097. * The target channel for the animation
  78098. */
  78099. animationChannelTargetPath: AnimationChannelTargetPath;
  78100. /**
  78101. * The glTF accessor type for the data.
  78102. */
  78103. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78104. /**
  78105. * Specifies if quaternions should be used.
  78106. */
  78107. useQuaternion: boolean;
  78108. }
  78109. /**
  78110. * @hidden
  78111. * Utility class for generating glTF animation data from BabylonJS.
  78112. */
  78113. export class _GLTFAnimation {
  78114. /**
  78115. * @ignore
  78116. *
  78117. * Creates glTF channel animation from BabylonJS animation.
  78118. * @param babylonTransformNode - BabylonJS mesh.
  78119. * @param animation - animation.
  78120. * @param animationChannelTargetPath - The target animation channel.
  78121. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78122. * @param useQuaternion - Specifies if quaternions are used.
  78123. * @returns nullable IAnimationData
  78124. */
  78125. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78126. private static _DeduceAnimationInfo;
  78127. /**
  78128. * @ignore
  78129. * Create node animations from the transform node animations
  78130. * @param babylonNode
  78131. * @param runtimeGLTFAnimation
  78132. * @param idleGLTFAnimations
  78133. * @param nodeMap
  78134. * @param nodes
  78135. * @param binaryWriter
  78136. * @param bufferViews
  78137. * @param accessors
  78138. * @param convertToRightHandedSystem
  78139. * @param animationSampleRate
  78140. */
  78141. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78142. [key: number]: number;
  78143. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78144. /**
  78145. * @ignore
  78146. * Create node animations from the animation groups
  78147. * @param babylonScene
  78148. * @param glTFAnimations
  78149. * @param nodeMap
  78150. * @param nodes
  78151. * @param binaryWriter
  78152. * @param bufferViews
  78153. * @param accessors
  78154. * @param convertToRightHandedSystemMap
  78155. * @param animationSampleRate
  78156. */
  78157. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78158. [key: number]: number;
  78159. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78160. [nodeId: number]: boolean;
  78161. }, animationSampleRate: number): void;
  78162. private static AddAnimation;
  78163. /**
  78164. * Create a baked animation
  78165. * @param babylonTransformNode BabylonJS mesh
  78166. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78167. * @param animationChannelTargetPath animation target channel
  78168. * @param minFrame minimum animation frame
  78169. * @param maxFrame maximum animation frame
  78170. * @param fps frames per second of the animation
  78171. * @param inputs input key frames of the animation
  78172. * @param outputs output key frame data of the animation
  78173. * @param convertToRightHandedSystem converts the values to right-handed
  78174. * @param useQuaternion specifies if quaternions should be used
  78175. */
  78176. private static _CreateBakedAnimation;
  78177. private static _ConvertFactorToVector3OrQuaternion;
  78178. private static _SetInterpolatedValue;
  78179. /**
  78180. * Creates linear animation from the animation key frames
  78181. * @param babylonTransformNode BabylonJS mesh
  78182. * @param animation BabylonJS animation
  78183. * @param animationChannelTargetPath The target animation channel
  78184. * @param frameDelta The difference between the last and first frame of the animation
  78185. * @param inputs Array to store the key frame times
  78186. * @param outputs Array to store the key frame data
  78187. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78188. * @param useQuaternion Specifies if quaternions are used in the animation
  78189. */
  78190. private static _CreateLinearOrStepAnimation;
  78191. /**
  78192. * Creates cubic spline animation from the animation key frames
  78193. * @param babylonTransformNode BabylonJS mesh
  78194. * @param animation BabylonJS animation
  78195. * @param animationChannelTargetPath The target animation channel
  78196. * @param frameDelta The difference between the last and first frame of the animation
  78197. * @param inputs Array to store the key frame times
  78198. * @param outputs Array to store the key frame data
  78199. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78200. * @param useQuaternion Specifies if quaternions are used in the animation
  78201. */
  78202. private static _CreateCubicSplineAnimation;
  78203. private static _GetBasePositionRotationOrScale;
  78204. /**
  78205. * Adds a key frame value
  78206. * @param keyFrame
  78207. * @param animation
  78208. * @param outputs
  78209. * @param animationChannelTargetPath
  78210. * @param basePositionRotationOrScale
  78211. * @param convertToRightHandedSystem
  78212. * @param useQuaternion
  78213. */
  78214. private static _AddKeyframeValue;
  78215. /**
  78216. * Determine the interpolation based on the key frames
  78217. * @param keyFrames
  78218. * @param animationChannelTargetPath
  78219. * @param useQuaternion
  78220. */
  78221. private static _DeduceInterpolation;
  78222. /**
  78223. * Adds an input tangent or output tangent to the output data
  78224. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78225. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78226. * @param outputs The animation data by keyframe
  78227. * @param animationChannelTargetPath The target animation channel
  78228. * @param interpolation The interpolation type
  78229. * @param keyFrame The key frame with the animation data
  78230. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78231. * @param useQuaternion Specifies if quaternions are used
  78232. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78233. */
  78234. private static AddSplineTangent;
  78235. /**
  78236. * Get the minimum and maximum key frames' frame values
  78237. * @param keyFrames animation key frames
  78238. * @returns the minimum and maximum key frame value
  78239. */
  78240. private static calculateMinMaxKeyFrames;
  78241. }
  78242. }
  78243. declare module BABYLON.GLTF2.Exporter {
  78244. /** @hidden */
  78245. export var textureTransformPixelShader: {
  78246. name: string;
  78247. shader: string;
  78248. };
  78249. }
  78250. declare module BABYLON.GLTF2.Exporter.Extensions {
  78251. /**
  78252. * @hidden
  78253. */
  78254. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78255. private _recordedTextures;
  78256. /** Name of this extension */
  78257. readonly name: string;
  78258. /** Defines whether this extension is enabled */
  78259. enabled: boolean;
  78260. /** Defines whether this extension is required */
  78261. required: boolean;
  78262. /** Reference to the glTF exporter */
  78263. private _wasUsed;
  78264. constructor(exporter: _Exporter);
  78265. dispose(): void;
  78266. /** @hidden */
  78267. get wasUsed(): boolean;
  78268. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78269. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78270. /**
  78271. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78272. * @param babylonTexture
  78273. * @param offset
  78274. * @param rotation
  78275. * @param scale
  78276. * @param scene
  78277. */
  78278. private _textureTransformTextureAsync;
  78279. }
  78280. }
  78281. declare module BABYLON.GLTF2.Exporter.Extensions {
  78282. /**
  78283. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78284. */
  78285. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78286. /** The name of this extension. */
  78287. readonly name: string;
  78288. /** Defines whether this extension is enabled. */
  78289. enabled: boolean;
  78290. /** Defines whether this extension is required */
  78291. required: boolean;
  78292. /** Reference to the glTF exporter */
  78293. private _exporter;
  78294. private _lights;
  78295. /** @hidden */
  78296. constructor(exporter: _Exporter);
  78297. /** @hidden */
  78298. dispose(): void;
  78299. /** @hidden */
  78300. get wasUsed(): boolean;
  78301. /** @hidden */
  78302. onExporting(): void;
  78303. /**
  78304. * Define this method to modify the default behavior when exporting a node
  78305. * @param context The context when exporting the node
  78306. * @param node glTF node
  78307. * @param babylonNode BabylonJS node
  78308. * @param nodeMap Node mapping of unique id to glTF node index
  78309. * @returns nullable INode promise
  78310. */
  78311. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78312. [key: number]: number;
  78313. }): Promise<Nullable<INode>>;
  78314. }
  78315. }
  78316. declare module BABYLON.GLTF2.Exporter.Extensions {
  78317. /**
  78318. * @hidden
  78319. */
  78320. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78321. /** Name of this extension */
  78322. readonly name: string;
  78323. /** Defines whether this extension is enabled */
  78324. enabled: boolean;
  78325. /** Defines whether this extension is required */
  78326. required: boolean;
  78327. /** Reference to the glTF exporter */
  78328. private _textureInfos;
  78329. private _exportedTextures;
  78330. private _wasUsed;
  78331. constructor(exporter: _Exporter);
  78332. dispose(): void;
  78333. /** @hidden */
  78334. get wasUsed(): boolean;
  78335. private _getTextureIndex;
  78336. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78337. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78338. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78339. }
  78340. }
  78341. declare module BABYLON {
  78342. /**
  78343. * Class for generating STL data from a Babylon scene.
  78344. */
  78345. export class STLExport {
  78346. /**
  78347. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78348. * @param meshes list defines the mesh to serialize
  78349. * @param download triggers the automatic download of the file.
  78350. * @param fileName changes the downloads fileName.
  78351. * @param binary changes the STL to a binary type.
  78352. * @param isLittleEndian toggle for binary type exporter.
  78353. * @returns the STL as UTF8 string
  78354. */
  78355. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78356. }
  78357. }
  78358. declare module "babylonjs-gltf2interface" {
  78359. export = BABYLON.GLTF2;
  78360. }
  78361. /**
  78362. * Module for glTF 2.0 Interface
  78363. */
  78364. declare module BABYLON.GLTF2 {
  78365. /**
  78366. * The datatype of the components in the attribute
  78367. */
  78368. const enum AccessorComponentType {
  78369. /**
  78370. * Byte
  78371. */
  78372. BYTE = 5120,
  78373. /**
  78374. * Unsigned Byte
  78375. */
  78376. UNSIGNED_BYTE = 5121,
  78377. /**
  78378. * Short
  78379. */
  78380. SHORT = 5122,
  78381. /**
  78382. * Unsigned Short
  78383. */
  78384. UNSIGNED_SHORT = 5123,
  78385. /**
  78386. * Unsigned Int
  78387. */
  78388. UNSIGNED_INT = 5125,
  78389. /**
  78390. * Float
  78391. */
  78392. FLOAT = 5126,
  78393. }
  78394. /**
  78395. * Specifies if the attirbute is a scalar, vector, or matrix
  78396. */
  78397. const enum AccessorType {
  78398. /**
  78399. * Scalar
  78400. */
  78401. SCALAR = "SCALAR",
  78402. /**
  78403. * Vector2
  78404. */
  78405. VEC2 = "VEC2",
  78406. /**
  78407. * Vector3
  78408. */
  78409. VEC3 = "VEC3",
  78410. /**
  78411. * Vector4
  78412. */
  78413. VEC4 = "VEC4",
  78414. /**
  78415. * Matrix2x2
  78416. */
  78417. MAT2 = "MAT2",
  78418. /**
  78419. * Matrix3x3
  78420. */
  78421. MAT3 = "MAT3",
  78422. /**
  78423. * Matrix4x4
  78424. */
  78425. MAT4 = "MAT4",
  78426. }
  78427. /**
  78428. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78429. */
  78430. const enum AnimationChannelTargetPath {
  78431. /**
  78432. * Translation
  78433. */
  78434. TRANSLATION = "translation",
  78435. /**
  78436. * Rotation
  78437. */
  78438. ROTATION = "rotation",
  78439. /**
  78440. * Scale
  78441. */
  78442. SCALE = "scale",
  78443. /**
  78444. * Weights
  78445. */
  78446. WEIGHTS = "weights",
  78447. }
  78448. /**
  78449. * Interpolation algorithm
  78450. */
  78451. const enum AnimationSamplerInterpolation {
  78452. /**
  78453. * The animated values are linearly interpolated between keyframes
  78454. */
  78455. LINEAR = "LINEAR",
  78456. /**
  78457. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78458. */
  78459. STEP = "STEP",
  78460. /**
  78461. * The animation's interpolation is computed using a cubic spline with specified tangents
  78462. */
  78463. CUBICSPLINE = "CUBICSPLINE",
  78464. }
  78465. /**
  78466. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78467. */
  78468. const enum CameraType {
  78469. /**
  78470. * A perspective camera containing properties to create a perspective projection matrix
  78471. */
  78472. PERSPECTIVE = "perspective",
  78473. /**
  78474. * An orthographic camera containing properties to create an orthographic projection matrix
  78475. */
  78476. ORTHOGRAPHIC = "orthographic",
  78477. }
  78478. /**
  78479. * The mime-type of the image
  78480. */
  78481. const enum ImageMimeType {
  78482. /**
  78483. * JPEG Mime-type
  78484. */
  78485. JPEG = "image/jpeg",
  78486. /**
  78487. * PNG Mime-type
  78488. */
  78489. PNG = "image/png",
  78490. }
  78491. /**
  78492. * The alpha rendering mode of the material
  78493. */
  78494. const enum MaterialAlphaMode {
  78495. /**
  78496. * The alpha value is ignored and the rendered output is fully opaque
  78497. */
  78498. OPAQUE = "OPAQUE",
  78499. /**
  78500. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78501. */
  78502. MASK = "MASK",
  78503. /**
  78504. * 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)
  78505. */
  78506. BLEND = "BLEND",
  78507. }
  78508. /**
  78509. * The type of the primitives to render
  78510. */
  78511. const enum MeshPrimitiveMode {
  78512. /**
  78513. * Points
  78514. */
  78515. POINTS = 0,
  78516. /**
  78517. * Lines
  78518. */
  78519. LINES = 1,
  78520. /**
  78521. * Line Loop
  78522. */
  78523. LINE_LOOP = 2,
  78524. /**
  78525. * Line Strip
  78526. */
  78527. LINE_STRIP = 3,
  78528. /**
  78529. * Triangles
  78530. */
  78531. TRIANGLES = 4,
  78532. /**
  78533. * Triangle Strip
  78534. */
  78535. TRIANGLE_STRIP = 5,
  78536. /**
  78537. * Triangle Fan
  78538. */
  78539. TRIANGLE_FAN = 6,
  78540. }
  78541. /**
  78542. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78543. */
  78544. const enum TextureMagFilter {
  78545. /**
  78546. * Nearest
  78547. */
  78548. NEAREST = 9728,
  78549. /**
  78550. * Linear
  78551. */
  78552. LINEAR = 9729,
  78553. }
  78554. /**
  78555. * Minification filter. All valid values correspond to WebGL enums
  78556. */
  78557. const enum TextureMinFilter {
  78558. /**
  78559. * Nearest
  78560. */
  78561. NEAREST = 9728,
  78562. /**
  78563. * Linear
  78564. */
  78565. LINEAR = 9729,
  78566. /**
  78567. * Nearest Mip-Map Nearest
  78568. */
  78569. NEAREST_MIPMAP_NEAREST = 9984,
  78570. /**
  78571. * Linear Mipmap Nearest
  78572. */
  78573. LINEAR_MIPMAP_NEAREST = 9985,
  78574. /**
  78575. * Nearest Mipmap Linear
  78576. */
  78577. NEAREST_MIPMAP_LINEAR = 9986,
  78578. /**
  78579. * Linear Mipmap Linear
  78580. */
  78581. LINEAR_MIPMAP_LINEAR = 9987,
  78582. }
  78583. /**
  78584. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78585. */
  78586. const enum TextureWrapMode {
  78587. /**
  78588. * Clamp to Edge
  78589. */
  78590. CLAMP_TO_EDGE = 33071,
  78591. /**
  78592. * Mirrored Repeat
  78593. */
  78594. MIRRORED_REPEAT = 33648,
  78595. /**
  78596. * Repeat
  78597. */
  78598. REPEAT = 10497,
  78599. }
  78600. /**
  78601. * glTF Property
  78602. */
  78603. interface IProperty {
  78604. /**
  78605. * Dictionary object with extension-specific objects
  78606. */
  78607. extensions?: {
  78608. [key: string]: any;
  78609. };
  78610. /**
  78611. * Application-Specific data
  78612. */
  78613. extras?: any;
  78614. }
  78615. /**
  78616. * glTF Child of Root Property
  78617. */
  78618. interface IChildRootProperty extends IProperty {
  78619. /**
  78620. * The user-defined name of this object
  78621. */
  78622. name?: string;
  78623. }
  78624. /**
  78625. * Indices of those attributes that deviate from their initialization value
  78626. */
  78627. interface IAccessorSparseIndices extends IProperty {
  78628. /**
  78629. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78630. */
  78631. bufferView: number;
  78632. /**
  78633. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78634. */
  78635. byteOffset?: number;
  78636. /**
  78637. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78638. */
  78639. componentType: AccessorComponentType;
  78640. }
  78641. /**
  78642. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78643. */
  78644. interface IAccessorSparseValues extends IProperty {
  78645. /**
  78646. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78647. */
  78648. bufferView: number;
  78649. /**
  78650. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78651. */
  78652. byteOffset?: number;
  78653. }
  78654. /**
  78655. * Sparse storage of attributes that deviate from their initialization value
  78656. */
  78657. interface IAccessorSparse extends IProperty {
  78658. /**
  78659. * The number of attributes encoded in this sparse accessor
  78660. */
  78661. count: number;
  78662. /**
  78663. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78664. */
  78665. indices: IAccessorSparseIndices;
  78666. /**
  78667. * 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
  78668. */
  78669. values: IAccessorSparseValues;
  78670. }
  78671. /**
  78672. * 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
  78673. */
  78674. interface IAccessor extends IChildRootProperty {
  78675. /**
  78676. * The index of the bufferview
  78677. */
  78678. bufferView?: number;
  78679. /**
  78680. * The offset relative to the start of the bufferView in bytes
  78681. */
  78682. byteOffset?: number;
  78683. /**
  78684. * The datatype of components in the attribute
  78685. */
  78686. componentType: AccessorComponentType;
  78687. /**
  78688. * Specifies whether integer data values should be normalized
  78689. */
  78690. normalized?: boolean;
  78691. /**
  78692. * The number of attributes referenced by this accessor
  78693. */
  78694. count: number;
  78695. /**
  78696. * Specifies if the attribute is a scalar, vector, or matrix
  78697. */
  78698. type: AccessorType;
  78699. /**
  78700. * Maximum value of each component in this attribute
  78701. */
  78702. max?: number[];
  78703. /**
  78704. * Minimum value of each component in this attribute
  78705. */
  78706. min?: number[];
  78707. /**
  78708. * Sparse storage of attributes that deviate from their initialization value
  78709. */
  78710. sparse?: IAccessorSparse;
  78711. }
  78712. /**
  78713. * Targets an animation's sampler at a node's property
  78714. */
  78715. interface IAnimationChannel extends IProperty {
  78716. /**
  78717. * The index of a sampler in this animation used to compute the value for the target
  78718. */
  78719. sampler: number;
  78720. /**
  78721. * The index of the node and TRS property to target
  78722. */
  78723. target: IAnimationChannelTarget;
  78724. }
  78725. /**
  78726. * The index of the node and TRS property that an animation channel targets
  78727. */
  78728. interface IAnimationChannelTarget extends IProperty {
  78729. /**
  78730. * The index of the node to target
  78731. */
  78732. node: number;
  78733. /**
  78734. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78735. */
  78736. path: AnimationChannelTargetPath;
  78737. }
  78738. /**
  78739. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78740. */
  78741. interface IAnimationSampler extends IProperty {
  78742. /**
  78743. * The index of an accessor containing keyframe input values, e.g., time
  78744. */
  78745. input: number;
  78746. /**
  78747. * Interpolation algorithm
  78748. */
  78749. interpolation?: AnimationSamplerInterpolation;
  78750. /**
  78751. * The index of an accessor, containing keyframe output values
  78752. */
  78753. output: number;
  78754. }
  78755. /**
  78756. * A keyframe animation
  78757. */
  78758. interface IAnimation extends IChildRootProperty {
  78759. /**
  78760. * An array of channels, each of which targets an animation's sampler at a node's property
  78761. */
  78762. channels: IAnimationChannel[];
  78763. /**
  78764. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78765. */
  78766. samplers: IAnimationSampler[];
  78767. }
  78768. /**
  78769. * Metadata about the glTF asset
  78770. */
  78771. interface IAsset extends IChildRootProperty {
  78772. /**
  78773. * A copyright message suitable for display to credit the content creator
  78774. */
  78775. copyright?: string;
  78776. /**
  78777. * Tool that generated this glTF model. Useful for debugging
  78778. */
  78779. generator?: string;
  78780. /**
  78781. * The glTF version that this asset targets
  78782. */
  78783. version: string;
  78784. /**
  78785. * The minimum glTF version that this asset targets
  78786. */
  78787. minVersion?: string;
  78788. }
  78789. /**
  78790. * A buffer points to binary geometry, animation, or skins
  78791. */
  78792. interface IBuffer extends IChildRootProperty {
  78793. /**
  78794. * 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
  78795. */
  78796. uri?: string;
  78797. /**
  78798. * The length of the buffer in bytes
  78799. */
  78800. byteLength: number;
  78801. }
  78802. /**
  78803. * A view into a buffer generally representing a subset of the buffer
  78804. */
  78805. interface IBufferView extends IChildRootProperty {
  78806. /**
  78807. * The index of the buffer
  78808. */
  78809. buffer: number;
  78810. /**
  78811. * The offset into the buffer in bytes
  78812. */
  78813. byteOffset?: number;
  78814. /**
  78815. * The lenth of the bufferView in bytes
  78816. */
  78817. byteLength: number;
  78818. /**
  78819. * The stride, in bytes
  78820. */
  78821. byteStride?: number;
  78822. }
  78823. /**
  78824. * An orthographic camera containing properties to create an orthographic projection matrix
  78825. */
  78826. interface ICameraOrthographic extends IProperty {
  78827. /**
  78828. * The floating-point horizontal magnification of the view. Must not be zero
  78829. */
  78830. xmag: number;
  78831. /**
  78832. * The floating-point vertical magnification of the view. Must not be zero
  78833. */
  78834. ymag: number;
  78835. /**
  78836. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78837. */
  78838. zfar: number;
  78839. /**
  78840. * The floating-point distance to the near clipping plane
  78841. */
  78842. znear: number;
  78843. }
  78844. /**
  78845. * A perspective camera containing properties to create a perspective projection matrix
  78846. */
  78847. interface ICameraPerspective extends IProperty {
  78848. /**
  78849. * The floating-point aspect ratio of the field of view
  78850. */
  78851. aspectRatio?: number;
  78852. /**
  78853. * The floating-point vertical field of view in radians
  78854. */
  78855. yfov: number;
  78856. /**
  78857. * The floating-point distance to the far clipping plane
  78858. */
  78859. zfar?: number;
  78860. /**
  78861. * The floating-point distance to the near clipping plane
  78862. */
  78863. znear: number;
  78864. }
  78865. /**
  78866. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78867. */
  78868. interface ICamera extends IChildRootProperty {
  78869. /**
  78870. * An orthographic camera containing properties to create an orthographic projection matrix
  78871. */
  78872. orthographic?: ICameraOrthographic;
  78873. /**
  78874. * A perspective camera containing properties to create a perspective projection matrix
  78875. */
  78876. perspective?: ICameraPerspective;
  78877. /**
  78878. * Specifies if the camera uses a perspective or orthographic projection
  78879. */
  78880. type: CameraType;
  78881. }
  78882. /**
  78883. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78884. */
  78885. interface IImage extends IChildRootProperty {
  78886. /**
  78887. * 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
  78888. */
  78889. uri?: string;
  78890. /**
  78891. * The image's MIME type
  78892. */
  78893. mimeType?: ImageMimeType;
  78894. /**
  78895. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78896. */
  78897. bufferView?: number;
  78898. }
  78899. /**
  78900. * Material Normal Texture Info
  78901. */
  78902. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78903. /**
  78904. * The scalar multiplier applied to each normal vector of the normal texture
  78905. */
  78906. scale?: number;
  78907. }
  78908. /**
  78909. * Material Occlusion Texture Info
  78910. */
  78911. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78912. /**
  78913. * A scalar multiplier controlling the amount of occlusion applied
  78914. */
  78915. strength?: number;
  78916. }
  78917. /**
  78918. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78919. */
  78920. interface IMaterialPbrMetallicRoughness {
  78921. /**
  78922. * The material's base color factor
  78923. */
  78924. baseColorFactor?: number[];
  78925. /**
  78926. * The base color texture
  78927. */
  78928. baseColorTexture?: ITextureInfo;
  78929. /**
  78930. * The metalness of the material
  78931. */
  78932. metallicFactor?: number;
  78933. /**
  78934. * The roughness of the material
  78935. */
  78936. roughnessFactor?: number;
  78937. /**
  78938. * The metallic-roughness texture
  78939. */
  78940. metallicRoughnessTexture?: ITextureInfo;
  78941. }
  78942. /**
  78943. * The material appearance of a primitive
  78944. */
  78945. interface IMaterial extends IChildRootProperty {
  78946. /**
  78947. * 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
  78948. */
  78949. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78950. /**
  78951. * The normal map texture
  78952. */
  78953. normalTexture?: IMaterialNormalTextureInfo;
  78954. /**
  78955. * The occlusion map texture
  78956. */
  78957. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78958. /**
  78959. * The emissive map texture
  78960. */
  78961. emissiveTexture?: ITextureInfo;
  78962. /**
  78963. * 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
  78964. */
  78965. emissiveFactor?: number[];
  78966. /**
  78967. * The alpha rendering mode of the material
  78968. */
  78969. alphaMode?: MaterialAlphaMode;
  78970. /**
  78971. * The alpha cutoff value of the material
  78972. */
  78973. alphaCutoff?: number;
  78974. /**
  78975. * Specifies whether the material is double sided
  78976. */
  78977. doubleSided?: boolean;
  78978. }
  78979. /**
  78980. * Geometry to be rendered with the given material
  78981. */
  78982. interface IMeshPrimitive extends IProperty {
  78983. /**
  78984. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78985. */
  78986. attributes: {
  78987. [name: string]: number;
  78988. };
  78989. /**
  78990. * The index of the accessor that contains the indices
  78991. */
  78992. indices?: number;
  78993. /**
  78994. * The index of the material to apply to this primitive when rendering
  78995. */
  78996. material?: number;
  78997. /**
  78998. * The type of primitives to render. All valid values correspond to WebGL enums
  78999. */
  79000. mode?: MeshPrimitiveMode;
  79001. /**
  79002. * 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
  79003. */
  79004. targets?: {
  79005. [name: string]: number;
  79006. }[];
  79007. }
  79008. /**
  79009. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79010. */
  79011. interface IMesh extends IChildRootProperty {
  79012. /**
  79013. * An array of primitives, each defining geometry to be rendered with a material
  79014. */
  79015. primitives: IMeshPrimitive[];
  79016. /**
  79017. * Array of weights to be applied to the Morph Targets
  79018. */
  79019. weights?: number[];
  79020. }
  79021. /**
  79022. * A node in the node hierarchy
  79023. */
  79024. interface INode extends IChildRootProperty {
  79025. /**
  79026. * The index of the camera referenced by this node
  79027. */
  79028. camera?: number;
  79029. /**
  79030. * The indices of this node's children
  79031. */
  79032. children?: number[];
  79033. /**
  79034. * The index of the skin referenced by this node
  79035. */
  79036. skin?: number;
  79037. /**
  79038. * A floating-point 4x4 transformation matrix stored in column-major order
  79039. */
  79040. matrix?: number[];
  79041. /**
  79042. * The index of the mesh in this node
  79043. */
  79044. mesh?: number;
  79045. /**
  79046. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79047. */
  79048. rotation?: number[];
  79049. /**
  79050. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79051. */
  79052. scale?: number[];
  79053. /**
  79054. * The node's translation along the x, y, and z axes
  79055. */
  79056. translation?: number[];
  79057. /**
  79058. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79059. */
  79060. weights?: number[];
  79061. }
  79062. /**
  79063. * Texture sampler properties for filtering and wrapping modes
  79064. */
  79065. interface ISampler extends IChildRootProperty {
  79066. /**
  79067. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79068. */
  79069. magFilter?: TextureMagFilter;
  79070. /**
  79071. * Minification filter. All valid values correspond to WebGL enums
  79072. */
  79073. minFilter?: TextureMinFilter;
  79074. /**
  79075. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79076. */
  79077. wrapS?: TextureWrapMode;
  79078. /**
  79079. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79080. */
  79081. wrapT?: TextureWrapMode;
  79082. }
  79083. /**
  79084. * The root nodes of a scene
  79085. */
  79086. interface IScene extends IChildRootProperty {
  79087. /**
  79088. * The indices of each root node
  79089. */
  79090. nodes: number[];
  79091. }
  79092. /**
  79093. * Joints and matrices defining a skin
  79094. */
  79095. interface ISkin extends IChildRootProperty {
  79096. /**
  79097. * 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
  79098. */
  79099. inverseBindMatrices?: number;
  79100. /**
  79101. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79102. */
  79103. skeleton?: number;
  79104. /**
  79105. * 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)
  79106. */
  79107. joints: number[];
  79108. }
  79109. /**
  79110. * A texture and its sampler
  79111. */
  79112. interface ITexture extends IChildRootProperty {
  79113. /**
  79114. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79115. */
  79116. sampler?: number;
  79117. /**
  79118. * The index of the image used by this texture
  79119. */
  79120. source: number;
  79121. }
  79122. /**
  79123. * Reference to a texture
  79124. */
  79125. interface ITextureInfo extends IProperty {
  79126. /**
  79127. * The index of the texture
  79128. */
  79129. index: number;
  79130. /**
  79131. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79132. */
  79133. texCoord?: number;
  79134. }
  79135. /**
  79136. * The root object for a glTF asset
  79137. */
  79138. interface IGLTF extends IProperty {
  79139. /**
  79140. * An array of accessors. An accessor is a typed view into a bufferView
  79141. */
  79142. accessors?: IAccessor[];
  79143. /**
  79144. * An array of keyframe animations
  79145. */
  79146. animations?: IAnimation[];
  79147. /**
  79148. * Metadata about the glTF asset
  79149. */
  79150. asset: IAsset;
  79151. /**
  79152. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79153. */
  79154. buffers?: IBuffer[];
  79155. /**
  79156. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79157. */
  79158. bufferViews?: IBufferView[];
  79159. /**
  79160. * An array of cameras
  79161. */
  79162. cameras?: ICamera[];
  79163. /**
  79164. * Names of glTF extensions used somewhere in this asset
  79165. */
  79166. extensionsUsed?: string[];
  79167. /**
  79168. * Names of glTF extensions required to properly load this asset
  79169. */
  79170. extensionsRequired?: string[];
  79171. /**
  79172. * An array of images. An image defines data used to create a texture
  79173. */
  79174. images?: IImage[];
  79175. /**
  79176. * An array of materials. A material defines the appearance of a primitive
  79177. */
  79178. materials?: IMaterial[];
  79179. /**
  79180. * An array of meshes. A mesh is a set of primitives to be rendered
  79181. */
  79182. meshes?: IMesh[];
  79183. /**
  79184. * An array of nodes
  79185. */
  79186. nodes?: INode[];
  79187. /**
  79188. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79189. */
  79190. samplers?: ISampler[];
  79191. /**
  79192. * The index of the default scene
  79193. */
  79194. scene?: number;
  79195. /**
  79196. * An array of scenes
  79197. */
  79198. scenes?: IScene[];
  79199. /**
  79200. * An array of skins. A skin is defined by joints and matrices
  79201. */
  79202. skins?: ISkin[];
  79203. /**
  79204. * An array of textures
  79205. */
  79206. textures?: ITexture[];
  79207. }
  79208. /**
  79209. * The glTF validation results
  79210. * @ignore
  79211. */
  79212. interface IGLTFValidationResults {
  79213. info: {
  79214. generator: string;
  79215. hasAnimations: boolean;
  79216. hasDefaultScene: boolean;
  79217. hasMaterials: boolean;
  79218. hasMorphTargets: boolean;
  79219. hasSkins: boolean;
  79220. hasTextures: boolean;
  79221. maxAttributesUsed: number;
  79222. primitivesCount: number
  79223. };
  79224. issues: {
  79225. messages: Array<string>;
  79226. numErrors: number;
  79227. numHints: number;
  79228. numInfos: number;
  79229. numWarnings: number;
  79230. truncated: boolean
  79231. };
  79232. mimeType: string;
  79233. uri: string;
  79234. validatedAt: string;
  79235. validatorVersion: string;
  79236. }
  79237. /**
  79238. * The glTF validation options
  79239. */
  79240. interface IGLTFValidationOptions {
  79241. /** Uri to use */
  79242. uri?: string;
  79243. /** Function used to load external resources */
  79244. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79245. /** Boolean indicating that we need to validate accessor data */
  79246. validateAccessorData?: boolean;
  79247. /** max number of issues allowed */
  79248. maxIssues?: number;
  79249. /** Ignored issues */
  79250. ignoredIssues?: Array<string>;
  79251. /** Value to override severy settings */
  79252. severityOverrides?: Object;
  79253. }
  79254. /**
  79255. * The glTF validator object
  79256. * @ignore
  79257. */
  79258. interface IGLTFValidator {
  79259. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79260. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79261. }
  79262. }
  79263. declare module BABYLON {
  79264. /** @hidden */
  79265. export var cellPixelShader: {
  79266. name: string;
  79267. shader: string;
  79268. };
  79269. }
  79270. declare module BABYLON {
  79271. /** @hidden */
  79272. export var cellVertexShader: {
  79273. name: string;
  79274. shader: string;
  79275. };
  79276. }
  79277. declare module BABYLON {
  79278. export class CellMaterial extends BABYLON.PushMaterial {
  79279. private _diffuseTexture;
  79280. diffuseTexture: BABYLON.BaseTexture;
  79281. diffuseColor: BABYLON.Color3;
  79282. _computeHighLevel: boolean;
  79283. computeHighLevel: boolean;
  79284. private _disableLighting;
  79285. disableLighting: boolean;
  79286. private _maxSimultaneousLights;
  79287. maxSimultaneousLights: number;
  79288. private _renderId;
  79289. constructor(name: string, scene: BABYLON.Scene);
  79290. needAlphaBlending(): boolean;
  79291. needAlphaTesting(): boolean;
  79292. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79293. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79294. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79295. getAnimatables(): BABYLON.IAnimatable[];
  79296. getActiveTextures(): BABYLON.BaseTexture[];
  79297. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79298. dispose(forceDisposeEffect?: boolean): void;
  79299. getClassName(): string;
  79300. clone(name: string): CellMaterial;
  79301. serialize(): any;
  79302. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79303. }
  79304. }
  79305. declare module BABYLON {
  79306. export class CustomShaderStructure {
  79307. FragmentStore: string;
  79308. VertexStore: string;
  79309. constructor();
  79310. }
  79311. export class ShaderSpecialParts {
  79312. constructor();
  79313. Fragment_Begin: string;
  79314. Fragment_Definitions: string;
  79315. Fragment_MainBegin: string;
  79316. Fragment_Custom_Diffuse: string;
  79317. Fragment_Before_Lights: string;
  79318. Fragment_Before_Fog: string;
  79319. Fragment_Custom_Alpha: string;
  79320. Fragment_Before_FragColor: string;
  79321. Vertex_Begin: string;
  79322. Vertex_Definitions: string;
  79323. Vertex_MainBegin: string;
  79324. Vertex_Before_PositionUpdated: string;
  79325. Vertex_Before_NormalUpdated: string;
  79326. Vertex_MainEnd: string;
  79327. }
  79328. export class CustomMaterial extends BABYLON.StandardMaterial {
  79329. static ShaderIndexer: number;
  79330. CustomParts: ShaderSpecialParts;
  79331. _isCreatedShader: boolean;
  79332. _createdShaderName: string;
  79333. _customUniform: string[];
  79334. _newUniforms: string[];
  79335. _newUniformInstances: any[];
  79336. _newSamplerInstances: BABYLON.Texture[];
  79337. FragmentShader: string;
  79338. VertexShader: string;
  79339. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79340. ReviewUniform(name: string, arr: string[]): string[];
  79341. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  79342. constructor(name: string, scene: BABYLON.Scene);
  79343. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79344. Fragment_Begin(shaderPart: string): CustomMaterial;
  79345. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79346. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79347. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79348. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79349. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79350. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79351. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79352. Vertex_Begin(shaderPart: string): CustomMaterial;
  79353. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79354. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79355. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79356. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79357. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79358. }
  79359. }
  79360. declare module BABYLON {
  79361. export class ShaderAlebdoParts {
  79362. constructor();
  79363. Fragment_Begin: string;
  79364. Fragment_Definitions: string;
  79365. Fragment_MainBegin: string;
  79366. Fragment_Custom_Albedo: string;
  79367. Fragment_Before_Lights: string;
  79368. Fragment_Custom_MetallicRoughness: string;
  79369. Fragment_Custom_MicroSurface: string;
  79370. Fragment_Before_Fog: string;
  79371. Fragment_Custom_Alpha: string;
  79372. Fragment_Before_FragColor: string;
  79373. Vertex_Begin: string;
  79374. Vertex_Definitions: string;
  79375. Vertex_MainBegin: string;
  79376. Vertex_Before_PositionUpdated: string;
  79377. Vertex_Before_NormalUpdated: string;
  79378. Vertex_MainEnd: string;
  79379. }
  79380. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79381. static ShaderIndexer: number;
  79382. CustomParts: ShaderAlebdoParts;
  79383. _isCreatedShader: boolean;
  79384. _createdShaderName: string;
  79385. _customUniform: string[];
  79386. _newUniforms: string[];
  79387. _newUniformInstances: any[];
  79388. _newSamplerInstances: BABYLON.Texture[];
  79389. FragmentShader: string;
  79390. VertexShader: string;
  79391. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79392. ReviewUniform(name: string, arr: string[]): string[];
  79393. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  79394. constructor(name: string, scene: BABYLON.Scene);
  79395. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79396. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79397. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79398. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79399. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79400. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79401. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79402. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79403. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79404. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79405. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79406. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79407. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79408. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79409. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79410. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79411. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79412. }
  79413. }
  79414. declare module BABYLON {
  79415. /** @hidden */
  79416. export var firePixelShader: {
  79417. name: string;
  79418. shader: string;
  79419. };
  79420. }
  79421. declare module BABYLON {
  79422. /** @hidden */
  79423. export var fireVertexShader: {
  79424. name: string;
  79425. shader: string;
  79426. };
  79427. }
  79428. declare module BABYLON {
  79429. export class FireMaterial extends BABYLON.PushMaterial {
  79430. private _diffuseTexture;
  79431. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79432. private _distortionTexture;
  79433. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79434. private _opacityTexture;
  79435. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79436. diffuseColor: BABYLON.Color3;
  79437. speed: number;
  79438. private _scaledDiffuse;
  79439. private _renderId;
  79440. private _lastTime;
  79441. constructor(name: string, scene: BABYLON.Scene);
  79442. needAlphaBlending(): boolean;
  79443. needAlphaTesting(): boolean;
  79444. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79445. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79446. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79447. getAnimatables(): BABYLON.IAnimatable[];
  79448. getActiveTextures(): BABYLON.BaseTexture[];
  79449. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79450. getClassName(): string;
  79451. dispose(forceDisposeEffect?: boolean): void;
  79452. clone(name: string): FireMaterial;
  79453. serialize(): any;
  79454. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79455. }
  79456. }
  79457. declare module BABYLON {
  79458. /** @hidden */
  79459. export var furPixelShader: {
  79460. name: string;
  79461. shader: string;
  79462. };
  79463. }
  79464. declare module BABYLON {
  79465. /** @hidden */
  79466. export var furVertexShader: {
  79467. name: string;
  79468. shader: string;
  79469. };
  79470. }
  79471. declare module BABYLON {
  79472. export class FurMaterial extends BABYLON.PushMaterial {
  79473. private _diffuseTexture;
  79474. diffuseTexture: BABYLON.BaseTexture;
  79475. private _heightTexture;
  79476. heightTexture: BABYLON.BaseTexture;
  79477. diffuseColor: BABYLON.Color3;
  79478. furLength: number;
  79479. furAngle: number;
  79480. furColor: BABYLON.Color3;
  79481. furOffset: number;
  79482. furSpacing: number;
  79483. furGravity: BABYLON.Vector3;
  79484. furSpeed: number;
  79485. furDensity: number;
  79486. furOcclusion: number;
  79487. furTexture: BABYLON.DynamicTexture;
  79488. private _disableLighting;
  79489. disableLighting: boolean;
  79490. private _maxSimultaneousLights;
  79491. maxSimultaneousLights: number;
  79492. highLevelFur: boolean;
  79493. _meshes: BABYLON.AbstractMesh[];
  79494. private _renderId;
  79495. private _furTime;
  79496. constructor(name: string, scene: BABYLON.Scene);
  79497. get furTime(): number;
  79498. set furTime(furTime: number);
  79499. needAlphaBlending(): boolean;
  79500. needAlphaTesting(): boolean;
  79501. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79502. updateFur(): void;
  79503. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79504. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79505. getAnimatables(): BABYLON.IAnimatable[];
  79506. getActiveTextures(): BABYLON.BaseTexture[];
  79507. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79508. dispose(forceDisposeEffect?: boolean): void;
  79509. clone(name: string): FurMaterial;
  79510. serialize(): any;
  79511. getClassName(): string;
  79512. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79513. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79514. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79515. }
  79516. }
  79517. declare module BABYLON {
  79518. /** @hidden */
  79519. export var gradientPixelShader: {
  79520. name: string;
  79521. shader: string;
  79522. };
  79523. }
  79524. declare module BABYLON {
  79525. /** @hidden */
  79526. export var gradientVertexShader: {
  79527. name: string;
  79528. shader: string;
  79529. };
  79530. }
  79531. declare module BABYLON {
  79532. export class GradientMaterial extends BABYLON.PushMaterial {
  79533. private _maxSimultaneousLights;
  79534. maxSimultaneousLights: number;
  79535. topColor: BABYLON.Color3;
  79536. topColorAlpha: number;
  79537. bottomColor: BABYLON.Color3;
  79538. bottomColorAlpha: number;
  79539. offset: number;
  79540. scale: number;
  79541. smoothness: number;
  79542. private _disableLighting;
  79543. disableLighting: boolean;
  79544. private _renderId;
  79545. constructor(name: string, scene: BABYLON.Scene);
  79546. needAlphaBlending(): boolean;
  79547. needAlphaTesting(): boolean;
  79548. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79549. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79550. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79551. getAnimatables(): BABYLON.IAnimatable[];
  79552. dispose(forceDisposeEffect?: boolean): void;
  79553. clone(name: string): GradientMaterial;
  79554. serialize(): any;
  79555. getClassName(): string;
  79556. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79557. }
  79558. }
  79559. declare module BABYLON {
  79560. /** @hidden */
  79561. export var gridPixelShader: {
  79562. name: string;
  79563. shader: string;
  79564. };
  79565. }
  79566. declare module BABYLON {
  79567. /** @hidden */
  79568. export var gridVertexShader: {
  79569. name: string;
  79570. shader: string;
  79571. };
  79572. }
  79573. declare module BABYLON {
  79574. /**
  79575. * The grid materials allows you to wrap any shape with a grid.
  79576. * Colors are customizable.
  79577. */
  79578. export class GridMaterial extends BABYLON.PushMaterial {
  79579. /**
  79580. * Main color of the grid (e.g. between lines)
  79581. */
  79582. mainColor: BABYLON.Color3;
  79583. /**
  79584. * Color of the grid lines.
  79585. */
  79586. lineColor: BABYLON.Color3;
  79587. /**
  79588. * The scale of the grid compared to unit.
  79589. */
  79590. gridRatio: number;
  79591. /**
  79592. * Allows setting an offset for the grid lines.
  79593. */
  79594. gridOffset: BABYLON.Vector3;
  79595. /**
  79596. * The frequency of thicker lines.
  79597. */
  79598. majorUnitFrequency: number;
  79599. /**
  79600. * The visibility of minor units in the grid.
  79601. */
  79602. minorUnitVisibility: number;
  79603. /**
  79604. * The grid opacity outside of the lines.
  79605. */
  79606. opacity: number;
  79607. /**
  79608. * Determine RBG output is premultiplied by alpha value.
  79609. */
  79610. preMultiplyAlpha: boolean;
  79611. private _opacityTexture;
  79612. opacityTexture: BABYLON.BaseTexture;
  79613. private _gridControl;
  79614. private _renderId;
  79615. /**
  79616. * constructor
  79617. * @param name The name given to the material in order to identify it afterwards.
  79618. * @param scene The scene the material is used in.
  79619. */
  79620. constructor(name: string, scene: BABYLON.Scene);
  79621. /**
  79622. * Returns wehter or not the grid requires alpha blending.
  79623. */
  79624. needAlphaBlending(): boolean;
  79625. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79626. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79627. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79628. /**
  79629. * Dispose the material and its associated resources.
  79630. * @param forceDisposeEffect will also dispose the used effect when true
  79631. */
  79632. dispose(forceDisposeEffect?: boolean): void;
  79633. clone(name: string): GridMaterial;
  79634. serialize(): any;
  79635. getClassName(): string;
  79636. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79637. }
  79638. }
  79639. declare module BABYLON {
  79640. /** @hidden */
  79641. export var lavaPixelShader: {
  79642. name: string;
  79643. shader: string;
  79644. };
  79645. }
  79646. declare module BABYLON {
  79647. /** @hidden */
  79648. export var lavaVertexShader: {
  79649. name: string;
  79650. shader: string;
  79651. };
  79652. }
  79653. declare module BABYLON {
  79654. export class LavaMaterial extends BABYLON.PushMaterial {
  79655. private _diffuseTexture;
  79656. diffuseTexture: BABYLON.BaseTexture;
  79657. noiseTexture: BABYLON.BaseTexture;
  79658. fogColor: BABYLON.Color3;
  79659. speed: number;
  79660. movingSpeed: number;
  79661. lowFrequencySpeed: number;
  79662. fogDensity: number;
  79663. private _lastTime;
  79664. diffuseColor: BABYLON.Color3;
  79665. private _disableLighting;
  79666. disableLighting: boolean;
  79667. private _unlit;
  79668. unlit: boolean;
  79669. private _maxSimultaneousLights;
  79670. maxSimultaneousLights: number;
  79671. private _scaledDiffuse;
  79672. private _renderId;
  79673. constructor(name: string, scene: BABYLON.Scene);
  79674. needAlphaBlending(): boolean;
  79675. needAlphaTesting(): boolean;
  79676. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79677. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79678. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79679. getAnimatables(): BABYLON.IAnimatable[];
  79680. getActiveTextures(): BABYLON.BaseTexture[];
  79681. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79682. dispose(forceDisposeEffect?: boolean): void;
  79683. clone(name: string): LavaMaterial;
  79684. serialize(): any;
  79685. getClassName(): string;
  79686. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79687. }
  79688. }
  79689. declare module BABYLON {
  79690. /** @hidden */
  79691. export var mixPixelShader: {
  79692. name: string;
  79693. shader: string;
  79694. };
  79695. }
  79696. declare module BABYLON {
  79697. /** @hidden */
  79698. export var mixVertexShader: {
  79699. name: string;
  79700. shader: string;
  79701. };
  79702. }
  79703. declare module BABYLON {
  79704. export class MixMaterial extends BABYLON.PushMaterial {
  79705. /**
  79706. * Mix textures
  79707. */
  79708. private _mixTexture1;
  79709. mixTexture1: BABYLON.BaseTexture;
  79710. private _mixTexture2;
  79711. mixTexture2: BABYLON.BaseTexture;
  79712. /**
  79713. * Diffuse textures
  79714. */
  79715. private _diffuseTexture1;
  79716. diffuseTexture1: BABYLON.Texture;
  79717. private _diffuseTexture2;
  79718. diffuseTexture2: BABYLON.Texture;
  79719. private _diffuseTexture3;
  79720. diffuseTexture3: BABYLON.Texture;
  79721. private _diffuseTexture4;
  79722. diffuseTexture4: BABYLON.Texture;
  79723. private _diffuseTexture5;
  79724. diffuseTexture5: BABYLON.Texture;
  79725. private _diffuseTexture6;
  79726. diffuseTexture6: BABYLON.Texture;
  79727. private _diffuseTexture7;
  79728. diffuseTexture7: BABYLON.Texture;
  79729. private _diffuseTexture8;
  79730. diffuseTexture8: BABYLON.Texture;
  79731. /**
  79732. * Uniforms
  79733. */
  79734. diffuseColor: BABYLON.Color3;
  79735. specularColor: BABYLON.Color3;
  79736. specularPower: number;
  79737. private _disableLighting;
  79738. disableLighting: boolean;
  79739. private _maxSimultaneousLights;
  79740. maxSimultaneousLights: number;
  79741. private _renderId;
  79742. constructor(name: string, scene: BABYLON.Scene);
  79743. needAlphaBlending(): boolean;
  79744. needAlphaTesting(): boolean;
  79745. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79746. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79747. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79748. getAnimatables(): BABYLON.IAnimatable[];
  79749. getActiveTextures(): BABYLON.BaseTexture[];
  79750. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79751. dispose(forceDisposeEffect?: boolean): void;
  79752. clone(name: string): MixMaterial;
  79753. serialize(): any;
  79754. getClassName(): string;
  79755. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79756. }
  79757. }
  79758. declare module BABYLON {
  79759. /** @hidden */
  79760. export var normalPixelShader: {
  79761. name: string;
  79762. shader: string;
  79763. };
  79764. }
  79765. declare module BABYLON {
  79766. /** @hidden */
  79767. export var normalVertexShader: {
  79768. name: string;
  79769. shader: string;
  79770. };
  79771. }
  79772. declare module BABYLON {
  79773. export class NormalMaterial extends BABYLON.PushMaterial {
  79774. private _diffuseTexture;
  79775. diffuseTexture: BABYLON.BaseTexture;
  79776. diffuseColor: BABYLON.Color3;
  79777. private _disableLighting;
  79778. disableLighting: boolean;
  79779. private _maxSimultaneousLights;
  79780. maxSimultaneousLights: number;
  79781. private _renderId;
  79782. constructor(name: string, scene: BABYLON.Scene);
  79783. needAlphaBlending(): boolean;
  79784. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79785. needAlphaTesting(): boolean;
  79786. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79787. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79788. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79789. getAnimatables(): BABYLON.IAnimatable[];
  79790. getActiveTextures(): BABYLON.BaseTexture[];
  79791. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79792. dispose(forceDisposeEffect?: boolean): void;
  79793. clone(name: string): NormalMaterial;
  79794. serialize(): any;
  79795. getClassName(): string;
  79796. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79797. }
  79798. }
  79799. declare module BABYLON {
  79800. /** @hidden */
  79801. export var shadowOnlyPixelShader: {
  79802. name: string;
  79803. shader: string;
  79804. };
  79805. }
  79806. declare module BABYLON {
  79807. /** @hidden */
  79808. export var shadowOnlyVertexShader: {
  79809. name: string;
  79810. shader: string;
  79811. };
  79812. }
  79813. declare module BABYLON {
  79814. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79815. private _renderId;
  79816. private _activeLight;
  79817. constructor(name: string, scene: BABYLON.Scene);
  79818. shadowColor: BABYLON.Color3;
  79819. needAlphaBlending(): boolean;
  79820. needAlphaTesting(): boolean;
  79821. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79822. get activeLight(): BABYLON.IShadowLight;
  79823. set activeLight(light: BABYLON.IShadowLight);
  79824. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79825. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79826. clone(name: string): ShadowOnlyMaterial;
  79827. serialize(): any;
  79828. getClassName(): string;
  79829. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79830. }
  79831. }
  79832. declare module BABYLON {
  79833. /** @hidden */
  79834. export var simplePixelShader: {
  79835. name: string;
  79836. shader: string;
  79837. };
  79838. }
  79839. declare module BABYLON {
  79840. /** @hidden */
  79841. export var simpleVertexShader: {
  79842. name: string;
  79843. shader: string;
  79844. };
  79845. }
  79846. declare module BABYLON {
  79847. export class SimpleMaterial extends BABYLON.PushMaterial {
  79848. private _diffuseTexture;
  79849. diffuseTexture: BABYLON.BaseTexture;
  79850. diffuseColor: BABYLON.Color3;
  79851. private _disableLighting;
  79852. disableLighting: boolean;
  79853. private _maxSimultaneousLights;
  79854. maxSimultaneousLights: number;
  79855. private _renderId;
  79856. constructor(name: string, scene: BABYLON.Scene);
  79857. needAlphaBlending(): boolean;
  79858. needAlphaTesting(): boolean;
  79859. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79860. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79861. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79862. getAnimatables(): BABYLON.IAnimatable[];
  79863. getActiveTextures(): BABYLON.BaseTexture[];
  79864. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79865. dispose(forceDisposeEffect?: boolean): void;
  79866. clone(name: string): SimpleMaterial;
  79867. serialize(): any;
  79868. getClassName(): string;
  79869. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79870. }
  79871. }
  79872. declare module BABYLON {
  79873. /** @hidden */
  79874. export var skyPixelShader: {
  79875. name: string;
  79876. shader: string;
  79877. };
  79878. }
  79879. declare module BABYLON {
  79880. /** @hidden */
  79881. export var skyVertexShader: {
  79882. name: string;
  79883. shader: string;
  79884. };
  79885. }
  79886. declare module BABYLON {
  79887. /**
  79888. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79889. * @see https://doc.babylonjs.com/extensions/sky
  79890. */
  79891. export class SkyMaterial extends BABYLON.PushMaterial {
  79892. /**
  79893. * Defines the overall luminance of sky in interval ]0, 1[.
  79894. */
  79895. luminance: number;
  79896. /**
  79897. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79898. */
  79899. turbidity: number;
  79900. /**
  79901. * Defines the sky appearance (light intensity).
  79902. */
  79903. rayleigh: number;
  79904. /**
  79905. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79906. */
  79907. mieCoefficient: number;
  79908. /**
  79909. * Defines the amount of haze particles following the Mie scattering theory.
  79910. */
  79911. mieDirectionalG: number;
  79912. /**
  79913. * Defines the distance of the sun according to the active scene camera.
  79914. */
  79915. distance: number;
  79916. /**
  79917. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79918. * "inclined".
  79919. */
  79920. inclination: number;
  79921. /**
  79922. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79923. * an object direction and a reference direction.
  79924. */
  79925. azimuth: number;
  79926. /**
  79927. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79928. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79929. */
  79930. sunPosition: BABYLON.Vector3;
  79931. /**
  79932. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79933. * .sunPosition property.
  79934. */
  79935. useSunPosition: boolean;
  79936. /**
  79937. * Defines an offset vector used to get a horizon offset.
  79938. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79939. */
  79940. cameraOffset: BABYLON.Vector3;
  79941. private _cameraPosition;
  79942. private _renderId;
  79943. /**
  79944. * Instantiates a new sky material.
  79945. * This material allows to create dynamic and texture free
  79946. * effects for skyboxes by taking care of the atmosphere state.
  79947. * @see https://doc.babylonjs.com/extensions/sky
  79948. * @param name Define the name of the material in the scene
  79949. * @param scene Define the scene the material belong to
  79950. */
  79951. constructor(name: string, scene: BABYLON.Scene);
  79952. /**
  79953. * Specifies if the material will require alpha blending
  79954. * @returns a boolean specifying if alpha blending is needed
  79955. */
  79956. needAlphaBlending(): boolean;
  79957. /**
  79958. * Specifies if this material should be rendered in alpha test mode
  79959. * @returns false as the sky material doesn't need alpha testing.
  79960. */
  79961. needAlphaTesting(): boolean;
  79962. /**
  79963. * Get the texture used for alpha test purpose.
  79964. * @returns null as the sky material has no texture.
  79965. */
  79966. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79967. /**
  79968. * Get if the submesh is ready to be used and all its information available.
  79969. * Child classes can use it to update shaders
  79970. * @param mesh defines the mesh to check
  79971. * @param subMesh defines which submesh to check
  79972. * @param useInstances specifies that instances should be used
  79973. * @returns a boolean indicating that the submesh is ready or not
  79974. */
  79975. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79976. /**
  79977. * Binds the submesh to this material by preparing the effect and shader to draw
  79978. * @param world defines the world transformation matrix
  79979. * @param mesh defines the mesh containing the submesh
  79980. * @param subMesh defines the submesh to bind the material to
  79981. */
  79982. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79983. /**
  79984. * Get the list of animatables in the material.
  79985. * @returns the list of animatables object used in the material
  79986. */
  79987. getAnimatables(): BABYLON.IAnimatable[];
  79988. /**
  79989. * Disposes the material
  79990. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79991. */
  79992. dispose(forceDisposeEffect?: boolean): void;
  79993. /**
  79994. * Makes a duplicate of the material, and gives it a new name
  79995. * @param name defines the new name for the duplicated material
  79996. * @returns the cloned material
  79997. */
  79998. clone(name: string): SkyMaterial;
  79999. /**
  80000. * Serializes this material in a JSON representation
  80001. * @returns the serialized material object
  80002. */
  80003. serialize(): any;
  80004. /**
  80005. * Gets the current class name of the material e.g. "SkyMaterial"
  80006. * Mainly use in serialization.
  80007. * @returns the class name
  80008. */
  80009. getClassName(): string;
  80010. /**
  80011. * Creates a sky material from parsed material data
  80012. * @param source defines the JSON representation of the material
  80013. * @param scene defines the hosting scene
  80014. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80015. * @returns a new sky material
  80016. */
  80017. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80018. }
  80019. }
  80020. declare module BABYLON {
  80021. /** @hidden */
  80022. export var terrainPixelShader: {
  80023. name: string;
  80024. shader: string;
  80025. };
  80026. }
  80027. declare module BABYLON {
  80028. /** @hidden */
  80029. export var terrainVertexShader: {
  80030. name: string;
  80031. shader: string;
  80032. };
  80033. }
  80034. declare module BABYLON {
  80035. export class TerrainMaterial extends BABYLON.PushMaterial {
  80036. private _mixTexture;
  80037. mixTexture: BABYLON.BaseTexture;
  80038. private _diffuseTexture1;
  80039. diffuseTexture1: BABYLON.Texture;
  80040. private _diffuseTexture2;
  80041. diffuseTexture2: BABYLON.Texture;
  80042. private _diffuseTexture3;
  80043. diffuseTexture3: BABYLON.Texture;
  80044. private _bumpTexture1;
  80045. bumpTexture1: BABYLON.Texture;
  80046. private _bumpTexture2;
  80047. bumpTexture2: BABYLON.Texture;
  80048. private _bumpTexture3;
  80049. bumpTexture3: BABYLON.Texture;
  80050. diffuseColor: BABYLON.Color3;
  80051. specularColor: BABYLON.Color3;
  80052. specularPower: number;
  80053. private _disableLighting;
  80054. disableLighting: boolean;
  80055. private _maxSimultaneousLights;
  80056. maxSimultaneousLights: number;
  80057. private _renderId;
  80058. constructor(name: string, scene: BABYLON.Scene);
  80059. needAlphaBlending(): boolean;
  80060. needAlphaTesting(): boolean;
  80061. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80062. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80063. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80064. getAnimatables(): BABYLON.IAnimatable[];
  80065. getActiveTextures(): BABYLON.BaseTexture[];
  80066. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80067. dispose(forceDisposeEffect?: boolean): void;
  80068. clone(name: string): TerrainMaterial;
  80069. serialize(): any;
  80070. getClassName(): string;
  80071. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80072. }
  80073. }
  80074. declare module BABYLON {
  80075. /** @hidden */
  80076. export var triplanarPixelShader: {
  80077. name: string;
  80078. shader: string;
  80079. };
  80080. }
  80081. declare module BABYLON {
  80082. /** @hidden */
  80083. export var triplanarVertexShader: {
  80084. name: string;
  80085. shader: string;
  80086. };
  80087. }
  80088. declare module BABYLON {
  80089. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80090. mixTexture: BABYLON.BaseTexture;
  80091. private _diffuseTextureX;
  80092. diffuseTextureX: BABYLON.BaseTexture;
  80093. private _diffuseTextureY;
  80094. diffuseTextureY: BABYLON.BaseTexture;
  80095. private _diffuseTextureZ;
  80096. diffuseTextureZ: BABYLON.BaseTexture;
  80097. private _normalTextureX;
  80098. normalTextureX: BABYLON.BaseTexture;
  80099. private _normalTextureY;
  80100. normalTextureY: BABYLON.BaseTexture;
  80101. private _normalTextureZ;
  80102. normalTextureZ: BABYLON.BaseTexture;
  80103. tileSize: number;
  80104. diffuseColor: BABYLON.Color3;
  80105. specularColor: BABYLON.Color3;
  80106. specularPower: number;
  80107. private _disableLighting;
  80108. disableLighting: boolean;
  80109. private _maxSimultaneousLights;
  80110. maxSimultaneousLights: number;
  80111. private _renderId;
  80112. constructor(name: string, scene: BABYLON.Scene);
  80113. needAlphaBlending(): boolean;
  80114. needAlphaTesting(): boolean;
  80115. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80116. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80117. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80118. getAnimatables(): BABYLON.IAnimatable[];
  80119. getActiveTextures(): BABYLON.BaseTexture[];
  80120. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80121. dispose(forceDisposeEffect?: boolean): void;
  80122. clone(name: string): TriPlanarMaterial;
  80123. serialize(): any;
  80124. getClassName(): string;
  80125. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80126. }
  80127. }
  80128. declare module BABYLON {
  80129. /** @hidden */
  80130. export var waterPixelShader: {
  80131. name: string;
  80132. shader: string;
  80133. };
  80134. }
  80135. declare module BABYLON {
  80136. /** @hidden */
  80137. export var waterVertexShader: {
  80138. name: string;
  80139. shader: string;
  80140. };
  80141. }
  80142. declare module BABYLON {
  80143. export class WaterMaterial extends BABYLON.PushMaterial {
  80144. renderTargetSize: BABYLON.Vector2;
  80145. private _bumpTexture;
  80146. bumpTexture: BABYLON.BaseTexture;
  80147. diffuseColor: BABYLON.Color3;
  80148. specularColor: BABYLON.Color3;
  80149. specularPower: number;
  80150. private _disableLighting;
  80151. disableLighting: boolean;
  80152. private _maxSimultaneousLights;
  80153. maxSimultaneousLights: number;
  80154. /**
  80155. * @param {number}: Represents the wind force
  80156. */
  80157. windForce: number;
  80158. /**
  80159. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80160. */
  80161. windDirection: BABYLON.Vector2;
  80162. /**
  80163. * @param {number}: Wave height, represents the height of the waves
  80164. */
  80165. waveHeight: number;
  80166. /**
  80167. * @param {number}: Bump height, represents the bump height related to the bump map
  80168. */
  80169. bumpHeight: number;
  80170. /**
  80171. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80172. */
  80173. private _bumpSuperimpose;
  80174. bumpSuperimpose: boolean;
  80175. /**
  80176. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80177. */
  80178. private _fresnelSeparate;
  80179. fresnelSeparate: boolean;
  80180. /**
  80181. * @param {boolean}: bump Waves modify the reflection.
  80182. */
  80183. private _bumpAffectsReflection;
  80184. bumpAffectsReflection: boolean;
  80185. /**
  80186. * @param {number}: The water color blended with the refraction (near)
  80187. */
  80188. waterColor: BABYLON.Color3;
  80189. /**
  80190. * @param {number}: The blend factor related to the water color
  80191. */
  80192. colorBlendFactor: number;
  80193. /**
  80194. * @param {number}: The water color blended with the reflection (far)
  80195. */
  80196. waterColor2: BABYLON.Color3;
  80197. /**
  80198. * @param {number}: The blend factor related to the water color (reflection, far)
  80199. */
  80200. colorBlendFactor2: number;
  80201. /**
  80202. * @param {number}: Represents the maximum length of a wave
  80203. */
  80204. waveLength: number;
  80205. /**
  80206. * @param {number}: Defines the waves speed
  80207. */
  80208. waveSpeed: number;
  80209. /**
  80210. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80211. * will avoid calculating useless pixels in the pixel shader of the water material.
  80212. */
  80213. disableClipPlane: boolean;
  80214. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80215. private _mesh;
  80216. private _refractionRTT;
  80217. private _reflectionRTT;
  80218. private _reflectionTransform;
  80219. private _lastTime;
  80220. private _lastDeltaTime;
  80221. private _renderId;
  80222. private _useLogarithmicDepth;
  80223. private _waitingRenderList;
  80224. private _imageProcessingConfiguration;
  80225. private _imageProcessingObserver;
  80226. /**
  80227. * Gets a boolean indicating that current material needs to register RTT
  80228. */
  80229. get hasRenderTargetTextures(): boolean;
  80230. /**
  80231. * Constructor
  80232. */
  80233. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80234. get useLogarithmicDepth(): boolean;
  80235. set useLogarithmicDepth(value: boolean);
  80236. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80237. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80238. addToRenderList(node: any): void;
  80239. enableRenderTargets(enable: boolean): void;
  80240. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80241. get renderTargetsEnabled(): boolean;
  80242. needAlphaBlending(): boolean;
  80243. needAlphaTesting(): boolean;
  80244. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80245. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80246. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80247. private _createRenderTargets;
  80248. getAnimatables(): BABYLON.IAnimatable[];
  80249. getActiveTextures(): BABYLON.BaseTexture[];
  80250. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80251. dispose(forceDisposeEffect?: boolean): void;
  80252. clone(name: string): WaterMaterial;
  80253. serialize(): any;
  80254. getClassName(): string;
  80255. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80256. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80257. }
  80258. }
  80259. declare module BABYLON {
  80260. /** @hidden */
  80261. export var asciiartPixelShader: {
  80262. name: string;
  80263. shader: string;
  80264. };
  80265. }
  80266. declare module BABYLON {
  80267. /**
  80268. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80269. *
  80270. * It basically takes care rendering the font front the given font size to a texture.
  80271. * This is used later on in the postprocess.
  80272. */
  80273. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80274. private _font;
  80275. private _text;
  80276. private _charSize;
  80277. /**
  80278. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80279. */
  80280. get charSize(): number;
  80281. /**
  80282. * Create a new instance of the Ascii Art FontTexture class
  80283. * @param name the name of the texture
  80284. * @param font the font to use, use the W3C CSS notation
  80285. * @param text the caracter set to use in the rendering.
  80286. * @param scene the scene that owns the texture
  80287. */
  80288. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80289. /**
  80290. * Gets the max char width of a font.
  80291. * @param font the font to use, use the W3C CSS notation
  80292. * @return the max char width
  80293. */
  80294. private getFontWidth;
  80295. /**
  80296. * Gets the max char height of a font.
  80297. * @param font the font to use, use the W3C CSS notation
  80298. * @return the max char height
  80299. */
  80300. private getFontHeight;
  80301. /**
  80302. * Clones the current AsciiArtTexture.
  80303. * @return the clone of the texture.
  80304. */
  80305. clone(): AsciiArtFontTexture;
  80306. /**
  80307. * Parses a json object representing the texture and returns an instance of it.
  80308. * @param source the source JSON representation
  80309. * @param scene the scene to create the texture for
  80310. * @return the parsed texture
  80311. */
  80312. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80313. }
  80314. /**
  80315. * Option available in the Ascii Art Post Process.
  80316. */
  80317. export interface IAsciiArtPostProcessOptions {
  80318. /**
  80319. * The font to use following the w3c font definition.
  80320. */
  80321. font?: string;
  80322. /**
  80323. * The character set to use in the postprocess.
  80324. */
  80325. characterSet?: string;
  80326. /**
  80327. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80328. * This number is defined between 0 and 1;
  80329. */
  80330. mixToTile?: number;
  80331. /**
  80332. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80333. * This number is defined between 0 and 1;
  80334. */
  80335. mixToNormal?: number;
  80336. }
  80337. /**
  80338. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80339. *
  80340. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80341. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80342. */
  80343. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80344. /**
  80345. * The font texture used to render the char in the post process.
  80346. */
  80347. private _asciiArtFontTexture;
  80348. /**
  80349. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80350. * This number is defined between 0 and 1;
  80351. */
  80352. mixToTile: number;
  80353. /**
  80354. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80355. * This number is defined between 0 and 1;
  80356. */
  80357. mixToNormal: number;
  80358. /**
  80359. * Instantiates a new Ascii Art Post Process.
  80360. * @param name the name to give to the postprocess
  80361. * @camera the camera to apply the post process to.
  80362. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80363. */
  80364. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80365. }
  80366. }
  80367. declare module BABYLON {
  80368. /** @hidden */
  80369. export var digitalrainPixelShader: {
  80370. name: string;
  80371. shader: string;
  80372. };
  80373. }
  80374. declare module BABYLON {
  80375. /**
  80376. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80377. *
  80378. * It basically takes care rendering the font front the given font size to a texture.
  80379. * This is used later on in the postprocess.
  80380. */
  80381. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80382. private _font;
  80383. private _text;
  80384. private _charSize;
  80385. /**
  80386. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80387. */
  80388. get charSize(): number;
  80389. /**
  80390. * Create a new instance of the Digital Rain FontTexture class
  80391. * @param name the name of the texture
  80392. * @param font the font to use, use the W3C CSS notation
  80393. * @param text the caracter set to use in the rendering.
  80394. * @param scene the scene that owns the texture
  80395. */
  80396. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80397. /**
  80398. * Gets the max char width of a font.
  80399. * @param font the font to use, use the W3C CSS notation
  80400. * @return the max char width
  80401. */
  80402. private getFontWidth;
  80403. /**
  80404. * Gets the max char height of a font.
  80405. * @param font the font to use, use the W3C CSS notation
  80406. * @return the max char height
  80407. */
  80408. private getFontHeight;
  80409. /**
  80410. * Clones the current DigitalRainFontTexture.
  80411. * @return the clone of the texture.
  80412. */
  80413. clone(): DigitalRainFontTexture;
  80414. /**
  80415. * Parses a json object representing the texture and returns an instance of it.
  80416. * @param source the source JSON representation
  80417. * @param scene the scene to create the texture for
  80418. * @return the parsed texture
  80419. */
  80420. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80421. }
  80422. /**
  80423. * Option available in the Digital Rain Post Process.
  80424. */
  80425. export interface IDigitalRainPostProcessOptions {
  80426. /**
  80427. * The font to use following the w3c font definition.
  80428. */
  80429. font?: string;
  80430. /**
  80431. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80432. * This number is defined between 0 and 1;
  80433. */
  80434. mixToTile?: number;
  80435. /**
  80436. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80437. * This number is defined between 0 and 1;
  80438. */
  80439. mixToNormal?: number;
  80440. }
  80441. /**
  80442. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80443. *
  80444. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80445. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80446. */
  80447. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80448. /**
  80449. * The font texture used to render the char in the post process.
  80450. */
  80451. private _digitalRainFontTexture;
  80452. /**
  80453. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80454. * This number is defined between 0 and 1;
  80455. */
  80456. mixToTile: number;
  80457. /**
  80458. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80459. * This number is defined between 0 and 1;
  80460. */
  80461. mixToNormal: number;
  80462. /**
  80463. * Instantiates a new Digital Rain Post Process.
  80464. * @param name the name to give to the postprocess
  80465. * @camera the camera to apply the post process to.
  80466. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80467. */
  80468. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80469. }
  80470. }
  80471. declare module BABYLON {
  80472. /** @hidden */
  80473. export var brickProceduralTexturePixelShader: {
  80474. name: string;
  80475. shader: string;
  80476. };
  80477. }
  80478. declare module BABYLON {
  80479. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80480. private _numberOfBricksHeight;
  80481. private _numberOfBricksWidth;
  80482. private _jointColor;
  80483. private _brickColor;
  80484. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80485. updateShaderUniforms(): void;
  80486. get numberOfBricksHeight(): number;
  80487. set numberOfBricksHeight(value: number);
  80488. get numberOfBricksWidth(): number;
  80489. set numberOfBricksWidth(value: number);
  80490. get jointColor(): BABYLON.Color3;
  80491. set jointColor(value: BABYLON.Color3);
  80492. get brickColor(): BABYLON.Color3;
  80493. set brickColor(value: BABYLON.Color3);
  80494. /**
  80495. * Serializes this brick procedural texture
  80496. * @returns a serialized brick procedural texture object
  80497. */
  80498. serialize(): any;
  80499. /**
  80500. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80501. * @param parsedTexture defines parsed texture data
  80502. * @param scene defines the current scene
  80503. * @param rootUrl defines the root URL containing brick procedural texture information
  80504. * @returns a parsed Brick Procedural BABYLON.Texture
  80505. */
  80506. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80507. }
  80508. }
  80509. declare module BABYLON {
  80510. /** @hidden */
  80511. export var cloudProceduralTexturePixelShader: {
  80512. name: string;
  80513. shader: string;
  80514. };
  80515. }
  80516. declare module BABYLON {
  80517. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80518. private _skyColor;
  80519. private _cloudColor;
  80520. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80521. updateShaderUniforms(): void;
  80522. get skyColor(): BABYLON.Color4;
  80523. set skyColor(value: BABYLON.Color4);
  80524. get cloudColor(): BABYLON.Color4;
  80525. set cloudColor(value: BABYLON.Color4);
  80526. /**
  80527. * Serializes this cloud procedural texture
  80528. * @returns a serialized cloud procedural texture object
  80529. */
  80530. serialize(): any;
  80531. /**
  80532. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80533. * @param parsedTexture defines parsed texture data
  80534. * @param scene defines the current scene
  80535. * @param rootUrl defines the root URL containing cloud procedural texture information
  80536. * @returns a parsed Cloud Procedural BABYLON.Texture
  80537. */
  80538. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80539. }
  80540. }
  80541. declare module BABYLON {
  80542. /** @hidden */
  80543. export var fireProceduralTexturePixelShader: {
  80544. name: string;
  80545. shader: string;
  80546. };
  80547. }
  80548. declare module BABYLON {
  80549. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80550. private _time;
  80551. private _speed;
  80552. private _autoGenerateTime;
  80553. private _fireColors;
  80554. private _alphaThreshold;
  80555. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80556. updateShaderUniforms(): void;
  80557. render(useCameraPostProcess?: boolean): void;
  80558. static get PurpleFireColors(): BABYLON.Color3[];
  80559. static get GreenFireColors(): BABYLON.Color3[];
  80560. static get RedFireColors(): BABYLON.Color3[];
  80561. static get BlueFireColors(): BABYLON.Color3[];
  80562. get autoGenerateTime(): boolean;
  80563. set autoGenerateTime(value: boolean);
  80564. get fireColors(): BABYLON.Color3[];
  80565. set fireColors(value: BABYLON.Color3[]);
  80566. get time(): number;
  80567. set time(value: number);
  80568. get speed(): BABYLON.Vector2;
  80569. set speed(value: BABYLON.Vector2);
  80570. get alphaThreshold(): number;
  80571. set alphaThreshold(value: number);
  80572. /**
  80573. * Serializes this fire procedural texture
  80574. * @returns a serialized fire procedural texture object
  80575. */
  80576. serialize(): any;
  80577. /**
  80578. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80579. * @param parsedTexture defines parsed texture data
  80580. * @param scene defines the current scene
  80581. * @param rootUrl defines the root URL containing fire procedural texture information
  80582. * @returns a parsed Fire Procedural BABYLON.Texture
  80583. */
  80584. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80585. }
  80586. }
  80587. declare module BABYLON {
  80588. /** @hidden */
  80589. export var grassProceduralTexturePixelShader: {
  80590. name: string;
  80591. shader: string;
  80592. };
  80593. }
  80594. declare module BABYLON {
  80595. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80596. private _grassColors;
  80597. private _groundColor;
  80598. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80599. updateShaderUniforms(): void;
  80600. get grassColors(): BABYLON.Color3[];
  80601. set grassColors(value: BABYLON.Color3[]);
  80602. get groundColor(): BABYLON.Color3;
  80603. set groundColor(value: BABYLON.Color3);
  80604. /**
  80605. * Serializes this grass procedural texture
  80606. * @returns a serialized grass procedural texture object
  80607. */
  80608. serialize(): any;
  80609. /**
  80610. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80611. * @param parsedTexture defines parsed texture data
  80612. * @param scene defines the current scene
  80613. * @param rootUrl defines the root URL containing grass procedural texture information
  80614. * @returns a parsed Grass Procedural BABYLON.Texture
  80615. */
  80616. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80617. }
  80618. }
  80619. declare module BABYLON {
  80620. /** @hidden */
  80621. export var marbleProceduralTexturePixelShader: {
  80622. name: string;
  80623. shader: string;
  80624. };
  80625. }
  80626. declare module BABYLON {
  80627. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80628. private _numberOfTilesHeight;
  80629. private _numberOfTilesWidth;
  80630. private _amplitude;
  80631. private _jointColor;
  80632. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80633. updateShaderUniforms(): void;
  80634. get numberOfTilesHeight(): number;
  80635. set numberOfTilesHeight(value: number);
  80636. get amplitude(): number;
  80637. set amplitude(value: number);
  80638. get numberOfTilesWidth(): number;
  80639. set numberOfTilesWidth(value: number);
  80640. get jointColor(): BABYLON.Color3;
  80641. set jointColor(value: BABYLON.Color3);
  80642. /**
  80643. * Serializes this marble procedural texture
  80644. * @returns a serialized marble procedural texture object
  80645. */
  80646. serialize(): any;
  80647. /**
  80648. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80649. * @param parsedTexture defines parsed texture data
  80650. * @param scene defines the current scene
  80651. * @param rootUrl defines the root URL containing marble procedural texture information
  80652. * @returns a parsed Marble Procedural BABYLON.Texture
  80653. */
  80654. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80655. }
  80656. }
  80657. declare module BABYLON {
  80658. /** @hidden */
  80659. export var normalMapProceduralTexturePixelShader: {
  80660. name: string;
  80661. shader: string;
  80662. };
  80663. }
  80664. declare module BABYLON {
  80665. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80666. private _baseTexture;
  80667. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80668. updateShaderUniforms(): void;
  80669. render(useCameraPostProcess?: boolean): void;
  80670. resize(size: any, generateMipMaps: any): void;
  80671. get baseTexture(): BABYLON.Texture;
  80672. set baseTexture(texture: BABYLON.Texture);
  80673. /**
  80674. * Serializes this normal map procedural texture
  80675. * @returns a serialized normal map procedural texture object
  80676. */
  80677. serialize(): any;
  80678. /**
  80679. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80680. * @param parsedTexture defines parsed texture data
  80681. * @param scene defines the current scene
  80682. * @param rootUrl defines the root URL containing normal map procedural texture information
  80683. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80684. */
  80685. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80686. }
  80687. }
  80688. declare module BABYLON {
  80689. /** @hidden */
  80690. export var perlinNoiseProceduralTexturePixelShader: {
  80691. name: string;
  80692. shader: string;
  80693. };
  80694. }
  80695. declare module BABYLON {
  80696. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80697. time: number;
  80698. timeScale: number;
  80699. translationSpeed: number;
  80700. private _currentTranslation;
  80701. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80702. updateShaderUniforms(): void;
  80703. render(useCameraPostProcess?: boolean): void;
  80704. resize(size: any, generateMipMaps: any): void;
  80705. /**
  80706. * Serializes this perlin noise procedural texture
  80707. * @returns a serialized perlin noise procedural texture object
  80708. */
  80709. serialize(): any;
  80710. /**
  80711. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  80712. * @param parsedTexture defines parsed texture data
  80713. * @param scene defines the current scene
  80714. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  80715. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  80716. */
  80717. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  80718. }
  80719. }
  80720. declare module BABYLON {
  80721. /** @hidden */
  80722. export var roadProceduralTexturePixelShader: {
  80723. name: string;
  80724. shader: string;
  80725. };
  80726. }
  80727. declare module BABYLON {
  80728. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  80729. private _roadColor;
  80730. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80731. updateShaderUniforms(): void;
  80732. get roadColor(): BABYLON.Color3;
  80733. set roadColor(value: BABYLON.Color3);
  80734. /**
  80735. * Serializes this road procedural texture
  80736. * @returns a serialized road procedural texture object
  80737. */
  80738. serialize(): any;
  80739. /**
  80740. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80741. * @param parsedTexture defines parsed texture data
  80742. * @param scene defines the current scene
  80743. * @param rootUrl defines the root URL containing road procedural texture information
  80744. * @returns a parsed Road Procedural BABYLON.Texture
  80745. */
  80746. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80747. }
  80748. }
  80749. declare module BABYLON {
  80750. /** @hidden */
  80751. export var starfieldProceduralTexturePixelShader: {
  80752. name: string;
  80753. shader: string;
  80754. };
  80755. }
  80756. declare module BABYLON {
  80757. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80758. private _time;
  80759. private _alpha;
  80760. private _beta;
  80761. private _zoom;
  80762. private _formuparam;
  80763. private _stepsize;
  80764. private _tile;
  80765. private _brightness;
  80766. private _darkmatter;
  80767. private _distfading;
  80768. private _saturation;
  80769. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80770. updateShaderUniforms(): void;
  80771. get time(): number;
  80772. set time(value: number);
  80773. get alpha(): number;
  80774. set alpha(value: number);
  80775. get beta(): number;
  80776. set beta(value: number);
  80777. get formuparam(): number;
  80778. set formuparam(value: number);
  80779. get stepsize(): number;
  80780. set stepsize(value: number);
  80781. get zoom(): number;
  80782. set zoom(value: number);
  80783. get tile(): number;
  80784. set tile(value: number);
  80785. get brightness(): number;
  80786. set brightness(value: number);
  80787. get darkmatter(): number;
  80788. set darkmatter(value: number);
  80789. get distfading(): number;
  80790. set distfading(value: number);
  80791. get saturation(): number;
  80792. set saturation(value: number);
  80793. /**
  80794. * Serializes this starfield procedural texture
  80795. * @returns a serialized starfield procedural texture object
  80796. */
  80797. serialize(): any;
  80798. /**
  80799. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80800. * @param parsedTexture defines parsed texture data
  80801. * @param scene defines the current scene
  80802. * @param rootUrl defines the root URL containing startfield procedural texture information
  80803. * @returns a parsed Starfield Procedural BABYLON.Texture
  80804. */
  80805. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80806. }
  80807. }
  80808. declare module BABYLON {
  80809. /** @hidden */
  80810. export var woodProceduralTexturePixelShader: {
  80811. name: string;
  80812. shader: string;
  80813. };
  80814. }
  80815. declare module BABYLON {
  80816. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80817. private _ampScale;
  80818. private _woodColor;
  80819. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80820. updateShaderUniforms(): void;
  80821. get ampScale(): number;
  80822. set ampScale(value: number);
  80823. get woodColor(): BABYLON.Color3;
  80824. set woodColor(value: BABYLON.Color3);
  80825. /**
  80826. * Serializes this wood procedural texture
  80827. * @returns a serialized wood procedural texture object
  80828. */
  80829. serialize(): any;
  80830. /**
  80831. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80832. * @param parsedTexture defines parsed texture data
  80833. * @param scene defines the current scene
  80834. * @param rootUrl defines the root URL containing wood procedural texture information
  80835. * @returns a parsed Wood Procedural BABYLON.Texture
  80836. */
  80837. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80838. }
  80839. }