babylon.d.ts 3.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * 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.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. }
  1053. }
  1054. declare module BABYLON {
  1055. /**
  1056. * This represents the required contract to create a new type of texture loader.
  1057. */
  1058. export interface IInternalTextureLoader {
  1059. /**
  1060. * Defines wether the loader supports cascade loading the different faces.
  1061. */
  1062. supportCascades: boolean;
  1063. /**
  1064. * This returns if the loader support the current file information.
  1065. * @param extension defines the file extension of the file being loaded
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string): boolean;
  1069. /**
  1070. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1071. * @param data contains the texture data
  1072. * @param texture defines the BabylonJS internal texture
  1073. * @param createPolynomials will be true if polynomials have been requested
  1074. * @param onLoad defines the callback to trigger once the texture is ready
  1075. * @param onError defines the callback to trigger in case of error
  1076. */
  1077. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1078. /**
  1079. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param callback defines the method to call once ready to upload
  1083. */
  1084. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1085. }
  1086. }
  1087. declare module BABYLON {
  1088. /**
  1089. * Class used to store and describe the pipeline context associated with an effect
  1090. */
  1091. export interface IPipelineContext {
  1092. /**
  1093. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1094. */
  1095. isAsync: boolean;
  1096. /**
  1097. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1098. */
  1099. isReady: boolean;
  1100. /** @hidden */
  1101. _getVertexShaderCode(): string | null;
  1102. /** @hidden */
  1103. _getFragmentShaderCode(): string | null;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module BABYLON {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module BABYLON {
  1143. /** @hidden */
  1144. export interface ProcessingOptions {
  1145. defines: string[];
  1146. indexParameters: any;
  1147. isFragment: boolean;
  1148. shouldUseHighPrecisionShader: boolean;
  1149. supportsUniformBuffers: boolean;
  1150. shadersRepository: string;
  1151. includesShadersStore: {
  1152. [key: string]: string;
  1153. };
  1154. processor?: IShaderProcessor;
  1155. version: string;
  1156. platformName: string;
  1157. lookForClosingBracketForUniformBuffer?: boolean;
  1158. }
  1159. }
  1160. declare module BABYLON {
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1188. process(preprocessors: {
  1189. [key: string]: string;
  1190. }, options: ProcessingOptions): string;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderDefineExpression {
  1196. isTrue(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. private static _OperatorPriority;
  1200. private static _Stack;
  1201. static postfixToInfix(postfix: string[]): string;
  1202. static infixToPostfix(infix: string): string[];
  1203. }
  1204. }
  1205. declare module BABYLON {
  1206. /** @hidden */
  1207. export class ShaderCodeTestNode extends ShaderCodeNode {
  1208. testExpression: ShaderDefineExpression;
  1209. isValid(preprocessors: {
  1210. [key: string]: string;
  1211. }): boolean;
  1212. }
  1213. }
  1214. declare module BABYLON {
  1215. /** @hidden */
  1216. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1217. define: string;
  1218. not: boolean;
  1219. constructor(define: string, not?: boolean);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1238. leftOperand: ShaderDefineExpression;
  1239. rightOperand: ShaderDefineExpression;
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /** @hidden */
  1247. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1248. define: string;
  1249. operand: string;
  1250. testValue: string;
  1251. constructor(define: string, operand: string, testValue: string);
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. }
  1256. }
  1257. declare module BABYLON {
  1258. /**
  1259. * Class used to enable access to offline support
  1260. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1261. */
  1262. export interface IOfflineProvider {
  1263. /**
  1264. * Gets a boolean indicating if scene must be saved in the database
  1265. */
  1266. enableSceneOffline: boolean;
  1267. /**
  1268. * Gets a boolean indicating if textures must be saved in the database
  1269. */
  1270. enableTexturesOffline: boolean;
  1271. /**
  1272. * Open the offline support and make it available
  1273. * @param successCallback defines the callback to call on success
  1274. * @param errorCallback defines the callback to call on error
  1275. */
  1276. open(successCallback: () => void, errorCallback: () => void): void;
  1277. /**
  1278. * Loads an image from the offline support
  1279. * @param url defines the url to load from
  1280. * @param image defines the target DOM image
  1281. */
  1282. loadImage(url: string, image: HTMLImageElement): void;
  1283. /**
  1284. * Loads a file from offline support
  1285. * @param url defines the URL to load from
  1286. * @param sceneLoaded defines a callback to call on success
  1287. * @param progressCallBack defines a callback to call when progress changed
  1288. * @param errorCallback defines a callback to call on error
  1289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1290. */
  1291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class used to help managing file picking and drag'n'drop
  1297. * File Storage
  1298. */
  1299. export class FilesInputStore {
  1300. /**
  1301. * List of files ready to be loaded
  1302. */
  1303. static FilesToLoad: {
  1304. [key: string]: File;
  1305. };
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module BABYLON {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module BABYLON {
  1332. /** @ignore */
  1333. export class LoadFileError extends BaseError {
  1334. request?: WebRequest;
  1335. file?: File;
  1336. /**
  1337. * Creates a new LoadFileError
  1338. * @param message defines the message of the error
  1339. * @param request defines the optional web request
  1340. * @param file defines the optional file
  1341. */
  1342. constructor(message: string, object?: WebRequest | File);
  1343. }
  1344. /** @ignore */
  1345. export class RequestFileError extends BaseError {
  1346. request: WebRequest;
  1347. /**
  1348. * Creates a new LoadFileError
  1349. * @param message defines the message of the error
  1350. * @param request defines the optional web request
  1351. */
  1352. constructor(message: string, request: WebRequest);
  1353. }
  1354. /** @ignore */
  1355. export class ReadFileError extends BaseError {
  1356. file: File;
  1357. /**
  1358. * Creates a new ReadFileError
  1359. * @param message defines the message of the error
  1360. * @param file defines the optional file
  1361. */
  1362. constructor(message: string, file: File);
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export class FileTools {
  1368. /**
  1369. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1370. */
  1371. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1372. /**
  1373. * Gets or sets the base URL to use to load assets
  1374. */
  1375. static BaseUrl: string;
  1376. /**
  1377. * Default behaviour for cors in the application.
  1378. * It can be a string if the expected behavior is identical in the entire app.
  1379. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1380. */
  1381. static CorsBehavior: string | ((url: string | string[]) => string);
  1382. /**
  1383. * Gets or sets a function used to pre-process url before using them to load assets
  1384. */
  1385. static PreprocessUrl: (url: string) => string;
  1386. /**
  1387. * Removes unwanted characters from an url
  1388. * @param url defines the url to clean
  1389. * @returns the cleaned url
  1390. */
  1391. private static _CleanUrl;
  1392. /**
  1393. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1394. * @param url define the url we are trying
  1395. * @param element define the dom element where to configure the cors policy
  1396. */
  1397. static SetCorsBehavior(url: string | string[], element: {
  1398. crossOrigin: string | null;
  1399. }): void;
  1400. /**
  1401. * Loads an image as an HTMLImageElement.
  1402. * @param input url string, ArrayBuffer, or Blob to load
  1403. * @param onLoad callback called when the image successfully loads
  1404. * @param onError callback called when the image fails to load
  1405. * @param offlineProvider offline provider for caching
  1406. * @param mimeType optional mime type
  1407. * @returns the HTMLImageElement of the loaded image
  1408. */
  1409. 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>;
  1410. /**
  1411. * Reads a file from a File object
  1412. * @param file defines the file to load
  1413. * @param onSuccess defines the callback to call when data is loaded
  1414. * @param onProgress defines the callback to call during loading process
  1415. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1416. * @param onError defines the callback to call when an error occurs
  1417. * @returns a file request object
  1418. */
  1419. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1420. /**
  1421. * Loads a file from a url
  1422. * @param url url to load
  1423. * @param onSuccess callback called when the file successfully loads
  1424. * @param onProgress callback called while file is loading (if the server supports this mode)
  1425. * @param offlineProvider defines the offline provider for caching
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @returns a file request object
  1429. */
  1430. 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;
  1431. /**
  1432. * Loads a file
  1433. * @param url url to load
  1434. * @param onSuccess callback called when the file successfully loads
  1435. * @param onProgress callback called while file is loading (if the server supports this mode)
  1436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1437. * @param onError callback called when the file fails to load
  1438. * @param onOpened callback called when the web request is opened
  1439. * @returns a file request object
  1440. */
  1441. 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;
  1442. /**
  1443. * Checks if the loaded document was accessed via `file:`-Protocol.
  1444. * @returns boolean
  1445. */
  1446. static IsFileURL(): boolean;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /** @hidden */
  1451. export class ShaderProcessor {
  1452. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1453. private static _ProcessPrecision;
  1454. private static _ExtractOperation;
  1455. private static _BuildSubExpression;
  1456. private static _BuildExpression;
  1457. private static _MoveCursorWithinIf;
  1458. private static _MoveCursor;
  1459. private static _EvaluatePreProcessors;
  1460. private static _PreparePreProcessors;
  1461. private static _ProcessShaderConversion;
  1462. private static _ProcessIncludes;
  1463. /**
  1464. * Loads a file from a url
  1465. * @param url url to load
  1466. * @param onSuccess callback called when the file successfully loads
  1467. * @param onProgress callback called while file is loading (if the server supports this mode)
  1468. * @param offlineProvider defines the offline provider for caching
  1469. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1470. * @param onError callback called when the file fails to load
  1471. * @returns a file request object
  1472. * @hidden
  1473. */
  1474. 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;
  1475. }
  1476. }
  1477. declare module BABYLON {
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module BABYLON {
  1545. /**
  1546. * Interface used to define common properties for effect fallbacks
  1547. */
  1548. export interface IEffectFallbacks {
  1549. /**
  1550. * Removes the defines that should be removed when falling back.
  1551. * @param currentDefines defines the current define statements for the shader.
  1552. * @param effect defines the current effect we try to compile
  1553. * @returns The resulting defines with defines of the current rank removed.
  1554. */
  1555. reduce(currentDefines: string, effect: Effect): string;
  1556. /**
  1557. * Removes the fallback from the bound mesh.
  1558. */
  1559. unBindMesh(): void;
  1560. /**
  1561. * Checks to see if more fallbacks are still availible.
  1562. */
  1563. hasMoreFallbacks: boolean;
  1564. }
  1565. }
  1566. declare module BABYLON {
  1567. /**
  1568. * Class used to evalaute queries containing `and` and `or` operators
  1569. */
  1570. export class AndOrNotEvaluator {
  1571. /**
  1572. * Evaluate a query
  1573. * @param query defines the query to evaluate
  1574. * @param evaluateCallback defines the callback used to filter result
  1575. * @returns true if the query matches
  1576. */
  1577. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1578. private static _HandleParenthesisContent;
  1579. private static _SimplifyNegation;
  1580. }
  1581. }
  1582. declare module BABYLON {
  1583. /**
  1584. * Class used to store custom tags
  1585. */
  1586. export class Tags {
  1587. /**
  1588. * Adds support for tags on the given object
  1589. * @param obj defines the object to use
  1590. */
  1591. static EnableFor(obj: any): void;
  1592. /**
  1593. * Removes tags support
  1594. * @param obj defines the object to use
  1595. */
  1596. static DisableFor(obj: any): void;
  1597. /**
  1598. * Gets a boolean indicating if the given object has tags
  1599. * @param obj defines the object to use
  1600. * @returns a boolean
  1601. */
  1602. static HasTags(obj: any): boolean;
  1603. /**
  1604. * Gets the tags available on a given object
  1605. * @param obj defines the object to use
  1606. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1607. * @returns the tags
  1608. */
  1609. static GetTags(obj: any, asString?: boolean): any;
  1610. /**
  1611. * Adds tags to an object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1614. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1615. */
  1616. static AddTagsTo(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _AddTagTo(obj: any, tag: string): void;
  1621. /**
  1622. * Removes specific tags from a specific object
  1623. * @param obj defines the object to use
  1624. * @param tagsString defines the tags to remove
  1625. */
  1626. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1627. /**
  1628. * @hidden
  1629. */
  1630. static _RemoveTagFrom(obj: any, tag: string): void;
  1631. /**
  1632. * Defines if tags hosted on an object match a given query
  1633. * @param obj defines the object to use
  1634. * @param tagsQuery defines the tag query
  1635. * @returns a boolean
  1636. */
  1637. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1638. }
  1639. }
  1640. declare module BABYLON {
  1641. /**
  1642. * Scalar computation library
  1643. */
  1644. export class Scalar {
  1645. /**
  1646. * Two pi constants convenient for computation.
  1647. */
  1648. static TwoPi: number;
  1649. /**
  1650. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1651. * @param a number
  1652. * @param b number
  1653. * @param epsilon (default = 1.401298E-45)
  1654. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1655. */
  1656. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1657. /**
  1658. * Returns a string : the upper case translation of the number i to hexadecimal.
  1659. * @param i number
  1660. * @returns the upper case translation of the number i to hexadecimal.
  1661. */
  1662. static ToHex(i: number): string;
  1663. /**
  1664. * Returns -1 if value is negative and +1 is value is positive.
  1665. * @param value the value
  1666. * @returns the value itself if it's equal to zero.
  1667. */
  1668. static Sign(value: number): number;
  1669. /**
  1670. * Returns the value itself if it's between min and max.
  1671. * Returns min if the value is lower than min.
  1672. * Returns max if the value is greater than max.
  1673. * @param value the value to clmap
  1674. * @param min the min value to clamp to (default: 0)
  1675. * @param max the max value to clamp to (default: 1)
  1676. * @returns the clamped value
  1677. */
  1678. static Clamp(value: number, min?: number, max?: number): number;
  1679. /**
  1680. * the log2 of value.
  1681. * @param value the value to compute log2 of
  1682. * @returns the log2 of value.
  1683. */
  1684. static Log2(value: number): number;
  1685. /**
  1686. * Loops the value, so that it is never larger than length and never smaller than 0.
  1687. *
  1688. * This is similar to the modulo operator but it works with floating point numbers.
  1689. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1690. * With t = 5 and length = 2.5, the result would be 0.0.
  1691. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1692. * @param value the value
  1693. * @param length the length
  1694. * @returns the looped value
  1695. */
  1696. static Repeat(value: number, length: number): number;
  1697. /**
  1698. * Normalize the value between 0.0 and 1.0 using min and max values
  1699. * @param value value to normalize
  1700. * @param min max to normalize between
  1701. * @param max min to normalize between
  1702. * @returns the normalized value
  1703. */
  1704. static Normalize(value: number, min: number, max: number): number;
  1705. /**
  1706. * Denormalize the value from 0.0 and 1.0 using min and max values
  1707. * @param normalized value to denormalize
  1708. * @param min max to denormalize between
  1709. * @param max min to denormalize between
  1710. * @returns the denormalized value
  1711. */
  1712. static Denormalize(normalized: number, min: number, max: number): number;
  1713. /**
  1714. * Calculates the shortest difference between two given angles given in degrees.
  1715. * @param current current angle in degrees
  1716. * @param target target angle in degrees
  1717. * @returns the delta
  1718. */
  1719. static DeltaAngle(current: number, target: number): number;
  1720. /**
  1721. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1722. * @param tx value
  1723. * @param length length
  1724. * @returns The returned value will move back and forth between 0 and length
  1725. */
  1726. static PingPong(tx: number, length: number): number;
  1727. /**
  1728. * Interpolates between min and max with smoothing at the limits.
  1729. *
  1730. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1731. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1732. * @param from from
  1733. * @param to to
  1734. * @param tx value
  1735. * @returns the smooth stepped value
  1736. */
  1737. static SmoothStep(from: number, to: number, tx: number): number;
  1738. /**
  1739. * Moves a value current towards target.
  1740. *
  1741. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1742. * Negative values of maxDelta pushes the value away from target.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting value
  1747. */
  1748. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1751. *
  1752. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1753. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1754. * @param current current value
  1755. * @param target target value
  1756. * @param maxDelta max distance to move
  1757. * @returns resulting angle
  1758. */
  1759. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1760. /**
  1761. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1762. * @param start start value
  1763. * @param end target value
  1764. * @param amount amount to lerp between
  1765. * @returns the lerped value
  1766. */
  1767. static Lerp(start: number, end: number, amount: number): number;
  1768. /**
  1769. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1771. * @param start start value
  1772. * @param end target value
  1773. * @param amount amount to lerp between
  1774. * @returns the lerped value
  1775. */
  1776. static LerpAngle(start: number, end: number, amount: number): number;
  1777. /**
  1778. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1779. * @param a start value
  1780. * @param b target value
  1781. * @param value value between a and b
  1782. * @returns the inverseLerp value
  1783. */
  1784. static InverseLerp(a: number, b: number, value: number): number;
  1785. /**
  1786. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1787. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1788. * @param value1 spline value
  1789. * @param tangent1 spline value
  1790. * @param value2 spline value
  1791. * @param tangent2 spline value
  1792. * @param amount input value
  1793. * @returns hermite result
  1794. */
  1795. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1796. /**
  1797. * Returns a random float number between and min and max values
  1798. * @param min min value of random
  1799. * @param max max value of random
  1800. * @returns random value
  1801. */
  1802. static RandomRange(min: number, max: number): number;
  1803. /**
  1804. * This function returns percentage of a number in a given range.
  1805. *
  1806. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1807. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1808. * @param number to convert to percentage
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the percentage
  1812. */
  1813. static RangeToPercent(number: number, min: number, max: number): number;
  1814. /**
  1815. * This function returns number that corresponds to the percentage in a given range.
  1816. *
  1817. * PercentToRange(0.34,0,100) will return 34.
  1818. * @param percent to convert to number
  1819. * @param min min range
  1820. * @param max max range
  1821. * @returns the number
  1822. */
  1823. static PercentToRange(percent: number, min: number, max: number): number;
  1824. /**
  1825. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1826. * @param angle The angle to normalize in radian.
  1827. * @return The converted angle.
  1828. */
  1829. static NormalizeRadians(angle: number): number;
  1830. }
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Constant used to convert a value to gamma space
  1835. * @ignorenaming
  1836. */
  1837. export const ToGammaSpace: number;
  1838. /**
  1839. * Constant used to convert a value to linear space
  1840. * @ignorenaming
  1841. */
  1842. export const ToLinearSpace = 2.2;
  1843. /**
  1844. * Constant used to define the minimal number value in Babylon.js
  1845. * @ignorenaming
  1846. */
  1847. let Epsilon: number;
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Class used to represent a viewport on screen
  1852. */
  1853. export class Viewport {
  1854. /** viewport left coordinate */
  1855. x: number;
  1856. /** viewport top coordinate */
  1857. y: number;
  1858. /**viewport width */
  1859. width: number;
  1860. /** viewport height */
  1861. height: number;
  1862. /**
  1863. * Creates a Viewport object located at (x, y) and sized (width, height)
  1864. * @param x defines viewport left coordinate
  1865. * @param y defines viewport top coordinate
  1866. * @param width defines the viewport width
  1867. * @param height defines the viewport height
  1868. */
  1869. constructor(
  1870. /** viewport left coordinate */
  1871. x: number,
  1872. /** viewport top coordinate */
  1873. y: number,
  1874. /**viewport width */
  1875. width: number,
  1876. /** viewport height */
  1877. height: number);
  1878. /**
  1879. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1880. * @param renderWidth defines the rendering width
  1881. * @param renderHeight defines the rendering height
  1882. * @returns a new Viewport
  1883. */
  1884. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1885. /**
  1886. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1887. * @param renderWidth defines the rendering width
  1888. * @param renderHeight defines the rendering height
  1889. * @param ref defines the target viewport
  1890. * @returns the current viewport
  1891. */
  1892. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1893. /**
  1894. * Returns a new Viewport copied from the current one
  1895. * @returns a new Viewport
  1896. */
  1897. clone(): Viewport;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. /**
  1902. * Class containing a set of static utilities functions for arrays.
  1903. */
  1904. export class ArrayTools {
  1905. /**
  1906. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1907. * @param size the number of element to construct and put in the array
  1908. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1909. * @returns a new array filled with new objects
  1910. */
  1911. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1912. }
  1913. }
  1914. declare module BABYLON {
  1915. /**
  1916. * Represens a plane by the equation ax + by + cz + d = 0
  1917. */
  1918. export class Plane {
  1919. private static _TmpMatrix;
  1920. /**
  1921. * Normal of the plane (a,b,c)
  1922. */
  1923. normal: Vector3;
  1924. /**
  1925. * d component of the plane
  1926. */
  1927. d: number;
  1928. /**
  1929. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1930. * @param a a component of the plane
  1931. * @param b b component of the plane
  1932. * @param c c component of the plane
  1933. * @param d d component of the plane
  1934. */
  1935. constructor(a: number, b: number, c: number, d: number);
  1936. /**
  1937. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1938. */
  1939. asArray(): number[];
  1940. /**
  1941. * @returns a new plane copied from the current Plane.
  1942. */
  1943. clone(): Plane;
  1944. /**
  1945. * @returns the string "Plane".
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * @returns the Plane hash code.
  1950. */
  1951. getHashCode(): number;
  1952. /**
  1953. * Normalize the current Plane in place.
  1954. * @returns the updated Plane.
  1955. */
  1956. normalize(): Plane;
  1957. /**
  1958. * Applies a transformation the plane and returns the result
  1959. * @param transformation the transformation matrix to be applied to the plane
  1960. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1961. */
  1962. transform(transformation: DeepImmutable<Matrix>): Plane;
  1963. /**
  1964. * Compute the dot product between the point and the plane normal
  1965. * @param point point to calculate the dot product with
  1966. * @returns the dot product (float) of the point coordinates and the plane normal.
  1967. */
  1968. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1969. /**
  1970. * Updates the current Plane from the plane defined by the three given points.
  1971. * @param point1 one of the points used to contruct the plane
  1972. * @param point2 one of the points used to contruct the plane
  1973. * @param point3 one of the points used to contruct the plane
  1974. * @returns the updated Plane.
  1975. */
  1976. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1977. /**
  1978. * Checks if the plane is facing a given direction
  1979. * @param direction the direction to check if the plane is facing
  1980. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1981. * @returns True is the vector "direction" is the same side than the plane normal.
  1982. */
  1983. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1984. /**
  1985. * Calculates the distance to a point
  1986. * @param point point to calculate distance to
  1987. * @returns the signed distance (float) from the given point to the Plane.
  1988. */
  1989. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1990. /**
  1991. * Creates a plane from an array
  1992. * @param array the array to create a plane from
  1993. * @returns a new Plane from the given array.
  1994. */
  1995. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1996. /**
  1997. * Creates a plane from three points
  1998. * @param point1 point used to create the plane
  1999. * @param point2 point used to create the plane
  2000. * @param point3 point used to create the plane
  2001. * @returns a new Plane defined by the three given points.
  2002. */
  2003. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Creates a plane from an origin point and a normal
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @returns a new Plane the normal vector to this plane at the given origin point.
  2009. * Note : the vector "normal" is updated because normalized.
  2010. */
  2011. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2012. /**
  2013. * Calculates the distance from a plane and a point
  2014. * @param origin origin of the plane to be constructed
  2015. * @param normal normal of the plane to be constructed
  2016. * @param point point to calculate distance to
  2017. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2018. */
  2019. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2020. }
  2021. }
  2022. declare module BABYLON {
  2023. /**
  2024. * Class representing a vector containing 2 coordinates
  2025. */
  2026. export class Vector2 {
  2027. /** defines the first coordinate */
  2028. x: number;
  2029. /** defines the second coordinate */
  2030. y: number;
  2031. /**
  2032. * Creates a new Vector2 from the given x and y coordinates
  2033. * @param x defines the first coordinate
  2034. * @param y defines the second coordinate
  2035. */
  2036. constructor(
  2037. /** defines the first coordinate */
  2038. x?: number,
  2039. /** defines the second coordinate */
  2040. y?: number);
  2041. /**
  2042. * Gets a string with the Vector2 coordinates
  2043. * @returns a string with the Vector2 coordinates
  2044. */
  2045. toString(): string;
  2046. /**
  2047. * Gets class name
  2048. * @returns the string "Vector2"
  2049. */
  2050. getClassName(): string;
  2051. /**
  2052. * Gets current vector hash code
  2053. * @returns the Vector2 hash code as a number
  2054. */
  2055. getHashCode(): number;
  2056. /**
  2057. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2058. * @param array defines the source array
  2059. * @param index defines the offset in source array
  2060. * @returns the current Vector2
  2061. */
  2062. toArray(array: FloatArray, index?: number): Vector2;
  2063. /**
  2064. * Copy the current vector to an array
  2065. * @returns a new array with 2 elements: the Vector2 coordinates.
  2066. */
  2067. asArray(): number[];
  2068. /**
  2069. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2070. * @param source defines the source Vector2
  2071. * @returns the current updated Vector2
  2072. */
  2073. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Sets the Vector2 coordinates with the given floats
  2076. * @param x defines the first coordinate
  2077. * @param y defines the second coordinate
  2078. * @returns the current updated Vector2
  2079. */
  2080. copyFromFloats(x: number, y: number): Vector2;
  2081. /**
  2082. * Sets the Vector2 coordinates with the given floats
  2083. * @param x defines the first coordinate
  2084. * @param y defines the second coordinate
  2085. * @returns the current updated Vector2
  2086. */
  2087. set(x: number, y: number): Vector2;
  2088. /**
  2089. * Add another vector with the current one
  2090. * @param otherVector defines the other vector
  2091. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2092. */
  2093. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2096. * @param otherVector defines the other vector
  2097. * @param result defines the target vector
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2101. /**
  2102. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2103. * @param otherVector defines the other vector
  2104. * @returns the current updated Vector2
  2105. */
  2106. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2107. /**
  2108. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2109. * @param otherVector defines the other vector
  2110. * @returns a new Vector2
  2111. */
  2112. addVector3(otherVector: Vector3): Vector2;
  2113. /**
  2114. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2115. * @param otherVector defines the other vector
  2116. * @returns a new Vector2
  2117. */
  2118. subtract(otherVector: Vector2): Vector2;
  2119. /**
  2120. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2121. * @param otherVector defines the other vector
  2122. * @param result defines the target vector
  2123. * @returns the unmodified current Vector2
  2124. */
  2125. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2126. /**
  2127. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Multiplies in place the current Vector2 coordinates by the given ones
  2134. * @param otherVector defines the other vector
  2135. * @returns the current updated Vector2
  2136. */
  2137. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2138. /**
  2139. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns a new Vector2
  2142. */
  2143. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2146. * @param otherVector defines the other vector
  2147. * @param result defines the target vector
  2148. * @returns the unmodified current Vector2
  2149. */
  2150. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns a new Vector2
  2156. */
  2157. multiplyByFloats(x: number, y: number): Vector2;
  2158. /**
  2159. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2
  2162. */
  2163. divide(otherVector: Vector2): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Divides the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 with current Vector2 negated coordinates
  2179. * @returns a new Vector2
  2180. */
  2181. negate(): Vector2;
  2182. /**
  2183. * Negate this vector in place
  2184. * @returns this
  2185. */
  2186. negateInPlace(): Vector2;
  2187. /**
  2188. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2189. * @param result defines the Vector3 object where to store the result
  2190. * @returns the current Vector2
  2191. */
  2192. negateToRef(result: Vector2): Vector2;
  2193. /**
  2194. * Multiply the Vector2 coordinates by scale
  2195. * @param scale defines the scaling factor
  2196. * @returns the current updated Vector2
  2197. */
  2198. scaleInPlace(scale: number): Vector2;
  2199. /**
  2200. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2201. * @param scale defines the scaling factor
  2202. * @returns a new Vector2
  2203. */
  2204. scale(scale: number): Vector2;
  2205. /**
  2206. * Scale the current Vector2 values by a factor to a given Vector2
  2207. * @param scale defines the scale factor
  2208. * @param result defines the Vector2 object where to store the result
  2209. * @returns the unmodified current Vector2
  2210. */
  2211. scaleToRef(scale: number, result: Vector2): Vector2;
  2212. /**
  2213. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2214. * @param scale defines the scale factor
  2215. * @param result defines the Vector2 object where to store the result
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a boolean if two vectors are equals
  2221. * @param otherVector defines the other vector
  2222. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2223. */
  2224. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2225. /**
  2226. * Gets a boolean if two vectors are equals (using an epsilon value)
  2227. * @param otherVector defines the other vector
  2228. * @param epsilon defines the minimal distance to consider equality
  2229. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2230. */
  2231. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2232. /**
  2233. * Gets a new Vector2 from current Vector2 floored values
  2234. * @returns a new Vector2
  2235. */
  2236. floor(): Vector2;
  2237. /**
  2238. * Gets a new Vector2 from current Vector2 floored values
  2239. * @returns a new Vector2
  2240. */
  2241. fract(): Vector2;
  2242. /**
  2243. * Gets the length of the vector
  2244. * @returns the vector length (float)
  2245. */
  2246. length(): number;
  2247. /**
  2248. * Gets the vector squared length
  2249. * @returns the vector squared length (float)
  2250. */
  2251. lengthSquared(): number;
  2252. /**
  2253. * Normalize the vector
  2254. * @returns the current updated Vector2
  2255. */
  2256. normalize(): Vector2;
  2257. /**
  2258. * Gets a new Vector2 copied from the Vector2
  2259. * @returns a new Vector2
  2260. */
  2261. clone(): Vector2;
  2262. /**
  2263. * Gets a new Vector2(0, 0)
  2264. * @returns a new Vector2
  2265. */
  2266. static Zero(): Vector2;
  2267. /**
  2268. * Gets a new Vector2(1, 1)
  2269. * @returns a new Vector2
  2270. */
  2271. static One(): Vector2;
  2272. /**
  2273. * Gets a new Vector2 set from the given index element of the given array
  2274. * @param array defines the data source
  2275. * @param offset defines the offset in the data source
  2276. * @returns a new Vector2
  2277. */
  2278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2279. /**
  2280. * Sets "result" from the given index element of the given array
  2281. * @param array defines the data source
  2282. * @param offset defines the offset in the data source
  2283. * @param result defines the target vector
  2284. */
  2285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2286. /**
  2287. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2288. * @param value1 defines 1st point of control
  2289. * @param value2 defines 2nd point of control
  2290. * @param value3 defines 3rd point of control
  2291. * @param value4 defines 4th point of control
  2292. * @param amount defines the interpolation factor
  2293. * @returns a new Vector2
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2296. /**
  2297. * 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".
  2298. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2299. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2300. * @param value defines the value to clamp
  2301. * @param min defines the lower limit
  2302. * @param max defines the upper limit
  2303. * @returns a new Vector2
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2306. /**
  2307. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2308. * @param value1 defines the 1st control point
  2309. * @param tangent1 defines the outgoing tangent
  2310. * @param value2 defines the 2nd control point
  2311. * @param tangent2 defines the incoming tangent
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2318. * @param start defines the start vector
  2319. * @param end defines the end vector
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * Gets the dot product of the vector "left" and the vector "right"
  2326. * @param left defines first vector
  2327. * @param right defines second vector
  2328. * @returns the dot product (float)
  2329. */
  2330. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2331. /**
  2332. * Returns a new Vector2 equal to the normalized given vector
  2333. * @param vector defines the vector to normalize
  2334. * @returns a new Vector2
  2335. */
  2336. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2337. /**
  2338. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2339. * @param left defines 1st vector
  2340. * @param right defines 2nd vector
  2341. * @returns a new Vector2
  2342. */
  2343. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2344. /**
  2345. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2346. * @param left defines 1st vector
  2347. * @param right defines 2nd vector
  2348. * @returns a new Vector2
  2349. */
  2350. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2351. /**
  2352. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2353. * @param vector defines the vector to transform
  2354. * @param transformation defines the matrix to apply
  2355. * @returns a new Vector2
  2356. */
  2357. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2358. /**
  2359. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2360. * @param vector defines the vector to transform
  2361. * @param transformation defines the matrix to apply
  2362. * @param result defines the target vector
  2363. */
  2364. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2365. /**
  2366. * Determines if a given vector is included in a triangle
  2367. * @param p defines the vector to test
  2368. * @param p0 defines 1st triangle point
  2369. * @param p1 defines 2nd triangle point
  2370. * @param p2 defines 3rd triangle point
  2371. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2372. */
  2373. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2374. /**
  2375. * Gets the distance between the vectors "value1" and "value2"
  2376. * @param value1 defines first vector
  2377. * @param value2 defines second vector
  2378. * @returns the distance between vectors
  2379. */
  2380. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2381. /**
  2382. * Returns the squared distance between the vectors "value1" and "value2"
  2383. * @param value1 defines first vector
  2384. * @param value2 defines second vector
  2385. * @returns the squared distance between vectors
  2386. */
  2387. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2388. /**
  2389. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2390. * @param value1 defines first vector
  2391. * @param value2 defines second vector
  2392. * @returns a new Vector2
  2393. */
  2394. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2397. * @param p defines the middle point
  2398. * @param segA defines one point of the segment
  2399. * @param segB defines the other point of the segment
  2400. * @returns the shortest distance
  2401. */
  2402. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2403. }
  2404. /**
  2405. * Class used to store (x,y,z) vector representation
  2406. * A Vector3 is the main object used in 3D geometry
  2407. * It can represent etiher the coordinates of a point the space, either a direction
  2408. * Reminder: js uses a left handed forward facing system
  2409. */
  2410. export class Vector3 {
  2411. /**
  2412. * Defines the first coordinates (on X axis)
  2413. */
  2414. x: number;
  2415. /**
  2416. * Defines the second coordinates (on Y axis)
  2417. */
  2418. y: number;
  2419. /**
  2420. * Defines the third coordinates (on Z axis)
  2421. */
  2422. z: number;
  2423. private static _UpReadOnly;
  2424. private static _ZeroReadOnly;
  2425. /**
  2426. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2427. * @param x defines the first coordinates (on X axis)
  2428. * @param y defines the second coordinates (on Y axis)
  2429. * @param z defines the third coordinates (on Z axis)
  2430. */
  2431. constructor(
  2432. /**
  2433. * Defines the first coordinates (on X axis)
  2434. */
  2435. x?: number,
  2436. /**
  2437. * Defines the second coordinates (on Y axis)
  2438. */
  2439. y?: number,
  2440. /**
  2441. * Defines the third coordinates (on Z axis)
  2442. */
  2443. z?: number);
  2444. /**
  2445. * Creates a string representation of the Vector3
  2446. * @returns a string with the Vector3 coordinates.
  2447. */
  2448. toString(): string;
  2449. /**
  2450. * Gets the class name
  2451. * @returns the string "Vector3"
  2452. */
  2453. getClassName(): string;
  2454. /**
  2455. * Creates the Vector3 hash code
  2456. * @returns a number which tends to be unique between Vector3 instances
  2457. */
  2458. getHashCode(): number;
  2459. /**
  2460. * Creates an array containing three elements : the coordinates of the Vector3
  2461. * @returns a new array of numbers
  2462. */
  2463. asArray(): number[];
  2464. /**
  2465. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2466. * @param array defines the destination array
  2467. * @param index defines the offset in the destination array
  2468. * @returns the current Vector3
  2469. */
  2470. toArray(array: FloatArray, index?: number): Vector3;
  2471. /**
  2472. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2473. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2474. */
  2475. toQuaternion(): Quaternion;
  2476. /**
  2477. * Adds the given vector to the current Vector3
  2478. * @param otherVector defines the second operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Adds the given coordinates to the current Vector3
  2484. * @param x defines the x coordinate of the operand
  2485. * @param y defines the y coordinate of the operand
  2486. * @param z defines the z coordinate of the operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2490. /**
  2491. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the resulting Vector3
  2494. */
  2495. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Subtract the given vector from the current Vector3
  2505. * @param otherVector defines the second operand
  2506. * @returns the current updated Vector3
  2507. */
  2508. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2509. /**
  2510. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2511. * @param otherVector defines the second operand
  2512. * @returns the resulting Vector3
  2513. */
  2514. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2515. /**
  2516. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2517. * @param otherVector defines the second operand
  2518. * @param result defines the Vector3 object where to store the result
  2519. * @returns the current Vector3
  2520. */
  2521. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @returns the resulting Vector3
  2528. */
  2529. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2530. /**
  2531. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2532. * @param x defines the x coordinate of the operand
  2533. * @param y defines the y coordinate of the operand
  2534. * @param z defines the z coordinate of the operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2539. /**
  2540. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2541. * @returns a new Vector3
  2542. */
  2543. negate(): Vector3;
  2544. /**
  2545. * Negate this vector in place
  2546. * @returns this
  2547. */
  2548. negateInPlace(): Vector3;
  2549. /**
  2550. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2551. * @param result defines the Vector3 object where to store the result
  2552. * @returns the current Vector3
  2553. */
  2554. negateToRef(result: Vector3): Vector3;
  2555. /**
  2556. * Multiplies the Vector3 coordinates by the float "scale"
  2557. * @param scale defines the multiplier factor
  2558. * @returns the current updated Vector3
  2559. */
  2560. scaleInPlace(scale: number): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2563. * @param scale defines the multiplier factor
  2564. * @returns a new Vector3
  2565. */
  2566. scale(scale: number): Vector3;
  2567. /**
  2568. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2569. * @param scale defines the multiplier factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the current Vector3
  2572. */
  2573. scaleToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2576. * @param scale defines the scale factor
  2577. * @param result defines the Vector3 object where to store the result
  2578. * @returns the unmodified current Vector3
  2579. */
  2580. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2581. /**
  2582. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2583. * @param origin defines the origin of the projection ray
  2584. * @param plane defines the plane to project to
  2585. * @returns the projected vector3
  2586. */
  2587. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2588. /**
  2589. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2590. * @param origin defines the origin of the projection ray
  2591. * @param plane defines the plane to project to
  2592. * @param result defines the Vector3 where to store the result
  2593. */
  2594. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2595. /**
  2596. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2597. * @param otherVector defines the second operand
  2598. * @returns true if both vectors are equals
  2599. */
  2600. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2603. * @param otherVector defines the second operand
  2604. * @param epsilon defines the minimal distance to define values as equals
  2605. * @returns true if both vectors are distant less than epsilon
  2606. */
  2607. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2608. /**
  2609. * Returns true if the current Vector3 coordinates equals the given floats
  2610. * @param x defines the x coordinate of the operand
  2611. * @param y defines the y coordinate of the operand
  2612. * @param z defines the z coordinate of the operand
  2613. * @returns true if both vectors are equals
  2614. */
  2615. equalsToFloats(x: number, y: number, z: number): boolean;
  2616. /**
  2617. * Multiplies the current Vector3 coordinates by the given ones
  2618. * @param otherVector defines the second operand
  2619. * @returns the current updated Vector3
  2620. */
  2621. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2624. * @param otherVector defines the second operand
  2625. * @returns the new Vector3
  2626. */
  2627. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2628. /**
  2629. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2630. * @param otherVector defines the second operand
  2631. * @param result defines the Vector3 object where to store the result
  2632. * @returns the current Vector3
  2633. */
  2634. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2637. * @param x defines the x coordinate of the operand
  2638. * @param y defines the y coordinate of the operand
  2639. * @param z defines the z coordinate of the operand
  2640. * @returns the new Vector3
  2641. */
  2642. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2643. /**
  2644. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2645. * @param otherVector defines the second operand
  2646. * @returns the new Vector3
  2647. */
  2648. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2651. * @param otherVector defines the second operand
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the current Vector3
  2654. */
  2655. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2656. /**
  2657. * Divides the current Vector3 coordinates by the given ones.
  2658. * @param otherVector defines the second operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. divideInPlace(otherVector: Vector3): Vector3;
  2662. /**
  2663. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2664. * @param other defines the second operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2668. /**
  2669. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2670. * @param other defines the second operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2684. * @param x defines the x coordinate of the operand
  2685. * @param y defines the y coordinate of the operand
  2686. * @param z defines the z coordinate of the operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2690. /**
  2691. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2692. * Check if is non uniform within a certain amount of decimal places to account for this
  2693. * @param epsilon the amount the values can differ
  2694. * @returns if the the vector is non uniform to a certain number of decimal places
  2695. */
  2696. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2697. /**
  2698. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2699. */
  2700. get isNonUniform(): boolean;
  2701. /**
  2702. * Gets a new Vector3 from current Vector3 floored values
  2703. * @returns a new Vector3
  2704. */
  2705. floor(): Vector3;
  2706. /**
  2707. * Gets a new Vector3 from current Vector3 floored values
  2708. * @returns a new Vector3
  2709. */
  2710. fract(): Vector3;
  2711. /**
  2712. * Gets the length of the Vector3
  2713. * @returns the length of the Vector3
  2714. */
  2715. length(): number;
  2716. /**
  2717. * Gets the squared length of the Vector3
  2718. * @returns squared length of the Vector3
  2719. */
  2720. lengthSquared(): number;
  2721. /**
  2722. * Normalize the current Vector3.
  2723. * Please note that this is an in place operation.
  2724. * @returns the current updated Vector3
  2725. */
  2726. normalize(): Vector3;
  2727. /**
  2728. * Reorders the x y z properties of the vector in place
  2729. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2730. * @returns the current updated vector
  2731. */
  2732. reorderInPlace(order: string): this;
  2733. /**
  2734. * Rotates the vector around 0,0,0 by a quaternion
  2735. * @param quaternion the rotation quaternion
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2740. /**
  2741. * Rotates a vector around a given point
  2742. * @param quaternion the rotation quaternion
  2743. * @param point the point to rotate around
  2744. * @param result vector to store the result
  2745. * @returns the resulting vector
  2746. */
  2747. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2748. /**
  2749. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2750. * The cross product is then orthogonal to both current and "other"
  2751. * @param other defines the right operand
  2752. * @returns the cross product
  2753. */
  2754. cross(other: Vector3): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 with the given input length.
  2757. * Please note that this is an in place operation.
  2758. * @param len the length of the vector
  2759. * @returns the current updated Vector3
  2760. */
  2761. normalizeFromLength(len: number): Vector3;
  2762. /**
  2763. * Normalize the current Vector3 to a new vector
  2764. * @returns the new Vector3
  2765. */
  2766. normalizeToNew(): Vector3;
  2767. /**
  2768. * Normalize the current Vector3 to the reference
  2769. * @param reference define the Vector3 to update
  2770. * @returns the updated Vector3
  2771. */
  2772. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2773. /**
  2774. * Creates a new Vector3 copied from the current Vector3
  2775. * @returns the new Vector3
  2776. */
  2777. clone(): Vector3;
  2778. /**
  2779. * Copies the given vector coordinates to the current Vector3 ones
  2780. * @param source defines the source Vector3
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. copyFromFloats(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given floats to the current Vector3 coordinates
  2794. * @param x defines the x coordinate of the operand
  2795. * @param y defines the y coordinate of the operand
  2796. * @param z defines the z coordinate of the operand
  2797. * @returns the current updated Vector3
  2798. */
  2799. set(x: number, y: number, z: number): Vector3;
  2800. /**
  2801. * Copies the given float to the current Vector3 coordinates
  2802. * @param v defines the x, y and z coordinates of the operand
  2803. * @returns the current updated Vector3
  2804. */
  2805. setAll(v: number): Vector3;
  2806. /**
  2807. * Get the clip factor between two vectors
  2808. * @param vector0 defines the first operand
  2809. * @param vector1 defines the second operand
  2810. * @param axis defines the axis to use
  2811. * @param size defines the size along the axis
  2812. * @returns the clip factor
  2813. */
  2814. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2815. /**
  2816. * Get angle between two vectors
  2817. * @param vector0 angle between vector0 and vector1
  2818. * @param vector1 angle between vector0 and vector1
  2819. * @param normal direction of the normal
  2820. * @return the angle between vector0 and vector1
  2821. */
  2822. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. */
  2829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2830. /**
  2831. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @returns the new Vector3
  2835. * @deprecated Please use FromArray instead.
  2836. */
  2837. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2840. * @param array defines the source array
  2841. * @param offset defines the offset in the source array
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2847. * @param array defines the source array
  2848. * @param offset defines the offset in the source array
  2849. * @param result defines the Vector3 where to store the result
  2850. * @deprecated Please use FromArrayToRef instead.
  2851. */
  2852. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2853. /**
  2854. * Sets the given vector "result" with the given floats.
  2855. * @param x defines the x coordinate of the source
  2856. * @param y defines the y coordinate of the source
  2857. * @param z defines the z coordinate of the source
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2863. * @returns a new empty Vector3
  2864. */
  2865. static Zero(): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2868. * @returns a new unit Vector3
  2869. */
  2870. static One(): Vector3;
  2871. /**
  2872. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2873. * @returns a new up Vector3
  2874. */
  2875. static Up(): Vector3;
  2876. /**
  2877. * Gets a up Vector3 that must not be updated
  2878. */
  2879. static get UpReadOnly(): DeepImmutable<Vector3>;
  2880. /**
  2881. * Gets a zero Vector3 that must not be updated
  2882. */
  2883. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2884. /**
  2885. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2886. * @returns a new down Vector3
  2887. */
  2888. static Down(): Vector3;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2891. * @param rightHandedSystem is the scene right-handed (negative z)
  2892. * @returns a new forward Vector3
  2893. */
  2894. static Forward(rightHandedSystem?: boolean): Vector3;
  2895. /**
  2896. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2897. * @param rightHandedSystem is the scene right-handed (negative-z)
  2898. * @returns a new forward Vector3
  2899. */
  2900. static Backward(rightHandedSystem?: boolean): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2903. * @returns a new right Vector3
  2904. */
  2905. static Right(): Vector3;
  2906. /**
  2907. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2908. * @returns a new left Vector3
  2909. */
  2910. static Left(): Vector3;
  2911. /**
  2912. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @returns the transformed Vector3
  2917. */
  2918. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2921. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2922. * @param vector defines the Vector3 to transform
  2923. * @param transformation defines the transformation matrix
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2929. * This method computes tranformed coordinates only, not transformed direction vectors
  2930. * @param x define the x coordinate of the source vector
  2931. * @param y define the y coordinate of the source vector
  2932. * @param z define the z coordinate of the source vector
  2933. * @param transformation defines the transformation matrix
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2937. /**
  2938. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @returns the new Vector3
  2943. */
  2944. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param vector defines the Vector3 to transform
  2949. * @param transformation defines the transformation matrix
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2955. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2956. * @param x define the x coordinate of the source vector
  2957. * @param y define the y coordinate of the source vector
  2958. * @param z define the z coordinate of the source vector
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2965. * @param value1 defines the first control point
  2966. * @param value2 defines the second control point
  2967. * @param value3 defines the third control point
  2968. * @param value4 defines the fourth control point
  2969. * @param amount defines the amount on the spline to use
  2970. * @returns the new Vector3
  2971. */
  2972. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2973. /**
  2974. * 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"
  2975. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2976. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2977. * @param value defines the current value
  2978. * @param min defines the lower range value
  2979. * @param max defines the upper range value
  2980. * @returns the new Vector3
  2981. */
  2982. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * 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"
  2985. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2986. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2987. * @param value defines the current value
  2988. * @param min defines the lower range value
  2989. * @param max defines the upper range value
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2993. /**
  2994. * Checks if a given vector is inside a specific range
  2995. * @param v defines the vector to test
  2996. * @param min defines the minimum range
  2997. * @param max defines the maximum range
  2998. */
  2999. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3000. /**
  3001. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3002. * @param value1 defines the first control point
  3003. * @param tangent1 defines the first tangent vector
  3004. * @param value2 defines the second control point
  3005. * @param tangent2 defines the second tangent vector
  3006. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @returns the new Vector3
  3016. */
  3017. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3018. /**
  3019. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3020. * @param start defines the start value
  3021. * @param end defines the end value
  3022. * @param amount max defines amount between both (between 0 and 1)
  3023. * @param result defines the Vector3 where to store the result
  3024. */
  3025. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3026. /**
  3027. * Returns the dot product (float) between the vectors "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the dot product
  3031. */
  3032. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3033. /**
  3034. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @returns the cross product
  3039. */
  3040. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3041. /**
  3042. * Sets the given vector "result" with the cross product of "left" and "right"
  3043. * The cross product is then orthogonal to both "left" and "right"
  3044. * @param left defines the left operand
  3045. * @param right defines the right operand
  3046. * @param result defines the Vector3 where to store the result
  3047. */
  3048. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3049. /**
  3050. * Returns a new Vector3 as the normalization of the given vector
  3051. * @param vector defines the Vector3 to normalize
  3052. * @returns the new Vector3
  3053. */
  3054. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * Sets the given vector "result" with the normalization of the given first vector
  3057. * @param vector defines the Vector3 to normalize
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Project a Vector3 onto screen space
  3063. * @param vector defines the Vector3 to project
  3064. * @param world defines the world matrix to use
  3065. * @param transform defines the transform (view x projection) matrix to use
  3066. * @param viewport defines the screen viewport to use
  3067. * @returns the new Vector3
  3068. */
  3069. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3070. /** @hidden */
  3071. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3072. /**
  3073. * Unproject from screen space to object space
  3074. * @param source defines the screen space Vector3 to use
  3075. * @param viewportWidth defines the current width of the viewport
  3076. * @param viewportHeight defines the current height of the viewport
  3077. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3078. * @param transform defines the transform (view x projection) matrix to use
  3079. * @returns the new Vector3
  3080. */
  3081. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3082. /**
  3083. * Unproject from screen space to object space
  3084. * @param source defines the screen space Vector3 to use
  3085. * @param viewportWidth defines the current width of the viewport
  3086. * @param viewportHeight defines the current height of the viewport
  3087. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3088. * @param view defines the view matrix to use
  3089. * @param projection defines the projection matrix to use
  3090. * @returns the new Vector3
  3091. */
  3092. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3093. /**
  3094. * Unproject from screen space to object space
  3095. * @param source defines the screen space Vector3 to use
  3096. * @param viewportWidth defines the current width of the viewport
  3097. * @param viewportHeight defines the current height of the viewport
  3098. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3099. * @param view defines the view matrix to use
  3100. * @param projection defines the projection matrix to use
  3101. * @param result defines the Vector3 where to store the result
  3102. */
  3103. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3104. /**
  3105. * Unproject from screen space to object space
  3106. * @param sourceX defines the screen space x coordinate to use
  3107. * @param sourceY defines the screen space y coordinate to use
  3108. * @param sourceZ defines the screen space z coordinate to use
  3109. * @param viewportWidth defines the current width of the viewport
  3110. * @param viewportHeight defines the current height of the viewport
  3111. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3112. * @param view defines the view matrix to use
  3113. * @param projection defines the projection matrix to use
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3117. /**
  3118. * Gets the minimal coordinate values between two Vector3
  3119. * @param left defines the first operand
  3120. * @param right defines the second operand
  3121. * @returns the new Vector3
  3122. */
  3123. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Gets the maximal coordinate values between two Vector3
  3126. * @param left defines the first operand
  3127. * @param right defines the second operand
  3128. * @returns the new Vector3
  3129. */
  3130. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3131. /**
  3132. * Returns the distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the distance
  3136. */
  3137. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns the squared distance between the vectors "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the squared distance
  3143. */
  3144. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3145. /**
  3146. * Returns a new Vector3 located at the center between "value1" and "value2"
  3147. * @param value1 defines the first operand
  3148. * @param value2 defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3154. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3155. * to something in order to rotate it from its local system to the given target system
  3156. * Note: axis1, axis2 and axis3 are normalized during this operation
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @returns a new Vector3
  3161. */
  3162. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3165. * @param axis1 defines the first axis
  3166. * @param axis2 defines the second axis
  3167. * @param axis3 defines the third axis
  3168. * @param ref defines the Vector3 where to store the result
  3169. */
  3170. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3171. }
  3172. /**
  3173. * Vector4 class created for EulerAngle class conversion to Quaternion
  3174. */
  3175. export class Vector4 {
  3176. /** x value of the vector */
  3177. x: number;
  3178. /** y value of the vector */
  3179. y: number;
  3180. /** z value of the vector */
  3181. z: number;
  3182. /** w value of the vector */
  3183. w: number;
  3184. /**
  3185. * Creates a Vector4 object from the given floats.
  3186. * @param x x value of the vector
  3187. * @param y y value of the vector
  3188. * @param z z value of the vector
  3189. * @param w w value of the vector
  3190. */
  3191. constructor(
  3192. /** x value of the vector */
  3193. x: number,
  3194. /** y value of the vector */
  3195. y: number,
  3196. /** z value of the vector */
  3197. z: number,
  3198. /** w value of the vector */
  3199. w: number);
  3200. /**
  3201. * Returns the string with the Vector4 coordinates.
  3202. * @returns a string containing all the vector values
  3203. */
  3204. toString(): string;
  3205. /**
  3206. * Returns the string "Vector4".
  3207. * @returns "Vector4"
  3208. */
  3209. getClassName(): string;
  3210. /**
  3211. * Returns the Vector4 hash code.
  3212. * @returns a unique hash code
  3213. */
  3214. getHashCode(): number;
  3215. /**
  3216. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3217. * @returns the resulting array
  3218. */
  3219. asArray(): number[];
  3220. /**
  3221. * Populates the given array from the given index with the Vector4 coordinates.
  3222. * @param array array to populate
  3223. * @param index index of the array to start at (default: 0)
  3224. * @returns the Vector4.
  3225. */
  3226. toArray(array: FloatArray, index?: number): Vector4;
  3227. /**
  3228. * Adds the given vector to the current Vector4.
  3229. * @param otherVector the vector to add
  3230. * @returns the updated Vector4.
  3231. */
  3232. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3235. * @param otherVector the vector to add
  3236. * @returns the resulting vector
  3237. */
  3238. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3239. /**
  3240. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3241. * @param otherVector the vector to add
  3242. * @param result the vector to store the result
  3243. * @returns the current Vector4.
  3244. */
  3245. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3246. /**
  3247. * Subtract in place the given vector from the current Vector4.
  3248. * @param otherVector the vector to subtract
  3249. * @returns the updated Vector4.
  3250. */
  3251. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3254. * @param otherVector the vector to add
  3255. * @returns the new vector with the result
  3256. */
  3257. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3260. * @param otherVector the vector to subtract
  3261. * @param result the vector to store the result
  3262. * @returns the current Vector4.
  3263. */
  3264. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3265. /**
  3266. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3267. */
  3268. /**
  3269. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3270. * @param x value to subtract
  3271. * @param y value to subtract
  3272. * @param z value to subtract
  3273. * @param w value to subtract
  3274. * @returns new vector containing the result
  3275. */
  3276. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3277. /**
  3278. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3279. * @param x value to subtract
  3280. * @param y value to subtract
  3281. * @param z value to subtract
  3282. * @param w value to subtract
  3283. * @param result the vector to store the result in
  3284. * @returns the current Vector4.
  3285. */
  3286. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3287. /**
  3288. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3289. * @returns a new vector with the negated values
  3290. */
  3291. negate(): Vector4;
  3292. /**
  3293. * Negate this vector in place
  3294. * @returns this
  3295. */
  3296. negateInPlace(): Vector4;
  3297. /**
  3298. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3299. * @param result defines the Vector3 object where to store the result
  3300. * @returns the current Vector4
  3301. */
  3302. negateToRef(result: Vector4): Vector4;
  3303. /**
  3304. * Multiplies the current Vector4 coordinates by scale (float).
  3305. * @param scale the number to scale with
  3306. * @returns the updated Vector4.
  3307. */
  3308. scaleInPlace(scale: number): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3311. * @param scale the number to scale with
  3312. * @returns a new vector with the result
  3313. */
  3314. scale(scale: number): Vector4;
  3315. /**
  3316. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3317. * @param scale the number to scale with
  3318. * @param result a vector to store the result in
  3319. * @returns the current Vector4.
  3320. */
  3321. scaleToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3324. * @param scale defines the scale factor
  3325. * @param result defines the Vector4 object where to store the result
  3326. * @returns the unmodified current Vector4
  3327. */
  3328. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3329. /**
  3330. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3331. * @param otherVector the vector to compare against
  3332. * @returns true if they are equal
  3333. */
  3334. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3335. /**
  3336. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3337. * @param otherVector vector to compare against
  3338. * @param epsilon (Default: very small number)
  3339. * @returns true if they are equal
  3340. */
  3341. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3342. /**
  3343. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3344. * @param x x value to compare against
  3345. * @param y y value to compare against
  3346. * @param z z value to compare against
  3347. * @param w w value to compare against
  3348. * @returns true if equal
  3349. */
  3350. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3351. /**
  3352. * Multiplies in place the current Vector4 by the given one.
  3353. * @param otherVector vector to multiple with
  3354. * @returns the updated Vector4.
  3355. */
  3356. multiplyInPlace(otherVector: Vector4): Vector4;
  3357. /**
  3358. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3359. * @param otherVector vector to multiple with
  3360. * @returns resulting new vector
  3361. */
  3362. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3365. * @param otherVector vector to multiple with
  3366. * @param result vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3372. * @param x x value multiply with
  3373. * @param y y value multiply with
  3374. * @param z z value multiply with
  3375. * @param w w value multiply with
  3376. * @returns resulting new vector
  3377. */
  3378. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3379. /**
  3380. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3381. * @param otherVector vector to devide with
  3382. * @returns resulting new vector
  3383. */
  3384. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3385. /**
  3386. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3387. * @param otherVector vector to devide with
  3388. * @param result vector to store the result
  3389. * @returns the current Vector4.
  3390. */
  3391. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3392. /**
  3393. * Divides the current Vector3 coordinates by the given ones.
  3394. * @param otherVector vector to devide with
  3395. * @returns the updated Vector3.
  3396. */
  3397. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3398. /**
  3399. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3400. * @param other defines the second operand
  3401. * @returns the current updated Vector4
  3402. */
  3403. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3406. * @param other defines the second operand
  3407. * @returns the current updated Vector4
  3408. */
  3409. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Gets a new Vector4 from current Vector4 floored values
  3412. * @returns a new Vector4
  3413. */
  3414. floor(): Vector4;
  3415. /**
  3416. * Gets a new Vector4 from current Vector3 floored values
  3417. * @returns a new Vector4
  3418. */
  3419. fract(): Vector4;
  3420. /**
  3421. * Returns the Vector4 length (float).
  3422. * @returns the length
  3423. */
  3424. length(): number;
  3425. /**
  3426. * Returns the Vector4 squared length (float).
  3427. * @returns the length squared
  3428. */
  3429. lengthSquared(): number;
  3430. /**
  3431. * Normalizes in place the Vector4.
  3432. * @returns the updated Vector4.
  3433. */
  3434. normalize(): Vector4;
  3435. /**
  3436. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3437. * @returns this converted to a new vector3
  3438. */
  3439. toVector3(): Vector3;
  3440. /**
  3441. * Returns a new Vector4 copied from the current one.
  3442. * @returns the new cloned vector
  3443. */
  3444. clone(): Vector4;
  3445. /**
  3446. * Updates the current Vector4 with the given one coordinates.
  3447. * @param source the source vector to copy from
  3448. * @returns the updated Vector4.
  3449. */
  3450. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3451. /**
  3452. * Updates the current Vector4 coordinates with the given floats.
  3453. * @param x float to copy from
  3454. * @param y float to copy from
  3455. * @param z float to copy from
  3456. * @param w float to copy from
  3457. * @returns the updated Vector4.
  3458. */
  3459. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3460. /**
  3461. * Updates the current Vector4 coordinates with the given floats.
  3462. * @param x float to set from
  3463. * @param y float to set from
  3464. * @param z float to set from
  3465. * @param w float to set from
  3466. * @returns the updated Vector4.
  3467. */
  3468. set(x: number, y: number, z: number, w: number): Vector4;
  3469. /**
  3470. * Copies the given float to the current Vector3 coordinates
  3471. * @param v defines the x, y, z and w coordinates of the operand
  3472. * @returns the current updated Vector3
  3473. */
  3474. setAll(v: number): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set from the starting index of the given array.
  3477. * @param array the array to pull values from
  3478. * @param offset the offset into the array to start at
  3479. * @returns the new vector
  3480. */
  3481. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given array.
  3484. * @param array the array to pull values from
  3485. * @param offset the offset into the array to start at
  3486. * @param result the vector to store the result in
  3487. */
  3488. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" from the starting index of the given Float32Array.
  3491. * @param array the array to pull values from
  3492. * @param offset the offset into the array to start at
  3493. * @param result the vector to store the result in
  3494. */
  3495. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3496. /**
  3497. * Updates the given vector "result" coordinates from the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @param result the vector to the floats in
  3503. */
  3504. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3505. /**
  3506. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3507. * @returns the new vector
  3508. */
  3509. static Zero(): Vector4;
  3510. /**
  3511. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3512. * @returns the new vector
  3513. */
  3514. static One(): Vector4;
  3515. /**
  3516. * Returns a new normalized Vector4 from the given one.
  3517. * @param vector the vector to normalize
  3518. * @returns the vector
  3519. */
  3520. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Updates the given vector "result" from the normalization of the given one.
  3523. * @param vector the vector to normalize
  3524. * @param result the vector to store the result in
  3525. */
  3526. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3527. /**
  3528. * Returns a vector with the minimum values from the left and right vectors
  3529. * @param left left vector to minimize
  3530. * @param right right vector to minimize
  3531. * @returns a new vector with the minimum of the left and right vector values
  3532. */
  3533. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns a vector with the maximum values from the left and right vectors
  3536. * @param left left vector to maximize
  3537. * @param right right vector to maximize
  3538. * @returns a new vector with the maximum of the left and right vector values
  3539. */
  3540. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3541. /**
  3542. * Returns the distance (float) between the vectors "value1" and "value2".
  3543. * @param value1 value to calulate the distance between
  3544. * @param value2 value to calulate the distance between
  3545. * @return the distance between the two vectors
  3546. */
  3547. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the distance between
  3551. * @param value2 value to calulate the distance between
  3552. * @return the distance between the two vectors squared
  3553. */
  3554. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3555. /**
  3556. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3557. * @param value1 value to calulate the center between
  3558. * @param value2 value to calulate the center between
  3559. * @return the center between the two vectors
  3560. */
  3561. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @returns the new vector
  3568. */
  3569. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param vector the vector to transform
  3574. * @param transformation the transformation matrix to apply
  3575. * @param result the vector to store the result in
  3576. */
  3577. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3578. /**
  3579. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3580. * This methods computes transformed normalized direction vectors only.
  3581. * @param x value to transform
  3582. * @param y value to transform
  3583. * @param z value to transform
  3584. * @param w value to transform
  3585. * @param transformation the transformation matrix to apply
  3586. * @param result the vector to store the results in
  3587. */
  3588. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3589. /**
  3590. * Creates a new Vector4 from a Vector3
  3591. * @param source defines the source data
  3592. * @param w defines the 4th component (default is 0)
  3593. * @returns a new Vector4
  3594. */
  3595. static FromVector3(source: Vector3, w?: number): Vector4;
  3596. }
  3597. /**
  3598. * Class used to store quaternion data
  3599. * @see https://en.wikipedia.org/wiki/Quaternion
  3600. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3601. */
  3602. export class Quaternion {
  3603. /** defines the first component (0 by default) */
  3604. x: number;
  3605. /** defines the second component (0 by default) */
  3606. y: number;
  3607. /** defines the third component (0 by default) */
  3608. z: number;
  3609. /** defines the fourth component (1.0 by default) */
  3610. w: number;
  3611. /**
  3612. * Creates a new Quaternion from the given floats
  3613. * @param x defines the first component (0 by default)
  3614. * @param y defines the second component (0 by default)
  3615. * @param z defines the third component (0 by default)
  3616. * @param w defines the fourth component (1.0 by default)
  3617. */
  3618. constructor(
  3619. /** defines the first component (0 by default) */
  3620. x?: number,
  3621. /** defines the second component (0 by default) */
  3622. y?: number,
  3623. /** defines the third component (0 by default) */
  3624. z?: number,
  3625. /** defines the fourth component (1.0 by default) */
  3626. w?: number);
  3627. /**
  3628. * Gets a string representation for the current quaternion
  3629. * @returns a string with the Quaternion coordinates
  3630. */
  3631. toString(): string;
  3632. /**
  3633. * Gets the class name of the quaternion
  3634. * @returns the string "Quaternion"
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * Gets a hash code for this quaternion
  3639. * @returns the quaternion hash code
  3640. */
  3641. getHashCode(): number;
  3642. /**
  3643. * Copy the quaternion to an array
  3644. * @returns a new array populated with 4 elements from the quaternion coordinates
  3645. */
  3646. asArray(): number[];
  3647. /**
  3648. * Check if two quaternions are equals
  3649. * @param otherQuaternion defines the second operand
  3650. * @return true if the current quaternion and the given one coordinates are strictly equals
  3651. */
  3652. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3653. /**
  3654. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3655. * @param otherQuaternion defines the other quaternion
  3656. * @param epsilon defines the minimal distance to consider equality
  3657. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3658. */
  3659. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3660. /**
  3661. * Clone the current quaternion
  3662. * @returns a new quaternion copied from the current one
  3663. */
  3664. clone(): Quaternion;
  3665. /**
  3666. * Copy a quaternion to the current one
  3667. * @param other defines the other quaternion
  3668. * @returns the updated current quaternion
  3669. */
  3670. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3671. /**
  3672. * Updates the current quaternion with the given float coordinates
  3673. * @param x defines the x coordinate
  3674. * @param y defines the y coordinate
  3675. * @param z defines the z coordinate
  3676. * @param w defines the w coordinate
  3677. * @returns the updated current quaternion
  3678. */
  3679. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given float coordinates
  3682. * @param x defines the x coordinate
  3683. * @param y defines the y coordinate
  3684. * @param z defines the z coordinate
  3685. * @param w defines the w coordinate
  3686. * @returns the updated current quaternion
  3687. */
  3688. set(x: number, y: number, z: number, w: number): Quaternion;
  3689. /**
  3690. * Adds two quaternions
  3691. * @param other defines the second operand
  3692. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3693. */
  3694. add(other: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Add a quaternion to the current one
  3697. * @param other defines the quaternion to add
  3698. * @returns the current quaternion
  3699. */
  3700. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3701. /**
  3702. * Subtract two quaternions
  3703. * @param other defines the second operand
  3704. * @returns a new quaternion as the subtraction result of the given one from the current one
  3705. */
  3706. subtract(other: Quaternion): Quaternion;
  3707. /**
  3708. * Multiplies the current quaternion by a scale factor
  3709. * @param value defines the scale factor
  3710. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3711. */
  3712. scale(value: number): Quaternion;
  3713. /**
  3714. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3715. * @param scale defines the scale factor
  3716. * @param result defines the Quaternion object where to store the result
  3717. * @returns the unmodified current quaternion
  3718. */
  3719. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Multiplies in place the current quaternion by a scale factor
  3722. * @param value defines the scale factor
  3723. * @returns the current modified quaternion
  3724. */
  3725. scaleInPlace(value: number): Quaternion;
  3726. /**
  3727. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3728. * @param scale defines the scale factor
  3729. * @param result defines the Quaternion object where to store the result
  3730. * @returns the unmodified current quaternion
  3731. */
  3732. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3733. /**
  3734. * Multiplies two quaternions
  3735. * @param q1 defines the second operand
  3736. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3737. */
  3738. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3741. * @param q1 defines the second operand
  3742. * @param result defines the target quaternion
  3743. * @returns the current quaternion
  3744. */
  3745. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3746. /**
  3747. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3748. * @param q1 defines the second operand
  3749. * @returns the currentupdated quaternion
  3750. */
  3751. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3752. /**
  3753. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3754. * @param ref defines the target quaternion
  3755. * @returns the current quaternion
  3756. */
  3757. conjugateToRef(ref: Quaternion): Quaternion;
  3758. /**
  3759. * Conjugates in place (1-q) the current quaternion
  3760. * @returns the current updated quaternion
  3761. */
  3762. conjugateInPlace(): Quaternion;
  3763. /**
  3764. * Conjugates in place (1-q) the current quaternion
  3765. * @returns a new quaternion
  3766. */
  3767. conjugate(): Quaternion;
  3768. /**
  3769. * Gets length of current quaternion
  3770. * @returns the quaternion length (float)
  3771. */
  3772. length(): number;
  3773. /**
  3774. * Normalize in place the current quaternion
  3775. * @returns the current updated quaternion
  3776. */
  3777. normalize(): Quaternion;
  3778. /**
  3779. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3780. * @param order is a reserved parameter and is ignore for now
  3781. * @returns a new Vector3 containing the Euler angles
  3782. */
  3783. toEulerAngles(order?: string): Vector3;
  3784. /**
  3785. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3786. * @param result defines the vector which will be filled with the Euler angles
  3787. * @param order is a reserved parameter and is ignore for now
  3788. * @returns the current unchanged quaternion
  3789. */
  3790. toEulerAnglesToRef(result: Vector3): Quaternion;
  3791. /**
  3792. * Updates the given rotation matrix with the current quaternion values
  3793. * @param result defines the target matrix
  3794. * @returns the current unchanged quaternion
  3795. */
  3796. toRotationMatrix(result: Matrix): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given rotation matrix values
  3799. * @param matrix defines the source matrix
  3800. * @returns the current updated quaternion
  3801. */
  3802. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3803. /**
  3804. * Creates a new quaternion from a rotation matrix
  3805. * @param matrix defines the source matrix
  3806. * @returns a new quaternion created from the given rotation matrix values
  3807. */
  3808. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3809. /**
  3810. * Updates the given quaternion with the given rotation matrix values
  3811. * @param matrix defines the source matrix
  3812. * @param result defines the target quaternion
  3813. */
  3814. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3815. /**
  3816. * Returns the dot product (float) between the quaternions "left" and "right"
  3817. * @param left defines the left operand
  3818. * @param right defines the right operand
  3819. * @returns the dot product
  3820. */
  3821. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3822. /**
  3823. * Checks if the two quaternions are close to each other
  3824. * @param quat0 defines the first quaternion to check
  3825. * @param quat1 defines the second quaternion to check
  3826. * @returns true if the two quaternions are close to each other
  3827. */
  3828. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3829. /**
  3830. * Creates an empty quaternion
  3831. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3832. */
  3833. static Zero(): Quaternion;
  3834. /**
  3835. * Inverse a given quaternion
  3836. * @param q defines the source quaternion
  3837. * @returns a new quaternion as the inverted current quaternion
  3838. */
  3839. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Inverse a given quaternion
  3842. * @param q defines the source quaternion
  3843. * @param result the quaternion the result will be stored in
  3844. * @returns the result quaternion
  3845. */
  3846. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3847. /**
  3848. * Creates an identity quaternion
  3849. * @returns the identity quaternion
  3850. */
  3851. static Identity(): Quaternion;
  3852. /**
  3853. * Gets a boolean indicating if the given quaternion is identity
  3854. * @param quaternion defines the quaternion to check
  3855. * @returns true if the quaternion is identity
  3856. */
  3857. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3858. /**
  3859. * Creates a quaternion from a rotation around an axis
  3860. * @param axis defines the axis to use
  3861. * @param angle defines the angle to use
  3862. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3863. */
  3864. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3865. /**
  3866. * Creates a rotation around an axis and stores it into the given quaternion
  3867. * @param axis defines the axis to use
  3868. * @param angle defines the angle to use
  3869. * @param result defines the target quaternion
  3870. * @returns the target quaternion
  3871. */
  3872. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3873. /**
  3874. * Creates a new quaternion from data stored into an array
  3875. * @param array defines the data source
  3876. * @param offset defines the offset in the source array where the data starts
  3877. * @returns a new quaternion
  3878. */
  3879. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3880. /**
  3881. * Updates the given quaternion "result" from the starting index of the given array.
  3882. * @param array the array to pull values from
  3883. * @param offset the offset into the array to start at
  3884. * @param result the quaternion to store the result in
  3885. */
  3886. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3887. /**
  3888. * Create a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @returns the new Quaternion
  3893. */
  3894. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3895. /**
  3896. * Updates a quaternion from Euler rotation angles
  3897. * @param x Pitch
  3898. * @param y Yaw
  3899. * @param z Roll
  3900. * @param result the quaternion to store the result
  3901. * @returns the updated quaternion
  3902. */
  3903. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3904. /**
  3905. * Create a quaternion from Euler rotation vector
  3906. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3907. * @returns the new Quaternion
  3908. */
  3909. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3910. /**
  3911. * Updates a quaternion from Euler rotation vector
  3912. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3913. * @param result the quaternion to store the result
  3914. * @returns the updated quaternion
  3915. */
  3916. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3917. /**
  3918. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @returns the new quaternion
  3923. */
  3924. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3925. /**
  3926. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3927. * @param yaw defines the rotation around Y axis
  3928. * @param pitch defines the rotation around X axis
  3929. * @param roll defines the rotation around Z axis
  3930. * @param result defines the target quaternion
  3931. */
  3932. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @returns the new quaternion
  3939. */
  3940. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3941. /**
  3942. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3943. * @param alpha defines the rotation around first axis
  3944. * @param beta defines the rotation around second axis
  3945. * @param gamma defines the rotation around third axis
  3946. * @param result defines the target quaternion
  3947. */
  3948. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3949. /**
  3950. * 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)
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @returns the new quaternion
  3955. */
  3956. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3957. /**
  3958. * 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
  3959. * @param axis1 defines the first axis
  3960. * @param axis2 defines the second axis
  3961. * @param axis3 defines the third axis
  3962. * @param ref defines the target quaternion
  3963. */
  3964. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3965. /**
  3966. * Interpolates between two quaternions
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @returns the new interpolated quaternion
  3971. */
  3972. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3973. /**
  3974. * Interpolates between two quaternions and stores it into a target quaternion
  3975. * @param left defines first quaternion
  3976. * @param right defines second quaternion
  3977. * @param amount defines the gradient to use
  3978. * @param result defines the target quaternion
  3979. */
  3980. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3981. /**
  3982. * Interpolate between two quaternions using Hermite interpolation
  3983. * @param value1 defines first quaternion
  3984. * @param tangent1 defines the incoming tangent
  3985. * @param value2 defines second quaternion
  3986. * @param tangent2 defines the outgoing tangent
  3987. * @param amount defines the target quaternion
  3988. * @returns the new interpolated quaternion
  3989. */
  3990. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3991. }
  3992. /**
  3993. * Class used to store matrix data (4x4)
  3994. */
  3995. export class Matrix {
  3996. private static _updateFlagSeed;
  3997. private static _identityReadOnly;
  3998. private _isIdentity;
  3999. private _isIdentityDirty;
  4000. private _isIdentity3x2;
  4001. private _isIdentity3x2Dirty;
  4002. /**
  4003. * Gets the update flag of the matrix which is an unique number for the matrix.
  4004. * It will be incremented every time the matrix data change.
  4005. * You can use it to speed the comparison between two versions of the same matrix.
  4006. */
  4007. updateFlag: number;
  4008. private readonly _m;
  4009. /**
  4010. * Gets the internal data of the matrix
  4011. */
  4012. get m(): DeepImmutable<Float32Array>;
  4013. /** @hidden */
  4014. _markAsUpdated(): void;
  4015. /** @hidden */
  4016. private _updateIdentityStatus;
  4017. /**
  4018. * Creates an empty matrix (filled with zeros)
  4019. */
  4020. constructor();
  4021. /**
  4022. * Check if the current matrix is identity
  4023. * @returns true is the matrix is the identity matrix
  4024. */
  4025. isIdentity(): boolean;
  4026. /**
  4027. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4028. * @returns true is the matrix is the identity matrix
  4029. */
  4030. isIdentityAs3x2(): boolean;
  4031. /**
  4032. * Gets the determinant of the matrix
  4033. * @returns the matrix determinant
  4034. */
  4035. determinant(): number;
  4036. /**
  4037. * Returns the matrix as a Float32Array
  4038. * @returns the matrix underlying array
  4039. */
  4040. toArray(): DeepImmutable<Float32Array>;
  4041. /**
  4042. * Returns the matrix as a Float32Array
  4043. * @returns the matrix underlying array.
  4044. */
  4045. asArray(): DeepImmutable<Float32Array>;
  4046. /**
  4047. * Inverts the current matrix in place
  4048. * @returns the current inverted matrix
  4049. */
  4050. invert(): Matrix;
  4051. /**
  4052. * Sets all the matrix elements to zero
  4053. * @returns the current matrix
  4054. */
  4055. reset(): Matrix;
  4056. /**
  4057. * Adds the current matrix with a second one
  4058. * @param other defines the matrix to add
  4059. * @returns a new matrix as the addition of the current matrix and the given one
  4060. */
  4061. add(other: DeepImmutable<Matrix>): Matrix;
  4062. /**
  4063. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4064. * @param other defines the matrix to add
  4065. * @param result defines the target matrix
  4066. * @returns the current matrix
  4067. */
  4068. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4069. /**
  4070. * Adds in place the given matrix to the current matrix
  4071. * @param other defines the second operand
  4072. * @returns the current updated matrix
  4073. */
  4074. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4075. /**
  4076. * Sets the given matrix to the current inverted Matrix
  4077. * @param other defines the target matrix
  4078. * @returns the unmodified current matrix
  4079. */
  4080. invertToRef(other: Matrix): Matrix;
  4081. /**
  4082. * add a value at the specified position in the current Matrix
  4083. * @param index the index of the value within the matrix. between 0 and 15.
  4084. * @param value the value to be added
  4085. * @returns the current updated matrix
  4086. */
  4087. addAtIndex(index: number, value: number): Matrix;
  4088. /**
  4089. * mutiply the specified position in the current Matrix by a value
  4090. * @param index the index of the value within the matrix. between 0 and 15.
  4091. * @param value the value to be added
  4092. * @returns the current updated matrix
  4093. */
  4094. multiplyAtIndex(index: number, value: number): Matrix;
  4095. /**
  4096. * Inserts the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Adds the translation vector (using 3 floats) in the current matrix
  4105. * @param x defines the 1st component of the translation
  4106. * @param y defines the 2nd component of the translation
  4107. * @param z defines the 3rd component of the translation
  4108. * @returns the current updated matrix
  4109. */
  4110. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4111. /**
  4112. * Inserts the translation vector in the current matrix
  4113. * @param vector3 defines the translation to insert
  4114. * @returns the current updated matrix
  4115. */
  4116. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4117. /**
  4118. * Gets the translation value of the current matrix
  4119. * @returns a new Vector3 as the extracted translation from the matrix
  4120. */
  4121. getTranslation(): Vector3;
  4122. /**
  4123. * Fill a Vector3 with the extracted translation from the matrix
  4124. * @param result defines the Vector3 where to store the translation
  4125. * @returns the current matrix
  4126. */
  4127. getTranslationToRef(result: Vector3): Matrix;
  4128. /**
  4129. * Remove rotation and scaling part from the matrix
  4130. * @returns the updated matrix
  4131. */
  4132. removeRotationAndScaling(): Matrix;
  4133. /**
  4134. * Multiply two matrices
  4135. * @param other defines the second operand
  4136. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4137. */
  4138. multiply(other: DeepImmutable<Matrix>): Matrix;
  4139. /**
  4140. * Copy the current matrix from the given one
  4141. * @param other defines the source matrix
  4142. * @returns the current updated matrix
  4143. */
  4144. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4145. /**
  4146. * Populates the given array from the starting index with the current matrix values
  4147. * @param array defines the target array
  4148. * @param offset defines the offset in the target array where to start storing values
  4149. * @returns the current matrix
  4150. */
  4151. copyToArray(array: Float32Array, offset?: number): Matrix;
  4152. /**
  4153. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4154. * @param other defines the second operand
  4155. * @param result defines the matrix where to store the multiplication
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4159. /**
  4160. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4161. * @param other defines the second operand
  4162. * @param result defines the array where to store the multiplication
  4163. * @param offset defines the offset in the target array where to start storing values
  4164. * @returns the current matrix
  4165. */
  4166. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4167. /**
  4168. * Check equality between this matrix and a second one
  4169. * @param value defines the second matrix to compare
  4170. * @returns true is the current matrix and the given one values are strictly equal
  4171. */
  4172. equals(value: DeepImmutable<Matrix>): boolean;
  4173. /**
  4174. * Clone the current matrix
  4175. * @returns a new matrix from the current matrix
  4176. */
  4177. clone(): Matrix;
  4178. /**
  4179. * Returns the name of the current matrix class
  4180. * @returns the string "Matrix"
  4181. */
  4182. getClassName(): string;
  4183. /**
  4184. * Gets the hash code of the current matrix
  4185. * @returns the hash code
  4186. */
  4187. getHashCode(): number;
  4188. /**
  4189. * Decomposes the current Matrix into a translation, rotation and scaling components
  4190. * @param scale defines the scale vector3 given as a reference to update
  4191. * @param rotation defines the rotation quaternion given as a reference to update
  4192. * @param translation defines the translation vector3 given as a reference to update
  4193. * @returns true if operation was successful
  4194. */
  4195. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4196. /**
  4197. * Gets specific row of the matrix
  4198. * @param index defines the number of the row to get
  4199. * @returns the index-th row of the current matrix as a new Vector4
  4200. */
  4201. getRow(index: number): Nullable<Vector4>;
  4202. /**
  4203. * Sets the index-th row of the current matrix to the vector4 values
  4204. * @param index defines the number of the row to set
  4205. * @param row defines the target vector4
  4206. * @returns the updated current matrix
  4207. */
  4208. setRow(index: number, row: Vector4): Matrix;
  4209. /**
  4210. * Compute the transpose of the matrix
  4211. * @returns the new transposed matrix
  4212. */
  4213. transpose(): Matrix;
  4214. /**
  4215. * Compute the transpose of the matrix and store it in a given matrix
  4216. * @param result defines the target matrix
  4217. * @returns the current matrix
  4218. */
  4219. transposeToRef(result: Matrix): Matrix;
  4220. /**
  4221. * Sets the index-th row of the current matrix with the given 4 x float values
  4222. * @param index defines the row index
  4223. * @param x defines the x component to set
  4224. * @param y defines the y component to set
  4225. * @param z defines the z component to set
  4226. * @param w defines the w component to set
  4227. * @returns the updated current matrix
  4228. */
  4229. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4230. /**
  4231. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4232. * @param scale defines the scale factor
  4233. * @returns a new matrix
  4234. */
  4235. scale(scale: number): Matrix;
  4236. /**
  4237. * Scale the current matrix values by a factor to a given result matrix
  4238. * @param scale defines the scale factor
  4239. * @param result defines the matrix to store the result
  4240. * @returns the current matrix
  4241. */
  4242. scaleToRef(scale: number, result: Matrix): Matrix;
  4243. /**
  4244. * Scale the current matrix values by a factor and add the result to a given matrix
  4245. * @param scale defines the scale factor
  4246. * @param result defines the Matrix to store the result
  4247. * @returns the current matrix
  4248. */
  4249. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4250. /**
  4251. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4252. * @param ref matrix to store the result
  4253. */
  4254. toNormalMatrix(ref: Matrix): void;
  4255. /**
  4256. * Gets only rotation part of the current matrix
  4257. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4258. */
  4259. getRotationMatrix(): Matrix;
  4260. /**
  4261. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4262. * @param result defines the target matrix to store data to
  4263. * @returns the current matrix
  4264. */
  4265. getRotationMatrixToRef(result: Matrix): Matrix;
  4266. /**
  4267. * Toggles model matrix from being right handed to left handed in place and vice versa
  4268. */
  4269. toggleModelMatrixHandInPlace(): void;
  4270. /**
  4271. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4272. */
  4273. toggleProjectionMatrixHandInPlace(): void;
  4274. /**
  4275. * Creates a matrix from an array
  4276. * @param array defines the source array
  4277. * @param offset defines an offset in the source array
  4278. * @returns a new Matrix set from the starting index of the given array
  4279. */
  4280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4281. /**
  4282. * Copy the content of an array into a given matrix
  4283. * @param array defines the source array
  4284. * @param offset defines an offset in the source array
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4288. /**
  4289. * Stores an array into a matrix after having multiplied each component by a given factor
  4290. * @param array defines the source array
  4291. * @param offset defines the offset in the source array
  4292. * @param scale defines the scaling factor
  4293. * @param result defines the target matrix
  4294. */
  4295. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4296. /**
  4297. * Gets an identity matrix that must not be updated
  4298. */
  4299. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4300. /**
  4301. * Stores a list of values (16) inside a given matrix
  4302. * @param initialM11 defines 1st value of 1st row
  4303. * @param initialM12 defines 2nd value of 1st row
  4304. * @param initialM13 defines 3rd value of 1st row
  4305. * @param initialM14 defines 4th value of 1st row
  4306. * @param initialM21 defines 1st value of 2nd row
  4307. * @param initialM22 defines 2nd value of 2nd row
  4308. * @param initialM23 defines 3rd value of 2nd row
  4309. * @param initialM24 defines 4th value of 2nd row
  4310. * @param initialM31 defines 1st value of 3rd row
  4311. * @param initialM32 defines 2nd value of 3rd row
  4312. * @param initialM33 defines 3rd value of 3rd row
  4313. * @param initialM34 defines 4th value of 3rd row
  4314. * @param initialM41 defines 1st value of 4th row
  4315. * @param initialM42 defines 2nd value of 4th row
  4316. * @param initialM43 defines 3rd value of 4th row
  4317. * @param initialM44 defines 4th value of 4th row
  4318. * @param result defines the target matrix
  4319. */
  4320. 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;
  4321. /**
  4322. * Creates new matrix from a list of values (16)
  4323. * @param initialM11 defines 1st value of 1st row
  4324. * @param initialM12 defines 2nd value of 1st row
  4325. * @param initialM13 defines 3rd value of 1st row
  4326. * @param initialM14 defines 4th value of 1st row
  4327. * @param initialM21 defines 1st value of 2nd row
  4328. * @param initialM22 defines 2nd value of 2nd row
  4329. * @param initialM23 defines 3rd value of 2nd row
  4330. * @param initialM24 defines 4th value of 2nd row
  4331. * @param initialM31 defines 1st value of 3rd row
  4332. * @param initialM32 defines 2nd value of 3rd row
  4333. * @param initialM33 defines 3rd value of 3rd row
  4334. * @param initialM34 defines 4th value of 3rd row
  4335. * @param initialM41 defines 1st value of 4th row
  4336. * @param initialM42 defines 2nd value of 4th row
  4337. * @param initialM43 defines 3rd value of 4th row
  4338. * @param initialM44 defines 4th value of 4th row
  4339. * @returns the new matrix
  4340. */
  4341. 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;
  4342. /**
  4343. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @returns a new matrix
  4348. */
  4349. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4352. * @param scale defines the scale vector3
  4353. * @param rotation defines the rotation quaternion
  4354. * @param translation defines the translation vector3
  4355. * @param result defines the target matrix
  4356. */
  4357. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4358. /**
  4359. * Creates a new identity matrix
  4360. * @returns a new identity matrix
  4361. */
  4362. static Identity(): Matrix;
  4363. /**
  4364. * Creates a new identity matrix and stores the result in a given matrix
  4365. * @param result defines the target matrix
  4366. */
  4367. static IdentityToRef(result: Matrix): void;
  4368. /**
  4369. * Creates a new zero matrix
  4370. * @returns a new zero matrix
  4371. */
  4372. static Zero(): Matrix;
  4373. /**
  4374. * Creates a new rotation matrix for "angle" radians around the X axis
  4375. * @param angle defines the angle (in radians) to use
  4376. * @return the new matrix
  4377. */
  4378. static RotationX(angle: number): Matrix;
  4379. /**
  4380. * Creates a new matrix as the invert of a given matrix
  4381. * @param source defines the source matrix
  4382. * @returns the new matrix
  4383. */
  4384. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4385. /**
  4386. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4387. * @param angle defines the angle (in radians) to use
  4388. * @param result defines the target matrix
  4389. */
  4390. static RotationXToRef(angle: number, result: Matrix): void;
  4391. /**
  4392. * Creates a new rotation matrix for "angle" radians around the Y axis
  4393. * @param angle defines the angle (in radians) to use
  4394. * @return the new matrix
  4395. */
  4396. static RotationY(angle: number): Matrix;
  4397. /**
  4398. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4399. * @param angle defines the angle (in radians) to use
  4400. * @param result defines the target matrix
  4401. */
  4402. static RotationYToRef(angle: number, result: Matrix): void;
  4403. /**
  4404. * Creates a new rotation matrix for "angle" radians around the Z axis
  4405. * @param angle defines the angle (in radians) to use
  4406. * @return the new matrix
  4407. */
  4408. static RotationZ(angle: number): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4411. * @param angle defines the angle (in radians) to use
  4412. * @param result defines the target matrix
  4413. */
  4414. static RotationZToRef(angle: number, result: Matrix): void;
  4415. /**
  4416. * Creates a new rotation matrix for "angle" radians around the given axis
  4417. * @param axis defines the axis to use
  4418. * @param angle defines the angle (in radians) to use
  4419. * @return the new matrix
  4420. */
  4421. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4422. /**
  4423. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4424. * @param axis defines the axis to use
  4425. * @param angle defines the angle (in radians) to use
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4429. /**
  4430. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4431. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4432. * @param from defines the vector to align
  4433. * @param to defines the vector to align to
  4434. * @param result defines the target matrix
  4435. */
  4436. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Creates a rotation matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @returns the new rotation matrix
  4443. */
  4444. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4445. /**
  4446. * Creates a rotation matrix and stores it in a given matrix
  4447. * @param yaw defines the yaw angle in radians (Y axis)
  4448. * @param pitch defines the pitch angle in radians (X axis)
  4449. * @param roll defines the roll angle in radians (X axis)
  4450. * @param result defines the target matrix
  4451. */
  4452. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4453. /**
  4454. * Creates a scaling matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @returns the new matrix
  4459. */
  4460. static Scaling(x: number, y: number, z: number): Matrix;
  4461. /**
  4462. * Creates a scaling matrix and stores it in a given matrix
  4463. * @param x defines the scale factor on X axis
  4464. * @param y defines the scale factor on Y axis
  4465. * @param z defines the scale factor on Z axis
  4466. * @param result defines the target matrix
  4467. */
  4468. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4469. /**
  4470. * Creates a translation matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @returns the new matrix
  4475. */
  4476. static Translation(x: number, y: number, z: number): Matrix;
  4477. /**
  4478. * Creates a translation matrix and stores it in a given matrix
  4479. * @param x defines the translation on X axis
  4480. * @param y defines the translation on Y axis
  4481. * @param z defines the translationon Z axis
  4482. * @param result defines the target matrix
  4483. */
  4484. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4485. /**
  4486. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @returns the new matrix
  4491. */
  4492. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4493. /**
  4494. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4495. * @param startValue defines the start value
  4496. * @param endValue defines the end value
  4497. * @param gradient defines the gradient factor
  4498. * @param result defines the Matrix object where to store data
  4499. */
  4500. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4501. /**
  4502. * Builds a new matrix whose values are computed by:
  4503. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4504. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4505. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4506. * @param startValue defines the first matrix
  4507. * @param endValue defines the second matrix
  4508. * @param gradient defines the gradient between the two matrices
  4509. * @returns the new matrix
  4510. */
  4511. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4512. /**
  4513. * Update a matrix to values which are computed by:
  4514. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4515. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4516. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4517. * @param startValue defines the first matrix
  4518. * @param endValue defines the second matrix
  4519. * @param gradient defines the gradient between the two matrices
  4520. * @param result defines the target matrix
  4521. */
  4522. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4523. /**
  4524. * 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"
  4525. * This function works in left handed mode
  4526. * @param eye defines the final position of the entity
  4527. * @param target defines where the entity should look at
  4528. * @param up defines the up vector for the entity
  4529. * @returns the new matrix
  4530. */
  4531. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4532. /**
  4533. * 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".
  4534. * This function works in left handed mode
  4535. * @param eye defines the final position of the entity
  4536. * @param target defines where the entity should look at
  4537. * @param up defines the up vector for the entity
  4538. * @param result defines the target matrix
  4539. */
  4540. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4541. /**
  4542. * 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"
  4543. * This function works in right handed mode
  4544. * @param eye defines the final position of the entity
  4545. * @param target defines where the entity should look at
  4546. * @param up defines the up vector for the entity
  4547. * @returns the new matrix
  4548. */
  4549. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4550. /**
  4551. * 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".
  4552. * This function works in right handed mode
  4553. * @param eye defines the final position of the entity
  4554. * @param target defines where the entity should look at
  4555. * @param up defines the up vector for the entity
  4556. * @param result defines the target matrix
  4557. */
  4558. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4559. /**
  4560. * Create a left-handed orthographic projection matrix
  4561. * @param width defines the viewport width
  4562. * @param height defines the viewport height
  4563. * @param znear defines the near clip plane
  4564. * @param zfar defines the far clip plane
  4565. * @returns a new matrix as a left-handed orthographic projection matrix
  4566. */
  4567. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4568. /**
  4569. * Store a left-handed orthographic projection to a given matrix
  4570. * @param width defines the viewport width
  4571. * @param height defines the viewport height
  4572. * @param znear defines the near clip plane
  4573. * @param zfar defines the far clip plane
  4574. * @param result defines the target matrix
  4575. */
  4576. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4577. /**
  4578. * Create a left-handed orthographic projection matrix
  4579. * @param left defines the viewport left coordinate
  4580. * @param right defines the viewport right coordinate
  4581. * @param bottom defines the viewport bottom coordinate
  4582. * @param top defines the viewport top coordinate
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @returns a new matrix as a left-handed orthographic projection matrix
  4586. */
  4587. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4588. /**
  4589. * Stores a left-handed orthographic projection into a given matrix
  4590. * @param left defines the viewport left coordinate
  4591. * @param right defines the viewport right coordinate
  4592. * @param bottom defines the viewport bottom coordinate
  4593. * @param top defines the viewport top coordinate
  4594. * @param znear defines the near clip plane
  4595. * @param zfar defines the far clip plane
  4596. * @param result defines the target matrix
  4597. */
  4598. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4599. /**
  4600. * Creates a right-handed orthographic projection matrix
  4601. * @param left defines the viewport left coordinate
  4602. * @param right defines the viewport right coordinate
  4603. * @param bottom defines the viewport bottom coordinate
  4604. * @param top defines the viewport top coordinate
  4605. * @param znear defines the near clip plane
  4606. * @param zfar defines the far clip plane
  4607. * @returns a new matrix as a right-handed orthographic projection matrix
  4608. */
  4609. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4610. /**
  4611. * Stores a right-handed orthographic projection into a given matrix
  4612. * @param left defines the viewport left coordinate
  4613. * @param right defines the viewport right coordinate
  4614. * @param bottom defines the viewport bottom coordinate
  4615. * @param top defines the viewport top coordinate
  4616. * @param znear defines the near clip plane
  4617. * @param zfar defines the far clip plane
  4618. * @param result defines the target matrix
  4619. */
  4620. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4621. /**
  4622. * Creates a left-handed perspective projection matrix
  4623. * @param width defines the viewport width
  4624. * @param height defines the viewport height
  4625. * @param znear defines the near clip plane
  4626. * @param zfar defines the far clip plane
  4627. * @returns a new matrix as a left-handed perspective projection matrix
  4628. */
  4629. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4630. /**
  4631. * Creates a left-handed perspective projection matrix
  4632. * @param fov defines the horizontal field of view
  4633. * @param aspect defines the aspect ratio
  4634. * @param znear defines the near clip plane
  4635. * @param zfar defines the far clip plane
  4636. * @returns a new matrix as a left-handed perspective projection matrix
  4637. */
  4638. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4639. /**
  4640. * Stores a left-handed perspective projection into a given matrix
  4641. * @param fov defines the horizontal field of view
  4642. * @param aspect defines the aspect ratio
  4643. * @param znear defines the near clip plane
  4644. * @param zfar defines the far clip plane
  4645. * @param result defines the target matrix
  4646. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4647. */
  4648. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4649. /**
  4650. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4651. * @param fov defines the horizontal field of view
  4652. * @param aspect defines the aspect ratio
  4653. * @param znear defines the near clip plane
  4654. * @param zfar not used as infinity is used as far clip
  4655. * @param result defines the target matrix
  4656. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4657. */
  4658. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4659. /**
  4660. * Creates a right-handed perspective projection matrix
  4661. * @param fov defines the horizontal field of view
  4662. * @param aspect defines the aspect ratio
  4663. * @param znear defines the near clip plane
  4664. * @param zfar defines the far clip plane
  4665. * @returns a new matrix as a right-handed perspective projection matrix
  4666. */
  4667. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4668. /**
  4669. * Stores a right-handed perspective projection into a given matrix
  4670. * @param fov defines the horizontal field of view
  4671. * @param aspect defines the aspect ratio
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4676. */
  4677. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4678. /**
  4679. * Stores a right-handed perspective projection into a given matrix
  4680. * @param fov defines the horizontal field of view
  4681. * @param aspect defines the aspect ratio
  4682. * @param znear defines the near clip plane
  4683. * @param zfar not used as infinity is used as far clip
  4684. * @param result defines the target matrix
  4685. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4686. */
  4687. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4688. /**
  4689. * Stores a perspective projection for WebVR info a given matrix
  4690. * @param fov defines the field of view
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @param result defines the target matrix
  4694. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4695. */
  4696. static PerspectiveFovWebVRToRef(fov: {
  4697. upDegrees: number;
  4698. downDegrees: number;
  4699. leftDegrees: number;
  4700. rightDegrees: number;
  4701. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4702. /**
  4703. * Computes a complete transformation matrix
  4704. * @param viewport defines the viewport to use
  4705. * @param world defines the world matrix
  4706. * @param view defines the view matrix
  4707. * @param projection defines the projection matrix
  4708. * @param zmin defines the near clip plane
  4709. * @param zmax defines the far clip plane
  4710. * @returns the transformation matrix
  4711. */
  4712. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4713. /**
  4714. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4715. * @param matrix defines the matrix to use
  4716. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4717. */
  4718. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4719. /**
  4720. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4721. * @param matrix defines the matrix to use
  4722. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4723. */
  4724. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4725. /**
  4726. * Compute the transpose of a given matrix
  4727. * @param matrix defines the matrix to transpose
  4728. * @returns the new matrix
  4729. */
  4730. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4731. /**
  4732. * Compute the transpose of a matrix and store it in a target matrix
  4733. * @param matrix defines the matrix to transpose
  4734. * @param result defines the target matrix
  4735. */
  4736. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4737. /**
  4738. * Computes a reflection matrix from a plane
  4739. * @param plane defines the reflection plane
  4740. * @returns a new matrix
  4741. */
  4742. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4743. /**
  4744. * Computes a reflection matrix from a plane
  4745. * @param plane defines the reflection plane
  4746. * @param result defines the target matrix
  4747. */
  4748. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4749. /**
  4750. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4751. * @param xaxis defines the value of the 1st axis
  4752. * @param yaxis defines the value of the 2nd axis
  4753. * @param zaxis defines the value of the 3rd axis
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4757. /**
  4758. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4759. * @param quat defines the quaternion to use
  4760. * @param result defines the target matrix
  4761. */
  4762. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4763. }
  4764. /**
  4765. * @hidden
  4766. */
  4767. export class TmpVectors {
  4768. static Vector2: Vector2[];
  4769. static Vector3: Vector3[];
  4770. static Vector4: Vector4[];
  4771. static Quaternion: Quaternion[];
  4772. static Matrix: Matrix[];
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /**
  4777. * Defines potential orientation for back face culling
  4778. */
  4779. export enum Orientation {
  4780. /**
  4781. * Clockwise
  4782. */
  4783. CW = 0,
  4784. /** Counter clockwise */
  4785. CCW = 1
  4786. }
  4787. /** Class used to represent a Bezier curve */
  4788. export class BezierCurve {
  4789. /**
  4790. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4791. * @param t defines the time
  4792. * @param x1 defines the left coordinate on X axis
  4793. * @param y1 defines the left coordinate on Y axis
  4794. * @param x2 defines the right coordinate on X axis
  4795. * @param y2 defines the right coordinate on Y axis
  4796. * @returns the interpolated value
  4797. */
  4798. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4799. }
  4800. /**
  4801. * Defines angle representation
  4802. */
  4803. export class Angle {
  4804. private _radians;
  4805. /**
  4806. * Creates an Angle object of "radians" radians (float).
  4807. * @param radians the angle in radians
  4808. */
  4809. constructor(radians: number);
  4810. /**
  4811. * Get value in degrees
  4812. * @returns the Angle value in degrees (float)
  4813. */
  4814. degrees(): number;
  4815. /**
  4816. * Get value in radians
  4817. * @returns the Angle value in radians (float)
  4818. */
  4819. radians(): number;
  4820. /**
  4821. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4822. * @param a defines first vector
  4823. * @param b defines second vector
  4824. * @returns a new Angle
  4825. */
  4826. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4827. /**
  4828. * Gets a new Angle object from the given float in radians
  4829. * @param radians defines the angle value in radians
  4830. * @returns a new Angle
  4831. */
  4832. static FromRadians(radians: number): Angle;
  4833. /**
  4834. * Gets a new Angle object from the given float in degrees
  4835. * @param degrees defines the angle value in degrees
  4836. * @returns a new Angle
  4837. */
  4838. static FromDegrees(degrees: number): Angle;
  4839. }
  4840. /**
  4841. * This represents an arc in a 2d space.
  4842. */
  4843. export class Arc2 {
  4844. /** Defines the start point of the arc */
  4845. startPoint: Vector2;
  4846. /** Defines the mid point of the arc */
  4847. midPoint: Vector2;
  4848. /** Defines the end point of the arc */
  4849. endPoint: Vector2;
  4850. /**
  4851. * Defines the center point of the arc.
  4852. */
  4853. centerPoint: Vector2;
  4854. /**
  4855. * Defines the radius of the arc.
  4856. */
  4857. radius: number;
  4858. /**
  4859. * Defines the angle of the arc (from mid point to end point).
  4860. */
  4861. angle: Angle;
  4862. /**
  4863. * Defines the start angle of the arc (from start point to middle point).
  4864. */
  4865. startAngle: Angle;
  4866. /**
  4867. * Defines the orientation of the arc (clock wise/counter clock wise).
  4868. */
  4869. orientation: Orientation;
  4870. /**
  4871. * Creates an Arc object from the three given points : start, middle and end.
  4872. * @param startPoint Defines the start point of the arc
  4873. * @param midPoint Defines the midlle point of the arc
  4874. * @param endPoint Defines the end point of the arc
  4875. */
  4876. constructor(
  4877. /** Defines the start point of the arc */
  4878. startPoint: Vector2,
  4879. /** Defines the mid point of the arc */
  4880. midPoint: Vector2,
  4881. /** Defines the end point of the arc */
  4882. endPoint: Vector2);
  4883. }
  4884. /**
  4885. * Represents a 2D path made up of multiple 2D points
  4886. */
  4887. export class Path2 {
  4888. private _points;
  4889. private _length;
  4890. /**
  4891. * If the path start and end point are the same
  4892. */
  4893. closed: boolean;
  4894. /**
  4895. * Creates a Path2 object from the starting 2D coordinates x and y.
  4896. * @param x the starting points x value
  4897. * @param y the starting points y value
  4898. */
  4899. constructor(x: number, y: number);
  4900. /**
  4901. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4902. * @param x the added points x value
  4903. * @param y the added points y value
  4904. * @returns the updated Path2.
  4905. */
  4906. addLineTo(x: number, y: number): Path2;
  4907. /**
  4908. * 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.
  4909. * @param midX middle point x value
  4910. * @param midY middle point y value
  4911. * @param endX end point x value
  4912. * @param endY end point y value
  4913. * @param numberOfSegments (default: 36)
  4914. * @returns the updated Path2.
  4915. */
  4916. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4917. /**
  4918. * Closes the Path2.
  4919. * @returns the Path2.
  4920. */
  4921. close(): Path2;
  4922. /**
  4923. * Gets the sum of the distance between each sequential point in the path
  4924. * @returns the Path2 total length (float).
  4925. */
  4926. length(): number;
  4927. /**
  4928. * Gets the points which construct the path
  4929. * @returns the Path2 internal array of points.
  4930. */
  4931. getPoints(): Vector2[];
  4932. /**
  4933. * Retreives the point at the distance aways from the starting point
  4934. * @param normalizedLengthPosition the length along the path to retreive the point from
  4935. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4936. */
  4937. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4938. /**
  4939. * Creates a new path starting from an x and y position
  4940. * @param x starting x value
  4941. * @param y starting y value
  4942. * @returns a new Path2 starting at the coordinates (x, y).
  4943. */
  4944. static StartingAt(x: number, y: number): Path2;
  4945. }
  4946. /**
  4947. * Represents a 3D path made up of multiple 3D points
  4948. */
  4949. export class Path3D {
  4950. /**
  4951. * an array of Vector3, the curve axis of the Path3D
  4952. */
  4953. path: Vector3[];
  4954. private _curve;
  4955. private _distances;
  4956. private _tangents;
  4957. private _normals;
  4958. private _binormals;
  4959. private _raw;
  4960. private _alignTangentsWithPath;
  4961. private readonly _pointAtData;
  4962. /**
  4963. * new Path3D(path, normal, raw)
  4964. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4965. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4966. * @param path an array of Vector3, the curve axis of the Path3D
  4967. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4968. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4969. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4970. */
  4971. constructor(
  4972. /**
  4973. * an array of Vector3, the curve axis of the Path3D
  4974. */
  4975. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4976. /**
  4977. * Returns the Path3D array of successive Vector3 designing its curve.
  4978. * @returns the Path3D array of successive Vector3 designing its curve.
  4979. */
  4980. getCurve(): Vector3[];
  4981. /**
  4982. * Returns the Path3D array of successive Vector3 designing its curve.
  4983. * @returns the Path3D array of successive Vector3 designing its curve.
  4984. */
  4985. getPoints(): Vector3[];
  4986. /**
  4987. * @returns the computed length (float) of the path.
  4988. */
  4989. length(): number;
  4990. /**
  4991. * Returns an array populated with tangent vectors on each Path3D curve point.
  4992. * @returns an array populated with tangent vectors on each Path3D curve point.
  4993. */
  4994. getTangents(): Vector3[];
  4995. /**
  4996. * Returns an array populated with normal vectors on each Path3D curve point.
  4997. * @returns an array populated with normal vectors on each Path3D curve point.
  4998. */
  4999. getNormals(): Vector3[];
  5000. /**
  5001. * Returns an array populated with binormal vectors on each Path3D curve point.
  5002. * @returns an array populated with binormal vectors on each Path3D curve point.
  5003. */
  5004. getBinormals(): Vector3[];
  5005. /**
  5006. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5008. */
  5009. getDistances(): number[];
  5010. /**
  5011. * Returns an interpolated point along this path
  5012. * @param position the position of the point along this path, from 0.0 to 1.0
  5013. * @returns a new Vector3 as the point
  5014. */
  5015. getPointAt(position: number): Vector3;
  5016. /**
  5017. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5018. * @param position the position of the point along this path, from 0.0 to 1.0
  5019. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5020. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5021. */
  5022. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5023. /**
  5024. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5025. * @param position the position of the point along this path, from 0.0 to 1.0
  5026. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5027. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5028. */
  5029. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5030. /**
  5031. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5032. * @param position the position of the point along this path, from 0.0 to 1.0
  5033. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5034. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5035. */
  5036. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5037. /**
  5038. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5039. * @param position the position of the point along this path, from 0.0 to 1.0
  5040. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5041. */
  5042. getDistanceAt(position: number): number;
  5043. /**
  5044. * Returns the array index of the previous point of an interpolated point along this path
  5045. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5046. * @returns the array index
  5047. */
  5048. getPreviousPointIndexAt(position: number): number;
  5049. /**
  5050. * 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)
  5051. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5052. * @returns the sub position
  5053. */
  5054. getSubPositionAt(position: number): number;
  5055. /**
  5056. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5057. * @param target the vector of which to get the closest position to
  5058. * @returns the position of the closest virtual point on this path to the target vector
  5059. */
  5060. getClosestPositionTo(target: Vector3): number;
  5061. /**
  5062. * Returns a sub path (slice) of this path
  5063. * @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
  5064. * @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
  5065. * @returns a sub path (slice) of this path
  5066. */
  5067. slice(start?: number, end?: number): Path3D;
  5068. /**
  5069. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5070. * @param path path which all values are copied into the curves points
  5071. * @param firstNormal which should be projected onto the curve
  5072. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5073. * @returns the same object updated.
  5074. */
  5075. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5076. private _compute;
  5077. private _getFirstNonNullVector;
  5078. private _getLastNonNullVector;
  5079. private _normalVector;
  5080. /**
  5081. * Updates the point at data for an interpolated point along this curve
  5082. * @param position the position of the point along this curve, from 0.0 to 1.0
  5083. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5084. * @returns the (updated) point at data
  5085. */
  5086. private _updatePointAtData;
  5087. /**
  5088. * Updates the point at data from the specified parameters
  5089. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5090. * @param point the interpolated point
  5091. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5092. */
  5093. private _setPointAtData;
  5094. /**
  5095. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5096. */
  5097. private _updateInterpolationMatrix;
  5098. }
  5099. /**
  5100. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5101. * A Curve3 is designed from a series of successive Vector3.
  5102. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5103. */
  5104. export class Curve3 {
  5105. private _points;
  5106. private _length;
  5107. /**
  5108. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5109. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5110. * @param v1 (Vector3) the control point
  5111. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5112. * @param nbPoints (integer) the wanted number of points in the curve
  5113. * @returns the created Curve3
  5114. */
  5115. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5116. /**
  5117. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5118. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5119. * @param v1 (Vector3) the first control point
  5120. * @param v2 (Vector3) the second control point
  5121. * @param v3 (Vector3) the end point of the Cubic Bezier
  5122. * @param nbPoints (integer) the wanted number of points in the curve
  5123. * @returns the created Curve3
  5124. */
  5125. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5126. /**
  5127. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5128. * @param p1 (Vector3) the origin point of the Hermite Spline
  5129. * @param t1 (Vector3) the tangent vector at the origin point
  5130. * @param p2 (Vector3) the end point of the Hermite Spline
  5131. * @param t2 (Vector3) the tangent vector at the end point
  5132. * @param nbPoints (integer) the wanted number of points in the curve
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5136. /**
  5137. * Returns a Curve3 object along a CatmullRom Spline curve :
  5138. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5139. * @param nbPoints (integer) the wanted number of points between each curve control points
  5140. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5141. * @returns the created Curve3
  5142. */
  5143. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5144. /**
  5145. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5146. * A Curve3 is designed from a series of successive Vector3.
  5147. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5148. * @param points points which make up the curve
  5149. */
  5150. constructor(points: Vector3[]);
  5151. /**
  5152. * @returns the Curve3 stored array of successive Vector3
  5153. */
  5154. getPoints(): Vector3[];
  5155. /**
  5156. * @returns the computed length (float) of the curve.
  5157. */
  5158. length(): number;
  5159. /**
  5160. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5161. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5162. * curveA and curveB keep unchanged.
  5163. * @param curve the curve to continue from this curve
  5164. * @returns the newly constructed curve
  5165. */
  5166. continue(curve: DeepImmutable<Curve3>): Curve3;
  5167. private _computeLength;
  5168. }
  5169. }
  5170. declare module BABYLON {
  5171. /**
  5172. * This represents the main contract an easing function should follow.
  5173. * Easing functions are used throughout the animation system.
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export interface IEasingFunction {
  5177. /**
  5178. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5179. * of the easing function.
  5180. * The link below provides some of the most common examples of easing functions.
  5181. * @see https://easings.net/
  5182. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5183. * @returns the corresponding value on the curve defined by the easing function
  5184. */
  5185. ease(gradient: number): number;
  5186. }
  5187. /**
  5188. * Base class used for every default easing function.
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class EasingFunction implements IEasingFunction {
  5192. /**
  5193. * Interpolation follows the mathematical formula associated with the easing function.
  5194. */
  5195. static readonly EASINGMODE_EASEIN: number;
  5196. /**
  5197. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5198. */
  5199. static readonly EASINGMODE_EASEOUT: number;
  5200. /**
  5201. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5202. */
  5203. static readonly EASINGMODE_EASEINOUT: number;
  5204. private _easingMode;
  5205. /**
  5206. * Sets the easing mode of the current function.
  5207. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5208. */
  5209. setEasingMode(easingMode: number): void;
  5210. /**
  5211. * Gets the current easing mode.
  5212. * @returns the easing mode
  5213. */
  5214. getEasingMode(): number;
  5215. /**
  5216. * @hidden
  5217. */
  5218. easeInCore(gradient: number): number;
  5219. /**
  5220. * Given an input gradient between 0 and 1, this returns the corresponding value
  5221. * of the easing function.
  5222. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5223. * @returns the corresponding value on the curve defined by the easing function
  5224. */
  5225. ease(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a circle shape (see link below).
  5229. * @see https://easings.net/#easeInCirc
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class CircleEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a ease back shape (see link below).
  5238. * @see https://easings.net/#easeInBack
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BackEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the amplitude of the function */
  5243. amplitude: number;
  5244. /**
  5245. * Instantiates a back ease easing
  5246. * @see https://easings.net/#easeInBack
  5247. * @param amplitude Defines the amplitude of the function
  5248. */
  5249. constructor(
  5250. /** Defines the amplitude of the function */
  5251. amplitude?: number);
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a bouncing shape (see link below).
  5257. * @see https://easings.net/#easeInBounce
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class BounceEase extends EasingFunction implements IEasingFunction {
  5261. /** Defines the number of bounces */
  5262. bounces: number;
  5263. /** Defines the amplitude of the bounce */
  5264. bounciness: number;
  5265. /**
  5266. * Instantiates a bounce easing
  5267. * @see https://easings.net/#easeInBounce
  5268. * @param bounces Defines the number of bounces
  5269. * @param bounciness Defines the amplitude of the bounce
  5270. */
  5271. constructor(
  5272. /** Defines the number of bounces */
  5273. bounces?: number,
  5274. /** Defines the amplitude of the bounce */
  5275. bounciness?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. /**
  5280. * Easing function with a power of 3 shape (see link below).
  5281. * @see https://easings.net/#easeInCubic
  5282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5283. */
  5284. export class CubicEase extends EasingFunction implements IEasingFunction {
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. /**
  5289. * Easing function with an elastic shape (see link below).
  5290. * @see https://easings.net/#easeInElastic
  5291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5292. */
  5293. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5294. /** Defines the number of oscillations*/
  5295. oscillations: number;
  5296. /** Defines the amplitude of the oscillations*/
  5297. springiness: number;
  5298. /**
  5299. * Instantiates an elastic easing function
  5300. * @see https://easings.net/#easeInElastic
  5301. * @param oscillations Defines the number of oscillations
  5302. * @param springiness Defines the amplitude of the oscillations
  5303. */
  5304. constructor(
  5305. /** Defines the number of oscillations*/
  5306. oscillations?: number,
  5307. /** Defines the amplitude of the oscillations*/
  5308. springiness?: number);
  5309. /** @hidden */
  5310. easeInCore(gradient: number): number;
  5311. }
  5312. /**
  5313. * Easing function with an exponential shape (see link below).
  5314. * @see https://easings.net/#easeInExpo
  5315. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5316. */
  5317. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5318. /** Defines the exponent of the function */
  5319. exponent: number;
  5320. /**
  5321. * Instantiates an exponential easing function
  5322. * @see https://easings.net/#easeInExpo
  5323. * @param exponent Defines the exponent of the function
  5324. */
  5325. constructor(
  5326. /** Defines the exponent of the function */
  5327. exponent?: number);
  5328. /** @hidden */
  5329. easeInCore(gradient: number): number;
  5330. }
  5331. /**
  5332. * Easing function with a power shape (see link below).
  5333. * @see https://easings.net/#easeInQuad
  5334. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5335. */
  5336. export class PowerEase extends EasingFunction implements IEasingFunction {
  5337. /** Defines the power of the function */
  5338. power: number;
  5339. /**
  5340. * Instantiates an power base easing function
  5341. * @see https://easings.net/#easeInQuad
  5342. * @param power Defines the power of the function
  5343. */
  5344. constructor(
  5345. /** Defines the power of the function */
  5346. power?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with a power of 2 shape (see link below).
  5352. * @see https://easings.net/#easeInQuad
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5356. /** @hidden */
  5357. easeInCore(gradient: number): number;
  5358. }
  5359. /**
  5360. * Easing function with a power of 4 shape (see link below).
  5361. * @see https://easings.net/#easeInQuart
  5362. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5363. */
  5364. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a power of 5 shape (see link below).
  5370. * @see https://easings.net/#easeInQuint
  5371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a sin shape (see link below).
  5379. * @see https://easings.net/#easeInSine
  5380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class SineEase extends EasingFunction implements IEasingFunction {
  5383. /** @hidden */
  5384. easeInCore(gradient: number): number;
  5385. }
  5386. /**
  5387. * Easing function with a bezier shape (see link below).
  5388. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5392. /** Defines the x component of the start tangent in the bezier curve */
  5393. x1: number;
  5394. /** Defines the y component of the start tangent in the bezier curve */
  5395. y1: number;
  5396. /** Defines the x component of the end tangent in the bezier curve */
  5397. x2: number;
  5398. /** Defines the y component of the end tangent in the bezier curve */
  5399. y2: number;
  5400. /**
  5401. * Instantiates a bezier function
  5402. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5403. * @param x1 Defines the x component of the start tangent in the bezier curve
  5404. * @param y1 Defines the y component of the start tangent in the bezier curve
  5405. * @param x2 Defines the x component of the end tangent in the bezier curve
  5406. * @param y2 Defines the y component of the end tangent in the bezier curve
  5407. */
  5408. constructor(
  5409. /** Defines the x component of the start tangent in the bezier curve */
  5410. x1?: number,
  5411. /** Defines the y component of the start tangent in the bezier curve */
  5412. y1?: number,
  5413. /** Defines the x component of the end tangent in the bezier curve */
  5414. x2?: number,
  5415. /** Defines the y component of the end tangent in the bezier curve */
  5416. y2?: number);
  5417. /** @hidden */
  5418. easeInCore(gradient: number): number;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /**
  5423. * Class used to hold a RBG color
  5424. */
  5425. export class Color3 {
  5426. /**
  5427. * Defines the red component (between 0 and 1, default is 0)
  5428. */
  5429. r: number;
  5430. /**
  5431. * Defines the green component (between 0 and 1, default is 0)
  5432. */
  5433. g: number;
  5434. /**
  5435. * Defines the blue component (between 0 and 1, default is 0)
  5436. */
  5437. b: number;
  5438. /**
  5439. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5440. * @param r defines the red component (between 0 and 1, default is 0)
  5441. * @param g defines the green component (between 0 and 1, default is 0)
  5442. * @param b defines the blue component (between 0 and 1, default is 0)
  5443. */
  5444. constructor(
  5445. /**
  5446. * Defines the red component (between 0 and 1, default is 0)
  5447. */
  5448. r?: number,
  5449. /**
  5450. * Defines the green component (between 0 and 1, default is 0)
  5451. */
  5452. g?: number,
  5453. /**
  5454. * Defines the blue component (between 0 and 1, default is 0)
  5455. */
  5456. b?: number);
  5457. /**
  5458. * Creates a string with the Color3 current values
  5459. * @returns the string representation of the Color3 object
  5460. */
  5461. toString(): string;
  5462. /**
  5463. * Returns the string "Color3"
  5464. * @returns "Color3"
  5465. */
  5466. getClassName(): string;
  5467. /**
  5468. * Compute the Color3 hash code
  5469. * @returns an unique number that can be used to hash Color3 objects
  5470. */
  5471. getHashCode(): number;
  5472. /**
  5473. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5474. * @param array defines the array where to store the r,g,b components
  5475. * @param index defines an optional index in the target array to define where to start storing values
  5476. * @returns the current Color3 object
  5477. */
  5478. toArray(array: FloatArray, index?: number): Color3;
  5479. /**
  5480. * Returns a new Color4 object from the current Color3 and the given alpha
  5481. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5482. * @returns a new Color4 object
  5483. */
  5484. toColor4(alpha?: number): Color4;
  5485. /**
  5486. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5487. * @returns the new array
  5488. */
  5489. asArray(): number[];
  5490. /**
  5491. * Returns the luminance value
  5492. * @returns a float value
  5493. */
  5494. toLuminance(): number;
  5495. /**
  5496. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5497. * @param otherColor defines the second operand
  5498. * @returns the new Color3 object
  5499. */
  5500. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5501. /**
  5502. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5503. * @param otherColor defines the second operand
  5504. * @param result defines the Color3 object where to store the result
  5505. * @returns the current Color3
  5506. */
  5507. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5508. /**
  5509. * Determines equality between Color3 objects
  5510. * @param otherColor defines the second operand
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equals(otherColor: DeepImmutable<Color3>): boolean;
  5514. /**
  5515. * Determines equality between the current Color3 object and a set of r,b,g values
  5516. * @param r defines the red component to check
  5517. * @param g defines the green component to check
  5518. * @param b defines the blue component to check
  5519. * @returns true if the rgb values are equal to the given ones
  5520. */
  5521. equalsFloats(r: number, g: number, b: number): boolean;
  5522. /**
  5523. * Multiplies in place each rgb value by scale
  5524. * @param scale defines the scaling factor
  5525. * @returns the updated Color3
  5526. */
  5527. scale(scale: number): Color3;
  5528. /**
  5529. * Multiplies the rgb values by scale and stores the result into "result"
  5530. * @param scale defines the scaling factor
  5531. * @param result defines the Color3 object where to store the result
  5532. * @returns the unmodified current Color3
  5533. */
  5534. scaleToRef(scale: number, result: Color3): Color3;
  5535. /**
  5536. * Scale the current Color3 values by a factor and add the result to a given Color3
  5537. * @param scale defines the scale factor
  5538. * @param result defines color to store the result into
  5539. * @returns the unmodified current Color3
  5540. */
  5541. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5542. /**
  5543. * Clamps the rgb values by the min and max values and stores the result into "result"
  5544. * @param min defines minimum clamping value (default is 0)
  5545. * @param max defines maximum clamping value (default is 1)
  5546. * @param result defines color to store the result into
  5547. * @returns the original Color3
  5548. */
  5549. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5550. /**
  5551. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5552. * @param otherColor defines the second operand
  5553. * @returns the new Color3
  5554. */
  5555. add(otherColor: DeepImmutable<Color3>): Color3;
  5556. /**
  5557. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5558. * @param otherColor defines the second operand
  5559. * @param result defines Color3 object to store the result into
  5560. * @returns the unmodified current Color3
  5561. */
  5562. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5563. /**
  5564. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5565. * @param otherColor defines the second operand
  5566. * @returns the new Color3
  5567. */
  5568. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5569. /**
  5570. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5571. * @param otherColor defines the second operand
  5572. * @param result defines Color3 object to store the result into
  5573. * @returns the unmodified current Color3
  5574. */
  5575. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5576. /**
  5577. * Copy the current object
  5578. * @returns a new Color3 copied the current one
  5579. */
  5580. clone(): Color3;
  5581. /**
  5582. * Copies the rgb values from the source in the current Color3
  5583. * @param source defines the source Color3 object
  5584. * @returns the updated Color3 object
  5585. */
  5586. copyFrom(source: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. copyFromFloats(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Updates the Color3 rgb values from the given floats
  5597. * @param r defines the red component to read from
  5598. * @param g defines the green component to read from
  5599. * @param b defines the blue component to read from
  5600. * @returns the current Color3 object
  5601. */
  5602. set(r: number, g: number, b: number): Color3;
  5603. /**
  5604. * Compute the Color3 hexadecimal code as a string
  5605. * @returns a string containing the hexadecimal representation of the Color3 object
  5606. */
  5607. toHexString(): string;
  5608. /**
  5609. * Computes a new Color3 converted from the current one to linear space
  5610. * @returns a new Color3 object
  5611. */
  5612. toLinearSpace(): Color3;
  5613. /**
  5614. * Converts current color in rgb space to HSV values
  5615. * @returns a new color3 representing the HSV values
  5616. */
  5617. toHSV(): Color3;
  5618. /**
  5619. * Converts current color in rgb space to HSV values
  5620. * @param result defines the Color3 where to store the HSV values
  5621. */
  5622. toHSVToRef(result: Color3): void;
  5623. /**
  5624. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5625. * @param convertedColor defines the Color3 object where to store the linear space version
  5626. * @returns the unmodified Color3
  5627. */
  5628. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5629. /**
  5630. * Computes a new Color3 converted from the current one to gamma space
  5631. * @returns a new Color3 object
  5632. */
  5633. toGammaSpace(): Color3;
  5634. /**
  5635. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5636. * @param convertedColor defines the Color3 object where to store the gamma space version
  5637. * @returns the unmodified Color3
  5638. */
  5639. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5640. private static _BlackReadOnly;
  5641. /**
  5642. * Convert Hue, saturation and value to a Color3 (RGB)
  5643. * @param hue defines the hue
  5644. * @param saturation defines the saturation
  5645. * @param value defines the value
  5646. * @param result defines the Color3 where to store the RGB values
  5647. */
  5648. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5649. /**
  5650. * Creates a new Color3 from the string containing valid hexadecimal values
  5651. * @param hex defines a string containing valid hexadecimal values
  5652. * @returns a new Color3 object
  5653. */
  5654. static FromHexString(hex: string): Color3;
  5655. /**
  5656. * Creates a new Color3 from the starting index of the given array
  5657. * @param array defines the source array
  5658. * @param offset defines an offset in the source array
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @returns a new Color3 object
  5668. */
  5669. static FromInts(r: number, g: number, b: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param start defines the start Color3 value
  5673. * @param end defines the end Color3 value
  5674. * @param amount defines the gradient value between start and end
  5675. * @returns a new Color3 object
  5676. */
  5677. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5678. /**
  5679. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5680. * @param left defines the start value
  5681. * @param right defines the end value
  5682. * @param amount defines the gradient factor
  5683. * @param result defines the Color3 object where to store the result
  5684. */
  5685. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5686. /**
  5687. * Returns a Color3 value containing a red color
  5688. * @returns a new Color3 object
  5689. */
  5690. static Red(): Color3;
  5691. /**
  5692. * Returns a Color3 value containing a green color
  5693. * @returns a new Color3 object
  5694. */
  5695. static Green(): Color3;
  5696. /**
  5697. * Returns a Color3 value containing a blue color
  5698. * @returns a new Color3 object
  5699. */
  5700. static Blue(): Color3;
  5701. /**
  5702. * Returns a Color3 value containing a black color
  5703. * @returns a new Color3 object
  5704. */
  5705. static Black(): Color3;
  5706. /**
  5707. * Gets a Color3 value containing a black color that must not be updated
  5708. */
  5709. static get BlackReadOnly(): DeepImmutable<Color3>;
  5710. /**
  5711. * Returns a Color3 value containing a white color
  5712. * @returns a new Color3 object
  5713. */
  5714. static White(): Color3;
  5715. /**
  5716. * Returns a Color3 value containing a purple color
  5717. * @returns a new Color3 object
  5718. */
  5719. static Purple(): Color3;
  5720. /**
  5721. * Returns a Color3 value containing a magenta color
  5722. * @returns a new Color3 object
  5723. */
  5724. static Magenta(): Color3;
  5725. /**
  5726. * Returns a Color3 value containing a yellow color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Yellow(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a gray color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Gray(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a teal color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Teal(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a random color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Random(): Color3;
  5745. }
  5746. /**
  5747. * Class used to hold a RBGA color
  5748. */
  5749. export class Color4 {
  5750. /**
  5751. * Defines the red component (between 0 and 1, default is 0)
  5752. */
  5753. r: number;
  5754. /**
  5755. * Defines the green component (between 0 and 1, default is 0)
  5756. */
  5757. g: number;
  5758. /**
  5759. * Defines the blue component (between 0 and 1, default is 0)
  5760. */
  5761. b: number;
  5762. /**
  5763. * Defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. a: number;
  5766. /**
  5767. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5768. * @param r defines the red component (between 0 and 1, default is 0)
  5769. * @param g defines the green component (between 0 and 1, default is 0)
  5770. * @param b defines the blue component (between 0 and 1, default is 0)
  5771. * @param a defines the alpha component (between 0 and 1, default is 1)
  5772. */
  5773. constructor(
  5774. /**
  5775. * Defines the red component (between 0 and 1, default is 0)
  5776. */
  5777. r?: number,
  5778. /**
  5779. * Defines the green component (between 0 and 1, default is 0)
  5780. */
  5781. g?: number,
  5782. /**
  5783. * Defines the blue component (between 0 and 1, default is 0)
  5784. */
  5785. b?: number,
  5786. /**
  5787. * Defines the alpha component (between 0 and 1, default is 1)
  5788. */
  5789. a?: number);
  5790. /**
  5791. * Adds in place the given Color4 values to the current Color4 object
  5792. * @param right defines the second operand
  5793. * @returns the current updated Color4 object
  5794. */
  5795. addInPlace(right: DeepImmutable<Color4>): Color4;
  5796. /**
  5797. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5798. * @returns the new array
  5799. */
  5800. asArray(): number[];
  5801. /**
  5802. * Stores from the starting index in the given array the Color4 successive values
  5803. * @param array defines the array where to store the r,g,b components
  5804. * @param index defines an optional index in the target array to define where to start storing values
  5805. * @returns the current Color4 object
  5806. */
  5807. toArray(array: number[], index?: number): Color4;
  5808. /**
  5809. * Determines equality between Color4 objects
  5810. * @param otherColor defines the second operand
  5811. * @returns true if the rgba values are equal to the given ones
  5812. */
  5813. equals(otherColor: DeepImmutable<Color4>): boolean;
  5814. /**
  5815. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5816. * @param right defines the second operand
  5817. * @returns a new Color4 object
  5818. */
  5819. add(right: DeepImmutable<Color4>): Color4;
  5820. /**
  5821. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5822. * @param right defines the second operand
  5823. * @returns a new Color4 object
  5824. */
  5825. subtract(right: DeepImmutable<Color4>): Color4;
  5826. /**
  5827. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5828. * @param right defines the second operand
  5829. * @param result defines the Color4 object where to store the result
  5830. * @returns the current Color4 object
  5831. */
  5832. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5833. /**
  5834. * Creates a new Color4 with the current Color4 values multiplied by scale
  5835. * @param scale defines the scaling factor to apply
  5836. * @returns a new Color4 object
  5837. */
  5838. scale(scale: number): Color4;
  5839. /**
  5840. * Multiplies the current Color4 values by scale and stores the result in "result"
  5841. * @param scale defines the scaling factor to apply
  5842. * @param result defines the Color4 object where to store the result
  5843. * @returns the current unmodified Color4
  5844. */
  5845. scaleToRef(scale: number, result: Color4): Color4;
  5846. /**
  5847. * Scale the current Color4 values by a factor and add the result to a given Color4
  5848. * @param scale defines the scale factor
  5849. * @param result defines the Color4 object where to store the result
  5850. * @returns the unmodified current Color4
  5851. */
  5852. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5853. /**
  5854. * Clamps the rgb values by the min and max values and stores the result into "result"
  5855. * @param min defines minimum clamping value (default is 0)
  5856. * @param max defines maximum clamping value (default is 1)
  5857. * @param result defines color to store the result into.
  5858. * @returns the cuurent Color4
  5859. */
  5860. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5861. /**
  5862. * Multipy an Color4 value by another and return a new Color4 object
  5863. * @param color defines the Color4 value to multiply by
  5864. * @returns a new Color4 object
  5865. */
  5866. multiply(color: Color4): Color4;
  5867. /**
  5868. * Multipy a Color4 value by another and push the result in a reference value
  5869. * @param color defines the Color4 value to multiply by
  5870. * @param result defines the Color4 to fill the result in
  5871. * @returns the result Color4
  5872. */
  5873. multiplyToRef(color: Color4, result: Color4): Color4;
  5874. /**
  5875. * Creates a string with the Color4 current values
  5876. * @returns the string representation of the Color4 object
  5877. */
  5878. toString(): string;
  5879. /**
  5880. * Returns the string "Color4"
  5881. * @returns "Color4"
  5882. */
  5883. getClassName(): string;
  5884. /**
  5885. * Compute the Color4 hash code
  5886. * @returns an unique number that can be used to hash Color4 objects
  5887. */
  5888. getHashCode(): number;
  5889. /**
  5890. * Creates a new Color4 copied from the current one
  5891. * @returns a new Color4 object
  5892. */
  5893. clone(): Color4;
  5894. /**
  5895. * Copies the given Color4 values into the current one
  5896. * @param source defines the source Color4 object
  5897. * @returns the current updated Color4 object
  5898. */
  5899. copyFrom(source: Color4): Color4;
  5900. /**
  5901. * Copies the given float values into the current one
  5902. * @param r defines the red component to read from
  5903. * @param g defines the green component to read from
  5904. * @param b defines the blue component to read from
  5905. * @param a defines the alpha component to read from
  5906. * @returns the current updated Color4 object
  5907. */
  5908. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5909. /**
  5910. * Copies the given float values into the current one
  5911. * @param r defines the red component to read from
  5912. * @param g defines the green component to read from
  5913. * @param b defines the blue component to read from
  5914. * @param a defines the alpha component to read from
  5915. * @returns the current updated Color4 object
  5916. */
  5917. set(r: number, g: number, b: number, a: number): Color4;
  5918. /**
  5919. * Compute the Color4 hexadecimal code as a string
  5920. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5921. * @returns a string containing the hexadecimal representation of the Color4 object
  5922. */
  5923. toHexString(returnAsColor3?: boolean): string;
  5924. /**
  5925. * Computes a new Color4 converted from the current one to linear space
  5926. * @returns a new Color4 object
  5927. */
  5928. toLinearSpace(): Color4;
  5929. /**
  5930. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5931. * @param convertedColor defines the Color4 object where to store the linear space version
  5932. * @returns the unmodified Color4
  5933. */
  5934. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5935. /**
  5936. * Computes a new Color4 converted from the current one to gamma space
  5937. * @returns a new Color4 object
  5938. */
  5939. toGammaSpace(): Color4;
  5940. /**
  5941. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5942. * @param convertedColor defines the Color4 object where to store the gamma space version
  5943. * @returns the unmodified Color4
  5944. */
  5945. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5946. /**
  5947. * Creates a new Color4 from the string containing valid hexadecimal values
  5948. * @param hex defines a string containing valid hexadecimal values
  5949. * @returns a new Color4 object
  5950. */
  5951. static FromHexString(hex: string): Color4;
  5952. /**
  5953. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @returns a new Color4 object
  5958. */
  5959. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5960. /**
  5961. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5962. * @param left defines the start value
  5963. * @param right defines the end value
  5964. * @param amount defines the gradient factor
  5965. * @param result defines the Color4 object where to store data
  5966. */
  5967. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5968. /**
  5969. * Creates a new Color4 from a Color3 and an alpha value
  5970. * @param color3 defines the source Color3 to read from
  5971. * @param alpha defines the alpha component (1.0 by default)
  5972. * @returns a new Color4 object
  5973. */
  5974. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5975. /**
  5976. * Creates a new Color4 from the starting index element of the given array
  5977. * @param array defines the source array to read from
  5978. * @param offset defines the offset in the source array
  5979. * @returns a new Color4 object
  5980. */
  5981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5982. /**
  5983. * Creates a new Color3 from integer values (< 256)
  5984. * @param r defines the red component to read from (value between 0 and 255)
  5985. * @param g defines the green component to read from (value between 0 and 255)
  5986. * @param b defines the blue component to read from (value between 0 and 255)
  5987. * @param a defines the alpha component to read from (value between 0 and 255)
  5988. * @returns a new Color3 object
  5989. */
  5990. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5991. /**
  5992. * Check the content of a given array and convert it to an array containing RGBA data
  5993. * If the original array was already containing count * 4 values then it is returned directly
  5994. * @param colors defines the array to check
  5995. * @param count defines the number of RGBA data to expect
  5996. * @returns an array containing count * 4 values (RGBA)
  5997. */
  5998. static CheckColors4(colors: number[], count: number): number[];
  5999. }
  6000. /**
  6001. * @hidden
  6002. */
  6003. export class TmpColors {
  6004. static Color3: Color3[];
  6005. static Color4: Color4[];
  6006. }
  6007. }
  6008. declare module BABYLON {
  6009. /**
  6010. * Defines an interface which represents an animation key frame
  6011. */
  6012. export interface IAnimationKey {
  6013. /**
  6014. * Frame of the key frame
  6015. */
  6016. frame: number;
  6017. /**
  6018. * Value at the specifies key frame
  6019. */
  6020. value: any;
  6021. /**
  6022. * The input tangent for the cubic hermite spline
  6023. */
  6024. inTangent?: any;
  6025. /**
  6026. * The output tangent for the cubic hermite spline
  6027. */
  6028. outTangent?: any;
  6029. /**
  6030. * The animation interpolation type
  6031. */
  6032. interpolation?: AnimationKeyInterpolation;
  6033. }
  6034. /**
  6035. * Enum for the animation key frame interpolation type
  6036. */
  6037. export enum AnimationKeyInterpolation {
  6038. /**
  6039. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6040. */
  6041. STEP = 1
  6042. }
  6043. }
  6044. declare module BABYLON {
  6045. /**
  6046. * Represents the range of an animation
  6047. */
  6048. export class AnimationRange {
  6049. /**The name of the animation range**/
  6050. name: string;
  6051. /**The starting frame of the animation */
  6052. from: number;
  6053. /**The ending frame of the animation*/
  6054. to: number;
  6055. /**
  6056. * Initializes the range of an animation
  6057. * @param name The name of the animation range
  6058. * @param from The starting frame of the animation
  6059. * @param to The ending frame of the animation
  6060. */
  6061. constructor(
  6062. /**The name of the animation range**/
  6063. name: string,
  6064. /**The starting frame of the animation */
  6065. from: number,
  6066. /**The ending frame of the animation*/
  6067. to: number);
  6068. /**
  6069. * Makes a copy of the animation range
  6070. * @returns A copy of the animation range
  6071. */
  6072. clone(): AnimationRange;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * Composed of a frame, and an action function
  6078. */
  6079. export class AnimationEvent {
  6080. /** The frame for which the event is triggered **/
  6081. frame: number;
  6082. /** The event to perform when triggered **/
  6083. action: (currentFrame: number) => void;
  6084. /** Specifies if the event should be triggered only once**/
  6085. onlyOnce?: boolean | undefined;
  6086. /**
  6087. * Specifies if the animation event is done
  6088. */
  6089. isDone: boolean;
  6090. /**
  6091. * Initializes the animation event
  6092. * @param frame The frame for which the event is triggered
  6093. * @param action The event to perform when triggered
  6094. * @param onlyOnce Specifies if the event should be triggered only once
  6095. */
  6096. constructor(
  6097. /** The frame for which the event is triggered **/
  6098. frame: number,
  6099. /** The event to perform when triggered **/
  6100. action: (currentFrame: number) => void,
  6101. /** Specifies if the event should be triggered only once**/
  6102. onlyOnce?: boolean | undefined);
  6103. /** @hidden */
  6104. _clone(): AnimationEvent;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * Interface used to define a behavior
  6110. */
  6111. export interface Behavior<T> {
  6112. /** gets or sets behavior's name */
  6113. name: string;
  6114. /**
  6115. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6116. */
  6117. init(): void;
  6118. /**
  6119. * Called when the behavior is attached to a target
  6120. * @param target defines the target where the behavior is attached to
  6121. */
  6122. attach(target: T): void;
  6123. /**
  6124. * Called when the behavior is detached from its target
  6125. */
  6126. detach(): void;
  6127. }
  6128. /**
  6129. * Interface implemented by classes supporting behaviors
  6130. */
  6131. export interface IBehaviorAware<T> {
  6132. /**
  6133. * Attach a behavior
  6134. * @param behavior defines the behavior to attach
  6135. * @returns the current host
  6136. */
  6137. addBehavior(behavior: Behavior<T>): T;
  6138. /**
  6139. * Remove a behavior from the current object
  6140. * @param behavior defines the behavior to detach
  6141. * @returns the current host
  6142. */
  6143. removeBehavior(behavior: Behavior<T>): T;
  6144. /**
  6145. * Gets a behavior using its name to search
  6146. * @param name defines the name to search
  6147. * @returns the behavior or null if not found
  6148. */
  6149. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6150. }
  6151. }
  6152. declare module BABYLON {
  6153. /**
  6154. * Defines an array and its length.
  6155. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6156. */
  6157. export interface ISmartArrayLike<T> {
  6158. /**
  6159. * The data of the array.
  6160. */
  6161. data: Array<T>;
  6162. /**
  6163. * The active length of the array.
  6164. */
  6165. length: number;
  6166. }
  6167. /**
  6168. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6169. */
  6170. export class SmartArray<T> implements ISmartArrayLike<T> {
  6171. /**
  6172. * The full set of data from the array.
  6173. */
  6174. data: Array<T>;
  6175. /**
  6176. * The active length of the array.
  6177. */
  6178. length: number;
  6179. protected _id: number;
  6180. /**
  6181. * Instantiates a Smart Array.
  6182. * @param capacity defines the default capacity of the array.
  6183. */
  6184. constructor(capacity: number);
  6185. /**
  6186. * Pushes a value at the end of the active data.
  6187. * @param value defines the object to push in the array.
  6188. */
  6189. push(value: T): void;
  6190. /**
  6191. * Iterates over the active data and apply the lambda to them.
  6192. * @param func defines the action to apply on each value.
  6193. */
  6194. forEach(func: (content: T) => void): void;
  6195. /**
  6196. * Sorts the full sets of data.
  6197. * @param compareFn defines the comparison function to apply.
  6198. */
  6199. sort(compareFn: (a: T, b: T) => number): void;
  6200. /**
  6201. * Resets the active data to an empty array.
  6202. */
  6203. reset(): void;
  6204. /**
  6205. * Releases all the data from the array as well as the array.
  6206. */
  6207. dispose(): void;
  6208. /**
  6209. * Concats the active data with a given array.
  6210. * @param array defines the data to concatenate with.
  6211. */
  6212. concat(array: any): void;
  6213. /**
  6214. * Returns the position of a value in the active data.
  6215. * @param value defines the value to find the index for
  6216. * @returns the index if found in the active data otherwise -1
  6217. */
  6218. indexOf(value: T): number;
  6219. /**
  6220. * Returns whether an element is part of the active data.
  6221. * @param value defines the value to look for
  6222. * @returns true if found in the active data otherwise false
  6223. */
  6224. contains(value: T): boolean;
  6225. private static _GlobalId;
  6226. }
  6227. /**
  6228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6229. * The data in this array can only be present once
  6230. */
  6231. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6232. private _duplicateId;
  6233. /**
  6234. * Pushes a value at the end of the active data.
  6235. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6236. * @param value defines the object to push in the array.
  6237. */
  6238. push(value: T): void;
  6239. /**
  6240. * Pushes a value at the end of the active data.
  6241. * If the data is already present, it won t be added again
  6242. * @param value defines the object to push in the array.
  6243. * @returns true if added false if it was already present
  6244. */
  6245. pushNoDuplicate(value: T): boolean;
  6246. /**
  6247. * Resets the active data to an empty array.
  6248. */
  6249. reset(): void;
  6250. /**
  6251. * Concats the active data with a given array.
  6252. * This ensures no dupplicate will be present in the result.
  6253. * @param array defines the data to concatenate with.
  6254. */
  6255. concatWithNoDuplicate(array: any): void;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. /**
  6260. * @ignore
  6261. * This is a list of all the different input types that are available in the application.
  6262. * Fo instance: ArcRotateCameraGamepadInput...
  6263. */
  6264. export var CameraInputTypes: {};
  6265. /**
  6266. * This is the contract to implement in order to create a new input class.
  6267. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6268. */
  6269. export interface ICameraInput<TCamera extends Camera> {
  6270. /**
  6271. * Defines the camera the input is attached to.
  6272. */
  6273. camera: Nullable<TCamera>;
  6274. /**
  6275. * Gets the class name of the current intput.
  6276. * @returns the class name
  6277. */
  6278. getClassName(): string;
  6279. /**
  6280. * Get the friendly name associated with the input class.
  6281. * @returns the input friendly name
  6282. */
  6283. getSimpleName(): string;
  6284. /**
  6285. * Attach the input controls to a specific dom element to get the input from.
  6286. * @param element Defines the element the controls should be listened from
  6287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6288. */
  6289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6290. /**
  6291. * Detach the current controls from the specified dom element.
  6292. * @param element Defines the element to stop listening the inputs from
  6293. */
  6294. detachControl(element: Nullable<HTMLElement>): void;
  6295. /**
  6296. * Update the current camera state depending on the inputs that have been used this frame.
  6297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6298. */
  6299. checkInputs?: () => void;
  6300. }
  6301. /**
  6302. * Represents a map of input types to input instance or input index to input instance.
  6303. */
  6304. export interface CameraInputsMap<TCamera extends Camera> {
  6305. /**
  6306. * Accessor to the input by input type.
  6307. */
  6308. [name: string]: ICameraInput<TCamera>;
  6309. /**
  6310. * Accessor to the input by input index.
  6311. */
  6312. [idx: number]: ICameraInput<TCamera>;
  6313. }
  6314. /**
  6315. * This represents the input manager used within a camera.
  6316. * It helps dealing with all the different kind of input attached to a camera.
  6317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6318. */
  6319. export class CameraInputsManager<TCamera extends Camera> {
  6320. /**
  6321. * Defines the list of inputs attahed to the camera.
  6322. */
  6323. attached: CameraInputsMap<TCamera>;
  6324. /**
  6325. * Defines the dom element the camera is collecting inputs from.
  6326. * This is null if the controls have not been attached.
  6327. */
  6328. attachedElement: Nullable<HTMLElement>;
  6329. /**
  6330. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6331. */
  6332. noPreventDefault: boolean;
  6333. /**
  6334. * Defined the camera the input manager belongs to.
  6335. */
  6336. camera: TCamera;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs: () => void;
  6342. /**
  6343. * Instantiate a new Camera Input Manager.
  6344. * @param camera Defines the camera the input manager blongs to
  6345. */
  6346. constructor(camera: TCamera);
  6347. /**
  6348. * Add an input method to a camera
  6349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6350. * @param input camera input method
  6351. */
  6352. add(input: ICameraInput<TCamera>): void;
  6353. /**
  6354. * Remove a specific input method from a camera
  6355. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6356. * @param inputToRemove camera input method
  6357. */
  6358. remove(inputToRemove: ICameraInput<TCamera>): void;
  6359. /**
  6360. * Remove a specific input type from a camera
  6361. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6362. * @param inputType the type of the input to remove
  6363. */
  6364. removeByType(inputType: string): void;
  6365. private _addCheckInputs;
  6366. /**
  6367. * Attach the input controls to the currently attached dom element to listen the events from.
  6368. * @param input Defines the input to attach
  6369. */
  6370. attachInput(input: ICameraInput<TCamera>): void;
  6371. /**
  6372. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6373. * @param element Defines the dom element to collect the events from
  6374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6375. */
  6376. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6377. /**
  6378. * Detach the current manager inputs controls from a specific dom element.
  6379. * @param element Defines the dom element to collect the events from
  6380. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6381. */
  6382. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6383. /**
  6384. * Rebuild the dynamic inputCheck function from the current list of
  6385. * defined inputs in the manager.
  6386. */
  6387. rebuildInputCheck(): void;
  6388. /**
  6389. * Remove all attached input methods from a camera
  6390. */
  6391. clear(): void;
  6392. /**
  6393. * Serialize the current input manager attached to a camera.
  6394. * This ensures than once parsed,
  6395. * the input associated to the camera will be identical to the current ones
  6396. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6397. */
  6398. serialize(serializedCamera: any): void;
  6399. /**
  6400. * Parses an input manager serialized JSON to restore the previous list of inputs
  6401. * and states associated to a camera.
  6402. * @param parsedCamera Defines the JSON to parse
  6403. */
  6404. parse(parsedCamera: any): void;
  6405. }
  6406. }
  6407. declare module BABYLON {
  6408. /**
  6409. * Class used to store data that will be store in GPU memory
  6410. */
  6411. export class Buffer {
  6412. private _engine;
  6413. private _buffer;
  6414. /** @hidden */
  6415. _data: Nullable<DataArray>;
  6416. private _updatable;
  6417. private _instanced;
  6418. private _divisor;
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Constructor
  6425. * @param engine the engine
  6426. * @param data the data to use for this buffer
  6427. * @param updatable whether the data is updatable
  6428. * @param stride the stride (optional)
  6429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param useBytes set to true if the stride in in bytes (optional)
  6432. * @param divisor sets an optional divisor for instances (1 by default)
  6433. */
  6434. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6435. /**
  6436. * Create a new VertexBuffer based on the current buffer
  6437. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6438. * @param offset defines offset in the buffer (0 by default)
  6439. * @param size defines the size in floats of attributes (position is 3 for instance)
  6440. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6441. * @param instanced defines if the vertex buffer contains indexed data
  6442. * @param useBytes defines if the offset and stride are in bytes *
  6443. * @param divisor sets an optional divisor for instances (1 by default)
  6444. * @returns the new vertex buffer
  6445. */
  6446. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6447. /**
  6448. * Gets a boolean indicating if the Buffer is updatable?
  6449. * @returns true if the buffer is updatable
  6450. */
  6451. isUpdatable(): boolean;
  6452. /**
  6453. * Gets current buffer's data
  6454. * @returns a DataArray or null
  6455. */
  6456. getData(): Nullable<DataArray>;
  6457. /**
  6458. * Gets underlying native buffer
  6459. * @returns underlying native buffer
  6460. */
  6461. getBuffer(): Nullable<DataBuffer>;
  6462. /**
  6463. * Gets the stride in float32 units (i.e. byte stride / 4).
  6464. * May not be an integer if the byte stride is not divisible by 4.
  6465. * @returns the stride in float32 units
  6466. * @deprecated Please use byteStride instead.
  6467. */
  6468. getStrideSize(): number;
  6469. /**
  6470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6471. * @param data defines the data to store
  6472. */
  6473. create(data?: Nullable<DataArray>): void;
  6474. /** @hidden */
  6475. _rebuild(): void;
  6476. /**
  6477. * Update current buffer data
  6478. * @param data defines the data to store
  6479. */
  6480. update(data: DataArray): void;
  6481. /**
  6482. * Updates the data directly.
  6483. * @param data the new data
  6484. * @param offset the new offset
  6485. * @param vertexCount the vertex count (optional)
  6486. * @param useBytes set to true if the offset is in bytes
  6487. */
  6488. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6489. /**
  6490. * Release all resources
  6491. */
  6492. dispose(): void;
  6493. }
  6494. /**
  6495. * Specialized buffer used to store vertex data
  6496. */
  6497. export class VertexBuffer {
  6498. /** @hidden */
  6499. _buffer: Buffer;
  6500. private _kind;
  6501. private _size;
  6502. private _ownsBuffer;
  6503. private _instanced;
  6504. private _instanceDivisor;
  6505. /**
  6506. * The byte type.
  6507. */
  6508. static readonly BYTE: number;
  6509. /**
  6510. * The unsigned byte type.
  6511. */
  6512. static readonly UNSIGNED_BYTE: number;
  6513. /**
  6514. * The short type.
  6515. */
  6516. static readonly SHORT: number;
  6517. /**
  6518. * The unsigned short type.
  6519. */
  6520. static readonly UNSIGNED_SHORT: number;
  6521. /**
  6522. * The integer type.
  6523. */
  6524. static readonly INT: number;
  6525. /**
  6526. * The unsigned integer type.
  6527. */
  6528. static readonly UNSIGNED_INT: number;
  6529. /**
  6530. * The float type.
  6531. */
  6532. static readonly FLOAT: number;
  6533. /**
  6534. * Gets or sets the instance divisor when in instanced mode
  6535. */
  6536. get instanceDivisor(): number;
  6537. set instanceDivisor(value: number);
  6538. /**
  6539. * Gets the byte stride.
  6540. */
  6541. readonly byteStride: number;
  6542. /**
  6543. * Gets the byte offset.
  6544. */
  6545. readonly byteOffset: number;
  6546. /**
  6547. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6548. */
  6549. readonly normalized: boolean;
  6550. /**
  6551. * Gets the data type of each component in the array.
  6552. */
  6553. readonly type: number;
  6554. /**
  6555. * Constructor
  6556. * @param engine the engine
  6557. * @param data the data to use for this vertex buffer
  6558. * @param kind the vertex buffer kind
  6559. * @param updatable whether the data is updatable
  6560. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6561. * @param stride the stride (optional)
  6562. * @param instanced whether the buffer is instanced (optional)
  6563. * @param offset the offset of the data (optional)
  6564. * @param size the number of components (optional)
  6565. * @param type the type of the component (optional)
  6566. * @param normalized whether the data contains normalized data (optional)
  6567. * @param useBytes set to true if stride and offset are in bytes (optional)
  6568. * @param divisor defines the instance divisor to use (1 by default)
  6569. */
  6570. 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);
  6571. /** @hidden */
  6572. _rebuild(): void;
  6573. /**
  6574. * Returns the kind of the VertexBuffer (string)
  6575. * @returns a string
  6576. */
  6577. getKind(): string;
  6578. /**
  6579. * Gets a boolean indicating if the VertexBuffer is updatable?
  6580. * @returns true if the buffer is updatable
  6581. */
  6582. isUpdatable(): boolean;
  6583. /**
  6584. * Gets current buffer's data
  6585. * @returns a DataArray or null
  6586. */
  6587. getData(): Nullable<DataArray>;
  6588. /**
  6589. * Gets underlying native buffer
  6590. * @returns underlying native buffer
  6591. */
  6592. getBuffer(): Nullable<DataBuffer>;
  6593. /**
  6594. * Gets the stride in float32 units (i.e. byte stride / 4).
  6595. * May not be an integer if the byte stride is not divisible by 4.
  6596. * @returns the stride in float32 units
  6597. * @deprecated Please use byteStride instead.
  6598. */
  6599. getStrideSize(): number;
  6600. /**
  6601. * Returns the offset as a multiple of the type byte length.
  6602. * @returns the offset in bytes
  6603. * @deprecated Please use byteOffset instead.
  6604. */
  6605. getOffset(): number;
  6606. /**
  6607. * Returns the number of components per vertex attribute (integer)
  6608. * @returns the size in float
  6609. */
  6610. getSize(): number;
  6611. /**
  6612. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6613. * @returns true if this buffer is instanced
  6614. */
  6615. getIsInstanced(): boolean;
  6616. /**
  6617. * Returns the instancing divisor, zero for non-instanced (integer).
  6618. * @returns a number
  6619. */
  6620. getInstanceDivisor(): number;
  6621. /**
  6622. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6623. * @param data defines the data to store
  6624. */
  6625. create(data?: DataArray): void;
  6626. /**
  6627. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6628. * This function will create a new buffer if the current one is not updatable
  6629. * @param data defines the data to store
  6630. */
  6631. update(data: DataArray): void;
  6632. /**
  6633. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6634. * Returns the directly updated WebGLBuffer.
  6635. * @param data the new data
  6636. * @param offset the new offset
  6637. * @param useBytes set to true if the offset is in bytes
  6638. */
  6639. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6640. /**
  6641. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6642. */
  6643. dispose(): void;
  6644. /**
  6645. * Enumerates each value of this vertex buffer as numbers.
  6646. * @param count the number of values to enumerate
  6647. * @param callback the callback function called for each value
  6648. */
  6649. forEach(count: number, callback: (value: number, index: number) => void): void;
  6650. /**
  6651. * Positions
  6652. */
  6653. static readonly PositionKind: string;
  6654. /**
  6655. * Normals
  6656. */
  6657. static readonly NormalKind: string;
  6658. /**
  6659. * Tangents
  6660. */
  6661. static readonly TangentKind: string;
  6662. /**
  6663. * Texture coordinates
  6664. */
  6665. static readonly UVKind: string;
  6666. /**
  6667. * Texture coordinates 2
  6668. */
  6669. static readonly UV2Kind: string;
  6670. /**
  6671. * Texture coordinates 3
  6672. */
  6673. static readonly UV3Kind: string;
  6674. /**
  6675. * Texture coordinates 4
  6676. */
  6677. static readonly UV4Kind: string;
  6678. /**
  6679. * Texture coordinates 5
  6680. */
  6681. static readonly UV5Kind: string;
  6682. /**
  6683. * Texture coordinates 6
  6684. */
  6685. static readonly UV6Kind: string;
  6686. /**
  6687. * Colors
  6688. */
  6689. static readonly ColorKind: string;
  6690. /**
  6691. * Matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesKind: string;
  6694. /**
  6695. * Matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsKind: string;
  6698. /**
  6699. * Additional matrix indices (for bones)
  6700. */
  6701. static readonly MatricesIndicesExtraKind: string;
  6702. /**
  6703. * Additional matrix weights (for bones)
  6704. */
  6705. static readonly MatricesWeightsExtraKind: string;
  6706. /**
  6707. * Deduces the stride given a kind.
  6708. * @param kind The kind string to deduce
  6709. * @returns The deduced stride
  6710. */
  6711. static DeduceStride(kind: string): number;
  6712. /**
  6713. * Gets the byte length of the given type.
  6714. * @param type the type
  6715. * @returns the number of bytes
  6716. */
  6717. static GetTypeByteLength(type: number): number;
  6718. /**
  6719. * Enumerates each value of the given parameters as numbers.
  6720. * @param data the data to enumerate
  6721. * @param byteOffset the byte offset of the data
  6722. * @param byteStride the byte stride of the data
  6723. * @param componentCount the number of components per element
  6724. * @param componentType the type of the component
  6725. * @param count the number of values to enumerate
  6726. * @param normalized whether the data is normalized
  6727. * @param callback the callback function called for each value
  6728. */
  6729. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6730. private static _GetFloatValue;
  6731. }
  6732. }
  6733. declare module BABYLON {
  6734. /**
  6735. * @hidden
  6736. */
  6737. export class IntersectionInfo {
  6738. bu: Nullable<number>;
  6739. bv: Nullable<number>;
  6740. distance: number;
  6741. faceId: number;
  6742. subMeshId: number;
  6743. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6744. }
  6745. }
  6746. declare module BABYLON {
  6747. /**
  6748. * Class used to store bounding sphere information
  6749. */
  6750. export class BoundingSphere {
  6751. /**
  6752. * Gets the center of the bounding sphere in local space
  6753. */
  6754. readonly center: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in local space
  6757. */
  6758. radius: number;
  6759. /**
  6760. * Gets the center of the bounding sphere in world space
  6761. */
  6762. readonly centerWorld: Vector3;
  6763. /**
  6764. * Radius of the bounding sphere in world space
  6765. */
  6766. radiusWorld: number;
  6767. /**
  6768. * Gets the minimum vector in local space
  6769. */
  6770. readonly minimum: Vector3;
  6771. /**
  6772. * Gets the maximum vector in local space
  6773. */
  6774. readonly maximum: Vector3;
  6775. private _worldMatrix;
  6776. private static readonly TmpVector3;
  6777. /**
  6778. * Creates a new bounding sphere
  6779. * @param min defines the minimum vector (in local space)
  6780. * @param max defines the maximum vector (in local space)
  6781. * @param worldMatrix defines the new world matrix
  6782. */
  6783. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6784. /**
  6785. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6786. * @param min defines the new minimum vector (in local space)
  6787. * @param max defines the new maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6791. /**
  6792. * Scale the current bounding sphere by applying a scale factor
  6793. * @param factor defines the scale factor to apply
  6794. * @returns the current bounding box
  6795. */
  6796. scale(factor: number): BoundingSphere;
  6797. /**
  6798. * Gets the world matrix of the bounding box
  6799. * @returns a matrix
  6800. */
  6801. getWorldMatrix(): DeepImmutable<Matrix>;
  6802. /** @hidden */
  6803. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Tests if the bounding sphere is intersecting the frustum planes
  6806. * @param frustumPlanes defines the frustum planes to test
  6807. * @returns true if there is an intersection
  6808. */
  6809. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6810. /**
  6811. * Tests if the bounding sphere center is in between the frustum planes.
  6812. * Used for optimistic fast inclusion.
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if the sphere center is in between the frustum planes
  6815. */
  6816. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if a point is inside the bounding sphere
  6819. * @param point defines the point to test
  6820. * @returns true if the point is inside the bounding sphere
  6821. */
  6822. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6823. /**
  6824. * Checks if two sphere intersct
  6825. * @param sphere0 sphere 0
  6826. * @param sphere1 sphere 1
  6827. * @returns true if the speres intersect
  6828. */
  6829. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6830. }
  6831. }
  6832. declare module BABYLON {
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /** @hidden */
  6979. export class Collider {
  6980. /** Define if a collision was found */
  6981. collisionFound: boolean;
  6982. /**
  6983. * Define last intersection point in local space
  6984. */
  6985. intersectionPoint: Vector3;
  6986. /**
  6987. * Define last collided mesh
  6988. */
  6989. collidedMesh: Nullable<AbstractMesh>;
  6990. private _collisionPoint;
  6991. private _planeIntersectionPoint;
  6992. private _tempVector;
  6993. private _tempVector2;
  6994. private _tempVector3;
  6995. private _tempVector4;
  6996. private _edge;
  6997. private _baseToVertex;
  6998. private _destinationPoint;
  6999. private _slidePlaneNormal;
  7000. private _displacementVector;
  7001. /** @hidden */
  7002. _radius: Vector3;
  7003. /** @hidden */
  7004. _retry: number;
  7005. private _velocity;
  7006. private _basePoint;
  7007. private _epsilon;
  7008. /** @hidden */
  7009. _velocityWorldLength: number;
  7010. /** @hidden */
  7011. _basePointWorld: Vector3;
  7012. private _velocityWorld;
  7013. private _normalizedVelocity;
  7014. /** @hidden */
  7015. _initialVelocity: Vector3;
  7016. /** @hidden */
  7017. _initialPosition: Vector3;
  7018. private _nearestDistance;
  7019. private _collisionMask;
  7020. get collisionMask(): number;
  7021. set collisionMask(mask: number);
  7022. /**
  7023. * Gets the plane normal used to compute the sliding response (in local space)
  7024. */
  7025. get slidePlaneNormal(): Vector3;
  7026. /** @hidden */
  7027. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7028. /** @hidden */
  7029. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7030. /** @hidden */
  7031. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7032. /** @hidden */
  7033. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7034. /** @hidden */
  7035. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7036. /** @hidden */
  7037. _getResponse(pos: Vector3, vel: Vector3): void;
  7038. }
  7039. }
  7040. declare module BABYLON {
  7041. /**
  7042. * Interface for cullable objects
  7043. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7044. */
  7045. export interface ICullable {
  7046. /**
  7047. * Checks if the object or part of the object is in the frustum
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isInFrustum(frustumPlanes: Plane[]): boolean;
  7052. /**
  7053. * Checks if a cullable object (mesh...) is in the camera frustum
  7054. * Unlike isInFrustum this cheks the full bounding box
  7055. * @param frustumPlanes Camera near/planes
  7056. * @returns true if the object is in frustum otherwise false
  7057. */
  7058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7059. }
  7060. /**
  7061. * Info for a bounding data of a mesh
  7062. */
  7063. export class BoundingInfo implements ICullable {
  7064. /**
  7065. * Bounding box for the mesh
  7066. */
  7067. readonly boundingBox: BoundingBox;
  7068. /**
  7069. * Bounding sphere for the mesh
  7070. */
  7071. readonly boundingSphere: BoundingSphere;
  7072. private _isLocked;
  7073. private static readonly TmpVector3;
  7074. /**
  7075. * Constructs bounding info
  7076. * @param minimum min vector of the bounding box/sphere
  7077. * @param maximum max vector of the bounding box/sphere
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * min vector of the bounding box/sphere
  7090. */
  7091. get minimum(): Vector3;
  7092. /**
  7093. * max vector of the bounding box/sphere
  7094. */
  7095. get maximum(): Vector3;
  7096. /**
  7097. * If the info is locked and won't be updated to avoid perf overhead
  7098. */
  7099. get isLocked(): boolean;
  7100. set isLocked(value: boolean);
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. get diagonalLength(): number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */
  7138. _checkCollision(collider: Collider): boolean;
  7139. /**
  7140. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7142. * @param point the point to check intersection with
  7143. * @returns if the point intersects
  7144. */
  7145. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7148. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7149. * @param boundingInfo the bounding info to check intersection with
  7150. * @param precise if the intersection should be done using OBB
  7151. * @returns if the bounding info intersects
  7152. */
  7153. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7154. }
  7155. }
  7156. declare module BABYLON {
  7157. /**
  7158. * Extracts minimum and maximum values from a list of indexed positions
  7159. * @param positions defines the positions to use
  7160. * @param indices defines the indices to the positions
  7161. * @param indexStart defines the start index
  7162. * @param indexCount defines the end index
  7163. * @param bias defines bias value to add to the result
  7164. * @return minimum and maximum values
  7165. */
  7166. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7167. minimum: Vector3;
  7168. maximum: Vector3;
  7169. };
  7170. /**
  7171. * Extracts minimum and maximum values from a list of positions
  7172. * @param positions defines the positions to use
  7173. * @param start defines the start index in the positions array
  7174. * @param count defines the number of positions to handle
  7175. * @param bias defines bias value to add to the result
  7176. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7177. * @return minimum and maximum values
  7178. */
  7179. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7180. minimum: Vector3;
  7181. maximum: Vector3;
  7182. };
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLDataBuffer extends DataBuffer {
  7187. private _buffer;
  7188. constructor(resource: WebGLBuffer);
  7189. get underlyingResource(): any;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. /** @hidden */
  7194. export class WebGLPipelineContext implements IPipelineContext {
  7195. engine: ThinEngine;
  7196. program: Nullable<WebGLProgram>;
  7197. context?: WebGLRenderingContext;
  7198. vertexShader?: WebGLShader;
  7199. fragmentShader?: WebGLShader;
  7200. isParallelCompiled: boolean;
  7201. onCompiled?: () => void;
  7202. transformFeedback?: WebGLTransformFeedback | null;
  7203. vertexCompilationError: Nullable<string>;
  7204. fragmentCompilationError: Nullable<string>;
  7205. programLinkError: Nullable<string>;
  7206. programValidationError: Nullable<string>;
  7207. get isAsync(): boolean;
  7208. get isReady(): boolean;
  7209. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7210. _getVertexShaderCode(): string | null;
  7211. _getFragmentShaderCode(): string | null;
  7212. }
  7213. }
  7214. declare module BABYLON {
  7215. interface ThinEngine {
  7216. /**
  7217. * Create an uniform buffer
  7218. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7219. * @param elements defines the content of the uniform buffer
  7220. * @returns the webGL uniform buffer
  7221. */
  7222. createUniformBuffer(elements: FloatArray): DataBuffer;
  7223. /**
  7224. * Create a dynamic uniform buffer
  7225. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7226. * @param elements defines the content of the uniform buffer
  7227. * @returns the webGL uniform buffer
  7228. */
  7229. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7230. /**
  7231. * Update an existing uniform buffer
  7232. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7233. * @param uniformBuffer defines the target uniform buffer
  7234. * @param elements defines the content to update
  7235. * @param offset defines the offset in the uniform buffer where update should start
  7236. * @param count defines the size of the data to update
  7237. */
  7238. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7239. /**
  7240. * Bind an uniform buffer to the current webGL context
  7241. * @param buffer defines the buffer to bind
  7242. */
  7243. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7244. /**
  7245. * Bind a buffer to the current webGL context at a given location
  7246. * @param buffer defines the buffer to bind
  7247. * @param location defines the index where to bind the buffer
  7248. */
  7249. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7250. /**
  7251. * Bind a specific block at a given index in a specific shader program
  7252. * @param pipelineContext defines the pipeline context to use
  7253. * @param blockName defines the block name
  7254. * @param index defines the index where to bind the block
  7255. */
  7256. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Uniform buffer objects.
  7262. *
  7263. * Handles blocks of uniform on the GPU.
  7264. *
  7265. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7266. *
  7267. * For more information, please refer to :
  7268. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7269. */
  7270. export class UniformBuffer {
  7271. private _engine;
  7272. private _buffer;
  7273. private _data;
  7274. private _bufferData;
  7275. private _dynamic?;
  7276. private _uniformLocations;
  7277. private _uniformSizes;
  7278. private _uniformLocationPointer;
  7279. private _needSync;
  7280. private _noUBO;
  7281. private _currentEffect;
  7282. /** @hidden */
  7283. _alreadyBound: boolean;
  7284. private static _MAX_UNIFORM_SIZE;
  7285. private static _tempBuffer;
  7286. /**
  7287. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7292. /**
  7293. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7298. /**
  7299. * Lambda to Update a single float in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateFloat: (name: string, x: number) => void;
  7304. /**
  7305. * Lambda to Update a vec2 of float in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update a vec3 of float in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7316. /**
  7317. * Lambda to Update a vec4 of float in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateMatrix: (name: string, mat: Matrix) => void;
  7328. /**
  7329. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7330. * This is dynamic to allow compat with webgl 1 and 2.
  7331. * You will need to pass the name of the uniform as well as the value.
  7332. */
  7333. updateVector3: (name: string, vector: Vector3) => void;
  7334. /**
  7335. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7336. * This is dynamic to allow compat with webgl 1 and 2.
  7337. * You will need to pass the name of the uniform as well as the value.
  7338. */
  7339. updateVector4: (name: string, vector: Vector4) => void;
  7340. /**
  7341. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7342. * This is dynamic to allow compat with webgl 1 and 2.
  7343. * You will need to pass the name of the uniform as well as the value.
  7344. */
  7345. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7346. /**
  7347. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7348. * This is dynamic to allow compat with webgl 1 and 2.
  7349. * You will need to pass the name of the uniform as well as the value.
  7350. */
  7351. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7352. /**
  7353. * Instantiates a new Uniform buffer objects.
  7354. *
  7355. * Handles blocks of uniform on the GPU.
  7356. *
  7357. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7358. *
  7359. * For more information, please refer to :
  7360. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7361. * @param engine Define the engine the buffer is associated with
  7362. * @param data Define the data contained in the buffer
  7363. * @param dynamic Define if the buffer is updatable
  7364. */
  7365. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7366. /**
  7367. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7368. * or just falling back on setUniformXXX calls.
  7369. */
  7370. get useUbo(): boolean;
  7371. /**
  7372. * Indicates if the WebGL underlying uniform buffer is in sync
  7373. * with the javascript cache data.
  7374. */
  7375. get isSync(): boolean;
  7376. /**
  7377. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7378. * Also, a dynamic UniformBuffer will disable cache verification and always
  7379. * update the underlying WebGL uniform buffer to the GPU.
  7380. * @returns if Dynamic, otherwise false
  7381. */
  7382. isDynamic(): boolean;
  7383. /**
  7384. * The data cache on JS side.
  7385. * @returns the underlying data as a float array
  7386. */
  7387. getData(): Float32Array;
  7388. /**
  7389. * The underlying WebGL Uniform buffer.
  7390. * @returns the webgl buffer
  7391. */
  7392. getBuffer(): Nullable<DataBuffer>;
  7393. /**
  7394. * std140 layout specifies how to align data within an UBO structure.
  7395. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7396. * for specs.
  7397. */
  7398. private _fillAlignment;
  7399. /**
  7400. * Adds an uniform in the buffer.
  7401. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7402. * for the layout to be correct !
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param size Data size, or data directly.
  7405. */
  7406. addUniform(name: string, size: number | number[]): void;
  7407. /**
  7408. * Adds a Matrix 4x4 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param mat A 4x4 matrix.
  7411. */
  7412. addMatrix(name: string, mat: Matrix): void;
  7413. /**
  7414. * Adds a vec2 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. * @param x Define the x component value of the vec2
  7417. * @param y Define the y component value of the vec2
  7418. */
  7419. addFloat2(name: string, x: number, y: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param x Define the x component value of the vec3
  7424. * @param y Define the y component value of the vec3
  7425. * @param z Define the z component value of the vec3
  7426. */
  7427. addFloat3(name: string, x: number, y: number, z: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param color Define the vec3 from a Color
  7432. */
  7433. addColor3(name: string, color: Color3): void;
  7434. /**
  7435. * Adds a vec4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param color Define the rgb components from a Color
  7438. * @param alpha Define the a component of the vec4
  7439. */
  7440. addColor4(name: string, color: Color3, alpha: number): void;
  7441. /**
  7442. * Adds a vec3 to the uniform buffer.
  7443. * @param name Name of the uniform, as used in the uniform block in the shader.
  7444. * @param vector Define the vec3 components from a Vector
  7445. */
  7446. addVector3(name: string, vector: Vector3): void;
  7447. /**
  7448. * Adds a Matrix 3x3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. */
  7451. addMatrix3x3(name: string): void;
  7452. /**
  7453. * Adds a Matrix 2x2 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. */
  7456. addMatrix2x2(name: string): void;
  7457. /**
  7458. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7459. */
  7460. create(): void;
  7461. /** @hidden */
  7462. _rebuild(): void;
  7463. /**
  7464. * Updates the WebGL Uniform Buffer on the GPU.
  7465. * If the `dynamic` flag is set to true, no cache comparison is done.
  7466. * Otherwise, the buffer will be updated only if the cache differs.
  7467. */
  7468. update(): void;
  7469. /**
  7470. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7471. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7472. * @param data Define the flattened data
  7473. * @param size Define the size of the data.
  7474. */
  7475. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7476. private _valueCache;
  7477. private _cacheMatrix;
  7478. private _updateMatrix3x3ForUniform;
  7479. private _updateMatrix3x3ForEffect;
  7480. private _updateMatrix2x2ForEffect;
  7481. private _updateMatrix2x2ForUniform;
  7482. private _updateFloatForEffect;
  7483. private _updateFloatForUniform;
  7484. private _updateFloat2ForEffect;
  7485. private _updateFloat2ForUniform;
  7486. private _updateFloat3ForEffect;
  7487. private _updateFloat3ForUniform;
  7488. private _updateFloat4ForEffect;
  7489. private _updateFloat4ForUniform;
  7490. private _updateMatrixForEffect;
  7491. private _updateMatrixForUniform;
  7492. private _updateVector3ForEffect;
  7493. private _updateVector3ForUniform;
  7494. private _updateVector4ForEffect;
  7495. private _updateVector4ForUniform;
  7496. private _updateColor3ForEffect;
  7497. private _updateColor3ForUniform;
  7498. private _updateColor4ForEffect;
  7499. private _updateColor4ForUniform;
  7500. /**
  7501. * Sets a sampler uniform on the effect.
  7502. * @param name Define the name of the sampler.
  7503. * @param texture Define the texture to set in the sampler
  7504. */
  7505. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7506. /**
  7507. * Directly updates the value of the uniform in the cache AND on the GPU.
  7508. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7509. * @param data Define the flattened data
  7510. */
  7511. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7512. /**
  7513. * Binds this uniform buffer to an effect.
  7514. * @param effect Define the effect to bind the buffer to
  7515. * @param name Name of the uniform block in the shader.
  7516. */
  7517. bindToEffect(effect: Effect, name: string): void;
  7518. /**
  7519. * Disposes the uniform buffer.
  7520. */
  7521. dispose(): void;
  7522. }
  7523. }
  7524. declare module BABYLON {
  7525. /**
  7526. * Enum that determines the text-wrapping mode to use.
  7527. */
  7528. export enum InspectableType {
  7529. /**
  7530. * Checkbox for booleans
  7531. */
  7532. Checkbox = 0,
  7533. /**
  7534. * Sliders for numbers
  7535. */
  7536. Slider = 1,
  7537. /**
  7538. * Vector3
  7539. */
  7540. Vector3 = 2,
  7541. /**
  7542. * Quaternions
  7543. */
  7544. Quaternion = 3,
  7545. /**
  7546. * Color3
  7547. */
  7548. Color3 = 4,
  7549. /**
  7550. * String
  7551. */
  7552. String = 5
  7553. }
  7554. /**
  7555. * Interface used to define custom inspectable properties.
  7556. * This interface is used by the inspector to display custom property grids
  7557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7558. */
  7559. export interface IInspectable {
  7560. /**
  7561. * Gets the label to display
  7562. */
  7563. label: string;
  7564. /**
  7565. * Gets the name of the property to edit
  7566. */
  7567. propertyName: string;
  7568. /**
  7569. * Gets the type of the editor to use
  7570. */
  7571. type: InspectableType;
  7572. /**
  7573. * Gets the minimum value of the property when using in "slider" mode
  7574. */
  7575. min?: number;
  7576. /**
  7577. * Gets the maximum value of the property when using in "slider" mode
  7578. */
  7579. max?: number;
  7580. /**
  7581. * Gets the setp to use when using in "slider" mode
  7582. */
  7583. step?: number;
  7584. }
  7585. }
  7586. declare module BABYLON {
  7587. /**
  7588. * Class used to provide helper for timing
  7589. */
  7590. export class TimingTools {
  7591. /**
  7592. * Polyfill for setImmediate
  7593. * @param action defines the action to execute after the current execution block
  7594. */
  7595. static SetImmediate(action: () => void): void;
  7596. }
  7597. }
  7598. declare module BABYLON {
  7599. /**
  7600. * Class used to enable instatition of objects by class name
  7601. */
  7602. export class InstantiationTools {
  7603. /**
  7604. * Use this object to register external classes like custom textures or material
  7605. * to allow the laoders to instantiate them
  7606. */
  7607. static RegisteredExternalClasses: {
  7608. [key: string]: Object;
  7609. };
  7610. /**
  7611. * Tries to instantiate a new object from a given class name
  7612. * @param className defines the class name to instantiate
  7613. * @returns the new object or null if the system was not able to do the instantiation
  7614. */
  7615. static Instantiate(className: string): any;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Define options used to create a depth texture
  7621. */
  7622. export class DepthTextureCreationOptions {
  7623. /** Specifies whether or not a stencil should be allocated in the texture */
  7624. generateStencil?: boolean;
  7625. /** Specifies whether or not bilinear filtering is enable on the texture */
  7626. bilinearFiltering?: boolean;
  7627. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7628. comparisonFunction?: number;
  7629. /** Specifies if the created texture is a cube texture */
  7630. isCube?: boolean;
  7631. }
  7632. }
  7633. declare module BABYLON {
  7634. interface ThinEngine {
  7635. /**
  7636. * Creates a depth stencil cube texture.
  7637. * This is only available in WebGL 2.
  7638. * @param size The size of face edge in the cube texture.
  7639. * @param options The options defining the cube texture.
  7640. * @returns The cube texture
  7641. */
  7642. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7643. /**
  7644. * Creates a cube texture
  7645. * @param rootUrl defines the url where the files to load is located
  7646. * @param scene defines the current scene
  7647. * @param files defines the list of files to load (1 per face)
  7648. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7649. * @param onLoad defines an optional callback raised when the texture is loaded
  7650. * @param onError defines an optional callback raised if there is an issue to load the texture
  7651. * @param format defines the format of the data
  7652. * @param forcedExtension defines the extension to use to pick the right loader
  7653. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7654. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7655. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7656. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. 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;
  7660. /**
  7661. * Creates a cube texture
  7662. * @param rootUrl defines the url where the files to load is located
  7663. * @param scene defines the current scene
  7664. * @param files defines the list of files to load (1 per face)
  7665. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7666. * @param onLoad defines an optional callback raised when the texture is loaded
  7667. * @param onError defines an optional callback raised if there is an issue to load the texture
  7668. * @param format defines the format of the data
  7669. * @param forcedExtension defines the extension to use to pick the right loader
  7670. * @returns the cube texture as an InternalTexture
  7671. */
  7672. 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;
  7673. /**
  7674. * Creates a cube texture
  7675. * @param rootUrl defines the url where the files to load is located
  7676. * @param scene defines the current scene
  7677. * @param files defines the list of files to load (1 per face)
  7678. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7679. * @param onLoad defines an optional callback raised when the texture is loaded
  7680. * @param onError defines an optional callback raised if there is an issue to load the texture
  7681. * @param format defines the format of the data
  7682. * @param forcedExtension defines the extension to use to pick the right loader
  7683. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7684. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7685. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7686. * @returns the cube texture as an InternalTexture
  7687. */
  7688. 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;
  7689. /** @hidden */
  7690. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7691. /** @hidden */
  7692. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7693. /** @hidden */
  7694. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7695. /** @hidden */
  7696. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7697. /**
  7698. * @hidden
  7699. */
  7700. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7701. }
  7702. }
  7703. declare module BABYLON {
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * Observable triggered once the texture has been loaded.
  7711. */
  7712. onLoadObservable: Observable<CubeTexture>;
  7713. /**
  7714. * The url of the texture
  7715. */
  7716. url: string;
  7717. /**
  7718. * Gets or sets the center of the bounding box associated with the cube texture.
  7719. * It must define where the camera used to render the texture was set
  7720. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7721. */
  7722. boundingBoxPosition: Vector3;
  7723. private _boundingBoxSize;
  7724. /**
  7725. * Gets or sets the size of the bounding box associated with the cube texture
  7726. * When defined, the cubemap will switch to local mode
  7727. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7728. * @example https://www.babylonjs-playground.com/#RNASML
  7729. */
  7730. set boundingBoxSize(value: Vector3);
  7731. /**
  7732. * Returns the bounding box size
  7733. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7734. */
  7735. get boundingBoxSize(): Vector3;
  7736. protected _rotationY: number;
  7737. /**
  7738. * Sets texture matrix rotation angle around Y axis in radians.
  7739. */
  7740. set rotationY(value: number);
  7741. /**
  7742. * Gets texture matrix rotation angle around Y axis radians.
  7743. */
  7744. get rotationY(): number;
  7745. /**
  7746. * Are mip maps generated for this texture or not.
  7747. */
  7748. get noMipmap(): boolean;
  7749. private _noMipmap;
  7750. private _files;
  7751. protected _forcedExtension: Nullable<string>;
  7752. private _extensions;
  7753. private _textureMatrix;
  7754. private _format;
  7755. private _createPolynomials;
  7756. /** @hidden */
  7757. _prefiltered: boolean;
  7758. /**
  7759. * Creates a cube texture from an array of image urls
  7760. * @param files defines an array of image urls
  7761. * @param scene defines the hosting scene
  7762. * @param noMipmap specifies if mip maps are not used
  7763. * @returns a cube texture
  7764. */
  7765. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7766. /**
  7767. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7768. * @param url defines the url of the prefiltered texture
  7769. * @param scene defines the scene the texture is attached to
  7770. * @param forcedExtension defines the extension of the file if different from the url
  7771. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7772. * @return the prefiltered texture
  7773. */
  7774. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7775. /**
  7776. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7777. * as prefiltered data.
  7778. * @param rootUrl defines the url of the texture or the root name of the six images
  7779. * @param null defines the scene or engine the texture is attached to
  7780. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7781. * @param noMipmap defines if mipmaps should be created or not
  7782. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7783. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7784. * @param onError defines a callback triggered in case of error during load
  7785. * @param format defines the internal format to use for the texture once loaded
  7786. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7787. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7788. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7789. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7790. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7791. * @return the cube texture
  7792. */
  7793. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  7794. /**
  7795. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7796. */
  7797. get isPrefiltered(): boolean;
  7798. /**
  7799. * Get the current class name of the texture useful for serialization or dynamic coding.
  7800. * @returns "CubeTexture"
  7801. */
  7802. getClassName(): string;
  7803. /**
  7804. * Update the url (and optional buffer) of this texture if url was null during construction.
  7805. * @param url the url of the texture
  7806. * @param forcedExtension defines the extension to use
  7807. * @param onLoad callback called when the texture is loaded (defaults to null)
  7808. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7809. */
  7810. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7811. /**
  7812. * Delays loading of the cube texture
  7813. * @param forcedExtension defines the extension to use
  7814. */
  7815. delayLoad(forcedExtension?: string): void;
  7816. /**
  7817. * Returns the reflection texture matrix
  7818. * @returns the reflection texture matrix
  7819. */
  7820. getReflectionTextureMatrix(): Matrix;
  7821. /**
  7822. * Sets the reflection texture matrix
  7823. * @param value Reflection texture matrix
  7824. */
  7825. setReflectionTextureMatrix(value: Matrix): void;
  7826. /**
  7827. * Parses text to create a cube texture
  7828. * @param parsedTexture define the serialized text to read from
  7829. * @param scene defines the hosting scene
  7830. * @param rootUrl defines the root url of the cube texture
  7831. * @returns a cube texture
  7832. */
  7833. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7834. /**
  7835. * Makes a clone, or deep copy, of the cube texture
  7836. * @returns a new cube texture
  7837. */
  7838. clone(): CubeTexture;
  7839. }
  7840. }
  7841. declare module BABYLON {
  7842. /**
  7843. * Manages the defines for the Material
  7844. */
  7845. export class MaterialDefines {
  7846. /** @hidden */
  7847. protected _keys: string[];
  7848. private _isDirty;
  7849. /** @hidden */
  7850. _renderId: number;
  7851. /** @hidden */
  7852. _areLightsDirty: boolean;
  7853. /** @hidden */
  7854. _areLightsDisposed: boolean;
  7855. /** @hidden */
  7856. _areAttributesDirty: boolean;
  7857. /** @hidden */
  7858. _areTexturesDirty: boolean;
  7859. /** @hidden */
  7860. _areFresnelDirty: boolean;
  7861. /** @hidden */
  7862. _areMiscDirty: boolean;
  7863. /** @hidden */
  7864. _areImageProcessingDirty: boolean;
  7865. /** @hidden */
  7866. _normals: boolean;
  7867. /** @hidden */
  7868. _uvs: boolean;
  7869. /** @hidden */
  7870. _needNormals: boolean;
  7871. /** @hidden */
  7872. _needUVs: boolean;
  7873. [id: string]: any;
  7874. /**
  7875. * Specifies if the material needs to be re-calculated
  7876. */
  7877. get isDirty(): boolean;
  7878. /**
  7879. * Marks the material to indicate that it has been re-calculated
  7880. */
  7881. markAsProcessed(): void;
  7882. /**
  7883. * Marks the material to indicate that it needs to be re-calculated
  7884. */
  7885. markAsUnprocessed(): void;
  7886. /**
  7887. * Marks the material to indicate all of its defines need to be re-calculated
  7888. */
  7889. markAllAsDirty(): void;
  7890. /**
  7891. * Marks the material to indicate that image processing needs to be re-calculated
  7892. */
  7893. markAsImageProcessingDirty(): void;
  7894. /**
  7895. * Marks the material to indicate the lights need to be re-calculated
  7896. * @param disposed Defines whether the light is dirty due to dispose or not
  7897. */
  7898. markAsLightDirty(disposed?: boolean): void;
  7899. /**
  7900. * Marks the attribute state as changed
  7901. */
  7902. markAsAttributesDirty(): void;
  7903. /**
  7904. * Marks the texture state as changed
  7905. */
  7906. markAsTexturesDirty(): void;
  7907. /**
  7908. * Marks the fresnel state as changed
  7909. */
  7910. markAsFresnelDirty(): void;
  7911. /**
  7912. * Marks the misc state as changed
  7913. */
  7914. markAsMiscDirty(): void;
  7915. /**
  7916. * Rebuilds the material defines
  7917. */
  7918. rebuild(): void;
  7919. /**
  7920. * Specifies if two material defines are equal
  7921. * @param other - A material define instance to compare to
  7922. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7923. */
  7924. isEqual(other: MaterialDefines): boolean;
  7925. /**
  7926. * Clones this instance's defines to another instance
  7927. * @param other - material defines to clone values to
  7928. */
  7929. cloneTo(other: MaterialDefines): void;
  7930. /**
  7931. * Resets the material define values
  7932. */
  7933. reset(): void;
  7934. /**
  7935. * Converts the material define values to a string
  7936. * @returns - String of material define information
  7937. */
  7938. toString(): string;
  7939. }
  7940. }
  7941. declare module BABYLON {
  7942. /**
  7943. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7944. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7945. * 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;
  7946. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7947. */
  7948. export class ColorCurves {
  7949. private _dirty;
  7950. private _tempColor;
  7951. private _globalCurve;
  7952. private _highlightsCurve;
  7953. private _midtonesCurve;
  7954. private _shadowsCurve;
  7955. private _positiveCurve;
  7956. private _negativeCurve;
  7957. private _globalHue;
  7958. private _globalDensity;
  7959. private _globalSaturation;
  7960. private _globalExposure;
  7961. /**
  7962. * Gets the global Hue value.
  7963. * 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).
  7964. */
  7965. get globalHue(): number;
  7966. /**
  7967. * Sets the global Hue value.
  7968. * 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).
  7969. */
  7970. set globalHue(value: number);
  7971. /**
  7972. * Gets the global Density value.
  7973. * 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.
  7974. * Values less than zero provide a filter of opposite hue.
  7975. */
  7976. get globalDensity(): number;
  7977. /**
  7978. * Sets the global Density value.
  7979. * 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.
  7980. * Values less than zero provide a filter of opposite hue.
  7981. */
  7982. set globalDensity(value: number);
  7983. /**
  7984. * Gets the global Saturation value.
  7985. * 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.
  7986. */
  7987. get globalSaturation(): number;
  7988. /**
  7989. * Sets the global Saturation value.
  7990. * 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.
  7991. */
  7992. set globalSaturation(value: number);
  7993. /**
  7994. * Gets the global Exposure value.
  7995. * 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.
  7996. */
  7997. get globalExposure(): number;
  7998. /**
  7999. * Sets the global Exposure value.
  8000. * 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.
  8001. */
  8002. set globalExposure(value: number);
  8003. private _highlightsHue;
  8004. private _highlightsDensity;
  8005. private _highlightsSaturation;
  8006. private _highlightsExposure;
  8007. /**
  8008. * Gets the highlights Hue value.
  8009. * 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).
  8010. */
  8011. get highlightsHue(): number;
  8012. /**
  8013. * Sets the highlights Hue value.
  8014. * 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).
  8015. */
  8016. set highlightsHue(value: number);
  8017. /**
  8018. * Gets the highlights Density value.
  8019. * 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.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. get highlightsDensity(): number;
  8023. /**
  8024. * Sets the highlights Density value.
  8025. * 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.
  8026. * Values less than zero provide a filter of opposite hue.
  8027. */
  8028. set highlightsDensity(value: number);
  8029. /**
  8030. * Gets the highlights Saturation value.
  8031. * 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.
  8032. */
  8033. get highlightsSaturation(): number;
  8034. /**
  8035. * Sets the highlights Saturation value.
  8036. * 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.
  8037. */
  8038. set highlightsSaturation(value: number);
  8039. /**
  8040. * Gets the highlights Exposure value.
  8041. * 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.
  8042. */
  8043. get highlightsExposure(): number;
  8044. /**
  8045. * Sets the highlights Exposure value.
  8046. * 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.
  8047. */
  8048. set highlightsExposure(value: number);
  8049. private _midtonesHue;
  8050. private _midtonesDensity;
  8051. private _midtonesSaturation;
  8052. private _midtonesExposure;
  8053. /**
  8054. * Gets the midtones Hue value.
  8055. * 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).
  8056. */
  8057. get midtonesHue(): number;
  8058. /**
  8059. * Sets the midtones Hue value.
  8060. * 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).
  8061. */
  8062. set midtonesHue(value: number);
  8063. /**
  8064. * Gets the midtones Density value.
  8065. * 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.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. get midtonesDensity(): number;
  8069. /**
  8070. * Sets the midtones Density value.
  8071. * 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.
  8072. * Values less than zero provide a filter of opposite hue.
  8073. */
  8074. set midtonesDensity(value: number);
  8075. /**
  8076. * Gets the midtones Saturation value.
  8077. * 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.
  8078. */
  8079. get midtonesSaturation(): number;
  8080. /**
  8081. * Sets the midtones Saturation value.
  8082. * 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.
  8083. */
  8084. set midtonesSaturation(value: number);
  8085. /**
  8086. * Gets the midtones Exposure value.
  8087. * 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.
  8088. */
  8089. get midtonesExposure(): number;
  8090. /**
  8091. * Sets the midtones Exposure value.
  8092. * 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.
  8093. */
  8094. set midtonesExposure(value: number);
  8095. private _shadowsHue;
  8096. private _shadowsDensity;
  8097. private _shadowsSaturation;
  8098. private _shadowsExposure;
  8099. /**
  8100. * Gets the shadows Hue value.
  8101. * 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).
  8102. */
  8103. get shadowsHue(): number;
  8104. /**
  8105. * Sets the shadows Hue value.
  8106. * 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).
  8107. */
  8108. set shadowsHue(value: number);
  8109. /**
  8110. * Gets the shadows Density value.
  8111. * 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.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. get shadowsDensity(): number;
  8115. /**
  8116. * Sets the shadows Density value.
  8117. * 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.
  8118. * Values less than zero provide a filter of opposite hue.
  8119. */
  8120. set shadowsDensity(value: number);
  8121. /**
  8122. * Gets the shadows Saturation value.
  8123. * 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.
  8124. */
  8125. get shadowsSaturation(): number;
  8126. /**
  8127. * Sets the shadows Saturation value.
  8128. * 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.
  8129. */
  8130. set shadowsSaturation(value: number);
  8131. /**
  8132. * Gets the shadows Exposure value.
  8133. * 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.
  8134. */
  8135. get shadowsExposure(): number;
  8136. /**
  8137. * Sets the shadows Exposure value.
  8138. * 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.
  8139. */
  8140. set shadowsExposure(value: number);
  8141. /**
  8142. * Returns the class name
  8143. * @returns The class name
  8144. */
  8145. getClassName(): string;
  8146. /**
  8147. * Binds the color curves to the shader.
  8148. * @param colorCurves The color curve to bind
  8149. * @param effect The effect to bind to
  8150. * @param positiveUniform The positive uniform shader parameter
  8151. * @param neutralUniform The neutral uniform shader parameter
  8152. * @param negativeUniform The negative uniform shader parameter
  8153. */
  8154. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8155. /**
  8156. * Prepare the list of uniforms associated with the ColorCurves effects.
  8157. * @param uniformsList The list of uniforms used in the effect
  8158. */
  8159. static PrepareUniforms(uniformsList: string[]): void;
  8160. /**
  8161. * Returns color grading data based on a hue, density, saturation and exposure value.
  8162. * @param filterHue The hue of the color filter.
  8163. * @param filterDensity The density of the color filter.
  8164. * @param saturation The saturation.
  8165. * @param exposure The exposure.
  8166. * @param result The result data container.
  8167. */
  8168. private getColorGradingDataToRef;
  8169. /**
  8170. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8171. * @param value The input slider value in range [-100,100].
  8172. * @returns Adjusted value.
  8173. */
  8174. private static applyColorGradingSliderNonlinear;
  8175. /**
  8176. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8177. * @param hue The hue (H) input.
  8178. * @param saturation The saturation (S) input.
  8179. * @param brightness The brightness (B) input.
  8180. * @result An RGBA color represented as Vector4.
  8181. */
  8182. private static fromHSBToRef;
  8183. /**
  8184. * Returns a value clamped between min and max
  8185. * @param value The value to clamp
  8186. * @param min The minimum of value
  8187. * @param max The maximum of value
  8188. * @returns The clamped value.
  8189. */
  8190. private static clamp;
  8191. /**
  8192. * Clones the current color curve instance.
  8193. * @return The cloned curves
  8194. */
  8195. clone(): ColorCurves;
  8196. /**
  8197. * Serializes the current color curve instance to a json representation.
  8198. * @return a JSON representation
  8199. */
  8200. serialize(): any;
  8201. /**
  8202. * Parses the color curve from a json representation.
  8203. * @param source the JSON source to parse
  8204. * @return The parsed curves
  8205. */
  8206. static Parse(source: any): ColorCurves;
  8207. }
  8208. }
  8209. declare module BABYLON {
  8210. /**
  8211. * Interface to follow in your material defines to integrate easily the
  8212. * Image proccessing functions.
  8213. * @hidden
  8214. */
  8215. export interface IImageProcessingConfigurationDefines {
  8216. IMAGEPROCESSING: boolean;
  8217. VIGNETTE: boolean;
  8218. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8219. VIGNETTEBLENDMODEOPAQUE: boolean;
  8220. TONEMAPPING: boolean;
  8221. TONEMAPPING_ACES: boolean;
  8222. CONTRAST: boolean;
  8223. EXPOSURE: boolean;
  8224. COLORCURVES: boolean;
  8225. COLORGRADING: boolean;
  8226. COLORGRADING3D: boolean;
  8227. SAMPLER3DGREENDEPTH: boolean;
  8228. SAMPLER3DBGRMAP: boolean;
  8229. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8230. }
  8231. /**
  8232. * @hidden
  8233. */
  8234. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8235. IMAGEPROCESSING: boolean;
  8236. VIGNETTE: boolean;
  8237. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8238. VIGNETTEBLENDMODEOPAQUE: boolean;
  8239. TONEMAPPING: boolean;
  8240. TONEMAPPING_ACES: boolean;
  8241. CONTRAST: boolean;
  8242. COLORCURVES: boolean;
  8243. COLORGRADING: boolean;
  8244. COLORGRADING3D: boolean;
  8245. SAMPLER3DGREENDEPTH: boolean;
  8246. SAMPLER3DBGRMAP: boolean;
  8247. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8248. EXPOSURE: boolean;
  8249. constructor();
  8250. }
  8251. /**
  8252. * This groups together the common properties used for image processing either in direct forward pass
  8253. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8254. * or not.
  8255. */
  8256. export class ImageProcessingConfiguration {
  8257. /**
  8258. * Default tone mapping applied in BabylonJS.
  8259. */
  8260. static readonly TONEMAPPING_STANDARD: number;
  8261. /**
  8262. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8263. * to other engines rendering to increase portability.
  8264. */
  8265. static readonly TONEMAPPING_ACES: number;
  8266. /**
  8267. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8268. */
  8269. colorCurves: Nullable<ColorCurves>;
  8270. private _colorCurvesEnabled;
  8271. /**
  8272. * Gets wether the color curves effect is enabled.
  8273. */
  8274. get colorCurvesEnabled(): boolean;
  8275. /**
  8276. * Sets wether the color curves effect is enabled.
  8277. */
  8278. set colorCurvesEnabled(value: boolean);
  8279. private _colorGradingTexture;
  8280. /**
  8281. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8282. */
  8283. get colorGradingTexture(): Nullable<BaseTexture>;
  8284. /**
  8285. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8286. */
  8287. set colorGradingTexture(value: Nullable<BaseTexture>);
  8288. private _colorGradingEnabled;
  8289. /**
  8290. * Gets wether the color grading effect is enabled.
  8291. */
  8292. get colorGradingEnabled(): boolean;
  8293. /**
  8294. * Sets wether the color grading effect is enabled.
  8295. */
  8296. set colorGradingEnabled(value: boolean);
  8297. private _colorGradingWithGreenDepth;
  8298. /**
  8299. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8300. */
  8301. get colorGradingWithGreenDepth(): boolean;
  8302. /**
  8303. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8304. */
  8305. set colorGradingWithGreenDepth(value: boolean);
  8306. private _colorGradingBGR;
  8307. /**
  8308. * Gets wether the color grading texture contains BGR values.
  8309. */
  8310. get colorGradingBGR(): boolean;
  8311. /**
  8312. * Sets wether the color grading texture contains BGR values.
  8313. */
  8314. set colorGradingBGR(value: boolean);
  8315. /** @hidden */
  8316. _exposure: number;
  8317. /**
  8318. * Gets the Exposure used in the effect.
  8319. */
  8320. get exposure(): number;
  8321. /**
  8322. * Sets the Exposure used in the effect.
  8323. */
  8324. set exposure(value: number);
  8325. private _toneMappingEnabled;
  8326. /**
  8327. * Gets wether the tone mapping effect is enabled.
  8328. */
  8329. get toneMappingEnabled(): boolean;
  8330. /**
  8331. * Sets wether the tone mapping effect is enabled.
  8332. */
  8333. set toneMappingEnabled(value: boolean);
  8334. private _toneMappingType;
  8335. /**
  8336. * Gets the type of tone mapping effect.
  8337. */
  8338. get toneMappingType(): number;
  8339. /**
  8340. * Sets the type of tone mapping effect used in BabylonJS.
  8341. */
  8342. set toneMappingType(value: number);
  8343. protected _contrast: number;
  8344. /**
  8345. * Gets the contrast used in the effect.
  8346. */
  8347. get contrast(): number;
  8348. /**
  8349. * Sets the contrast used in the effect.
  8350. */
  8351. set contrast(value: number);
  8352. /**
  8353. * Vignette stretch size.
  8354. */
  8355. vignetteStretch: number;
  8356. /**
  8357. * Vignette centre X Offset.
  8358. */
  8359. vignetteCentreX: number;
  8360. /**
  8361. * Vignette centre Y Offset.
  8362. */
  8363. vignetteCentreY: number;
  8364. /**
  8365. * Vignette weight or intensity of the vignette effect.
  8366. */
  8367. vignetteWeight: number;
  8368. /**
  8369. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8370. * if vignetteEnabled is set to true.
  8371. */
  8372. vignetteColor: Color4;
  8373. /**
  8374. * Camera field of view used by the Vignette effect.
  8375. */
  8376. vignetteCameraFov: number;
  8377. private _vignetteBlendMode;
  8378. /**
  8379. * Gets the vignette blend mode allowing different kind of effect.
  8380. */
  8381. get vignetteBlendMode(): number;
  8382. /**
  8383. * Sets the vignette blend mode allowing different kind of effect.
  8384. */
  8385. set vignetteBlendMode(value: number);
  8386. private _vignetteEnabled;
  8387. /**
  8388. * Gets wether the vignette effect is enabled.
  8389. */
  8390. get vignetteEnabled(): boolean;
  8391. /**
  8392. * Sets wether the vignette effect is enabled.
  8393. */
  8394. set vignetteEnabled(value: boolean);
  8395. private _applyByPostProcess;
  8396. /**
  8397. * Gets wether the image processing is applied through a post process or not.
  8398. */
  8399. get applyByPostProcess(): boolean;
  8400. /**
  8401. * Sets wether the image processing is applied through a post process or not.
  8402. */
  8403. set applyByPostProcess(value: boolean);
  8404. private _isEnabled;
  8405. /**
  8406. * Gets wether the image processing is enabled or not.
  8407. */
  8408. get isEnabled(): boolean;
  8409. /**
  8410. * Sets wether the image processing is enabled or not.
  8411. */
  8412. set isEnabled(value: boolean);
  8413. /**
  8414. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8415. */
  8416. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8417. /**
  8418. * Method called each time the image processing information changes requires to recompile the effect.
  8419. */
  8420. protected _updateParameters(): void;
  8421. /**
  8422. * Gets the current class name.
  8423. * @return "ImageProcessingConfiguration"
  8424. */
  8425. getClassName(): string;
  8426. /**
  8427. * Prepare the list of uniforms associated with the Image Processing effects.
  8428. * @param uniforms The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of samplers associated with the Image Processing effects.
  8434. * @param samplersList The list of uniforms used in the effect
  8435. * @param defines the list of defines currently in use
  8436. */
  8437. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8438. /**
  8439. * Prepare the list of defines associated to the shader.
  8440. * @param defines the list of defines to complete
  8441. * @param forPostProcess Define if we are currently in post process mode or not
  8442. */
  8443. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8444. /**
  8445. * Returns true if all the image processing information are ready.
  8446. * @returns True if ready, otherwise, false
  8447. */
  8448. isReady(): boolean;
  8449. /**
  8450. * Binds the image processing to the shader.
  8451. * @param effect The effect to bind to
  8452. * @param overrideAspectRatio Override the aspect ratio of the effect
  8453. */
  8454. bind(effect: Effect, overrideAspectRatio?: number): void;
  8455. /**
  8456. * Clones the current image processing instance.
  8457. * @return The cloned image processing
  8458. */
  8459. clone(): ImageProcessingConfiguration;
  8460. /**
  8461. * Serializes the current image processing instance to a json representation.
  8462. * @return a JSON representation
  8463. */
  8464. serialize(): any;
  8465. /**
  8466. * Parses the image processing from a json representation.
  8467. * @param source the JSON source to parse
  8468. * @return The parsed image processing
  8469. */
  8470. static Parse(source: any): ImageProcessingConfiguration;
  8471. private static _VIGNETTEMODE_MULTIPLY;
  8472. private static _VIGNETTEMODE_OPAQUE;
  8473. /**
  8474. * Used to apply the vignette as a mix with the pixel color.
  8475. */
  8476. static get VIGNETTEMODE_MULTIPLY(): number;
  8477. /**
  8478. * Used to apply the vignette as a replacement of the pixel color.
  8479. */
  8480. static get VIGNETTEMODE_OPAQUE(): number;
  8481. }
  8482. }
  8483. declare module BABYLON {
  8484. /** @hidden */
  8485. export var postprocessVertexShader: {
  8486. name: string;
  8487. shader: string;
  8488. };
  8489. }
  8490. declare module BABYLON {
  8491. interface ThinEngine {
  8492. /**
  8493. * Creates a new render target texture
  8494. * @param size defines the size of the texture
  8495. * @param options defines the options used to create the texture
  8496. * @returns a new render target texture stored in an InternalTexture
  8497. */
  8498. createRenderTargetTexture(size: number | {
  8499. width: number;
  8500. height: number;
  8501. layers?: number;
  8502. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8503. /**
  8504. * Creates a depth stencil texture.
  8505. * This is only available in WebGL 2 or with the depth texture extension available.
  8506. * @param size The size of face edge in the texture.
  8507. * @param options The options defining the texture.
  8508. * @returns The texture
  8509. */
  8510. createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. /** @hidden */
  8516. _createDepthStencilTexture(size: number | {
  8517. width: number;
  8518. height: number;
  8519. layers?: number;
  8520. }, options: DepthTextureCreationOptions): InternalTexture;
  8521. }
  8522. }
  8523. declare module BABYLON {
  8524. /**
  8525. * Defines the kind of connection point for node based material
  8526. */
  8527. export enum NodeMaterialBlockConnectionPointTypes {
  8528. /** Float */
  8529. Float = 1,
  8530. /** Int */
  8531. Int = 2,
  8532. /** Vector2 */
  8533. Vector2 = 4,
  8534. /** Vector3 */
  8535. Vector3 = 8,
  8536. /** Vector4 */
  8537. Vector4 = 16,
  8538. /** Color3 */
  8539. Color3 = 32,
  8540. /** Color4 */
  8541. Color4 = 64,
  8542. /** Matrix */
  8543. Matrix = 128,
  8544. /** Custom object */
  8545. Object = 256,
  8546. /** Detect type based on connection */
  8547. AutoDetect = 1024,
  8548. /** Output type that will be defined by input type */
  8549. BasedOnInput = 2048
  8550. }
  8551. }
  8552. declare module BABYLON {
  8553. /**
  8554. * Enum used to define the target of a block
  8555. */
  8556. export enum NodeMaterialBlockTargets {
  8557. /** Vertex shader */
  8558. Vertex = 1,
  8559. /** Fragment shader */
  8560. Fragment = 2,
  8561. /** Neutral */
  8562. Neutral = 4,
  8563. /** Vertex and Fragment */
  8564. VertexAndFragment = 3
  8565. }
  8566. }
  8567. declare module BABYLON {
  8568. /**
  8569. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8570. */
  8571. export enum NodeMaterialBlockConnectionPointMode {
  8572. /** Value is an uniform */
  8573. Uniform = 0,
  8574. /** Value is a mesh attribute */
  8575. Attribute = 1,
  8576. /** Value is a varying between vertex and fragment shaders */
  8577. Varying = 2,
  8578. /** Mode is undefined */
  8579. Undefined = 3
  8580. }
  8581. }
  8582. declare module BABYLON {
  8583. /**
  8584. * Enum used to define system values e.g. values automatically provided by the system
  8585. */
  8586. export enum NodeMaterialSystemValues {
  8587. /** World */
  8588. World = 1,
  8589. /** View */
  8590. View = 2,
  8591. /** Projection */
  8592. Projection = 3,
  8593. /** ViewProjection */
  8594. ViewProjection = 4,
  8595. /** WorldView */
  8596. WorldView = 5,
  8597. /** WorldViewProjection */
  8598. WorldViewProjection = 6,
  8599. /** CameraPosition */
  8600. CameraPosition = 7,
  8601. /** Fog Color */
  8602. FogColor = 8,
  8603. /** Delta time */
  8604. DeltaTime = 9
  8605. }
  8606. }
  8607. declare module BABYLON {
  8608. /** Defines supported spaces */
  8609. export enum Space {
  8610. /** Local (object) space */
  8611. LOCAL = 0,
  8612. /** World space */
  8613. WORLD = 1,
  8614. /** Bone space */
  8615. BONE = 2
  8616. }
  8617. /** Defines the 3 main axes */
  8618. export class Axis {
  8619. /** X axis */
  8620. static X: Vector3;
  8621. /** Y axis */
  8622. static Y: Vector3;
  8623. /** Z axis */
  8624. static Z: Vector3;
  8625. }
  8626. }
  8627. declare module BABYLON {
  8628. /**
  8629. * Represents a camera frustum
  8630. */
  8631. export class Frustum {
  8632. /**
  8633. * Gets the planes representing the frustum
  8634. * @param transform matrix to be applied to the returned planes
  8635. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8636. */
  8637. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8638. /**
  8639. * Gets the near frustum plane transformed by the transform matrix
  8640. * @param transform transformation matrix to be applied to the resulting frustum plane
  8641. * @param frustumPlane the resuling frustum plane
  8642. */
  8643. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8644. /**
  8645. * Gets the far frustum plane transformed by the transform matrix
  8646. * @param transform transformation matrix to be applied to the resulting frustum plane
  8647. * @param frustumPlane the resuling frustum plane
  8648. */
  8649. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8650. /**
  8651. * Gets the left frustum plane transformed by the transform matrix
  8652. * @param transform transformation matrix to be applied to the resulting frustum plane
  8653. * @param frustumPlane the resuling frustum plane
  8654. */
  8655. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8656. /**
  8657. * Gets the right frustum plane transformed by the transform matrix
  8658. * @param transform transformation matrix to be applied to the resulting frustum plane
  8659. * @param frustumPlane the resuling frustum plane
  8660. */
  8661. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8662. /**
  8663. * Gets the top frustum plane transformed by the transform matrix
  8664. * @param transform transformation matrix to be applied to the resulting frustum plane
  8665. * @param frustumPlane the resuling frustum plane
  8666. */
  8667. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8668. /**
  8669. * Gets the bottom frustum plane transformed by the transform matrix
  8670. * @param transform transformation matrix to be applied to the resulting frustum plane
  8671. * @param frustumPlane the resuling frustum plane
  8672. */
  8673. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8674. /**
  8675. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8676. * @param transform transformation matrix to be applied to the resulting frustum planes
  8677. * @param frustumPlanes the resuling frustum planes
  8678. */
  8679. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8680. }
  8681. }
  8682. declare module BABYLON {
  8683. /**
  8684. * Interface for the size containing width and height
  8685. */
  8686. export interface ISize {
  8687. /**
  8688. * Width
  8689. */
  8690. width: number;
  8691. /**
  8692. * Heighht
  8693. */
  8694. height: number;
  8695. }
  8696. /**
  8697. * Size containing widht and height
  8698. */
  8699. export class Size implements ISize {
  8700. /**
  8701. * Width
  8702. */
  8703. width: number;
  8704. /**
  8705. * Height
  8706. */
  8707. height: number;
  8708. /**
  8709. * Creates a Size object from the given width and height (floats).
  8710. * @param width width of the new size
  8711. * @param height height of the new size
  8712. */
  8713. constructor(width: number, height: number);
  8714. /**
  8715. * Returns a string with the Size width and height
  8716. * @returns a string with the Size width and height
  8717. */
  8718. toString(): string;
  8719. /**
  8720. * "Size"
  8721. * @returns the string "Size"
  8722. */
  8723. getClassName(): string;
  8724. /**
  8725. * Returns the Size hash code.
  8726. * @returns a hash code for a unique width and height
  8727. */
  8728. getHashCode(): number;
  8729. /**
  8730. * Updates the current size from the given one.
  8731. * @param src the given size
  8732. */
  8733. copyFrom(src: Size): void;
  8734. /**
  8735. * Updates in place the current Size from the given floats.
  8736. * @param width width of the new size
  8737. * @param height height of the new size
  8738. * @returns the updated Size.
  8739. */
  8740. copyFromFloats(width: number, height: number): Size;
  8741. /**
  8742. * Updates in place the current Size from the given floats.
  8743. * @param width width to set
  8744. * @param height height to set
  8745. * @returns the updated Size.
  8746. */
  8747. set(width: number, height: number): Size;
  8748. /**
  8749. * Multiplies the width and height by numbers
  8750. * @param w factor to multiple the width by
  8751. * @param h factor to multiple the height by
  8752. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8753. */
  8754. multiplyByFloats(w: number, h: number): Size;
  8755. /**
  8756. * Clones the size
  8757. * @returns a new Size copied from the given one.
  8758. */
  8759. clone(): Size;
  8760. /**
  8761. * True if the current Size and the given one width and height are strictly equal.
  8762. * @param other the other size to compare against
  8763. * @returns True if the current Size and the given one width and height are strictly equal.
  8764. */
  8765. equals(other: Size): boolean;
  8766. /**
  8767. * The surface of the Size : width * height (float).
  8768. */
  8769. get surface(): number;
  8770. /**
  8771. * Create a new size of zero
  8772. * @returns a new Size set to (0.0, 0.0)
  8773. */
  8774. static Zero(): Size;
  8775. /**
  8776. * Sums the width and height of two sizes
  8777. * @param otherSize size to add to this size
  8778. * @returns a new Size set as the addition result of the current Size and the given one.
  8779. */
  8780. add(otherSize: Size): Size;
  8781. /**
  8782. * Subtracts the width and height of two
  8783. * @param otherSize size to subtract to this size
  8784. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8785. */
  8786. subtract(otherSize: Size): Size;
  8787. /**
  8788. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8789. * @param start starting size to lerp between
  8790. * @param end end size to lerp between
  8791. * @param amount amount to lerp between the start and end values
  8792. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8793. */
  8794. static Lerp(start: Size, end: Size, amount: number): Size;
  8795. }
  8796. }
  8797. declare module BABYLON {
  8798. /**
  8799. * Contains position and normal vectors for a vertex
  8800. */
  8801. export class PositionNormalVertex {
  8802. /** the position of the vertex (defaut: 0,0,0) */
  8803. position: Vector3;
  8804. /** the normal of the vertex (defaut: 0,1,0) */
  8805. normal: Vector3;
  8806. /**
  8807. * Creates a PositionNormalVertex
  8808. * @param position the position of the vertex (defaut: 0,0,0)
  8809. * @param normal the normal of the vertex (defaut: 0,1,0)
  8810. */
  8811. constructor(
  8812. /** the position of the vertex (defaut: 0,0,0) */
  8813. position?: Vector3,
  8814. /** the normal of the vertex (defaut: 0,1,0) */
  8815. normal?: Vector3);
  8816. /**
  8817. * Clones the PositionNormalVertex
  8818. * @returns the cloned PositionNormalVertex
  8819. */
  8820. clone(): PositionNormalVertex;
  8821. }
  8822. /**
  8823. * Contains position, normal and uv vectors for a vertex
  8824. */
  8825. export class PositionNormalTextureVertex {
  8826. /** the position of the vertex (defaut: 0,0,0) */
  8827. position: Vector3;
  8828. /** the normal of the vertex (defaut: 0,1,0) */
  8829. normal: Vector3;
  8830. /** the uv of the vertex (default: 0,0) */
  8831. uv: Vector2;
  8832. /**
  8833. * Creates a PositionNormalTextureVertex
  8834. * @param position the position of the vertex (defaut: 0,0,0)
  8835. * @param normal the normal of the vertex (defaut: 0,1,0)
  8836. * @param uv the uv of the vertex (default: 0,0)
  8837. */
  8838. constructor(
  8839. /** the position of the vertex (defaut: 0,0,0) */
  8840. position?: Vector3,
  8841. /** the normal of the vertex (defaut: 0,1,0) */
  8842. normal?: Vector3,
  8843. /** the uv of the vertex (default: 0,0) */
  8844. uv?: Vector2);
  8845. /**
  8846. * Clones the PositionNormalTextureVertex
  8847. * @returns the cloned PositionNormalTextureVertex
  8848. */
  8849. clone(): PositionNormalTextureVertex;
  8850. }
  8851. }
  8852. declare module BABYLON {
  8853. /**
  8854. * Enum defining the type of animations supported by InputBlock
  8855. */
  8856. export enum AnimatedInputBlockTypes {
  8857. /** No animation */
  8858. None = 0,
  8859. /** Time based animation. Will only work for floats */
  8860. Time = 1
  8861. }
  8862. }
  8863. declare module BABYLON {
  8864. /**
  8865. * Interface describing all the common properties and methods a shadow light needs to implement.
  8866. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8867. * as well as binding the different shadow properties to the effects.
  8868. */
  8869. export interface IShadowLight extends Light {
  8870. /**
  8871. * The light id in the scene (used in scene.findLighById for instance)
  8872. */
  8873. id: string;
  8874. /**
  8875. * The position the shdow will be casted from.
  8876. */
  8877. position: Vector3;
  8878. /**
  8879. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8880. */
  8881. direction: Vector3;
  8882. /**
  8883. * The transformed position. Position of the light in world space taking parenting in account.
  8884. */
  8885. transformedPosition: Vector3;
  8886. /**
  8887. * The transformed direction. Direction of the light in world space taking parenting in account.
  8888. */
  8889. transformedDirection: Vector3;
  8890. /**
  8891. * The friendly name of the light in the scene.
  8892. */
  8893. name: string;
  8894. /**
  8895. * Defines the shadow projection clipping minimum z value.
  8896. */
  8897. shadowMinZ: number;
  8898. /**
  8899. * Defines the shadow projection clipping maximum z value.
  8900. */
  8901. shadowMaxZ: number;
  8902. /**
  8903. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8904. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8905. */
  8906. computeTransformedInformation(): boolean;
  8907. /**
  8908. * Gets the scene the light belongs to.
  8909. * @returns The scene
  8910. */
  8911. getScene(): Scene;
  8912. /**
  8913. * Callback defining a custom Projection Matrix Builder.
  8914. * This can be used to override the default projection matrix computation.
  8915. */
  8916. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8917. /**
  8918. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8919. * @param matrix The materix to updated with the projection information
  8920. * @param viewMatrix The transform matrix of the light
  8921. * @param renderList The list of mesh to render in the map
  8922. * @returns The current light
  8923. */
  8924. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8925. /**
  8926. * Gets the current depth scale used in ESM.
  8927. * @returns The scale
  8928. */
  8929. getDepthScale(): number;
  8930. /**
  8931. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8932. * @returns true if a cube texture needs to be use
  8933. */
  8934. needCube(): boolean;
  8935. /**
  8936. * Detects if the projection matrix requires to be recomputed this frame.
  8937. * @returns true if it requires to be recomputed otherwise, false.
  8938. */
  8939. needProjectionMatrixCompute(): boolean;
  8940. /**
  8941. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8942. */
  8943. forceProjectionMatrixCompute(): void;
  8944. /**
  8945. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8946. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8947. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8948. */
  8949. getShadowDirection(faceIndex?: number): Vector3;
  8950. /**
  8951. * Gets the minZ used for shadow according to both the scene and the light.
  8952. * @param activeCamera The camera we are returning the min for
  8953. * @returns the depth min z
  8954. */
  8955. getDepthMinZ(activeCamera: Camera): number;
  8956. /**
  8957. * Gets the maxZ used for shadow according to both the scene and the light.
  8958. * @param activeCamera The camera we are returning the max for
  8959. * @returns the depth max z
  8960. */
  8961. getDepthMaxZ(activeCamera: Camera): number;
  8962. }
  8963. /**
  8964. * Base implementation IShadowLight
  8965. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8966. */
  8967. export abstract class ShadowLight extends Light implements IShadowLight {
  8968. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8969. protected _position: Vector3;
  8970. protected _setPosition(value: Vector3): void;
  8971. /**
  8972. * Sets the position the shadow will be casted from. Also use as the light position for both
  8973. * point and spot lights.
  8974. */
  8975. get position(): Vector3;
  8976. /**
  8977. * Sets the position the shadow will be casted from. Also use as the light position for both
  8978. * point and spot lights.
  8979. */
  8980. set position(value: Vector3);
  8981. protected _direction: Vector3;
  8982. protected _setDirection(value: Vector3): void;
  8983. /**
  8984. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8985. * Also use as the light direction on spot and directional lights.
  8986. */
  8987. get direction(): Vector3;
  8988. /**
  8989. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8990. * Also use as the light direction on spot and directional lights.
  8991. */
  8992. set direction(value: Vector3);
  8993. protected _shadowMinZ: number;
  8994. /**
  8995. * Gets the shadow projection clipping minimum z value.
  8996. */
  8997. get shadowMinZ(): number;
  8998. /**
  8999. * Sets the shadow projection clipping minimum z value.
  9000. */
  9001. set shadowMinZ(value: number);
  9002. protected _shadowMaxZ: number;
  9003. /**
  9004. * Sets the shadow projection clipping maximum z value.
  9005. */
  9006. get shadowMaxZ(): number;
  9007. /**
  9008. * Gets the shadow projection clipping maximum z value.
  9009. */
  9010. set shadowMaxZ(value: number);
  9011. /**
  9012. * Callback defining a custom Projection Matrix Builder.
  9013. * This can be used to override the default projection matrix computation.
  9014. */
  9015. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9016. /**
  9017. * The transformed position. Position of the light in world space taking parenting in account.
  9018. */
  9019. transformedPosition: Vector3;
  9020. /**
  9021. * The transformed direction. Direction of the light in world space taking parenting in account.
  9022. */
  9023. transformedDirection: Vector3;
  9024. private _needProjectionMatrixCompute;
  9025. /**
  9026. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9027. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9028. */
  9029. computeTransformedInformation(): boolean;
  9030. /**
  9031. * Return the depth scale used for the shadow map.
  9032. * @returns the depth scale.
  9033. */
  9034. getDepthScale(): number;
  9035. /**
  9036. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9037. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9038. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9039. */
  9040. getShadowDirection(faceIndex?: number): Vector3;
  9041. /**
  9042. * Returns the ShadowLight absolute position in the World.
  9043. * @returns the position vector in world space
  9044. */
  9045. getAbsolutePosition(): Vector3;
  9046. /**
  9047. * Sets the ShadowLight direction toward the passed target.
  9048. * @param target The point to target in local space
  9049. * @returns the updated ShadowLight direction
  9050. */
  9051. setDirectionToTarget(target: Vector3): Vector3;
  9052. /**
  9053. * Returns the light rotation in euler definition.
  9054. * @returns the x y z rotation in local space.
  9055. */
  9056. getRotation(): Vector3;
  9057. /**
  9058. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9059. * @returns true if a cube texture needs to be use
  9060. */
  9061. needCube(): boolean;
  9062. /**
  9063. * Detects if the projection matrix requires to be recomputed this frame.
  9064. * @returns true if it requires to be recomputed otherwise, false.
  9065. */
  9066. needProjectionMatrixCompute(): boolean;
  9067. /**
  9068. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9069. */
  9070. forceProjectionMatrixCompute(): void;
  9071. /** @hidden */
  9072. _initCache(): void;
  9073. /** @hidden */
  9074. _isSynchronized(): boolean;
  9075. /**
  9076. * Computes the world matrix of the node
  9077. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9078. * @returns the world matrix
  9079. */
  9080. computeWorldMatrix(force?: boolean): Matrix;
  9081. /**
  9082. * Gets the minZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the min for
  9084. * @returns the depth min z
  9085. */
  9086. getDepthMinZ(activeCamera: Camera): number;
  9087. /**
  9088. * Gets the maxZ used for shadow according to both the scene and the light.
  9089. * @param activeCamera The camera we are returning the max for
  9090. * @returns the depth max z
  9091. */
  9092. getDepthMaxZ(activeCamera: Camera): number;
  9093. /**
  9094. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9095. * @param matrix The materix to updated with the projection information
  9096. * @param viewMatrix The transform matrix of the light
  9097. * @param renderList The list of mesh to render in the map
  9098. * @returns The current light
  9099. */
  9100. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9101. }
  9102. }
  9103. declare module BABYLON {
  9104. /** @hidden */
  9105. export var packingFunctions: {
  9106. name: string;
  9107. shader: string;
  9108. };
  9109. }
  9110. declare module BABYLON {
  9111. /** @hidden */
  9112. export var bayerDitherFunctions: {
  9113. name: string;
  9114. shader: string;
  9115. };
  9116. }
  9117. declare module BABYLON {
  9118. /** @hidden */
  9119. export var shadowMapFragmentDeclaration: {
  9120. name: string;
  9121. shader: string;
  9122. };
  9123. }
  9124. declare module BABYLON {
  9125. /** @hidden */
  9126. export var clipPlaneFragmentDeclaration: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module BABYLON {
  9132. /** @hidden */
  9133. export var clipPlaneFragment: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module BABYLON {
  9139. /** @hidden */
  9140. export var shadowMapFragment: {
  9141. name: string;
  9142. shader: string;
  9143. };
  9144. }
  9145. declare module BABYLON {
  9146. /** @hidden */
  9147. export var shadowMapPixelShader: {
  9148. name: string;
  9149. shader: string;
  9150. };
  9151. }
  9152. declare module BABYLON {
  9153. /** @hidden */
  9154. export var bonesDeclaration: {
  9155. name: string;
  9156. shader: string;
  9157. };
  9158. }
  9159. declare module BABYLON {
  9160. /** @hidden */
  9161. export var morphTargetsVertexGlobalDeclaration: {
  9162. name: string;
  9163. shader: string;
  9164. };
  9165. }
  9166. declare module BABYLON {
  9167. /** @hidden */
  9168. export var morphTargetsVertexDeclaration: {
  9169. name: string;
  9170. shader: string;
  9171. };
  9172. }
  9173. declare module BABYLON {
  9174. /** @hidden */
  9175. export var instancesDeclaration: {
  9176. name: string;
  9177. shader: string;
  9178. };
  9179. }
  9180. declare module BABYLON {
  9181. /** @hidden */
  9182. export var helperFunctions: {
  9183. name: string;
  9184. shader: string;
  9185. };
  9186. }
  9187. declare module BABYLON {
  9188. /** @hidden */
  9189. export var shadowMapVertexDeclaration: {
  9190. name: string;
  9191. shader: string;
  9192. };
  9193. }
  9194. declare module BABYLON {
  9195. /** @hidden */
  9196. export var clipPlaneVertexDeclaration: {
  9197. name: string;
  9198. shader: string;
  9199. };
  9200. }
  9201. declare module BABYLON {
  9202. /** @hidden */
  9203. export var morphTargetsVertex: {
  9204. name: string;
  9205. shader: string;
  9206. };
  9207. }
  9208. declare module BABYLON {
  9209. /** @hidden */
  9210. export var instancesVertex: {
  9211. name: string;
  9212. shader: string;
  9213. };
  9214. }
  9215. declare module BABYLON {
  9216. /** @hidden */
  9217. export var bonesVertex: {
  9218. name: string;
  9219. shader: string;
  9220. };
  9221. }
  9222. declare module BABYLON {
  9223. /** @hidden */
  9224. export var shadowMapVertexNormalBias: {
  9225. name: string;
  9226. shader: string;
  9227. };
  9228. }
  9229. declare module BABYLON {
  9230. /** @hidden */
  9231. export var shadowMapVertexMetric: {
  9232. name: string;
  9233. shader: string;
  9234. };
  9235. }
  9236. declare module BABYLON {
  9237. /** @hidden */
  9238. export var clipPlaneVertex: {
  9239. name: string;
  9240. shader: string;
  9241. };
  9242. }
  9243. declare module BABYLON {
  9244. /** @hidden */
  9245. export var shadowMapVertexShader: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module BABYLON {
  9251. /** @hidden */
  9252. export var depthBoxBlurPixelShader: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module BABYLON {
  9258. /** @hidden */
  9259. export var shadowMapFragmentSoftTransparentShadow: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module BABYLON {
  9265. /**
  9266. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9267. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9268. */
  9269. export class EffectFallbacks implements IEffectFallbacks {
  9270. private _defines;
  9271. private _currentRank;
  9272. private _maxRank;
  9273. private _mesh;
  9274. /**
  9275. * Removes the fallback from the bound mesh.
  9276. */
  9277. unBindMesh(): void;
  9278. /**
  9279. * Adds a fallback on the specified property.
  9280. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9281. * @param define The name of the define in the shader
  9282. */
  9283. addFallback(rank: number, define: string): void;
  9284. /**
  9285. * Sets the mesh to use CPU skinning when needing to fallback.
  9286. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9287. * @param mesh The mesh to use the fallbacks.
  9288. */
  9289. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9290. /**
  9291. * Checks to see if more fallbacks are still availible.
  9292. */
  9293. get hasMoreFallbacks(): boolean;
  9294. /**
  9295. * Removes the defines that should be removed when falling back.
  9296. * @param currentDefines defines the current define statements for the shader.
  9297. * @param effect defines the current effect we try to compile
  9298. * @returns The resulting defines with defines of the current rank removed.
  9299. */
  9300. reduce(currentDefines: string, effect: Effect): string;
  9301. }
  9302. }
  9303. declare module BABYLON {
  9304. /**
  9305. * Interface used to define Action
  9306. */
  9307. export interface IAction {
  9308. /**
  9309. * Trigger for the action
  9310. */
  9311. trigger: number;
  9312. /** Options of the trigger */
  9313. triggerOptions: any;
  9314. /**
  9315. * Gets the trigger parameters
  9316. * @returns the trigger parameters
  9317. */
  9318. getTriggerParameter(): any;
  9319. /**
  9320. * Internal only - executes current action event
  9321. * @hidden
  9322. */
  9323. _executeCurrent(evt?: ActionEvent): void;
  9324. /**
  9325. * Serialize placeholder for child classes
  9326. * @param parent of child
  9327. * @returns the serialized object
  9328. */
  9329. serialize(parent: any): any;
  9330. /**
  9331. * Internal only
  9332. * @hidden
  9333. */
  9334. _prepare(): void;
  9335. /**
  9336. * Internal only - manager for action
  9337. * @hidden
  9338. */
  9339. _actionManager: AbstractActionManager;
  9340. /**
  9341. * Adds action to chain of actions, may be a DoNothingAction
  9342. * @param action defines the next action to execute
  9343. * @returns The action passed in
  9344. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9345. */
  9346. then(action: IAction): IAction;
  9347. }
  9348. /**
  9349. * The action to be carried out following a trigger
  9350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9351. */
  9352. export class Action implements IAction {
  9353. /** the trigger, with or without parameters, for the action */
  9354. triggerOptions: any;
  9355. /**
  9356. * Trigger for the action
  9357. */
  9358. trigger: number;
  9359. /**
  9360. * Internal only - manager for action
  9361. * @hidden
  9362. */
  9363. _actionManager: ActionManager;
  9364. private _nextActiveAction;
  9365. private _child;
  9366. private _condition?;
  9367. private _triggerParameter;
  9368. /**
  9369. * An event triggered prior to action being executed.
  9370. */
  9371. onBeforeExecuteObservable: Observable<Action>;
  9372. /**
  9373. * Creates a new Action
  9374. * @param triggerOptions the trigger, with or without parameters, for the action
  9375. * @param condition an optional determinant of action
  9376. */
  9377. constructor(
  9378. /** the trigger, with or without parameters, for the action */
  9379. triggerOptions: any, condition?: Condition);
  9380. /**
  9381. * Internal only
  9382. * @hidden
  9383. */
  9384. _prepare(): void;
  9385. /**
  9386. * Gets the trigger parameters
  9387. * @returns the trigger parameters
  9388. */
  9389. getTriggerParameter(): any;
  9390. /**
  9391. * Internal only - executes current action event
  9392. * @hidden
  9393. */
  9394. _executeCurrent(evt?: ActionEvent): void;
  9395. /**
  9396. * Execute placeholder for child classes
  9397. * @param evt optional action event
  9398. */
  9399. execute(evt?: ActionEvent): void;
  9400. /**
  9401. * Skips to next active action
  9402. */
  9403. skipToNextActiveAction(): void;
  9404. /**
  9405. * Adds action to chain of actions, may be a DoNothingAction
  9406. * @param action defines the next action to execute
  9407. * @returns The action passed in
  9408. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9409. */
  9410. then(action: Action): Action;
  9411. /**
  9412. * Internal only
  9413. * @hidden
  9414. */
  9415. _getProperty(propertyPath: string): string;
  9416. /**
  9417. * Internal only
  9418. * @hidden
  9419. */
  9420. _getEffectiveTarget(target: any, propertyPath: string): any;
  9421. /**
  9422. * Serialize placeholder for child classes
  9423. * @param parent of child
  9424. * @returns the serialized object
  9425. */
  9426. serialize(parent: any): any;
  9427. /**
  9428. * Internal only called by serialize
  9429. * @hidden
  9430. */
  9431. protected _serialize(serializedAction: any, parent?: any): any;
  9432. /**
  9433. * Internal only
  9434. * @hidden
  9435. */
  9436. static _SerializeValueAsString: (value: any) => string;
  9437. /**
  9438. * Internal only
  9439. * @hidden
  9440. */
  9441. static _GetTargetProperty: (target: Node | Scene) => {
  9442. name: string;
  9443. targetType: string;
  9444. value: string;
  9445. };
  9446. }
  9447. }
  9448. declare module BABYLON {
  9449. /**
  9450. * A Condition applied to an Action
  9451. */
  9452. export class Condition {
  9453. /**
  9454. * Internal only - manager for action
  9455. * @hidden
  9456. */
  9457. _actionManager: ActionManager;
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _evaluationId: number;
  9463. /**
  9464. * Internal only
  9465. * @hidden
  9466. */
  9467. _currentResult: boolean;
  9468. /**
  9469. * Creates a new Condition
  9470. * @param actionManager the manager of the action the condition is applied to
  9471. */
  9472. constructor(actionManager: ActionManager);
  9473. /**
  9474. * Check if the current condition is valid
  9475. * @returns a boolean
  9476. */
  9477. isValid(): boolean;
  9478. /**
  9479. * Internal only
  9480. * @hidden
  9481. */
  9482. _getProperty(propertyPath: string): string;
  9483. /**
  9484. * Internal only
  9485. * @hidden
  9486. */
  9487. _getEffectiveTarget(target: any, propertyPath: string): any;
  9488. /**
  9489. * Serialize placeholder for child classes
  9490. * @returns the serialized object
  9491. */
  9492. serialize(): any;
  9493. /**
  9494. * Internal only
  9495. * @hidden
  9496. */
  9497. protected _serialize(serializedCondition: any): any;
  9498. }
  9499. /**
  9500. * Defines specific conditional operators as extensions of Condition
  9501. */
  9502. export class ValueCondition extends Condition {
  9503. /** path to specify the property of the target the conditional operator uses */
  9504. propertyPath: string;
  9505. /** the value compared by the conditional operator against the current value of the property */
  9506. value: any;
  9507. /** the conditional operator, default ValueCondition.IsEqual */
  9508. operator: number;
  9509. /**
  9510. * Internal only
  9511. * @hidden
  9512. */
  9513. private static _IsEqual;
  9514. /**
  9515. * Internal only
  9516. * @hidden
  9517. */
  9518. private static _IsDifferent;
  9519. /**
  9520. * Internal only
  9521. * @hidden
  9522. */
  9523. private static _IsGreater;
  9524. /**
  9525. * Internal only
  9526. * @hidden
  9527. */
  9528. private static _IsLesser;
  9529. /**
  9530. * returns the number for IsEqual
  9531. */
  9532. static get IsEqual(): number;
  9533. /**
  9534. * Returns the number for IsDifferent
  9535. */
  9536. static get IsDifferent(): number;
  9537. /**
  9538. * Returns the number for IsGreater
  9539. */
  9540. static get IsGreater(): number;
  9541. /**
  9542. * Returns the number for IsLesser
  9543. */
  9544. static get IsLesser(): number;
  9545. /**
  9546. * Internal only The action manager for the condition
  9547. * @hidden
  9548. */
  9549. _actionManager: ActionManager;
  9550. /**
  9551. * Internal only
  9552. * @hidden
  9553. */
  9554. private _target;
  9555. /**
  9556. * Internal only
  9557. * @hidden
  9558. */
  9559. private _effectiveTarget;
  9560. /**
  9561. * Internal only
  9562. * @hidden
  9563. */
  9564. private _property;
  9565. /**
  9566. * Creates a new ValueCondition
  9567. * @param actionManager manager for the action the condition applies to
  9568. * @param target for the action
  9569. * @param propertyPath path to specify the property of the target the conditional operator uses
  9570. * @param value the value compared by the conditional operator against the current value of the property
  9571. * @param operator the conditional operator, default ValueCondition.IsEqual
  9572. */
  9573. constructor(actionManager: ActionManager, target: any,
  9574. /** path to specify the property of the target the conditional operator uses */
  9575. propertyPath: string,
  9576. /** the value compared by the conditional operator against the current value of the property */
  9577. value: any,
  9578. /** the conditional operator, default ValueCondition.IsEqual */
  9579. operator?: number);
  9580. /**
  9581. * Compares the given value with the property value for the specified conditional operator
  9582. * @returns the result of the comparison
  9583. */
  9584. isValid(): boolean;
  9585. /**
  9586. * Serialize the ValueCondition into a JSON compatible object
  9587. * @returns serialization object
  9588. */
  9589. serialize(): any;
  9590. /**
  9591. * Gets the name of the conditional operator for the ValueCondition
  9592. * @param operator the conditional operator
  9593. * @returns the name
  9594. */
  9595. static GetOperatorName(operator: number): string;
  9596. }
  9597. /**
  9598. * Defines a predicate condition as an extension of Condition
  9599. */
  9600. export class PredicateCondition extends Condition {
  9601. /** defines the predicate function used to validate the condition */
  9602. predicate: () => boolean;
  9603. /**
  9604. * Internal only - manager for action
  9605. * @hidden
  9606. */
  9607. _actionManager: ActionManager;
  9608. /**
  9609. * Creates a new PredicateCondition
  9610. * @param actionManager manager for the action the condition applies to
  9611. * @param predicate defines the predicate function used to validate the condition
  9612. */
  9613. constructor(actionManager: ActionManager,
  9614. /** defines the predicate function used to validate the condition */
  9615. predicate: () => boolean);
  9616. /**
  9617. * @returns the validity of the predicate condition
  9618. */
  9619. isValid(): boolean;
  9620. }
  9621. /**
  9622. * Defines a state condition as an extension of Condition
  9623. */
  9624. export class StateCondition extends Condition {
  9625. /** Value to compare with target state */
  9626. value: string;
  9627. /**
  9628. * Internal only - manager for action
  9629. * @hidden
  9630. */
  9631. _actionManager: ActionManager;
  9632. /**
  9633. * Internal only
  9634. * @hidden
  9635. */
  9636. private _target;
  9637. /**
  9638. * Creates a new StateCondition
  9639. * @param actionManager manager for the action the condition applies to
  9640. * @param target of the condition
  9641. * @param value to compare with target state
  9642. */
  9643. constructor(actionManager: ActionManager, target: any,
  9644. /** Value to compare with target state */
  9645. value: string);
  9646. /**
  9647. * Gets a boolean indicating if the current condition is met
  9648. * @returns the validity of the state
  9649. */
  9650. isValid(): boolean;
  9651. /**
  9652. * Serialize the StateCondition into a JSON compatible object
  9653. * @returns serialization object
  9654. */
  9655. serialize(): any;
  9656. }
  9657. }
  9658. declare module BABYLON {
  9659. /**
  9660. * This defines an action responsible to toggle a boolean once triggered.
  9661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9662. */
  9663. export class SwitchBooleanAction extends Action {
  9664. /**
  9665. * The path to the boolean property in the target object
  9666. */
  9667. propertyPath: string;
  9668. private _target;
  9669. private _effectiveTarget;
  9670. private _property;
  9671. /**
  9672. * Instantiate the action
  9673. * @param triggerOptions defines the trigger options
  9674. * @param target defines the object containing the boolean
  9675. * @param propertyPath defines the path to the boolean property in the target object
  9676. * @param condition defines the trigger related conditions
  9677. */
  9678. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9679. /** @hidden */
  9680. _prepare(): void;
  9681. /**
  9682. * Execute the action toggle the boolean value.
  9683. */
  9684. execute(): void;
  9685. /**
  9686. * Serializes the actions and its related information.
  9687. * @param parent defines the object to serialize in
  9688. * @returns the serialized object
  9689. */
  9690. serialize(parent: any): any;
  9691. }
  9692. /**
  9693. * This defines an action responsible to set a the state field of the target
  9694. * to a desired value once triggered.
  9695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9696. */
  9697. export class SetStateAction extends Action {
  9698. /**
  9699. * The value to store in the state field.
  9700. */
  9701. value: string;
  9702. private _target;
  9703. /**
  9704. * Instantiate the action
  9705. * @param triggerOptions defines the trigger options
  9706. * @param target defines the object containing the state property
  9707. * @param value defines the value to store in the state field
  9708. * @param condition defines the trigger related conditions
  9709. */
  9710. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9711. /**
  9712. * Execute the action and store the value on the target state property.
  9713. */
  9714. execute(): void;
  9715. /**
  9716. * Serializes the actions and its related information.
  9717. * @param parent defines the object to serialize in
  9718. * @returns the serialized object
  9719. */
  9720. serialize(parent: any): any;
  9721. }
  9722. /**
  9723. * This defines an action responsible to set a property of the target
  9724. * to a desired value once triggered.
  9725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9726. */
  9727. export class SetValueAction extends Action {
  9728. /**
  9729. * The path of the property to set in the target.
  9730. */
  9731. propertyPath: string;
  9732. /**
  9733. * The value to set in the property
  9734. */
  9735. value: any;
  9736. private _target;
  9737. private _effectiveTarget;
  9738. private _property;
  9739. /**
  9740. * Instantiate the action
  9741. * @param triggerOptions defines the trigger options
  9742. * @param target defines the object containing the property
  9743. * @param propertyPath defines the path of the property to set in the target
  9744. * @param value defines the value to set in the property
  9745. * @param condition defines the trigger related conditions
  9746. */
  9747. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9748. /** @hidden */
  9749. _prepare(): void;
  9750. /**
  9751. * Execute the action and set the targetted property to the desired value.
  9752. */
  9753. execute(): void;
  9754. /**
  9755. * Serializes the actions and its related information.
  9756. * @param parent defines the object to serialize in
  9757. * @returns the serialized object
  9758. */
  9759. serialize(parent: any): any;
  9760. }
  9761. /**
  9762. * This defines an action responsible to increment the target value
  9763. * to a desired value once triggered.
  9764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9765. */
  9766. export class IncrementValueAction extends Action {
  9767. /**
  9768. * The path of the property to increment in the target.
  9769. */
  9770. propertyPath: string;
  9771. /**
  9772. * The value we should increment the property by.
  9773. */
  9774. value: any;
  9775. private _target;
  9776. private _effectiveTarget;
  9777. private _property;
  9778. /**
  9779. * Instantiate the action
  9780. * @param triggerOptions defines the trigger options
  9781. * @param target defines the object containing the property
  9782. * @param propertyPath defines the path of the property to increment in the target
  9783. * @param value defines the value value we should increment the property by
  9784. * @param condition defines the trigger related conditions
  9785. */
  9786. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9787. /** @hidden */
  9788. _prepare(): void;
  9789. /**
  9790. * Execute the action and increment the target of the value amount.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to start an animation once triggered.
  9802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9803. */
  9804. export class PlayAnimationAction extends Action {
  9805. /**
  9806. * Where the animation should start (animation frame)
  9807. */
  9808. from: number;
  9809. /**
  9810. * Where the animation should stop (animation frame)
  9811. */
  9812. to: number;
  9813. /**
  9814. * Define if the animation should loop or stop after the first play.
  9815. */
  9816. loop?: boolean;
  9817. private _target;
  9818. /**
  9819. * Instantiate the action
  9820. * @param triggerOptions defines the trigger options
  9821. * @param target defines the target animation or animation name
  9822. * @param from defines from where the animation should start (animation frame)
  9823. * @param end defines where the animation should stop (animation frame)
  9824. * @param loop defines if the animation should loop or stop after the first play
  9825. * @param condition defines the trigger related conditions
  9826. */
  9827. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9828. /** @hidden */
  9829. _prepare(): void;
  9830. /**
  9831. * Execute the action and play the animation.
  9832. */
  9833. execute(): void;
  9834. /**
  9835. * Serializes the actions and its related information.
  9836. * @param parent defines the object to serialize in
  9837. * @returns the serialized object
  9838. */
  9839. serialize(parent: any): any;
  9840. }
  9841. /**
  9842. * This defines an action responsible to stop an animation once triggered.
  9843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9844. */
  9845. export class StopAnimationAction extends Action {
  9846. private _target;
  9847. /**
  9848. * Instantiate the action
  9849. * @param triggerOptions defines the trigger options
  9850. * @param target defines the target animation or animation name
  9851. * @param condition defines the trigger related conditions
  9852. */
  9853. constructor(triggerOptions: any, target: any, condition?: Condition);
  9854. /** @hidden */
  9855. _prepare(): void;
  9856. /**
  9857. * Execute the action and stop the animation.
  9858. */
  9859. execute(): void;
  9860. /**
  9861. * Serializes the actions and its related information.
  9862. * @param parent defines the object to serialize in
  9863. * @returns the serialized object
  9864. */
  9865. serialize(parent: any): any;
  9866. }
  9867. /**
  9868. * This defines an action responsible that does nothing once triggered.
  9869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9870. */
  9871. export class DoNothingAction extends Action {
  9872. /**
  9873. * Instantiate the action
  9874. * @param triggerOptions defines the trigger options
  9875. * @param condition defines the trigger related conditions
  9876. */
  9877. constructor(triggerOptions?: any, condition?: Condition);
  9878. /**
  9879. * Execute the action and do nothing.
  9880. */
  9881. execute(): void;
  9882. /**
  9883. * Serializes the actions and its related information.
  9884. * @param parent defines the object to serialize in
  9885. * @returns the serialized object
  9886. */
  9887. serialize(parent: any): any;
  9888. }
  9889. /**
  9890. * This defines an action responsible to trigger several actions once triggered.
  9891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9892. */
  9893. export class CombineAction extends Action {
  9894. /**
  9895. * The list of aggregated animations to run.
  9896. */
  9897. children: Action[];
  9898. /**
  9899. * Instantiate the action
  9900. * @param triggerOptions defines the trigger options
  9901. * @param children defines the list of aggregated animations to run
  9902. * @param condition defines the trigger related conditions
  9903. */
  9904. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9905. /** @hidden */
  9906. _prepare(): void;
  9907. /**
  9908. * Execute the action and executes all the aggregated actions.
  9909. */
  9910. execute(evt: ActionEvent): void;
  9911. /**
  9912. * Serializes the actions and its related information.
  9913. * @param parent defines the object to serialize in
  9914. * @returns the serialized object
  9915. */
  9916. serialize(parent: any): any;
  9917. }
  9918. /**
  9919. * This defines an action responsible to run code (external event) once triggered.
  9920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9921. */
  9922. export class ExecuteCodeAction extends Action {
  9923. /**
  9924. * The callback function to run.
  9925. */
  9926. func: (evt: ActionEvent) => void;
  9927. /**
  9928. * Instantiate the action
  9929. * @param triggerOptions defines the trigger options
  9930. * @param func defines the callback function to run
  9931. * @param condition defines the trigger related conditions
  9932. */
  9933. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9934. /**
  9935. * Execute the action and run the attached code.
  9936. */
  9937. execute(evt: ActionEvent): void;
  9938. }
  9939. /**
  9940. * This defines an action responsible to set the parent property of the target once triggered.
  9941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9942. */
  9943. export class SetParentAction extends Action {
  9944. private _parent;
  9945. private _target;
  9946. /**
  9947. * Instantiate the action
  9948. * @param triggerOptions defines the trigger options
  9949. * @param target defines the target containing the parent property
  9950. * @param parent defines from where the animation should start (animation frame)
  9951. * @param condition defines the trigger related conditions
  9952. */
  9953. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9954. /** @hidden */
  9955. _prepare(): void;
  9956. /**
  9957. * Execute the action and set the parent property.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9971. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9973. */
  9974. export class ActionManager extends AbstractActionManager {
  9975. /**
  9976. * Nothing
  9977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9978. */
  9979. static readonly NothingTrigger: number;
  9980. /**
  9981. * On pick
  9982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9983. */
  9984. static readonly OnPickTrigger: number;
  9985. /**
  9986. * On left pick
  9987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9988. */
  9989. static readonly OnLeftPickTrigger: number;
  9990. /**
  9991. * On right pick
  9992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9993. */
  9994. static readonly OnRightPickTrigger: number;
  9995. /**
  9996. * On center pick
  9997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9998. */
  9999. static readonly OnCenterPickTrigger: number;
  10000. /**
  10001. * On pick down
  10002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10003. */
  10004. static readonly OnPickDownTrigger: number;
  10005. /**
  10006. * On double pick
  10007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10008. */
  10009. static readonly OnDoublePickTrigger: number;
  10010. /**
  10011. * On pick up
  10012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickUpTrigger: number;
  10015. /**
  10016. * On pick out.
  10017. * This trigger will only be raised if you also declared a OnPickDown
  10018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10019. */
  10020. static readonly OnPickOutTrigger: number;
  10021. /**
  10022. * On long press
  10023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10024. */
  10025. static readonly OnLongPressTrigger: number;
  10026. /**
  10027. * On pointer over
  10028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10029. */
  10030. static readonly OnPointerOverTrigger: number;
  10031. /**
  10032. * On pointer out
  10033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10034. */
  10035. static readonly OnPointerOutTrigger: number;
  10036. /**
  10037. * On every frame
  10038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10039. */
  10040. static readonly OnEveryFrameTrigger: number;
  10041. /**
  10042. * On intersection enter
  10043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10044. */
  10045. static readonly OnIntersectionEnterTrigger: number;
  10046. /**
  10047. * On intersection exit
  10048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10049. */
  10050. static readonly OnIntersectionExitTrigger: number;
  10051. /**
  10052. * On key down
  10053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10054. */
  10055. static readonly OnKeyDownTrigger: number;
  10056. /**
  10057. * On key up
  10058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10059. */
  10060. static readonly OnKeyUpTrigger: number;
  10061. private _scene;
  10062. /**
  10063. * Creates a new action manager
  10064. * @param scene defines the hosting scene
  10065. */
  10066. constructor(scene: Scene);
  10067. /**
  10068. * Releases all associated resources
  10069. */
  10070. dispose(): void;
  10071. /**
  10072. * Gets hosting scene
  10073. * @returns the hosting scene
  10074. */
  10075. getScene(): Scene;
  10076. /**
  10077. * Does this action manager handles actions of any of the given triggers
  10078. * @param triggers defines the triggers to be tested
  10079. * @return a boolean indicating whether one (or more) of the triggers is handled
  10080. */
  10081. hasSpecificTriggers(triggers: number[]): boolean;
  10082. /**
  10083. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10084. * speed.
  10085. * @param triggerA defines the trigger to be tested
  10086. * @param triggerB defines the trigger to be tested
  10087. * @return a boolean indicating whether one (or more) of the triggers is handled
  10088. */
  10089. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10090. /**
  10091. * Does this action manager handles actions of a given trigger
  10092. * @param trigger defines the trigger to be tested
  10093. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10094. * @return whether the trigger is handled
  10095. */
  10096. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10097. /**
  10098. * Does this action manager has pointer triggers
  10099. */
  10100. get hasPointerTriggers(): boolean;
  10101. /**
  10102. * Does this action manager has pick triggers
  10103. */
  10104. get hasPickTriggers(): boolean;
  10105. /**
  10106. * Registers an action to this action manager
  10107. * @param action defines the action to be registered
  10108. * @return the action amended (prepared) after registration
  10109. */
  10110. registerAction(action: IAction): Nullable<IAction>;
  10111. /**
  10112. * Unregisters an action to this action manager
  10113. * @param action defines the action to be unregistered
  10114. * @return a boolean indicating whether the action has been unregistered
  10115. */
  10116. unregisterAction(action: IAction): Boolean;
  10117. /**
  10118. * Process a specific trigger
  10119. * @param trigger defines the trigger to process
  10120. * @param evt defines the event details to be processed
  10121. */
  10122. processTrigger(trigger: number, evt?: IActionEvent): void;
  10123. /** @hidden */
  10124. _getEffectiveTarget(target: any, propertyPath: string): any;
  10125. /** @hidden */
  10126. _getProperty(propertyPath: string): string;
  10127. /**
  10128. * Serialize this manager to a JSON object
  10129. * @param name defines the property name to store this manager
  10130. * @returns a JSON representation of this manager
  10131. */
  10132. serialize(name: string): any;
  10133. /**
  10134. * Creates a new ActionManager from a JSON data
  10135. * @param parsedActions defines the JSON data to read from
  10136. * @param object defines the hosting mesh
  10137. * @param scene defines the hosting scene
  10138. */
  10139. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10140. /**
  10141. * Get a trigger name by index
  10142. * @param trigger defines the trigger index
  10143. * @returns a trigger name
  10144. */
  10145. static GetTriggerName(trigger: number): string;
  10146. }
  10147. }
  10148. declare module BABYLON {
  10149. /**
  10150. * Class used to represent a sprite
  10151. * @see http://doc.babylonjs.com/babylon101/sprites
  10152. */
  10153. export class Sprite implements IAnimatable {
  10154. /** defines the name */
  10155. name: string;
  10156. /** Gets or sets the current world position */
  10157. position: Vector3;
  10158. /** Gets or sets the main color */
  10159. color: Color4;
  10160. /** Gets or sets the width */
  10161. width: number;
  10162. /** Gets or sets the height */
  10163. height: number;
  10164. /** Gets or sets rotation angle */
  10165. angle: number;
  10166. /** Gets or sets the cell index in the sprite sheet */
  10167. cellIndex: number;
  10168. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10169. cellRef: string;
  10170. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10171. invertU: boolean;
  10172. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10173. invertV: boolean;
  10174. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10175. disposeWhenFinishedAnimating: boolean;
  10176. /** Gets the list of attached animations */
  10177. animations: Nullable<Array<Animation>>;
  10178. /** Gets or sets a boolean indicating if the sprite can be picked */
  10179. isPickable: boolean;
  10180. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10181. useAlphaForPicking: boolean;
  10182. /** @hidden */
  10183. _xOffset: number;
  10184. /** @hidden */
  10185. _yOffset: number;
  10186. /** @hidden */
  10187. _xSize: number;
  10188. /** @hidden */
  10189. _ySize: number;
  10190. /**
  10191. * Gets or sets the associated action manager
  10192. */
  10193. actionManager: Nullable<ActionManager>;
  10194. /**
  10195. * An event triggered when the control has been disposed
  10196. */
  10197. onDisposeObservable: Observable<Sprite>;
  10198. private _animationStarted;
  10199. private _loopAnimation;
  10200. private _fromIndex;
  10201. private _toIndex;
  10202. private _delay;
  10203. private _direction;
  10204. private _manager;
  10205. private _time;
  10206. private _onAnimationEnd;
  10207. /**
  10208. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10209. */
  10210. isVisible: boolean;
  10211. /**
  10212. * Gets or sets the sprite size
  10213. */
  10214. get size(): number;
  10215. set size(value: number);
  10216. /**
  10217. * Returns a boolean indicating if the animation is started
  10218. */
  10219. get animationStarted(): boolean;
  10220. /**
  10221. * Gets or sets the unique id of the sprite
  10222. */
  10223. uniqueId: number;
  10224. /**
  10225. * Gets the manager of this sprite
  10226. */
  10227. get manager(): ISpriteManager;
  10228. /**
  10229. * Creates a new Sprite
  10230. * @param name defines the name
  10231. * @param manager defines the manager
  10232. */
  10233. constructor(
  10234. /** defines the name */
  10235. name: string, manager: ISpriteManager);
  10236. /**
  10237. * Returns the string "Sprite"
  10238. * @returns "Sprite"
  10239. */
  10240. getClassName(): string;
  10241. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10242. get fromIndex(): number;
  10243. set fromIndex(value: number);
  10244. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10245. get toIndex(): number;
  10246. set toIndex(value: number);
  10247. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10248. get loopAnimation(): boolean;
  10249. set loopAnimation(value: boolean);
  10250. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10251. get delay(): number;
  10252. set delay(value: number);
  10253. /**
  10254. * Starts an animation
  10255. * @param from defines the initial key
  10256. * @param to defines the end key
  10257. * @param loop defines if the animation must loop
  10258. * @param delay defines the start delay (in ms)
  10259. * @param onAnimationEnd defines a callback to call when animation ends
  10260. */
  10261. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10262. /** Stops current animation (if any) */
  10263. stopAnimation(): void;
  10264. /** @hidden */
  10265. _animate(deltaTime: number): void;
  10266. /** Release associated resources */
  10267. dispose(): void;
  10268. /**
  10269. * Serializes the sprite to a JSON object
  10270. * @returns the JSON object
  10271. */
  10272. serialize(): any;
  10273. /**
  10274. * Parses a JSON object to create a new sprite
  10275. * @param parsedSprite The JSON object to parse
  10276. * @param manager defines the hosting manager
  10277. * @returns the new sprite
  10278. */
  10279. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10280. }
  10281. }
  10282. declare module BABYLON {
  10283. /**
  10284. * Information about the result of picking within a scene
  10285. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10286. */
  10287. export class PickingInfo {
  10288. /** @hidden */
  10289. _pickingUnavailable: boolean;
  10290. /**
  10291. * If the pick collided with an object
  10292. */
  10293. hit: boolean;
  10294. /**
  10295. * Distance away where the pick collided
  10296. */
  10297. distance: number;
  10298. /**
  10299. * The location of pick collision
  10300. */
  10301. pickedPoint: Nullable<Vector3>;
  10302. /**
  10303. * The mesh corresponding the the pick collision
  10304. */
  10305. pickedMesh: Nullable<AbstractMesh>;
  10306. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10307. bu: number;
  10308. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10309. bv: number;
  10310. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10311. faceId: number;
  10312. /** Id of the the submesh that was picked */
  10313. subMeshId: number;
  10314. /** If a sprite was picked, this will be the sprite the pick collided with */
  10315. pickedSprite: Nullable<Sprite>;
  10316. /**
  10317. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10318. */
  10319. originMesh: Nullable<AbstractMesh>;
  10320. /**
  10321. * The ray that was used to perform the picking.
  10322. */
  10323. ray: Nullable<Ray>;
  10324. /**
  10325. * Gets the normal correspodning to the face the pick collided with
  10326. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10327. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10328. * @returns The normal correspodning to the face the pick collided with
  10329. */
  10330. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10331. /**
  10332. * Gets the texture coordinates of where the pick occured
  10333. * @returns the vector containing the coordnates of the texture
  10334. */
  10335. getTextureCoordinates(): Nullable<Vector2>;
  10336. }
  10337. }
  10338. declare module BABYLON {
  10339. /**
  10340. * Class representing a ray with position and direction
  10341. */
  10342. export class Ray {
  10343. /** origin point */
  10344. origin: Vector3;
  10345. /** direction */
  10346. direction: Vector3;
  10347. /** length of the ray */
  10348. length: number;
  10349. private static readonly TmpVector3;
  10350. private _tmpRay;
  10351. /**
  10352. * Creates a new ray
  10353. * @param origin origin point
  10354. * @param direction direction
  10355. * @param length length of the ray
  10356. */
  10357. constructor(
  10358. /** origin point */
  10359. origin: Vector3,
  10360. /** direction */
  10361. direction: Vector3,
  10362. /** length of the ray */
  10363. length?: number);
  10364. /**
  10365. * Checks if the ray intersects a box
  10366. * This does not account for the ray lenght by design to improve perfs.
  10367. * @param minimum bound of the box
  10368. * @param maximum bound of the box
  10369. * @param intersectionTreshold extra extend to be added to the box in all direction
  10370. * @returns if the box was hit
  10371. */
  10372. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10373. /**
  10374. * Checks if the ray intersects a box
  10375. * This does not account for the ray lenght by design to improve perfs.
  10376. * @param box the bounding box to check
  10377. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10378. * @returns if the box was hit
  10379. */
  10380. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10381. /**
  10382. * If the ray hits a sphere
  10383. * @param sphere the bounding sphere to check
  10384. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10385. * @returns true if it hits the sphere
  10386. */
  10387. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10388. /**
  10389. * If the ray hits a triange
  10390. * @param vertex0 triangle vertex
  10391. * @param vertex1 triangle vertex
  10392. * @param vertex2 triangle vertex
  10393. * @returns intersection information if hit
  10394. */
  10395. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10396. /**
  10397. * Checks if ray intersects a plane
  10398. * @param plane the plane to check
  10399. * @returns the distance away it was hit
  10400. */
  10401. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10402. /**
  10403. * Calculate the intercept of a ray on a given axis
  10404. * @param axis to check 'x' | 'y' | 'z'
  10405. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10406. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10407. */
  10408. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10409. /**
  10410. * Checks if ray intersects a mesh
  10411. * @param mesh the mesh to check
  10412. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10413. * @returns picking info of the intersecton
  10414. */
  10415. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10416. /**
  10417. * Checks if ray intersects a mesh
  10418. * @param meshes the meshes to check
  10419. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10420. * @param results array to store result in
  10421. * @returns Array of picking infos
  10422. */
  10423. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10424. private _comparePickingInfo;
  10425. private static smallnum;
  10426. private static rayl;
  10427. /**
  10428. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10429. * @param sega the first point of the segment to test the intersection against
  10430. * @param segb the second point of the segment to test the intersection against
  10431. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10432. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10433. */
  10434. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10435. /**
  10436. * Update the ray from viewport position
  10437. * @param x position
  10438. * @param y y position
  10439. * @param viewportWidth viewport width
  10440. * @param viewportHeight viewport height
  10441. * @param world world matrix
  10442. * @param view view matrix
  10443. * @param projection projection matrix
  10444. * @returns this ray updated
  10445. */
  10446. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10447. /**
  10448. * Creates a ray with origin and direction of 0,0,0
  10449. * @returns the new ray
  10450. */
  10451. static Zero(): Ray;
  10452. /**
  10453. * Creates a new ray from screen space and viewport
  10454. * @param x position
  10455. * @param y y position
  10456. * @param viewportWidth viewport width
  10457. * @param viewportHeight viewport height
  10458. * @param world world matrix
  10459. * @param view view matrix
  10460. * @param projection projection matrix
  10461. * @returns new ray
  10462. */
  10463. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10464. /**
  10465. * 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
  10466. * transformed to the given world matrix.
  10467. * @param origin The origin point
  10468. * @param end The end point
  10469. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10470. * @returns the new ray
  10471. */
  10472. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10473. /**
  10474. * Transforms a ray by a matrix
  10475. * @param ray ray to transform
  10476. * @param matrix matrix to apply
  10477. * @returns the resulting new ray
  10478. */
  10479. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10480. /**
  10481. * Transforms a ray by a matrix
  10482. * @param ray ray to transform
  10483. * @param matrix matrix to apply
  10484. * @param result ray to store result in
  10485. */
  10486. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10487. /**
  10488. * Unproject a ray from screen space to object space
  10489. * @param sourceX defines the screen space x coordinate to use
  10490. * @param sourceY defines the screen space y coordinate to use
  10491. * @param viewportWidth defines the current width of the viewport
  10492. * @param viewportHeight defines the current height of the viewport
  10493. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10494. * @param view defines the view matrix to use
  10495. * @param projection defines the projection matrix to use
  10496. */
  10497. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10498. }
  10499. /**
  10500. * Type used to define predicate used to select faces when a mesh intersection is detected
  10501. */
  10502. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10503. interface Scene {
  10504. /** @hidden */
  10505. _tempPickingRay: Nullable<Ray>;
  10506. /** @hidden */
  10507. _cachedRayForTransform: Ray;
  10508. /** @hidden */
  10509. _pickWithRayInverseMatrix: Matrix;
  10510. /** @hidden */
  10511. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10512. /** @hidden */
  10513. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10514. }
  10515. }
  10516. declare module BABYLON {
  10517. /**
  10518. * Groups all the scene component constants in one place to ease maintenance.
  10519. * @hidden
  10520. */
  10521. export class SceneComponentConstants {
  10522. static readonly NAME_EFFECTLAYER: string;
  10523. static readonly NAME_LAYER: string;
  10524. static readonly NAME_LENSFLARESYSTEM: string;
  10525. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10526. static readonly NAME_PARTICLESYSTEM: string;
  10527. static readonly NAME_GAMEPAD: string;
  10528. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10529. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10530. static readonly NAME_DEPTHRENDERER: string;
  10531. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10532. static readonly NAME_SPRITE: string;
  10533. static readonly NAME_OUTLINERENDERER: string;
  10534. static readonly NAME_PROCEDURALTEXTURE: string;
  10535. static readonly NAME_SHADOWGENERATOR: string;
  10536. static readonly NAME_OCTREE: string;
  10537. static readonly NAME_PHYSICSENGINE: string;
  10538. static readonly NAME_AUDIO: string;
  10539. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10540. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10541. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10542. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10543. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10544. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10545. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10546. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10547. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10548. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10549. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10550. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10551. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10552. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10553. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10554. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10555. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10556. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10557. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10558. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10559. static readonly STEP_AFTERRENDER_AUDIO: number;
  10560. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10561. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10562. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10563. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10564. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10565. static readonly STEP_POINTERMOVE_SPRITE: number;
  10566. static readonly STEP_POINTERDOWN_SPRITE: number;
  10567. static readonly STEP_POINTERUP_SPRITE: number;
  10568. }
  10569. /**
  10570. * This represents a scene component.
  10571. *
  10572. * This is used to decouple the dependency the scene is having on the different workloads like
  10573. * layers, post processes...
  10574. */
  10575. export interface ISceneComponent {
  10576. /**
  10577. * The name of the component. Each component must have a unique name.
  10578. */
  10579. name: string;
  10580. /**
  10581. * The scene the component belongs to.
  10582. */
  10583. scene: Scene;
  10584. /**
  10585. * Register the component to one instance of a scene.
  10586. */
  10587. register(): void;
  10588. /**
  10589. * Rebuilds the elements related to this component in case of
  10590. * context lost for instance.
  10591. */
  10592. rebuild(): void;
  10593. /**
  10594. * Disposes the component and the associated ressources.
  10595. */
  10596. dispose(): void;
  10597. }
  10598. /**
  10599. * This represents a SERIALIZABLE scene component.
  10600. *
  10601. * This extends Scene Component to add Serialization methods on top.
  10602. */
  10603. export interface ISceneSerializableComponent extends ISceneComponent {
  10604. /**
  10605. * Adds all the elements from the container to the scene
  10606. * @param container the container holding the elements
  10607. */
  10608. addFromContainer(container: AbstractScene): void;
  10609. /**
  10610. * Removes all the elements in the container from the scene
  10611. * @param container contains the elements to remove
  10612. * @param dispose if the removed element should be disposed (default: false)
  10613. */
  10614. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10615. /**
  10616. * Serializes the component data to the specified json object
  10617. * @param serializationObject The object to serialize to
  10618. */
  10619. serialize(serializationObject: any): void;
  10620. }
  10621. /**
  10622. * Strong typing of a Mesh related stage step action
  10623. */
  10624. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10625. /**
  10626. * Strong typing of a Evaluate Sub Mesh related stage step action
  10627. */
  10628. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10629. /**
  10630. * Strong typing of a Active Mesh related stage step action
  10631. */
  10632. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10633. /**
  10634. * Strong typing of a Camera related stage step action
  10635. */
  10636. export type CameraStageAction = (camera: Camera) => void;
  10637. /**
  10638. * Strong typing of a Camera Frame buffer related stage step action
  10639. */
  10640. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10641. /**
  10642. * Strong typing of a Render Target related stage step action
  10643. */
  10644. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10645. /**
  10646. * Strong typing of a RenderingGroup related stage step action
  10647. */
  10648. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10649. /**
  10650. * Strong typing of a Mesh Render related stage step action
  10651. */
  10652. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10653. /**
  10654. * Strong typing of a simple stage step action
  10655. */
  10656. export type SimpleStageAction = () => void;
  10657. /**
  10658. * Strong typing of a render target action.
  10659. */
  10660. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10661. /**
  10662. * Strong typing of a pointer move action.
  10663. */
  10664. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10665. /**
  10666. * Strong typing of a pointer up/down action.
  10667. */
  10668. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10669. /**
  10670. * Representation of a stage in the scene (Basically a list of ordered steps)
  10671. * @hidden
  10672. */
  10673. export class Stage<T extends Function> extends Array<{
  10674. index: number;
  10675. component: ISceneComponent;
  10676. action: T;
  10677. }> {
  10678. /**
  10679. * Hide ctor from the rest of the world.
  10680. * @param items The items to add.
  10681. */
  10682. private constructor();
  10683. /**
  10684. * Creates a new Stage.
  10685. * @returns A new instance of a Stage
  10686. */
  10687. static Create<T extends Function>(): Stage<T>;
  10688. /**
  10689. * Registers a step in an ordered way in the targeted stage.
  10690. * @param index Defines the position to register the step in
  10691. * @param component Defines the component attached to the step
  10692. * @param action Defines the action to launch during the step
  10693. */
  10694. registerStep(index: number, component: ISceneComponent, action: T): void;
  10695. /**
  10696. * Clears all the steps from the stage.
  10697. */
  10698. clear(): void;
  10699. }
  10700. }
  10701. declare module BABYLON {
  10702. interface Scene {
  10703. /** @hidden */
  10704. _pointerOverSprite: Nullable<Sprite>;
  10705. /** @hidden */
  10706. _pickedDownSprite: Nullable<Sprite>;
  10707. /** @hidden */
  10708. _tempSpritePickingRay: Nullable<Ray>;
  10709. /**
  10710. * All of the sprite managers added to this scene
  10711. * @see http://doc.babylonjs.com/babylon101/sprites
  10712. */
  10713. spriteManagers: Array<ISpriteManager>;
  10714. /**
  10715. * An event triggered when sprites rendering is about to start
  10716. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10717. */
  10718. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10719. /**
  10720. * An event triggered when sprites rendering is done
  10721. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10722. */
  10723. onAfterSpritesRenderingObservable: Observable<Scene>;
  10724. /** @hidden */
  10725. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10726. /** Launch a ray to try to pick a sprite in the scene
  10727. * @param x position on screen
  10728. * @param y position on screen
  10729. * @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
  10730. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10731. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10732. * @returns a PickingInfo
  10733. */
  10734. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10735. /** Use the given ray to pick a sprite in the scene
  10736. * @param ray The ray (in world space) to use to pick meshes
  10737. * @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
  10738. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10739. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10740. * @returns a PickingInfo
  10741. */
  10742. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10743. /** @hidden */
  10744. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10745. /** Launch a ray to try to pick sprites in the scene
  10746. * @param x position on screen
  10747. * @param y position on screen
  10748. * @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
  10749. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10750. * @returns a PickingInfo array
  10751. */
  10752. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10753. /** Use the given ray to pick sprites in the scene
  10754. * @param ray The ray (in world space) to use to pick meshes
  10755. * @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
  10756. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10757. * @returns a PickingInfo array
  10758. */
  10759. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10760. /**
  10761. * Force the sprite under the pointer
  10762. * @param sprite defines the sprite to use
  10763. */
  10764. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10765. /**
  10766. * Gets the sprite under the pointer
  10767. * @returns a Sprite or null if no sprite is under the pointer
  10768. */
  10769. getPointerOverSprite(): Nullable<Sprite>;
  10770. }
  10771. /**
  10772. * Defines the sprite scene component responsible to manage sprites
  10773. * in a given scene.
  10774. */
  10775. export class SpriteSceneComponent implements ISceneComponent {
  10776. /**
  10777. * The component name helpfull to identify the component in the list of scene components.
  10778. */
  10779. readonly name: string;
  10780. /**
  10781. * The scene the component belongs to.
  10782. */
  10783. scene: Scene;
  10784. /** @hidden */
  10785. private _spritePredicate;
  10786. /**
  10787. * Creates a new instance of the component for the given scene
  10788. * @param scene Defines the scene to register the component in
  10789. */
  10790. constructor(scene: Scene);
  10791. /**
  10792. * Registers the component in a given scene
  10793. */
  10794. register(): void;
  10795. /**
  10796. * Rebuilds the elements related to this component in case of
  10797. * context lost for instance.
  10798. */
  10799. rebuild(): void;
  10800. /**
  10801. * Disposes the component and the associated ressources.
  10802. */
  10803. dispose(): void;
  10804. private _pickSpriteButKeepRay;
  10805. private _pointerMove;
  10806. private _pointerDown;
  10807. private _pointerUp;
  10808. }
  10809. }
  10810. declare module BABYLON {
  10811. /** @hidden */
  10812. export var fogFragmentDeclaration: {
  10813. name: string;
  10814. shader: string;
  10815. };
  10816. }
  10817. declare module BABYLON {
  10818. /** @hidden */
  10819. export var fogFragment: {
  10820. name: string;
  10821. shader: string;
  10822. };
  10823. }
  10824. declare module BABYLON {
  10825. /** @hidden */
  10826. export var spritesPixelShader: {
  10827. name: string;
  10828. shader: string;
  10829. };
  10830. }
  10831. declare module BABYLON {
  10832. /** @hidden */
  10833. export var fogVertexDeclaration: {
  10834. name: string;
  10835. shader: string;
  10836. };
  10837. }
  10838. declare module BABYLON {
  10839. /** @hidden */
  10840. export var spritesVertexShader: {
  10841. name: string;
  10842. shader: string;
  10843. };
  10844. }
  10845. declare module BABYLON {
  10846. /**
  10847. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10848. */
  10849. export interface ISpriteManager extends IDisposable {
  10850. /**
  10851. * Gets manager's name
  10852. */
  10853. name: string;
  10854. /**
  10855. * Restricts the camera to viewing objects with the same layerMask.
  10856. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10857. */
  10858. layerMask: number;
  10859. /**
  10860. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10861. */
  10862. isPickable: boolean;
  10863. /**
  10864. * Gets the hosting scene
  10865. */
  10866. scene: Scene;
  10867. /**
  10868. * Specifies the rendering group id for this mesh (0 by default)
  10869. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10870. */
  10871. renderingGroupId: number;
  10872. /**
  10873. * Defines the list of sprites managed by the manager.
  10874. */
  10875. sprites: Array<Sprite>;
  10876. /**
  10877. * Gets or sets the spritesheet texture
  10878. */
  10879. texture: Texture;
  10880. /** Defines the default width of a cell in the spritesheet */
  10881. cellWidth: number;
  10882. /** Defines the default height of a cell in the spritesheet */
  10883. cellHeight: number;
  10884. /**
  10885. * Tests the intersection of a sprite with a specific ray.
  10886. * @param ray The ray we are sending to test the collision
  10887. * @param camera The camera space we are sending rays in
  10888. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10889. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10890. * @returns picking info or null.
  10891. */
  10892. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10893. /**
  10894. * Intersects the sprites with a ray
  10895. * @param ray defines the ray to intersect with
  10896. * @param camera defines the current active camera
  10897. * @param predicate defines a predicate used to select candidate sprites
  10898. * @returns null if no hit or a PickingInfo array
  10899. */
  10900. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10901. /**
  10902. * Renders the list of sprites on screen.
  10903. */
  10904. render(): void;
  10905. }
  10906. /**
  10907. * Class used to manage multiple sprites on the same spritesheet
  10908. * @see http://doc.babylonjs.com/babylon101/sprites
  10909. */
  10910. export class SpriteManager implements ISpriteManager {
  10911. /** defines the manager's name */
  10912. name: string;
  10913. /** Define the Url to load snippets */
  10914. static SnippetUrl: string;
  10915. /** Snippet ID if the manager was created from the snippet server */
  10916. snippetId: string;
  10917. /** Gets the list of sprites */
  10918. sprites: Sprite[];
  10919. /** Gets or sets the rendering group id (0 by default) */
  10920. renderingGroupId: number;
  10921. /** Gets or sets camera layer mask */
  10922. layerMask: number;
  10923. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10924. fogEnabled: boolean;
  10925. /** Gets or sets a boolean indicating if the sprites are pickable */
  10926. isPickable: boolean;
  10927. /** Defines the default width of a cell in the spritesheet */
  10928. cellWidth: number;
  10929. /** Defines the default height of a cell in the spritesheet */
  10930. cellHeight: number;
  10931. /** Associative array from JSON sprite data file */
  10932. private _cellData;
  10933. /** Array of sprite names from JSON sprite data file */
  10934. private _spriteMap;
  10935. /** True when packed cell data from JSON file is ready*/
  10936. private _packedAndReady;
  10937. private _textureContent;
  10938. /**
  10939. * An event triggered when the manager is disposed.
  10940. */
  10941. onDisposeObservable: Observable<SpriteManager>;
  10942. private _onDisposeObserver;
  10943. /**
  10944. * Callback called when the manager is disposed
  10945. */
  10946. set onDispose(callback: () => void);
  10947. private _capacity;
  10948. private _fromPacked;
  10949. private _spriteTexture;
  10950. private _epsilon;
  10951. private _scene;
  10952. private _vertexData;
  10953. private _buffer;
  10954. private _vertexBuffers;
  10955. private _indexBuffer;
  10956. private _effectBase;
  10957. private _effectFog;
  10958. /**
  10959. * Gets or sets the unique id of the sprite
  10960. */
  10961. uniqueId: number;
  10962. /**
  10963. * Gets the array of sprites
  10964. */
  10965. get children(): Sprite[];
  10966. /**
  10967. * Gets the hosting scene
  10968. */
  10969. get scene(): Scene;
  10970. /**
  10971. * Gets the capacity of the manager
  10972. */
  10973. get capacity(): number;
  10974. /**
  10975. * Gets or sets the spritesheet texture
  10976. */
  10977. get texture(): Texture;
  10978. set texture(value: Texture);
  10979. private _blendMode;
  10980. /**
  10981. * Blend mode use to render the particle, it can be any of
  10982. * the static Constants.ALPHA_x properties provided in this class.
  10983. * Default value is Constants.ALPHA_COMBINE
  10984. */
  10985. get blendMode(): number;
  10986. set blendMode(blendMode: number);
  10987. /** Disables writing to the depth buffer when rendering the sprites.
  10988. * It can be handy to disable depth writing when using textures without alpha channel
  10989. * and setting some specific blend modes.
  10990. */
  10991. disableDepthWrite: boolean;
  10992. /**
  10993. * Creates a new sprite manager
  10994. * @param name defines the manager's name
  10995. * @param imgUrl defines the sprite sheet url
  10996. * @param capacity defines the maximum allowed number of sprites
  10997. * @param cellSize defines the size of a sprite cell
  10998. * @param scene defines the hosting scene
  10999. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11000. * @param samplingMode defines the smapling mode to use with spritesheet
  11001. * @param fromPacked set to false; do not alter
  11002. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11003. */
  11004. constructor(
  11005. /** defines the manager's name */
  11006. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11007. /**
  11008. * Returns the string "SpriteManager"
  11009. * @returns "SpriteManager"
  11010. */
  11011. getClassName(): string;
  11012. private _makePacked;
  11013. private _appendSpriteVertex;
  11014. private _checkTextureAlpha;
  11015. /**
  11016. * Intersects the sprites with a ray
  11017. * @param ray defines the ray to intersect with
  11018. * @param camera defines the current active camera
  11019. * @param predicate defines a predicate used to select candidate sprites
  11020. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11021. * @returns null if no hit or a PickingInfo
  11022. */
  11023. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11024. /**
  11025. * Intersects the sprites with a ray
  11026. * @param ray defines the ray to intersect with
  11027. * @param camera defines the current active camera
  11028. * @param predicate defines a predicate used to select candidate sprites
  11029. * @returns null if no hit or a PickingInfo array
  11030. */
  11031. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11032. /**
  11033. * Render all child sprites
  11034. */
  11035. render(): void;
  11036. /**
  11037. * Release associated resources
  11038. */
  11039. dispose(): void;
  11040. /**
  11041. * Serializes the sprite manager to a JSON object
  11042. * @param serializeTexture defines if the texture must be serialized as well
  11043. * @returns the JSON object
  11044. */
  11045. serialize(serializeTexture?: boolean): any;
  11046. /**
  11047. * Parses a JSON object to create a new sprite manager.
  11048. * @param parsedManager The JSON object to parse
  11049. * @param scene The scene to create the sprite managerin
  11050. * @param rootUrl The root url to use to load external dependencies like texture
  11051. * @returns the new sprite manager
  11052. */
  11053. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11054. /**
  11055. * Creates a sprite manager from a snippet saved by the sprite editor
  11056. * @param snippetId defines the snippet to load
  11057. * @param scene defines the hosting scene
  11058. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11059. * @returns a promise that will resolve to the new sprite manager
  11060. */
  11061. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11062. }
  11063. }
  11064. declare module BABYLON {
  11065. /** Interface used by value gradients (color, factor, ...) */
  11066. export interface IValueGradient {
  11067. /**
  11068. * Gets or sets the gradient value (between 0 and 1)
  11069. */
  11070. gradient: number;
  11071. }
  11072. /** Class used to store color4 gradient */
  11073. export class ColorGradient implements IValueGradient {
  11074. /**
  11075. * Gets or sets the gradient value (between 0 and 1)
  11076. */
  11077. gradient: number;
  11078. /**
  11079. * Gets or sets first associated color
  11080. */
  11081. color1: Color4;
  11082. /**
  11083. * Gets or sets second associated color
  11084. */
  11085. color2?: Color4 | undefined;
  11086. /**
  11087. * Creates a new color4 gradient
  11088. * @param gradient gets or sets the gradient value (between 0 and 1)
  11089. * @param color1 gets or sets first associated color
  11090. * @param color2 gets or sets first second color
  11091. */
  11092. constructor(
  11093. /**
  11094. * Gets or sets the gradient value (between 0 and 1)
  11095. */
  11096. gradient: number,
  11097. /**
  11098. * Gets or sets first associated color
  11099. */
  11100. color1: Color4,
  11101. /**
  11102. * Gets or sets second associated color
  11103. */
  11104. color2?: Color4 | undefined);
  11105. /**
  11106. * Will get a color picked randomly between color1 and color2.
  11107. * If color2 is undefined then color1 will be used
  11108. * @param result defines the target Color4 to store the result in
  11109. */
  11110. getColorToRef(result: Color4): void;
  11111. }
  11112. /** Class used to store color 3 gradient */
  11113. export class Color3Gradient implements IValueGradient {
  11114. /**
  11115. * Gets or sets the gradient value (between 0 and 1)
  11116. */
  11117. gradient: number;
  11118. /**
  11119. * Gets or sets the associated color
  11120. */
  11121. color: Color3;
  11122. /**
  11123. * Creates a new color3 gradient
  11124. * @param gradient gets or sets the gradient value (between 0 and 1)
  11125. * @param color gets or sets associated color
  11126. */
  11127. constructor(
  11128. /**
  11129. * Gets or sets the gradient value (between 0 and 1)
  11130. */
  11131. gradient: number,
  11132. /**
  11133. * Gets or sets the associated color
  11134. */
  11135. color: Color3);
  11136. }
  11137. /** Class used to store factor gradient */
  11138. export class FactorGradient implements IValueGradient {
  11139. /**
  11140. * Gets or sets the gradient value (between 0 and 1)
  11141. */
  11142. gradient: number;
  11143. /**
  11144. * Gets or sets first associated factor
  11145. */
  11146. factor1: number;
  11147. /**
  11148. * Gets or sets second associated factor
  11149. */
  11150. factor2?: number | undefined;
  11151. /**
  11152. * Creates a new factor gradient
  11153. * @param gradient gets or sets the gradient value (between 0 and 1)
  11154. * @param factor1 gets or sets first associated factor
  11155. * @param factor2 gets or sets second associated factor
  11156. */
  11157. constructor(
  11158. /**
  11159. * Gets or sets the gradient value (between 0 and 1)
  11160. */
  11161. gradient: number,
  11162. /**
  11163. * Gets or sets first associated factor
  11164. */
  11165. factor1: number,
  11166. /**
  11167. * Gets or sets second associated factor
  11168. */
  11169. factor2?: number | undefined);
  11170. /**
  11171. * Will get a number picked randomly between factor1 and factor2.
  11172. * If factor2 is undefined then factor1 will be used
  11173. * @returns the picked number
  11174. */
  11175. getFactor(): number;
  11176. }
  11177. /**
  11178. * Helper used to simplify some generic gradient tasks
  11179. */
  11180. export class GradientHelper {
  11181. /**
  11182. * Gets the current gradient from an array of IValueGradient
  11183. * @param ratio defines the current ratio to get
  11184. * @param gradients defines the array of IValueGradient
  11185. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11186. */
  11187. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11188. }
  11189. }
  11190. declare module BABYLON {
  11191. interface ThinEngine {
  11192. /**
  11193. * Creates a dynamic texture
  11194. * @param width defines the width of the texture
  11195. * @param height defines the height of the texture
  11196. * @param generateMipMaps defines if the engine should generate the mip levels
  11197. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11198. * @returns the dynamic texture inside an InternalTexture
  11199. */
  11200. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11201. /**
  11202. * Update the content of a dynamic texture
  11203. * @param texture defines the texture to update
  11204. * @param canvas defines the canvas containing the source
  11205. * @param invertY defines if data must be stored with Y axis inverted
  11206. * @param premulAlpha defines if alpha is stored as premultiplied
  11207. * @param format defines the format of the data
  11208. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11209. */
  11210. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11211. }
  11212. }
  11213. declare module BABYLON {
  11214. /**
  11215. * Helper class used to generate a canvas to manipulate images
  11216. */
  11217. export class CanvasGenerator {
  11218. /**
  11219. * Create a new canvas (or offscreen canvas depending on the context)
  11220. * @param width defines the expected width
  11221. * @param height defines the expected height
  11222. * @return a new canvas or offscreen canvas
  11223. */
  11224. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11225. }
  11226. }
  11227. declare module BABYLON {
  11228. /**
  11229. * A class extending Texture allowing drawing on a texture
  11230. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11231. */
  11232. export class DynamicTexture extends Texture {
  11233. private _generateMipMaps;
  11234. private _canvas;
  11235. private _context;
  11236. /**
  11237. * Creates a DynamicTexture
  11238. * @param name defines the name of the texture
  11239. * @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
  11240. * @param scene defines the scene where you want the texture
  11241. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11242. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11243. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11244. */
  11245. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11246. /**
  11247. * Get the current class name of the texture useful for serialization or dynamic coding.
  11248. * @returns "DynamicTexture"
  11249. */
  11250. getClassName(): string;
  11251. /**
  11252. * Gets the current state of canRescale
  11253. */
  11254. get canRescale(): boolean;
  11255. private _recreate;
  11256. /**
  11257. * Scales the texture
  11258. * @param ratio the scale factor to apply to both width and height
  11259. */
  11260. scale(ratio: number): void;
  11261. /**
  11262. * Resizes the texture
  11263. * @param width the new width
  11264. * @param height the new height
  11265. */
  11266. scaleTo(width: number, height: number): void;
  11267. /**
  11268. * Gets the context of the canvas used by the texture
  11269. * @returns the canvas context of the dynamic texture
  11270. */
  11271. getContext(): CanvasRenderingContext2D;
  11272. /**
  11273. * Clears the texture
  11274. */
  11275. clear(): void;
  11276. /**
  11277. * Updates the texture
  11278. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11279. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11280. */
  11281. update(invertY?: boolean, premulAlpha?: boolean): void;
  11282. /**
  11283. * Draws text onto the texture
  11284. * @param text defines the text to be drawn
  11285. * @param x defines the placement of the text from the left
  11286. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11287. * @param font defines the font to be used with font-style, font-size, font-name
  11288. * @param color defines the color used for the text
  11289. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11290. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11291. * @param update defines whether texture is immediately update (default is true)
  11292. */
  11293. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11294. /**
  11295. * Clones the texture
  11296. * @returns the clone of the texture.
  11297. */
  11298. clone(): DynamicTexture;
  11299. /**
  11300. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11301. * @returns a serialized dynamic texture object
  11302. */
  11303. serialize(): any;
  11304. /** @hidden */
  11305. _rebuild(): void;
  11306. }
  11307. }
  11308. declare module BABYLON {
  11309. interface ThinEngine {
  11310. /**
  11311. * Creates a raw texture
  11312. * @param data defines the data to store in the texture
  11313. * @param width defines the width of the texture
  11314. * @param height defines the height of the texture
  11315. * @param format defines the format of the data
  11316. * @param generateMipMaps defines if the engine should generate the mip levels
  11317. * @param invertY defines if data must be stored with Y axis inverted
  11318. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11319. * @param compression defines the compression used (null by default)
  11320. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11321. * @returns the raw texture inside an InternalTexture
  11322. */
  11323. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11324. /**
  11325. * Update a raw texture
  11326. * @param texture defines the texture to update
  11327. * @param data defines the data to store in the texture
  11328. * @param format defines the format of the data
  11329. * @param invertY defines if data must be stored with Y axis inverted
  11330. */
  11331. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11332. /**
  11333. * Update a raw texture
  11334. * @param texture defines the texture to update
  11335. * @param data defines the data to store in the texture
  11336. * @param format defines the format of the data
  11337. * @param invertY defines if data must be stored with Y axis inverted
  11338. * @param compression defines the compression used (null by default)
  11339. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11340. */
  11341. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11342. /**
  11343. * Creates a new raw cube texture
  11344. * @param data defines the array of data to use to create each face
  11345. * @param size defines the size of the textures
  11346. * @param format defines the format of the data
  11347. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11348. * @param generateMipMaps defines if the engine should generate the mip levels
  11349. * @param invertY defines if data must be stored with Y axis inverted
  11350. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11351. * @param compression defines the compression used (null by default)
  11352. * @returns the cube texture as an InternalTexture
  11353. */
  11354. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11355. /**
  11356. * Update a raw cube texture
  11357. * @param texture defines the texture to udpdate
  11358. * @param data defines the data to store
  11359. * @param format defines the data format
  11360. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11361. * @param invertY defines if data must be stored with Y axis inverted
  11362. */
  11363. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11364. /**
  11365. * Update a raw cube texture
  11366. * @param texture defines the texture to udpdate
  11367. * @param data defines the data to store
  11368. * @param format defines the data format
  11369. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11370. * @param invertY defines if data must be stored with Y axis inverted
  11371. * @param compression defines the compression used (null by default)
  11372. */
  11373. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11374. /**
  11375. * Update a raw cube texture
  11376. * @param texture defines the texture to udpdate
  11377. * @param data defines the data to store
  11378. * @param format defines the data format
  11379. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11380. * @param invertY defines if data must be stored with Y axis inverted
  11381. * @param compression defines the compression used (null by default)
  11382. * @param level defines which level of the texture to update
  11383. */
  11384. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11385. /**
  11386. * Creates a new raw cube texture from a specified url
  11387. * @param url defines the url where the data is located
  11388. * @param scene defines the current scene
  11389. * @param size defines the size of the textures
  11390. * @param format defines the format of the data
  11391. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11392. * @param noMipmap defines if the engine should avoid generating the mip levels
  11393. * @param callback defines a callback used to extract texture data from loaded data
  11394. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11395. * @param onLoad defines a callback called when texture is loaded
  11396. * @param onError defines a callback called if there is an error
  11397. * @returns the cube texture as an InternalTexture
  11398. */
  11399. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  11400. /**
  11401. * Creates a new raw cube texture from a specified url
  11402. * @param url defines the url where the data is located
  11403. * @param scene defines the current scene
  11404. * @param size defines the size of the textures
  11405. * @param format defines the format of the data
  11406. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11407. * @param noMipmap defines if the engine should avoid generating the mip levels
  11408. * @param callback defines a callback used to extract texture data from loaded data
  11409. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11410. * @param onLoad defines a callback called when texture is loaded
  11411. * @param onError defines a callback called if there is an error
  11412. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11413. * @param invertY defines if data must be stored with Y axis inverted
  11414. * @returns the cube texture as an InternalTexture
  11415. */
  11416. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  11417. /**
  11418. * Creates a new raw 3D texture
  11419. * @param data defines the data used to create the texture
  11420. * @param width defines the width of the texture
  11421. * @param height defines the height of the texture
  11422. * @param depth defines the depth of the texture
  11423. * @param format defines the format of the texture
  11424. * @param generateMipMaps defines if the engine must generate mip levels
  11425. * @param invertY defines if data must be stored with Y axis inverted
  11426. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11427. * @param compression defines the compressed used (can be null)
  11428. * @param textureType defines the compressed used (can be null)
  11429. * @returns a new raw 3D texture (stored in an InternalTexture)
  11430. */
  11431. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11432. /**
  11433. * Update a raw 3D texture
  11434. * @param texture defines the texture to update
  11435. * @param data defines the data to store
  11436. * @param format defines the data format
  11437. * @param invertY defines if data must be stored with Y axis inverted
  11438. */
  11439. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11440. /**
  11441. * Update a raw 3D texture
  11442. * @param texture defines the texture to update
  11443. * @param data defines the data to store
  11444. * @param format defines the data format
  11445. * @param invertY defines if data must be stored with Y axis inverted
  11446. * @param compression defines the used compression (can be null)
  11447. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11448. */
  11449. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11450. /**
  11451. * Creates a new raw 2D array texture
  11452. * @param data defines the data used to create the texture
  11453. * @param width defines the width of the texture
  11454. * @param height defines the height of the texture
  11455. * @param depth defines the number of layers of the texture
  11456. * @param format defines the format of the texture
  11457. * @param generateMipMaps defines if the engine must generate mip levels
  11458. * @param invertY defines if data must be stored with Y axis inverted
  11459. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11460. * @param compression defines the compressed used (can be null)
  11461. * @param textureType defines the compressed used (can be null)
  11462. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11463. */
  11464. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11465. /**
  11466. * Update a raw 2D array texture
  11467. * @param texture defines the texture to update
  11468. * @param data defines the data to store
  11469. * @param format defines the data format
  11470. * @param invertY defines if data must be stored with Y axis inverted
  11471. */
  11472. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11473. /**
  11474. * Update a raw 2D array texture
  11475. * @param texture defines the texture to update
  11476. * @param data defines the data to store
  11477. * @param format defines the data format
  11478. * @param invertY defines if data must be stored with Y axis inverted
  11479. * @param compression defines the used compression (can be null)
  11480. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11481. */
  11482. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11483. }
  11484. }
  11485. declare module BABYLON {
  11486. /**
  11487. * Raw texture can help creating a texture directly from an array of data.
  11488. * This can be super useful if you either get the data from an uncompressed source or
  11489. * if you wish to create your texture pixel by pixel.
  11490. */
  11491. export class RawTexture extends Texture {
  11492. /**
  11493. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11494. */
  11495. format: number;
  11496. /**
  11497. * Instantiates a new RawTexture.
  11498. * Raw texture can help creating a texture directly from an array of data.
  11499. * This can be super useful if you either get the data from an uncompressed source or
  11500. * if you wish to create your texture pixel by pixel.
  11501. * @param data define the array of data to use to create the texture
  11502. * @param width define the width of the texture
  11503. * @param height define the height of the texture
  11504. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11505. * @param scene define the scene the texture belongs to
  11506. * @param generateMipMaps define whether mip maps should be generated or not
  11507. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11508. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11509. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11510. */
  11511. constructor(data: ArrayBufferView, width: number, height: number,
  11512. /**
  11513. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11514. */
  11515. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11516. /**
  11517. * Updates the texture underlying data.
  11518. * @param data Define the new data of the texture
  11519. */
  11520. update(data: ArrayBufferView): void;
  11521. /**
  11522. * Creates a luminance texture from some data.
  11523. * @param data Define the texture data
  11524. * @param width Define the width of the texture
  11525. * @param height Define the height of the texture
  11526. * @param scene Define the scene the texture belongs to
  11527. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11528. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11529. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11530. * @returns the luminance texture
  11531. */
  11532. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11533. /**
  11534. * Creates a luminance alpha texture from some data.
  11535. * @param data Define the texture data
  11536. * @param width Define the width of the texture
  11537. * @param height Define the height of the texture
  11538. * @param scene Define the scene the texture belongs to
  11539. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11540. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11541. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11542. * @returns the luminance alpha texture
  11543. */
  11544. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11545. /**
  11546. * Creates an alpha texture from some data.
  11547. * @param data Define the texture data
  11548. * @param width Define the width of the texture
  11549. * @param height Define the height of the texture
  11550. * @param scene Define the scene the texture belongs to
  11551. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11552. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11553. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11554. * @returns the alpha texture
  11555. */
  11556. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11557. /**
  11558. * Creates a RGB texture from some data.
  11559. * @param data Define the texture data
  11560. * @param width Define the width of the texture
  11561. * @param height Define the height of the texture
  11562. * @param scene Define the scene the texture belongs to
  11563. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11564. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11565. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11566. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11567. * @returns the RGB alpha texture
  11568. */
  11569. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11570. /**
  11571. * Creates a RGBA texture from some data.
  11572. * @param data Define the texture data
  11573. * @param width Define the width of the texture
  11574. * @param height Define the height of the texture
  11575. * @param scene Define the scene the texture belongs to
  11576. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11577. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11578. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11579. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11580. * @returns the RGBA texture
  11581. */
  11582. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11583. /**
  11584. * Creates a R texture from some data.
  11585. * @param data Define the texture data
  11586. * @param width Define the width of the texture
  11587. * @param height Define the height of the texture
  11588. * @param scene Define the scene the texture belongs to
  11589. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11590. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11591. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11592. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11593. * @returns the R texture
  11594. */
  11595. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11596. }
  11597. }
  11598. declare module BABYLON {
  11599. interface AbstractScene {
  11600. /**
  11601. * The list of procedural textures added to the scene
  11602. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11603. */
  11604. proceduralTextures: Array<ProceduralTexture>;
  11605. }
  11606. /**
  11607. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11608. * in a given scene.
  11609. */
  11610. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11611. /**
  11612. * The component name helpfull to identify the component in the list of scene components.
  11613. */
  11614. readonly name: string;
  11615. /**
  11616. * The scene the component belongs to.
  11617. */
  11618. scene: Scene;
  11619. /**
  11620. * Creates a new instance of the component for the given scene
  11621. * @param scene Defines the scene to register the component in
  11622. */
  11623. constructor(scene: Scene);
  11624. /**
  11625. * Registers the component in a given scene
  11626. */
  11627. register(): void;
  11628. /**
  11629. * Rebuilds the elements related to this component in case of
  11630. * context lost for instance.
  11631. */
  11632. rebuild(): void;
  11633. /**
  11634. * Disposes the component and the associated ressources.
  11635. */
  11636. dispose(): void;
  11637. private _beforeClear;
  11638. }
  11639. }
  11640. declare module BABYLON {
  11641. interface ThinEngine {
  11642. /**
  11643. * Creates a new render target cube texture
  11644. * @param size defines the size of the texture
  11645. * @param options defines the options used to create the texture
  11646. * @returns a new render target cube texture stored in an InternalTexture
  11647. */
  11648. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11649. }
  11650. }
  11651. declare module BABYLON {
  11652. /** @hidden */
  11653. export var proceduralVertexShader: {
  11654. name: string;
  11655. shader: string;
  11656. };
  11657. }
  11658. declare module BABYLON {
  11659. /**
  11660. * 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.
  11661. * This is the base class of any Procedural texture and contains most of the shareable code.
  11662. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11663. */
  11664. export class ProceduralTexture extends Texture {
  11665. isCube: boolean;
  11666. /**
  11667. * Define if the texture is enabled or not (disabled texture will not render)
  11668. */
  11669. isEnabled: boolean;
  11670. /**
  11671. * Define if the texture must be cleared before rendering (default is true)
  11672. */
  11673. autoClear: boolean;
  11674. /**
  11675. * Callback called when the texture is generated
  11676. */
  11677. onGenerated: () => void;
  11678. /**
  11679. * Event raised when the texture is generated
  11680. */
  11681. onGeneratedObservable: Observable<ProceduralTexture>;
  11682. /** @hidden */
  11683. _generateMipMaps: boolean;
  11684. /** @hidden **/
  11685. _effect: Effect;
  11686. /** @hidden */
  11687. _textures: {
  11688. [key: string]: Texture;
  11689. };
  11690. /** @hidden */
  11691. protected _fallbackTexture: Nullable<Texture>;
  11692. private _size;
  11693. private _currentRefreshId;
  11694. private _frameId;
  11695. private _refreshRate;
  11696. private _vertexBuffers;
  11697. private _indexBuffer;
  11698. private _uniforms;
  11699. private _samplers;
  11700. private _fragment;
  11701. private _floats;
  11702. private _ints;
  11703. private _floatsArrays;
  11704. private _colors3;
  11705. private _colors4;
  11706. private _vectors2;
  11707. private _vectors3;
  11708. private _matrices;
  11709. private _fallbackTextureUsed;
  11710. private _fullEngine;
  11711. private _cachedDefines;
  11712. private _contentUpdateId;
  11713. private _contentData;
  11714. /**
  11715. * Instantiates a new procedural texture.
  11716. * 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.
  11717. * This is the base class of any Procedural texture and contains most of the shareable code.
  11718. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11719. * @param name Define the name of the texture
  11720. * @param size Define the size of the texture to create
  11721. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11722. * @param scene Define the scene the texture belongs to
  11723. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11724. * @param generateMipMaps Define if the texture should creates mip maps or not
  11725. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11726. */
  11727. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11728. /**
  11729. * The effect that is created when initializing the post process.
  11730. * @returns The created effect corresponding the the postprocess.
  11731. */
  11732. getEffect(): Effect;
  11733. /**
  11734. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11735. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11736. */
  11737. getContent(): Nullable<ArrayBufferView>;
  11738. private _createIndexBuffer;
  11739. /** @hidden */
  11740. _rebuild(): void;
  11741. /**
  11742. * Resets the texture in order to recreate its associated resources.
  11743. * This can be called in case of context loss
  11744. */
  11745. reset(): void;
  11746. protected _getDefines(): string;
  11747. /**
  11748. * Is the texture ready to be used ? (rendered at least once)
  11749. * @returns true if ready, otherwise, false.
  11750. */
  11751. isReady(): boolean;
  11752. /**
  11753. * Resets the refresh counter of the texture and start bak from scratch.
  11754. * Could be useful to regenerate the texture if it is setup to render only once.
  11755. */
  11756. resetRefreshCounter(): void;
  11757. /**
  11758. * Set the fragment shader to use in order to render the texture.
  11759. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11760. */
  11761. setFragment(fragment: any): void;
  11762. /**
  11763. * Define the refresh rate of the texture or the rendering frequency.
  11764. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11765. */
  11766. get refreshRate(): number;
  11767. set refreshRate(value: number);
  11768. /** @hidden */
  11769. _shouldRender(): boolean;
  11770. /**
  11771. * Get the size the texture is rendering at.
  11772. * @returns the size (texture is always squared)
  11773. */
  11774. getRenderSize(): number;
  11775. /**
  11776. * Resize the texture to new value.
  11777. * @param size Define the new size the texture should have
  11778. * @param generateMipMaps Define whether the new texture should create mip maps
  11779. */
  11780. resize(size: number, generateMipMaps: boolean): void;
  11781. private _checkUniform;
  11782. /**
  11783. * Set a texture in the shader program used to render.
  11784. * @param name Define the name of the uniform samplers as defined in the shader
  11785. * @param texture Define the texture to bind to this sampler
  11786. * @return the texture itself allowing "fluent" like uniform updates
  11787. */
  11788. setTexture(name: string, texture: Texture): ProceduralTexture;
  11789. /**
  11790. * Set a float in the shader.
  11791. * @param name Define the name of the uniform as defined in the shader
  11792. * @param value Define the value to give to the uniform
  11793. * @return the texture itself allowing "fluent" like uniform updates
  11794. */
  11795. setFloat(name: string, value: number): ProceduralTexture;
  11796. /**
  11797. * Set a int in the shader.
  11798. * @param name Define the name of the uniform as defined in the shader
  11799. * @param value Define the value to give to the uniform
  11800. * @return the texture itself allowing "fluent" like uniform updates
  11801. */
  11802. setInt(name: string, value: number): ProceduralTexture;
  11803. /**
  11804. * Set an array of floats in the shader.
  11805. * @param name Define the name of the uniform as defined in the shader
  11806. * @param value Define the value to give to the uniform
  11807. * @return the texture itself allowing "fluent" like uniform updates
  11808. */
  11809. setFloats(name: string, value: number[]): ProceduralTexture;
  11810. /**
  11811. * Set a vec3 in the shader from a Color3.
  11812. * @param name Define the name of the uniform as defined in the shader
  11813. * @param value Define the value to give to the uniform
  11814. * @return the texture itself allowing "fluent" like uniform updates
  11815. */
  11816. setColor3(name: string, value: Color3): ProceduralTexture;
  11817. /**
  11818. * Set a vec4 in the shader from a Color4.
  11819. * @param name Define the name of the uniform as defined in the shader
  11820. * @param value Define the value to give to the uniform
  11821. * @return the texture itself allowing "fluent" like uniform updates
  11822. */
  11823. setColor4(name: string, value: Color4): ProceduralTexture;
  11824. /**
  11825. * Set a vec2 in the shader from a Vector2.
  11826. * @param name Define the name of the uniform as defined in the shader
  11827. * @param value Define the value to give to the uniform
  11828. * @return the texture itself allowing "fluent" like uniform updates
  11829. */
  11830. setVector2(name: string, value: Vector2): ProceduralTexture;
  11831. /**
  11832. * Set a vec3 in the shader from a Vector3.
  11833. * @param name Define the name of the uniform as defined in the shader
  11834. * @param value Define the value to give to the uniform
  11835. * @return the texture itself allowing "fluent" like uniform updates
  11836. */
  11837. setVector3(name: string, value: Vector3): ProceduralTexture;
  11838. /**
  11839. * Set a mat4 in the shader from a MAtrix.
  11840. * @param name Define the name of the uniform as defined in the shader
  11841. * @param value Define the value to give to the uniform
  11842. * @return the texture itself allowing "fluent" like uniform updates
  11843. */
  11844. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11845. /**
  11846. * Render the texture to its associated render target.
  11847. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11848. */
  11849. render(useCameraPostProcess?: boolean): void;
  11850. /**
  11851. * Clone the texture.
  11852. * @returns the cloned texture
  11853. */
  11854. clone(): ProceduralTexture;
  11855. /**
  11856. * Dispose the texture and release its asoociated resources.
  11857. */
  11858. dispose(): void;
  11859. }
  11860. }
  11861. declare module BABYLON {
  11862. /**
  11863. * This represents the base class for particle system in Babylon.
  11864. * 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.
  11865. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11866. * @example https://doc.babylonjs.com/babylon101/particles
  11867. */
  11868. export class BaseParticleSystem {
  11869. /**
  11870. * Source color is added to the destination color without alpha affecting the result
  11871. */
  11872. static BLENDMODE_ONEONE: number;
  11873. /**
  11874. * Blend current color and particle color using particle’s alpha
  11875. */
  11876. static BLENDMODE_STANDARD: number;
  11877. /**
  11878. * Add current color and particle color multiplied by particle’s alpha
  11879. */
  11880. static BLENDMODE_ADD: number;
  11881. /**
  11882. * Multiply current color with particle color
  11883. */
  11884. static BLENDMODE_MULTIPLY: number;
  11885. /**
  11886. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11887. */
  11888. static BLENDMODE_MULTIPLYADD: number;
  11889. /**
  11890. * List of animations used by the particle system.
  11891. */
  11892. animations: Animation[];
  11893. /**
  11894. * Gets or sets the unique id of the particle system
  11895. */
  11896. uniqueId: number;
  11897. /**
  11898. * The id of the Particle system.
  11899. */
  11900. id: string;
  11901. /**
  11902. * The friendly name of the Particle system.
  11903. */
  11904. name: string;
  11905. /**
  11906. * Snippet ID if the particle system was created from the snippet server
  11907. */
  11908. snippetId: string;
  11909. /**
  11910. * The rendering group used by the Particle system to chose when to render.
  11911. */
  11912. renderingGroupId: number;
  11913. /**
  11914. * The emitter represents the Mesh or position we are attaching the particle system to.
  11915. */
  11916. emitter: Nullable<AbstractMesh | Vector3>;
  11917. /**
  11918. * The maximum number of particles to emit per frame
  11919. */
  11920. emitRate: number;
  11921. /**
  11922. * If you want to launch only a few particles at once, that can be done, as well.
  11923. */
  11924. manualEmitCount: number;
  11925. /**
  11926. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11927. */
  11928. updateSpeed: number;
  11929. /**
  11930. * The amount of time the particle system is running (depends of the overall update speed).
  11931. */
  11932. targetStopDuration: number;
  11933. /**
  11934. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11935. */
  11936. disposeOnStop: boolean;
  11937. /**
  11938. * Minimum power of emitting particles.
  11939. */
  11940. minEmitPower: number;
  11941. /**
  11942. * Maximum power of emitting particles.
  11943. */
  11944. maxEmitPower: number;
  11945. /**
  11946. * Minimum life time of emitting particles.
  11947. */
  11948. minLifeTime: number;
  11949. /**
  11950. * Maximum life time of emitting particles.
  11951. */
  11952. maxLifeTime: number;
  11953. /**
  11954. * Minimum Size of emitting particles.
  11955. */
  11956. minSize: number;
  11957. /**
  11958. * Maximum Size of emitting particles.
  11959. */
  11960. maxSize: number;
  11961. /**
  11962. * Minimum scale of emitting particles on X axis.
  11963. */
  11964. minScaleX: number;
  11965. /**
  11966. * Maximum scale of emitting particles on X axis.
  11967. */
  11968. maxScaleX: number;
  11969. /**
  11970. * Minimum scale of emitting particles on Y axis.
  11971. */
  11972. minScaleY: number;
  11973. /**
  11974. * Maximum scale of emitting particles on Y axis.
  11975. */
  11976. maxScaleY: number;
  11977. /**
  11978. * Gets or sets the minimal initial rotation in radians.
  11979. */
  11980. minInitialRotation: number;
  11981. /**
  11982. * Gets or sets the maximal initial rotation in radians.
  11983. */
  11984. maxInitialRotation: number;
  11985. /**
  11986. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11987. */
  11988. minAngularSpeed: number;
  11989. /**
  11990. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11991. */
  11992. maxAngularSpeed: number;
  11993. /**
  11994. * The texture used to render each particle. (this can be a spritesheet)
  11995. */
  11996. particleTexture: Nullable<Texture>;
  11997. /**
  11998. * The layer mask we are rendering the particles through.
  11999. */
  12000. layerMask: number;
  12001. /**
  12002. * This can help using your own shader to render the particle system.
  12003. * The according effect will be created
  12004. */
  12005. customShader: any;
  12006. /**
  12007. * By default particle system starts as soon as they are created. This prevents the
  12008. * automatic start to happen and let you decide when to start emitting particles.
  12009. */
  12010. preventAutoStart: boolean;
  12011. private _noiseTexture;
  12012. /**
  12013. * Gets or sets a texture used to add random noise to particle positions
  12014. */
  12015. get noiseTexture(): Nullable<ProceduralTexture>;
  12016. set noiseTexture(value: Nullable<ProceduralTexture>);
  12017. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12018. noiseStrength: Vector3;
  12019. /**
  12020. * Callback triggered when the particle animation is ending.
  12021. */
  12022. onAnimationEnd: Nullable<() => void>;
  12023. /**
  12024. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12025. */
  12026. blendMode: number;
  12027. /**
  12028. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12029. * to override the particles.
  12030. */
  12031. forceDepthWrite: boolean;
  12032. /** 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 */
  12033. preWarmCycles: number;
  12034. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12035. preWarmStepOffset: number;
  12036. /**
  12037. * 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)
  12038. */
  12039. spriteCellChangeSpeed: number;
  12040. /**
  12041. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12042. */
  12043. startSpriteCellID: number;
  12044. /**
  12045. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12046. */
  12047. endSpriteCellID: number;
  12048. /**
  12049. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12050. */
  12051. spriteCellWidth: number;
  12052. /**
  12053. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12054. */
  12055. spriteCellHeight: number;
  12056. /**
  12057. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12058. */
  12059. spriteRandomStartCell: boolean;
  12060. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12061. translationPivot: Vector2;
  12062. /** @hidden */
  12063. protected _isAnimationSheetEnabled: boolean;
  12064. /**
  12065. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12066. */
  12067. beginAnimationOnStart: boolean;
  12068. /**
  12069. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12070. */
  12071. beginAnimationFrom: number;
  12072. /**
  12073. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12074. */
  12075. beginAnimationTo: number;
  12076. /**
  12077. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12078. */
  12079. beginAnimationLoop: boolean;
  12080. /**
  12081. * Gets or sets a world offset applied to all particles
  12082. */
  12083. worldOffset: Vector3;
  12084. /**
  12085. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12086. */
  12087. get isAnimationSheetEnabled(): boolean;
  12088. set isAnimationSheetEnabled(value: boolean);
  12089. /**
  12090. * Get hosting scene
  12091. * @returns the scene
  12092. */
  12093. getScene(): Scene;
  12094. /**
  12095. * You can use gravity if you want to give an orientation to your particles.
  12096. */
  12097. gravity: Vector3;
  12098. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12099. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12100. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12101. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12102. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12103. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12104. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12105. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12106. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12107. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12108. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12109. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12110. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12111. /**
  12112. * Defines the delay in milliseconds before starting the system (0 by default)
  12113. */
  12114. startDelay: number;
  12115. /**
  12116. * Gets the current list of drag gradients.
  12117. * You must use addDragGradient and removeDragGradient to udpate this list
  12118. * @returns the list of drag gradients
  12119. */
  12120. getDragGradients(): Nullable<Array<FactorGradient>>;
  12121. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12122. limitVelocityDamping: number;
  12123. /**
  12124. * Gets the current list of limit velocity gradients.
  12125. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12126. * @returns the list of limit velocity gradients
  12127. */
  12128. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12129. /**
  12130. * Gets the current list of color gradients.
  12131. * You must use addColorGradient and removeColorGradient to udpate this list
  12132. * @returns the list of color gradients
  12133. */
  12134. getColorGradients(): Nullable<Array<ColorGradient>>;
  12135. /**
  12136. * Gets the current list of size gradients.
  12137. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12138. * @returns the list of size gradients
  12139. */
  12140. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12141. /**
  12142. * Gets the current list of color remap gradients.
  12143. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12144. * @returns the list of color remap gradients
  12145. */
  12146. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12147. /**
  12148. * Gets the current list of alpha remap gradients.
  12149. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12150. * @returns the list of alpha remap gradients
  12151. */
  12152. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12153. /**
  12154. * Gets the current list of life time gradients.
  12155. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12156. * @returns the list of life time gradients
  12157. */
  12158. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12159. /**
  12160. * Gets the current list of angular speed gradients.
  12161. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12162. * @returns the list of angular speed gradients
  12163. */
  12164. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12165. /**
  12166. * Gets the current list of velocity gradients.
  12167. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12168. * @returns the list of velocity gradients
  12169. */
  12170. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12171. /**
  12172. * Gets the current list of start size gradients.
  12173. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12174. * @returns the list of start size gradients
  12175. */
  12176. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12177. /**
  12178. * Gets the current list of emit rate gradients.
  12179. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12180. * @returns the list of emit rate gradients
  12181. */
  12182. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12183. /**
  12184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12186. */
  12187. get direction1(): Vector3;
  12188. set direction1(value: Vector3);
  12189. /**
  12190. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12192. */
  12193. get direction2(): Vector3;
  12194. set direction2(value: Vector3);
  12195. /**
  12196. * 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.
  12197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12198. */
  12199. get minEmitBox(): Vector3;
  12200. set minEmitBox(value: Vector3);
  12201. /**
  12202. * 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.
  12203. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12204. */
  12205. get maxEmitBox(): Vector3;
  12206. set maxEmitBox(value: Vector3);
  12207. /**
  12208. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12209. */
  12210. color1: Color4;
  12211. /**
  12212. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12213. */
  12214. color2: Color4;
  12215. /**
  12216. * Color the particle will have at the end of its lifetime
  12217. */
  12218. colorDead: Color4;
  12219. /**
  12220. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12221. */
  12222. textureMask: Color4;
  12223. /**
  12224. * The particle emitter type defines the emitter used by the particle system.
  12225. * It can be for example box, sphere, or cone...
  12226. */
  12227. particleEmitterType: IParticleEmitterType;
  12228. /** @hidden */
  12229. _isSubEmitter: boolean;
  12230. /**
  12231. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12232. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12233. */
  12234. billboardMode: number;
  12235. protected _isBillboardBased: boolean;
  12236. /**
  12237. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12238. */
  12239. get isBillboardBased(): boolean;
  12240. set isBillboardBased(value: boolean);
  12241. /**
  12242. * The scene the particle system belongs to.
  12243. */
  12244. protected _scene: Scene;
  12245. /**
  12246. * Local cache of defines for image processing.
  12247. */
  12248. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12249. /**
  12250. * Default configuration related to image processing available in the standard Material.
  12251. */
  12252. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12253. /**
  12254. * Gets the image processing configuration used either in this material.
  12255. */
  12256. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12257. /**
  12258. * Sets the Default image processing configuration used either in the this material.
  12259. *
  12260. * If sets to null, the scene one is in use.
  12261. */
  12262. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12263. /**
  12264. * Attaches a new image processing configuration to the Standard Material.
  12265. * @param configuration
  12266. */
  12267. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12268. /** @hidden */
  12269. protected _reset(): void;
  12270. /** @hidden */
  12271. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12272. /**
  12273. * Instantiates a particle system.
  12274. * 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.
  12275. * @param name The name of the particle system
  12276. */
  12277. constructor(name: string);
  12278. /**
  12279. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12280. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12281. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12282. * @returns the emitter
  12283. */
  12284. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12285. /**
  12286. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12287. * @param radius The radius of the hemisphere to emit from
  12288. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12289. * @returns the emitter
  12290. */
  12291. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12292. /**
  12293. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12294. * @param radius The radius of the sphere to emit from
  12295. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12296. * @returns the emitter
  12297. */
  12298. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12299. /**
  12300. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12301. * @param radius The radius of the sphere to emit from
  12302. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12303. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12304. * @returns the emitter
  12305. */
  12306. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12307. /**
  12308. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12309. * @param radius The radius of the emission cylinder
  12310. * @param height The height of the emission cylinder
  12311. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12312. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12313. * @returns the emitter
  12314. */
  12315. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12316. /**
  12317. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12318. * @param radius The radius of the cylinder to emit from
  12319. * @param height The height of the emission cylinder
  12320. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12321. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12322. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12323. * @returns the emitter
  12324. */
  12325. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12326. /**
  12327. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12328. * @param radius The radius of the cone to emit from
  12329. * @param angle The base angle of the cone
  12330. * @returns the emitter
  12331. */
  12332. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12333. /**
  12334. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12335. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12336. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12337. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12338. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12339. * @returns the emitter
  12340. */
  12341. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12342. }
  12343. }
  12344. declare module BABYLON {
  12345. /**
  12346. * Type of sub emitter
  12347. */
  12348. export enum SubEmitterType {
  12349. /**
  12350. * Attached to the particle over it's lifetime
  12351. */
  12352. ATTACHED = 0,
  12353. /**
  12354. * Created when the particle dies
  12355. */
  12356. END = 1
  12357. }
  12358. /**
  12359. * Sub emitter class used to emit particles from an existing particle
  12360. */
  12361. export class SubEmitter {
  12362. /**
  12363. * the particle system to be used by the sub emitter
  12364. */
  12365. particleSystem: ParticleSystem;
  12366. /**
  12367. * Type of the submitter (Default: END)
  12368. */
  12369. type: SubEmitterType;
  12370. /**
  12371. * 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)
  12372. * Note: This only is supported when using an emitter of type Mesh
  12373. */
  12374. inheritDirection: boolean;
  12375. /**
  12376. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12377. */
  12378. inheritedVelocityAmount: number;
  12379. /**
  12380. * Creates a sub emitter
  12381. * @param particleSystem the particle system to be used by the sub emitter
  12382. */
  12383. constructor(
  12384. /**
  12385. * the particle system to be used by the sub emitter
  12386. */
  12387. particleSystem: ParticleSystem);
  12388. /**
  12389. * Clones the sub emitter
  12390. * @returns the cloned sub emitter
  12391. */
  12392. clone(): SubEmitter;
  12393. /**
  12394. * Serialize current object to a JSON object
  12395. * @returns the serialized object
  12396. */
  12397. serialize(): any;
  12398. /** @hidden */
  12399. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12400. /**
  12401. * Creates a new SubEmitter from a serialized JSON version
  12402. * @param serializationObject defines the JSON object to read from
  12403. * @param scene defines the hosting scene
  12404. * @param rootUrl defines the rootUrl for data loading
  12405. * @returns a new SubEmitter
  12406. */
  12407. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12408. /** Release associated resources */
  12409. dispose(): void;
  12410. }
  12411. }
  12412. declare module BABYLON {
  12413. /** @hidden */
  12414. export var imageProcessingDeclaration: {
  12415. name: string;
  12416. shader: string;
  12417. };
  12418. }
  12419. declare module BABYLON {
  12420. /** @hidden */
  12421. export var imageProcessingFunctions: {
  12422. name: string;
  12423. shader: string;
  12424. };
  12425. }
  12426. declare module BABYLON {
  12427. /** @hidden */
  12428. export var particlesPixelShader: {
  12429. name: string;
  12430. shader: string;
  12431. };
  12432. }
  12433. declare module BABYLON {
  12434. /** @hidden */
  12435. export var particlesVertexShader: {
  12436. name: string;
  12437. shader: string;
  12438. };
  12439. }
  12440. declare module BABYLON {
  12441. /**
  12442. * This represents a particle system in Babylon.
  12443. * 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.
  12444. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12445. * @example https://doc.babylonjs.com/babylon101/particles
  12446. */
  12447. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12448. /**
  12449. * Billboard mode will only apply to Y axis
  12450. */
  12451. static readonly BILLBOARDMODE_Y: number;
  12452. /**
  12453. * Billboard mode will apply to all axes
  12454. */
  12455. static readonly BILLBOARDMODE_ALL: number;
  12456. /**
  12457. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12458. */
  12459. static readonly BILLBOARDMODE_STRETCHED: number;
  12460. /**
  12461. * This function can be defined to provide custom update for active particles.
  12462. * This function will be called instead of regular update (age, position, color, etc.).
  12463. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12464. */
  12465. updateFunction: (particles: Particle[]) => void;
  12466. private _emitterWorldMatrix;
  12467. /**
  12468. * This function can be defined to specify initial direction for every new particle.
  12469. * It by default use the emitterType defined function
  12470. */
  12471. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12472. /**
  12473. * This function can be defined to specify initial position for every new particle.
  12474. * It by default use the emitterType defined function
  12475. */
  12476. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12477. /**
  12478. * @hidden
  12479. */
  12480. _inheritedVelocityOffset: Vector3;
  12481. /**
  12482. * An event triggered when the system is disposed
  12483. */
  12484. onDisposeObservable: Observable<IParticleSystem>;
  12485. private _onDisposeObserver;
  12486. /**
  12487. * Sets a callback that will be triggered when the system is disposed
  12488. */
  12489. set onDispose(callback: () => void);
  12490. private _particles;
  12491. private _epsilon;
  12492. private _capacity;
  12493. private _stockParticles;
  12494. private _newPartsExcess;
  12495. private _vertexData;
  12496. private _vertexBuffer;
  12497. private _vertexBuffers;
  12498. private _spriteBuffer;
  12499. private _indexBuffer;
  12500. private _effect;
  12501. private _customEffect;
  12502. private _cachedDefines;
  12503. private _scaledColorStep;
  12504. private _colorDiff;
  12505. private _scaledDirection;
  12506. private _scaledGravity;
  12507. private _currentRenderId;
  12508. private _alive;
  12509. private _useInstancing;
  12510. private _started;
  12511. private _stopped;
  12512. private _actualFrame;
  12513. private _scaledUpdateSpeed;
  12514. private _vertexBufferSize;
  12515. /** @hidden */
  12516. _currentEmitRateGradient: Nullable<FactorGradient>;
  12517. /** @hidden */
  12518. _currentEmitRate1: number;
  12519. /** @hidden */
  12520. _currentEmitRate2: number;
  12521. /** @hidden */
  12522. _currentStartSizeGradient: Nullable<FactorGradient>;
  12523. /** @hidden */
  12524. _currentStartSize1: number;
  12525. /** @hidden */
  12526. _currentStartSize2: number;
  12527. private readonly _rawTextureWidth;
  12528. private _rampGradientsTexture;
  12529. private _useRampGradients;
  12530. /** Gets or sets a boolean indicating that ramp gradients must be used
  12531. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12532. */
  12533. get useRampGradients(): boolean;
  12534. set useRampGradients(value: boolean);
  12535. /**
  12536. * 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.
  12537. * 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: [])
  12538. */
  12539. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12540. private _subEmitters;
  12541. /**
  12542. * @hidden
  12543. * If the particle systems emitter should be disposed when the particle system is disposed
  12544. */
  12545. _disposeEmitterOnDispose: boolean;
  12546. /**
  12547. * The current active Sub-systems, this property is used by the root particle system only.
  12548. */
  12549. activeSubSystems: Array<ParticleSystem>;
  12550. /**
  12551. * Specifies if the particles are updated in emitter local space or world space
  12552. */
  12553. isLocal: boolean;
  12554. private _rootParticleSystem;
  12555. /**
  12556. * Gets the current list of active particles
  12557. */
  12558. get particles(): Particle[];
  12559. /**
  12560. * Gets the number of particles active at the same time.
  12561. * @returns The number of active particles.
  12562. */
  12563. getActiveCount(): number;
  12564. /**
  12565. * Returns the string "ParticleSystem"
  12566. * @returns a string containing the class name
  12567. */
  12568. getClassName(): string;
  12569. /**
  12570. * Gets a boolean indicating that the system is stopping
  12571. * @returns true if the system is currently stopping
  12572. */
  12573. isStopping(): boolean;
  12574. /**
  12575. * Gets the custom effect used to render the particles
  12576. * @param blendMode Blend mode for which the effect should be retrieved
  12577. * @returns The effect
  12578. */
  12579. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12580. /**
  12581. * Sets the custom effect used to render the particles
  12582. * @param effect The effect to set
  12583. * @param blendMode Blend mode for which the effect should be set
  12584. */
  12585. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12586. /** @hidden */
  12587. private _onBeforeDrawParticlesObservable;
  12588. /**
  12589. * Observable that will be called just before the particles are drawn
  12590. */
  12591. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12592. /**
  12593. * Gets the name of the particle vertex shader
  12594. */
  12595. get vertexShaderName(): string;
  12596. /**
  12597. * Instantiates a particle system.
  12598. * 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.
  12599. * @param name The name of the particle system
  12600. * @param capacity The max number of particles alive at the same time
  12601. * @param scene The scene the particle system belongs to
  12602. * @param customEffect a custom effect used to change the way particles are rendered by default
  12603. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12604. * @param epsilon Offset used to render the particles
  12605. */
  12606. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12607. private _addFactorGradient;
  12608. private _removeFactorGradient;
  12609. /**
  12610. * Adds a new life time gradient
  12611. * @param gradient defines the gradient to use (between 0 and 1)
  12612. * @param factor defines the life time factor to affect to the specified gradient
  12613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12614. * @returns the current particle system
  12615. */
  12616. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12617. /**
  12618. * Remove a specific life time gradient
  12619. * @param gradient defines the gradient to remove
  12620. * @returns the current particle system
  12621. */
  12622. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12623. /**
  12624. * Adds a new size gradient
  12625. * @param gradient defines the gradient to use (between 0 and 1)
  12626. * @param factor defines the size factor to affect to the specified gradient
  12627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12628. * @returns the current particle system
  12629. */
  12630. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12631. /**
  12632. * Remove a specific size gradient
  12633. * @param gradient defines the gradient to remove
  12634. * @returns the current particle system
  12635. */
  12636. removeSizeGradient(gradient: number): IParticleSystem;
  12637. /**
  12638. * Adds a new color remap gradient
  12639. * @param gradient defines the gradient to use (between 0 and 1)
  12640. * @param min defines the color remap minimal range
  12641. * @param max defines the color remap maximal range
  12642. * @returns the current particle system
  12643. */
  12644. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12645. /**
  12646. * Remove a specific color remap gradient
  12647. * @param gradient defines the gradient to remove
  12648. * @returns the current particle system
  12649. */
  12650. removeColorRemapGradient(gradient: number): IParticleSystem;
  12651. /**
  12652. * Adds a new alpha remap gradient
  12653. * @param gradient defines the gradient to use (between 0 and 1)
  12654. * @param min defines the alpha remap minimal range
  12655. * @param max defines the alpha remap maximal range
  12656. * @returns the current particle system
  12657. */
  12658. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12659. /**
  12660. * Remove a specific alpha remap gradient
  12661. * @param gradient defines the gradient to remove
  12662. * @returns the current particle system
  12663. */
  12664. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12665. /**
  12666. * Adds a new angular speed gradient
  12667. * @param gradient defines the gradient to use (between 0 and 1)
  12668. * @param factor defines the angular speed to affect to the specified gradient
  12669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12670. * @returns the current particle system
  12671. */
  12672. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12673. /**
  12674. * Remove a specific angular speed gradient
  12675. * @param gradient defines the gradient to remove
  12676. * @returns the current particle system
  12677. */
  12678. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12679. /**
  12680. * Adds a new velocity gradient
  12681. * @param gradient defines the gradient to use (between 0 and 1)
  12682. * @param factor defines the velocity to affect to the specified gradient
  12683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12684. * @returns the current particle system
  12685. */
  12686. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12687. /**
  12688. * Remove a specific velocity gradient
  12689. * @param gradient defines the gradient to remove
  12690. * @returns the current particle system
  12691. */
  12692. removeVelocityGradient(gradient: number): IParticleSystem;
  12693. /**
  12694. * Adds a new limit velocity gradient
  12695. * @param gradient defines the gradient to use (between 0 and 1)
  12696. * @param factor defines the limit velocity value to affect to the specified gradient
  12697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12698. * @returns the current particle system
  12699. */
  12700. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12701. /**
  12702. * Remove a specific limit velocity gradient
  12703. * @param gradient defines the gradient to remove
  12704. * @returns the current particle system
  12705. */
  12706. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12707. /**
  12708. * Adds a new drag gradient
  12709. * @param gradient defines the gradient to use (between 0 and 1)
  12710. * @param factor defines the drag value to affect to the specified gradient
  12711. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12712. * @returns the current particle system
  12713. */
  12714. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12715. /**
  12716. * Remove a specific drag gradient
  12717. * @param gradient defines the gradient to remove
  12718. * @returns the current particle system
  12719. */
  12720. removeDragGradient(gradient: number): IParticleSystem;
  12721. /**
  12722. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12723. * @param gradient defines the gradient to use (between 0 and 1)
  12724. * @param factor defines the emit rate value to affect to the specified gradient
  12725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12726. * @returns the current particle system
  12727. */
  12728. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12729. /**
  12730. * Remove a specific emit rate gradient
  12731. * @param gradient defines the gradient to remove
  12732. * @returns the current particle system
  12733. */
  12734. removeEmitRateGradient(gradient: number): IParticleSystem;
  12735. /**
  12736. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12737. * @param gradient defines the gradient to use (between 0 and 1)
  12738. * @param factor defines the start size value to affect to the specified gradient
  12739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12740. * @returns the current particle system
  12741. */
  12742. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12743. /**
  12744. * Remove a specific start size gradient
  12745. * @param gradient defines the gradient to remove
  12746. * @returns the current particle system
  12747. */
  12748. removeStartSizeGradient(gradient: number): IParticleSystem;
  12749. private _createRampGradientTexture;
  12750. /**
  12751. * Gets the current list of ramp gradients.
  12752. * You must use addRampGradient and removeRampGradient to udpate this list
  12753. * @returns the list of ramp gradients
  12754. */
  12755. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12756. /** Force the system to rebuild all gradients that need to be resync */
  12757. forceRefreshGradients(): void;
  12758. private _syncRampGradientTexture;
  12759. /**
  12760. * Adds a new ramp gradient used to remap particle colors
  12761. * @param gradient defines the gradient to use (between 0 and 1)
  12762. * @param color defines the color to affect to the specified gradient
  12763. * @returns the current particle system
  12764. */
  12765. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12766. /**
  12767. * Remove a specific ramp gradient
  12768. * @param gradient defines the gradient to remove
  12769. * @returns the current particle system
  12770. */
  12771. removeRampGradient(gradient: number): ParticleSystem;
  12772. /**
  12773. * Adds a new color gradient
  12774. * @param gradient defines the gradient to use (between 0 and 1)
  12775. * @param color1 defines the color to affect to the specified gradient
  12776. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12777. * @returns this particle system
  12778. */
  12779. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12780. /**
  12781. * Remove a specific color gradient
  12782. * @param gradient defines the gradient to remove
  12783. * @returns this particle system
  12784. */
  12785. removeColorGradient(gradient: number): IParticleSystem;
  12786. private _fetchR;
  12787. protected _reset(): void;
  12788. private _resetEffect;
  12789. private _createVertexBuffers;
  12790. private _createIndexBuffer;
  12791. /**
  12792. * Gets the maximum number of particles active at the same time.
  12793. * @returns The max number of active particles.
  12794. */
  12795. getCapacity(): number;
  12796. /**
  12797. * Gets whether there are still active particles in the system.
  12798. * @returns True if it is alive, otherwise false.
  12799. */
  12800. isAlive(): boolean;
  12801. /**
  12802. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12803. * @returns True if it has been started, otherwise false.
  12804. */
  12805. isStarted(): boolean;
  12806. private _prepareSubEmitterInternalArray;
  12807. /**
  12808. * Starts the particle system and begins to emit
  12809. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12810. */
  12811. start(delay?: number): void;
  12812. /**
  12813. * Stops the particle system.
  12814. * @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.
  12815. */
  12816. stop(stopSubEmitters?: boolean): void;
  12817. /**
  12818. * Remove all active particles
  12819. */
  12820. reset(): void;
  12821. /**
  12822. * @hidden (for internal use only)
  12823. */
  12824. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12825. /**
  12826. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12827. * Its lifetime will start back at 0.
  12828. */
  12829. recycleParticle: (particle: Particle) => void;
  12830. private _stopSubEmitters;
  12831. private _createParticle;
  12832. private _removeFromRoot;
  12833. private _emitFromParticle;
  12834. private _update;
  12835. /** @hidden */
  12836. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12837. /** @hidden */
  12838. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12839. /**
  12840. * Fill the defines array according to the current settings of the particle system
  12841. * @param defines Array to be updated
  12842. * @param blendMode blend mode to take into account when updating the array
  12843. */
  12844. fillDefines(defines: Array<string>, blendMode: number): void;
  12845. /**
  12846. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12847. * @param uniforms Uniforms array to fill
  12848. * @param attributes Attributes array to fill
  12849. * @param samplers Samplers array to fill
  12850. */
  12851. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12852. /** @hidden */
  12853. private _getEffect;
  12854. /**
  12855. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12856. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12857. */
  12858. animate(preWarmOnly?: boolean): void;
  12859. private _appendParticleVertices;
  12860. /**
  12861. * Rebuilds the particle system.
  12862. */
  12863. rebuild(): void;
  12864. /**
  12865. * Is this system ready to be used/rendered
  12866. * @return true if the system is ready
  12867. */
  12868. isReady(): boolean;
  12869. private _render;
  12870. /**
  12871. * Renders the particle system in its current state.
  12872. * @returns the current number of particles
  12873. */
  12874. render(): number;
  12875. /**
  12876. * Disposes the particle system and free the associated resources
  12877. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12878. */
  12879. dispose(disposeTexture?: boolean): void;
  12880. /**
  12881. * Clones the particle system.
  12882. * @param name The name of the cloned object
  12883. * @param newEmitter The new emitter to use
  12884. * @returns the cloned particle system
  12885. */
  12886. clone(name: string, newEmitter: any): ParticleSystem;
  12887. /**
  12888. * Serializes the particle system to a JSON object
  12889. * @param serializeTexture defines if the texture must be serialized as well
  12890. * @returns the JSON object
  12891. */
  12892. serialize(serializeTexture?: boolean): any;
  12893. /** @hidden */
  12894. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12895. /** @hidden */
  12896. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12897. /**
  12898. * Parses a JSON object to create a particle system.
  12899. * @param parsedParticleSystem The JSON object to parse
  12900. * @param scene The scene to create the particle system in
  12901. * @param rootUrl The root url to use to load external dependencies like texture
  12902. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12903. * @returns the Parsed particle system
  12904. */
  12905. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12906. }
  12907. }
  12908. declare module BABYLON {
  12909. /**
  12910. * A particle represents one of the element emitted by a particle system.
  12911. * This is mainly define by its coordinates, direction, velocity and age.
  12912. */
  12913. export class Particle {
  12914. /**
  12915. * The particle system the particle belongs to.
  12916. */
  12917. particleSystem: ParticleSystem;
  12918. private static _Count;
  12919. /**
  12920. * Unique ID of the particle
  12921. */
  12922. id: number;
  12923. /**
  12924. * The world position of the particle in the scene.
  12925. */
  12926. position: Vector3;
  12927. /**
  12928. * The world direction of the particle in the scene.
  12929. */
  12930. direction: Vector3;
  12931. /**
  12932. * The color of the particle.
  12933. */
  12934. color: Color4;
  12935. /**
  12936. * The color change of the particle per step.
  12937. */
  12938. colorStep: Color4;
  12939. /**
  12940. * Defines how long will the life of the particle be.
  12941. */
  12942. lifeTime: number;
  12943. /**
  12944. * The current age of the particle.
  12945. */
  12946. age: number;
  12947. /**
  12948. * The current size of the particle.
  12949. */
  12950. size: number;
  12951. /**
  12952. * The current scale of the particle.
  12953. */
  12954. scale: Vector2;
  12955. /**
  12956. * The current angle of the particle.
  12957. */
  12958. angle: number;
  12959. /**
  12960. * Defines how fast is the angle changing.
  12961. */
  12962. angularSpeed: number;
  12963. /**
  12964. * Defines the cell index used by the particle to be rendered from a sprite.
  12965. */
  12966. cellIndex: number;
  12967. /**
  12968. * The information required to support color remapping
  12969. */
  12970. remapData: Vector4;
  12971. /** @hidden */
  12972. _randomCellOffset?: number;
  12973. /** @hidden */
  12974. _initialDirection: Nullable<Vector3>;
  12975. /** @hidden */
  12976. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12977. /** @hidden */
  12978. _initialStartSpriteCellID: number;
  12979. /** @hidden */
  12980. _initialEndSpriteCellID: number;
  12981. /** @hidden */
  12982. _currentColorGradient: Nullable<ColorGradient>;
  12983. /** @hidden */
  12984. _currentColor1: Color4;
  12985. /** @hidden */
  12986. _currentColor2: Color4;
  12987. /** @hidden */
  12988. _currentSizeGradient: Nullable<FactorGradient>;
  12989. /** @hidden */
  12990. _currentSize1: number;
  12991. /** @hidden */
  12992. _currentSize2: number;
  12993. /** @hidden */
  12994. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12995. /** @hidden */
  12996. _currentAngularSpeed1: number;
  12997. /** @hidden */
  12998. _currentAngularSpeed2: number;
  12999. /** @hidden */
  13000. _currentVelocityGradient: Nullable<FactorGradient>;
  13001. /** @hidden */
  13002. _currentVelocity1: number;
  13003. /** @hidden */
  13004. _currentVelocity2: number;
  13005. /** @hidden */
  13006. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13007. /** @hidden */
  13008. _currentLimitVelocity1: number;
  13009. /** @hidden */
  13010. _currentLimitVelocity2: number;
  13011. /** @hidden */
  13012. _currentDragGradient: Nullable<FactorGradient>;
  13013. /** @hidden */
  13014. _currentDrag1: number;
  13015. /** @hidden */
  13016. _currentDrag2: number;
  13017. /** @hidden */
  13018. _randomNoiseCoordinates1: Vector3;
  13019. /** @hidden */
  13020. _randomNoiseCoordinates2: Vector3;
  13021. /** @hidden */
  13022. _localPosition?: Vector3;
  13023. /**
  13024. * Creates a new instance Particle
  13025. * @param particleSystem the particle system the particle belongs to
  13026. */
  13027. constructor(
  13028. /**
  13029. * The particle system the particle belongs to.
  13030. */
  13031. particleSystem: ParticleSystem);
  13032. private updateCellInfoFromSystem;
  13033. /**
  13034. * Defines how the sprite cell index is updated for the particle
  13035. */
  13036. updateCellIndex(): void;
  13037. /** @hidden */
  13038. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13039. /** @hidden */
  13040. _inheritParticleInfoToSubEmitters(): void;
  13041. /** @hidden */
  13042. _reset(): void;
  13043. /**
  13044. * Copy the properties of particle to another one.
  13045. * @param other the particle to copy the information to.
  13046. */
  13047. copyTo(other: Particle): void;
  13048. }
  13049. }
  13050. declare module BABYLON {
  13051. /**
  13052. * Particle emitter represents a volume emitting particles.
  13053. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13054. */
  13055. export interface IParticleEmitterType {
  13056. /**
  13057. * Called by the particle System when the direction is computed for the created particle.
  13058. * @param worldMatrix is the world matrix of the particle system
  13059. * @param directionToUpdate is the direction vector to update with the result
  13060. * @param particle is the particle we are computed the direction for
  13061. * @param isLocal defines if the direction should be set in local space
  13062. */
  13063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13064. /**
  13065. * Called by the particle System when the position is computed for the created particle.
  13066. * @param worldMatrix is the world matrix of the particle system
  13067. * @param positionToUpdate is the position vector to update with the result
  13068. * @param particle is the particle we are computed the position for
  13069. * @param isLocal defines if the position should be set in local space
  13070. */
  13071. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13072. /**
  13073. * Clones the current emitter and returns a copy of it
  13074. * @returns the new emitter
  13075. */
  13076. clone(): IParticleEmitterType;
  13077. /**
  13078. * Called by the GPUParticleSystem to setup the update shader
  13079. * @param effect defines the update shader
  13080. */
  13081. applyToShader(effect: Effect): void;
  13082. /**
  13083. * Returns a string to use to update the GPU particles update shader
  13084. * @returns the effect defines string
  13085. */
  13086. getEffectDefines(): string;
  13087. /**
  13088. * Returns a string representing the class name
  13089. * @returns a string containing the class name
  13090. */
  13091. getClassName(): string;
  13092. /**
  13093. * Serializes the particle system to a JSON object.
  13094. * @returns the JSON object
  13095. */
  13096. serialize(): any;
  13097. /**
  13098. * Parse properties from a JSON object
  13099. * @param serializationObject defines the JSON object
  13100. * @param scene defines the hosting scene
  13101. */
  13102. parse(serializationObject: any, scene: Scene): void;
  13103. }
  13104. }
  13105. declare module BABYLON {
  13106. /**
  13107. * Particle emitter emitting particles from the inside of a box.
  13108. * It emits the particles randomly between 2 given directions.
  13109. */
  13110. export class BoxParticleEmitter implements IParticleEmitterType {
  13111. /**
  13112. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13113. */
  13114. direction1: Vector3;
  13115. /**
  13116. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13117. */
  13118. direction2: Vector3;
  13119. /**
  13120. * 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.
  13121. */
  13122. minEmitBox: Vector3;
  13123. /**
  13124. * 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.
  13125. */
  13126. maxEmitBox: Vector3;
  13127. /**
  13128. * Creates a new instance BoxParticleEmitter
  13129. */
  13130. constructor();
  13131. /**
  13132. * Called by the particle System when the direction is computed for the created particle.
  13133. * @param worldMatrix is the world matrix of the particle system
  13134. * @param directionToUpdate is the direction vector to update with the result
  13135. * @param particle is the particle we are computed the direction for
  13136. * @param isLocal defines if the direction should be set in local space
  13137. */
  13138. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13139. /**
  13140. * Called by the particle System when the position is computed for the created particle.
  13141. * @param worldMatrix is the world matrix of the particle system
  13142. * @param positionToUpdate is the position vector to update with the result
  13143. * @param particle is the particle we are computed the position for
  13144. * @param isLocal defines if the position should be set in local space
  13145. */
  13146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13147. /**
  13148. * Clones the current emitter and returns a copy of it
  13149. * @returns the new emitter
  13150. */
  13151. clone(): BoxParticleEmitter;
  13152. /**
  13153. * Called by the GPUParticleSystem to setup the update shader
  13154. * @param effect defines the update shader
  13155. */
  13156. applyToShader(effect: Effect): void;
  13157. /**
  13158. * Returns a string to use to update the GPU particles update shader
  13159. * @returns a string containng the defines string
  13160. */
  13161. getEffectDefines(): string;
  13162. /**
  13163. * Returns the string "BoxParticleEmitter"
  13164. * @returns a string containing the class name
  13165. */
  13166. getClassName(): string;
  13167. /**
  13168. * Serializes the particle system to a JSON object.
  13169. * @returns the JSON object
  13170. */
  13171. serialize(): any;
  13172. /**
  13173. * Parse properties from a JSON object
  13174. * @param serializationObject defines the JSON object
  13175. */
  13176. parse(serializationObject: any): void;
  13177. }
  13178. }
  13179. declare module BABYLON {
  13180. /**
  13181. * Particle emitter emitting particles from the inside of a cone.
  13182. * It emits the particles alongside the cone volume from the base to the particle.
  13183. * The emission direction might be randomized.
  13184. */
  13185. export class ConeParticleEmitter implements IParticleEmitterType {
  13186. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13187. directionRandomizer: number;
  13188. private _radius;
  13189. private _angle;
  13190. private _height;
  13191. /**
  13192. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13193. */
  13194. radiusRange: number;
  13195. /**
  13196. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13197. */
  13198. heightRange: number;
  13199. /**
  13200. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13201. */
  13202. emitFromSpawnPointOnly: boolean;
  13203. /**
  13204. * Gets or sets the radius of the emission cone
  13205. */
  13206. get radius(): number;
  13207. set radius(value: number);
  13208. /**
  13209. * Gets or sets the angle of the emission cone
  13210. */
  13211. get angle(): number;
  13212. set angle(value: number);
  13213. private _buildHeight;
  13214. /**
  13215. * Creates a new instance ConeParticleEmitter
  13216. * @param radius the radius of the emission cone (1 by default)
  13217. * @param angle the cone base angle (PI by default)
  13218. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13219. */
  13220. constructor(radius?: number, angle?: number,
  13221. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13222. directionRandomizer?: number);
  13223. /**
  13224. * Called by the particle System when the direction is computed for the created particle.
  13225. * @param worldMatrix is the world matrix of the particle system
  13226. * @param directionToUpdate is the direction vector to update with the result
  13227. * @param particle is the particle we are computed the direction for
  13228. * @param isLocal defines if the direction should be set in local space
  13229. */
  13230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13231. /**
  13232. * Called by the particle System when the position is computed for the created particle.
  13233. * @param worldMatrix is the world matrix of the particle system
  13234. * @param positionToUpdate is the position vector to update with the result
  13235. * @param particle is the particle we are computed the position for
  13236. * @param isLocal defines if the position should be set in local space
  13237. */
  13238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13239. /**
  13240. * Clones the current emitter and returns a copy of it
  13241. * @returns the new emitter
  13242. */
  13243. clone(): ConeParticleEmitter;
  13244. /**
  13245. * Called by the GPUParticleSystem to setup the update shader
  13246. * @param effect defines the update shader
  13247. */
  13248. applyToShader(effect: Effect): void;
  13249. /**
  13250. * Returns a string to use to update the GPU particles update shader
  13251. * @returns a string containng the defines string
  13252. */
  13253. getEffectDefines(): string;
  13254. /**
  13255. * Returns the string "ConeParticleEmitter"
  13256. * @returns a string containing the class name
  13257. */
  13258. getClassName(): string;
  13259. /**
  13260. * Serializes the particle system to a JSON object.
  13261. * @returns the JSON object
  13262. */
  13263. serialize(): any;
  13264. /**
  13265. * Parse properties from a JSON object
  13266. * @param serializationObject defines the JSON object
  13267. */
  13268. parse(serializationObject: any): void;
  13269. }
  13270. }
  13271. declare module BABYLON {
  13272. /**
  13273. * Particle emitter emitting particles from the inside of a cylinder.
  13274. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13275. */
  13276. export class CylinderParticleEmitter implements IParticleEmitterType {
  13277. /**
  13278. * The radius of the emission cylinder.
  13279. */
  13280. radius: number;
  13281. /**
  13282. * The height of the emission cylinder.
  13283. */
  13284. height: number;
  13285. /**
  13286. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13287. */
  13288. radiusRange: number;
  13289. /**
  13290. * How much to randomize the particle direction [0-1].
  13291. */
  13292. directionRandomizer: number;
  13293. /**
  13294. * Creates a new instance CylinderParticleEmitter
  13295. * @param radius the radius of the emission cylinder (1 by default)
  13296. * @param height the height of the emission cylinder (1 by default)
  13297. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13298. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13299. */
  13300. constructor(
  13301. /**
  13302. * The radius of the emission cylinder.
  13303. */
  13304. radius?: number,
  13305. /**
  13306. * The height of the emission cylinder.
  13307. */
  13308. height?: number,
  13309. /**
  13310. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13311. */
  13312. radiusRange?: number,
  13313. /**
  13314. * How much to randomize the particle direction [0-1].
  13315. */
  13316. directionRandomizer?: number);
  13317. /**
  13318. * Called by the particle System when the direction is computed for the created particle.
  13319. * @param worldMatrix is the world matrix of the particle system
  13320. * @param directionToUpdate is the direction vector to update with the result
  13321. * @param particle is the particle we are computed the direction for
  13322. * @param isLocal defines if the direction should be set in local space
  13323. */
  13324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13325. /**
  13326. * Called by the particle System when the position is computed for the created particle.
  13327. * @param worldMatrix is the world matrix of the particle system
  13328. * @param positionToUpdate is the position vector to update with the result
  13329. * @param particle is the particle we are computed the position for
  13330. * @param isLocal defines if the position should be set in local space
  13331. */
  13332. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13333. /**
  13334. * Clones the current emitter and returns a copy of it
  13335. * @returns the new emitter
  13336. */
  13337. clone(): CylinderParticleEmitter;
  13338. /**
  13339. * Called by the GPUParticleSystem to setup the update shader
  13340. * @param effect defines the update shader
  13341. */
  13342. applyToShader(effect: Effect): void;
  13343. /**
  13344. * Returns a string to use to update the GPU particles update shader
  13345. * @returns a string containng the defines string
  13346. */
  13347. getEffectDefines(): string;
  13348. /**
  13349. * Returns the string "CylinderParticleEmitter"
  13350. * @returns a string containing the class name
  13351. */
  13352. getClassName(): string;
  13353. /**
  13354. * Serializes the particle system to a JSON object.
  13355. * @returns the JSON object
  13356. */
  13357. serialize(): any;
  13358. /**
  13359. * Parse properties from a JSON object
  13360. * @param serializationObject defines the JSON object
  13361. */
  13362. parse(serializationObject: any): void;
  13363. }
  13364. /**
  13365. * Particle emitter emitting particles from the inside of a cylinder.
  13366. * It emits the particles randomly between two vectors.
  13367. */
  13368. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13369. /**
  13370. * The min limit of the emission direction.
  13371. */
  13372. direction1: Vector3;
  13373. /**
  13374. * The max limit of the emission direction.
  13375. */
  13376. direction2: Vector3;
  13377. /**
  13378. * Creates a new instance CylinderDirectedParticleEmitter
  13379. * @param radius the radius of the emission cylinder (1 by default)
  13380. * @param height the height of the emission cylinder (1 by default)
  13381. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13382. * @param direction1 the min limit of the emission direction (up vector by default)
  13383. * @param direction2 the max limit of the emission direction (up vector by default)
  13384. */
  13385. constructor(radius?: number, height?: number, radiusRange?: number,
  13386. /**
  13387. * The min limit of the emission direction.
  13388. */
  13389. direction1?: Vector3,
  13390. /**
  13391. * The max limit of the emission direction.
  13392. */
  13393. direction2?: Vector3);
  13394. /**
  13395. * Called by the particle System when the direction is computed for the created particle.
  13396. * @param worldMatrix is the world matrix of the particle system
  13397. * @param directionToUpdate is the direction vector to update with the result
  13398. * @param particle is the particle we are computed the direction for
  13399. */
  13400. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13401. /**
  13402. * Clones the current emitter and returns a copy of it
  13403. * @returns the new emitter
  13404. */
  13405. clone(): CylinderDirectedParticleEmitter;
  13406. /**
  13407. * Called by the GPUParticleSystem to setup the update shader
  13408. * @param effect defines the update shader
  13409. */
  13410. applyToShader(effect: Effect): void;
  13411. /**
  13412. * Returns a string to use to update the GPU particles update shader
  13413. * @returns a string containng the defines string
  13414. */
  13415. getEffectDefines(): string;
  13416. /**
  13417. * Returns the string "CylinderDirectedParticleEmitter"
  13418. * @returns a string containing the class name
  13419. */
  13420. getClassName(): string;
  13421. /**
  13422. * Serializes the particle system to a JSON object.
  13423. * @returns the JSON object
  13424. */
  13425. serialize(): any;
  13426. /**
  13427. * Parse properties from a JSON object
  13428. * @param serializationObject defines the JSON object
  13429. */
  13430. parse(serializationObject: any): void;
  13431. }
  13432. }
  13433. declare module BABYLON {
  13434. /**
  13435. * Particle emitter emitting particles from the inside of a hemisphere.
  13436. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13437. */
  13438. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13439. /**
  13440. * The radius of the emission hemisphere.
  13441. */
  13442. radius: number;
  13443. /**
  13444. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13445. */
  13446. radiusRange: number;
  13447. /**
  13448. * How much to randomize the particle direction [0-1].
  13449. */
  13450. directionRandomizer: number;
  13451. /**
  13452. * Creates a new instance HemisphericParticleEmitter
  13453. * @param radius the radius of the emission hemisphere (1 by default)
  13454. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13455. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13456. */
  13457. constructor(
  13458. /**
  13459. * The radius of the emission hemisphere.
  13460. */
  13461. radius?: number,
  13462. /**
  13463. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13464. */
  13465. radiusRange?: number,
  13466. /**
  13467. * How much to randomize the particle direction [0-1].
  13468. */
  13469. directionRandomizer?: number);
  13470. /**
  13471. * Called by the particle System when the direction is computed for the created particle.
  13472. * @param worldMatrix is the world matrix of the particle system
  13473. * @param directionToUpdate is the direction vector to update with the result
  13474. * @param particle is the particle we are computed the direction for
  13475. * @param isLocal defines if the direction should be set in local space
  13476. */
  13477. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13478. /**
  13479. * Called by the particle System when the position is computed for the created particle.
  13480. * @param worldMatrix is the world matrix of the particle system
  13481. * @param positionToUpdate is the position vector to update with the result
  13482. * @param particle is the particle we are computed the position for
  13483. * @param isLocal defines if the position should be set in local space
  13484. */
  13485. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13486. /**
  13487. * Clones the current emitter and returns a copy of it
  13488. * @returns the new emitter
  13489. */
  13490. clone(): HemisphericParticleEmitter;
  13491. /**
  13492. * Called by the GPUParticleSystem to setup the update shader
  13493. * @param effect defines the update shader
  13494. */
  13495. applyToShader(effect: Effect): void;
  13496. /**
  13497. * Returns a string to use to update the GPU particles update shader
  13498. * @returns a string containng the defines string
  13499. */
  13500. getEffectDefines(): string;
  13501. /**
  13502. * Returns the string "HemisphericParticleEmitter"
  13503. * @returns a string containing the class name
  13504. */
  13505. getClassName(): string;
  13506. /**
  13507. * Serializes the particle system to a JSON object.
  13508. * @returns the JSON object
  13509. */
  13510. serialize(): any;
  13511. /**
  13512. * Parse properties from a JSON object
  13513. * @param serializationObject defines the JSON object
  13514. */
  13515. parse(serializationObject: any): void;
  13516. }
  13517. }
  13518. declare module BABYLON {
  13519. /**
  13520. * Particle emitter emitting particles from a point.
  13521. * It emits the particles randomly between 2 given directions.
  13522. */
  13523. export class PointParticleEmitter implements IParticleEmitterType {
  13524. /**
  13525. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13526. */
  13527. direction1: Vector3;
  13528. /**
  13529. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13530. */
  13531. direction2: Vector3;
  13532. /**
  13533. * Creates a new instance PointParticleEmitter
  13534. */
  13535. constructor();
  13536. /**
  13537. * Called by the particle System when the direction is computed for the created particle.
  13538. * @param worldMatrix is the world matrix of the particle system
  13539. * @param directionToUpdate is the direction vector to update with the result
  13540. * @param particle is the particle we are computed the direction for
  13541. * @param isLocal defines if the direction should be set in local space
  13542. */
  13543. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13544. /**
  13545. * Called by the particle System when the position is computed for the created particle.
  13546. * @param worldMatrix is the world matrix of the particle system
  13547. * @param positionToUpdate is the position vector to update with the result
  13548. * @param particle is the particle we are computed the position for
  13549. * @param isLocal defines if the position should be set in local space
  13550. */
  13551. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13552. /**
  13553. * Clones the current emitter and returns a copy of it
  13554. * @returns the new emitter
  13555. */
  13556. clone(): PointParticleEmitter;
  13557. /**
  13558. * Called by the GPUParticleSystem to setup the update shader
  13559. * @param effect defines the update shader
  13560. */
  13561. applyToShader(effect: Effect): void;
  13562. /**
  13563. * Returns a string to use to update the GPU particles update shader
  13564. * @returns a string containng the defines string
  13565. */
  13566. getEffectDefines(): string;
  13567. /**
  13568. * Returns the string "PointParticleEmitter"
  13569. * @returns a string containing the class name
  13570. */
  13571. getClassName(): string;
  13572. /**
  13573. * Serializes the particle system to a JSON object.
  13574. * @returns the JSON object
  13575. */
  13576. serialize(): any;
  13577. /**
  13578. * Parse properties from a JSON object
  13579. * @param serializationObject defines the JSON object
  13580. */
  13581. parse(serializationObject: any): void;
  13582. }
  13583. }
  13584. declare module BABYLON {
  13585. /**
  13586. * Particle emitter emitting particles from the inside of a sphere.
  13587. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13588. */
  13589. export class SphereParticleEmitter implements IParticleEmitterType {
  13590. /**
  13591. * The radius of the emission sphere.
  13592. */
  13593. radius: number;
  13594. /**
  13595. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13596. */
  13597. radiusRange: number;
  13598. /**
  13599. * How much to randomize the particle direction [0-1].
  13600. */
  13601. directionRandomizer: number;
  13602. /**
  13603. * Creates a new instance SphereParticleEmitter
  13604. * @param radius the radius of the emission sphere (1 by default)
  13605. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13606. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13607. */
  13608. constructor(
  13609. /**
  13610. * The radius of the emission sphere.
  13611. */
  13612. radius?: number,
  13613. /**
  13614. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13615. */
  13616. radiusRange?: number,
  13617. /**
  13618. * How much to randomize the particle direction [0-1].
  13619. */
  13620. directionRandomizer?: number);
  13621. /**
  13622. * Called by the particle System when the direction is computed for the created particle.
  13623. * @param worldMatrix is the world matrix of the particle system
  13624. * @param directionToUpdate is the direction vector to update with the result
  13625. * @param particle is the particle we are computed the direction for
  13626. * @param isLocal defines if the direction should be set in local space
  13627. */
  13628. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13629. /**
  13630. * Called by the particle System when the position is computed for the created particle.
  13631. * @param worldMatrix is the world matrix of the particle system
  13632. * @param positionToUpdate is the position vector to update with the result
  13633. * @param particle is the particle we are computed the position for
  13634. * @param isLocal defines if the position should be set in local space
  13635. */
  13636. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13637. /**
  13638. * Clones the current emitter and returns a copy of it
  13639. * @returns the new emitter
  13640. */
  13641. clone(): SphereParticleEmitter;
  13642. /**
  13643. * Called by the GPUParticleSystem to setup the update shader
  13644. * @param effect defines the update shader
  13645. */
  13646. applyToShader(effect: Effect): void;
  13647. /**
  13648. * Returns a string to use to update the GPU particles update shader
  13649. * @returns a string containng the defines string
  13650. */
  13651. getEffectDefines(): string;
  13652. /**
  13653. * Returns the string "SphereParticleEmitter"
  13654. * @returns a string containing the class name
  13655. */
  13656. getClassName(): string;
  13657. /**
  13658. * Serializes the particle system to a JSON object.
  13659. * @returns the JSON object
  13660. */
  13661. serialize(): any;
  13662. /**
  13663. * Parse properties from a JSON object
  13664. * @param serializationObject defines the JSON object
  13665. */
  13666. parse(serializationObject: any): void;
  13667. }
  13668. /**
  13669. * Particle emitter emitting particles from the inside of a sphere.
  13670. * It emits the particles randomly between two vectors.
  13671. */
  13672. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13673. /**
  13674. * The min limit of the emission direction.
  13675. */
  13676. direction1: Vector3;
  13677. /**
  13678. * The max limit of the emission direction.
  13679. */
  13680. direction2: Vector3;
  13681. /**
  13682. * Creates a new instance SphereDirectedParticleEmitter
  13683. * @param radius the radius of the emission sphere (1 by default)
  13684. * @param direction1 the min limit of the emission direction (up vector by default)
  13685. * @param direction2 the max limit of the emission direction (up vector by default)
  13686. */
  13687. constructor(radius?: number,
  13688. /**
  13689. * The min limit of the emission direction.
  13690. */
  13691. direction1?: Vector3,
  13692. /**
  13693. * The max limit of the emission direction.
  13694. */
  13695. direction2?: Vector3);
  13696. /**
  13697. * Called by the particle System when the direction is computed for the created particle.
  13698. * @param worldMatrix is the world matrix of the particle system
  13699. * @param directionToUpdate is the direction vector to update with the result
  13700. * @param particle is the particle we are computed the direction for
  13701. */
  13702. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13703. /**
  13704. * Clones the current emitter and returns a copy of it
  13705. * @returns the new emitter
  13706. */
  13707. clone(): SphereDirectedParticleEmitter;
  13708. /**
  13709. * Called by the GPUParticleSystem to setup the update shader
  13710. * @param effect defines the update shader
  13711. */
  13712. applyToShader(effect: Effect): void;
  13713. /**
  13714. * Returns a string to use to update the GPU particles update shader
  13715. * @returns a string containng the defines string
  13716. */
  13717. getEffectDefines(): string;
  13718. /**
  13719. * Returns the string "SphereDirectedParticleEmitter"
  13720. * @returns a string containing the class name
  13721. */
  13722. getClassName(): string;
  13723. /**
  13724. * Serializes the particle system to a JSON object.
  13725. * @returns the JSON object
  13726. */
  13727. serialize(): any;
  13728. /**
  13729. * Parse properties from a JSON object
  13730. * @param serializationObject defines the JSON object
  13731. */
  13732. parse(serializationObject: any): void;
  13733. }
  13734. }
  13735. declare module BABYLON {
  13736. /**
  13737. * Particle emitter emitting particles from a custom list of positions.
  13738. */
  13739. export class CustomParticleEmitter implements IParticleEmitterType {
  13740. /**
  13741. * Gets or sets the position generator that will create the inital position of each particle.
  13742. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13743. */
  13744. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13745. /**
  13746. * Gets or sets the destination generator that will create the final destination of each particle.
  13747. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13748. */
  13749. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13750. /**
  13751. * Creates a new instance CustomParticleEmitter
  13752. */
  13753. constructor();
  13754. /**
  13755. * Called by the particle System when the direction is computed for the created particle.
  13756. * @param worldMatrix is the world matrix of the particle system
  13757. * @param directionToUpdate is the direction vector to update with the result
  13758. * @param particle is the particle we are computed the direction for
  13759. * @param isLocal defines if the direction should be set in local space
  13760. */
  13761. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13762. /**
  13763. * Called by the particle System when the position is computed for the created particle.
  13764. * @param worldMatrix is the world matrix of the particle system
  13765. * @param positionToUpdate is the position vector to update with the result
  13766. * @param particle is the particle we are computed the position for
  13767. * @param isLocal defines if the position should be set in local space
  13768. */
  13769. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13770. /**
  13771. * Clones the current emitter and returns a copy of it
  13772. * @returns the new emitter
  13773. */
  13774. clone(): CustomParticleEmitter;
  13775. /**
  13776. * Called by the GPUParticleSystem to setup the update shader
  13777. * @param effect defines the update shader
  13778. */
  13779. applyToShader(effect: Effect): void;
  13780. /**
  13781. * Returns a string to use to update the GPU particles update shader
  13782. * @returns a string containng the defines string
  13783. */
  13784. getEffectDefines(): string;
  13785. /**
  13786. * Returns the string "PointParticleEmitter"
  13787. * @returns a string containing the class name
  13788. */
  13789. getClassName(): string;
  13790. /**
  13791. * Serializes the particle system to a JSON object.
  13792. * @returns the JSON object
  13793. */
  13794. serialize(): any;
  13795. /**
  13796. * Parse properties from a JSON object
  13797. * @param serializationObject defines the JSON object
  13798. */
  13799. parse(serializationObject: any): void;
  13800. }
  13801. }
  13802. declare module BABYLON {
  13803. /**
  13804. * Particle emitter emitting particles from the inside of a box.
  13805. * It emits the particles randomly between 2 given directions.
  13806. */
  13807. export class MeshParticleEmitter implements IParticleEmitterType {
  13808. private _indices;
  13809. private _positions;
  13810. private _normals;
  13811. private _storedNormal;
  13812. private _mesh;
  13813. /**
  13814. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13815. */
  13816. direction1: Vector3;
  13817. /**
  13818. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13819. */
  13820. direction2: Vector3;
  13821. /**
  13822. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13823. */
  13824. useMeshNormalsForDirection: boolean;
  13825. /** Defines the mesh to use as source */
  13826. get mesh(): Nullable<AbstractMesh>;
  13827. set mesh(value: Nullable<AbstractMesh>);
  13828. /**
  13829. * Creates a new instance MeshParticleEmitter
  13830. * @param mesh defines the mesh to use as source
  13831. */
  13832. constructor(mesh?: Nullable<AbstractMesh>);
  13833. /**
  13834. * Called by the particle System when the direction is computed for the created particle.
  13835. * @param worldMatrix is the world matrix of the particle system
  13836. * @param directionToUpdate is the direction vector to update with the result
  13837. * @param particle is the particle we are computed the direction for
  13838. * @param isLocal defines if the direction should be set in local space
  13839. */
  13840. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13841. /**
  13842. * Called by the particle System when the position is computed for the created particle.
  13843. * @param worldMatrix is the world matrix of the particle system
  13844. * @param positionToUpdate is the position vector to update with the result
  13845. * @param particle is the particle we are computed the position for
  13846. * @param isLocal defines if the position should be set in local space
  13847. */
  13848. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13849. /**
  13850. * Clones the current emitter and returns a copy of it
  13851. * @returns the new emitter
  13852. */
  13853. clone(): MeshParticleEmitter;
  13854. /**
  13855. * Called by the GPUParticleSystem to setup the update shader
  13856. * @param effect defines the update shader
  13857. */
  13858. applyToShader(effect: Effect): void;
  13859. /**
  13860. * Returns a string to use to update the GPU particles update shader
  13861. * @returns a string containng the defines string
  13862. */
  13863. getEffectDefines(): string;
  13864. /**
  13865. * Returns the string "BoxParticleEmitter"
  13866. * @returns a string containing the class name
  13867. */
  13868. getClassName(): string;
  13869. /**
  13870. * Serializes the particle system to a JSON object.
  13871. * @returns the JSON object
  13872. */
  13873. serialize(): any;
  13874. /**
  13875. * Parse properties from a JSON object
  13876. * @param serializationObject defines the JSON object
  13877. * @param scene defines the hosting scene
  13878. */
  13879. parse(serializationObject: any, scene: Scene): void;
  13880. }
  13881. }
  13882. declare module BABYLON {
  13883. /**
  13884. * Interface representing a particle system in Babylon.js.
  13885. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13886. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13887. */
  13888. export interface IParticleSystem {
  13889. /**
  13890. * List of animations used by the particle system.
  13891. */
  13892. animations: Animation[];
  13893. /**
  13894. * The id of the Particle system.
  13895. */
  13896. id: string;
  13897. /**
  13898. * The name of the Particle system.
  13899. */
  13900. name: string;
  13901. /**
  13902. * The emitter represents the Mesh or position we are attaching the particle system to.
  13903. */
  13904. emitter: Nullable<AbstractMesh | Vector3>;
  13905. /**
  13906. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13907. */
  13908. isBillboardBased: boolean;
  13909. /**
  13910. * The rendering group used by the Particle system to chose when to render.
  13911. */
  13912. renderingGroupId: number;
  13913. /**
  13914. * The layer mask we are rendering the particles through.
  13915. */
  13916. layerMask: number;
  13917. /**
  13918. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13919. */
  13920. updateSpeed: number;
  13921. /**
  13922. * The amount of time the particle system is running (depends of the overall update speed).
  13923. */
  13924. targetStopDuration: number;
  13925. /**
  13926. * The texture used to render each particle. (this can be a spritesheet)
  13927. */
  13928. particleTexture: Nullable<Texture>;
  13929. /**
  13930. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13931. */
  13932. blendMode: number;
  13933. /**
  13934. * Minimum life time of emitting particles.
  13935. */
  13936. minLifeTime: number;
  13937. /**
  13938. * Maximum life time of emitting particles.
  13939. */
  13940. maxLifeTime: number;
  13941. /**
  13942. * Minimum Size of emitting particles.
  13943. */
  13944. minSize: number;
  13945. /**
  13946. * Maximum Size of emitting particles.
  13947. */
  13948. maxSize: number;
  13949. /**
  13950. * Minimum scale of emitting particles on X axis.
  13951. */
  13952. minScaleX: number;
  13953. /**
  13954. * Maximum scale of emitting particles on X axis.
  13955. */
  13956. maxScaleX: number;
  13957. /**
  13958. * Minimum scale of emitting particles on Y axis.
  13959. */
  13960. minScaleY: number;
  13961. /**
  13962. * Maximum scale of emitting particles on Y axis.
  13963. */
  13964. maxScaleY: number;
  13965. /**
  13966. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13967. */
  13968. color1: Color4;
  13969. /**
  13970. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13971. */
  13972. color2: Color4;
  13973. /**
  13974. * Color the particle will have at the end of its lifetime.
  13975. */
  13976. colorDead: Color4;
  13977. /**
  13978. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13979. */
  13980. emitRate: number;
  13981. /**
  13982. * You can use gravity if you want to give an orientation to your particles.
  13983. */
  13984. gravity: Vector3;
  13985. /**
  13986. * Minimum power of emitting particles.
  13987. */
  13988. minEmitPower: number;
  13989. /**
  13990. * Maximum power of emitting particles.
  13991. */
  13992. maxEmitPower: number;
  13993. /**
  13994. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13995. */
  13996. minAngularSpeed: number;
  13997. /**
  13998. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13999. */
  14000. maxAngularSpeed: number;
  14001. /**
  14002. * Gets or sets the minimal initial rotation in radians.
  14003. */
  14004. minInitialRotation: number;
  14005. /**
  14006. * Gets or sets the maximal initial rotation in radians.
  14007. */
  14008. maxInitialRotation: number;
  14009. /**
  14010. * The particle emitter type defines the emitter used by the particle system.
  14011. * It can be for example box, sphere, or cone...
  14012. */
  14013. particleEmitterType: Nullable<IParticleEmitterType>;
  14014. /**
  14015. * Defines the delay in milliseconds before starting the system (0 by default)
  14016. */
  14017. startDelay: number;
  14018. /**
  14019. * 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
  14020. */
  14021. preWarmCycles: number;
  14022. /**
  14023. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14024. */
  14025. preWarmStepOffset: number;
  14026. /**
  14027. * 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)
  14028. */
  14029. spriteCellChangeSpeed: number;
  14030. /**
  14031. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14032. */
  14033. startSpriteCellID: number;
  14034. /**
  14035. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14036. */
  14037. endSpriteCellID: number;
  14038. /**
  14039. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14040. */
  14041. spriteCellWidth: number;
  14042. /**
  14043. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14044. */
  14045. spriteCellHeight: number;
  14046. /**
  14047. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14048. */
  14049. spriteRandomStartCell: boolean;
  14050. /**
  14051. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14052. */
  14053. isAnimationSheetEnabled: boolean;
  14054. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14055. translationPivot: Vector2;
  14056. /**
  14057. * Gets or sets a texture used to add random noise to particle positions
  14058. */
  14059. noiseTexture: Nullable<BaseTexture>;
  14060. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14061. noiseStrength: Vector3;
  14062. /**
  14063. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14064. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14065. */
  14066. billboardMode: number;
  14067. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14068. limitVelocityDamping: number;
  14069. /**
  14070. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14071. */
  14072. beginAnimationOnStart: boolean;
  14073. /**
  14074. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14075. */
  14076. beginAnimationFrom: number;
  14077. /**
  14078. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14079. */
  14080. beginAnimationTo: number;
  14081. /**
  14082. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14083. */
  14084. beginAnimationLoop: boolean;
  14085. /**
  14086. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14087. */
  14088. disposeOnStop: boolean;
  14089. /**
  14090. * Specifies if the particles are updated in emitter local space or world space
  14091. */
  14092. isLocal: boolean;
  14093. /** Snippet ID if the particle system was created from the snippet server */
  14094. snippetId: string;
  14095. /**
  14096. * Gets the maximum number of particles active at the same time.
  14097. * @returns The max number of active particles.
  14098. */
  14099. getCapacity(): number;
  14100. /**
  14101. * Gets the number of particles active at the same time.
  14102. * @returns The number of active particles.
  14103. */
  14104. getActiveCount(): number;
  14105. /**
  14106. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14107. * @returns True if it has been started, otherwise false.
  14108. */
  14109. isStarted(): boolean;
  14110. /**
  14111. * Animates the particle system for this frame.
  14112. */
  14113. animate(): void;
  14114. /**
  14115. * Renders the particle system in its current state.
  14116. * @returns the current number of particles
  14117. */
  14118. render(): number;
  14119. /**
  14120. * Dispose the particle system and frees its associated resources.
  14121. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14122. */
  14123. dispose(disposeTexture?: boolean): void;
  14124. /**
  14125. * An event triggered when the system is disposed
  14126. */
  14127. onDisposeObservable: Observable<IParticleSystem>;
  14128. /**
  14129. * Clones the particle system.
  14130. * @param name The name of the cloned object
  14131. * @param newEmitter The new emitter to use
  14132. * @returns the cloned particle system
  14133. */
  14134. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14135. /**
  14136. * Serializes the particle system to a JSON object
  14137. * @param serializeTexture defines if the texture must be serialized as well
  14138. * @returns the JSON object
  14139. */
  14140. serialize(serializeTexture: boolean): any;
  14141. /**
  14142. * Rebuild the particle system
  14143. */
  14144. rebuild(): void;
  14145. /** Force the system to rebuild all gradients that need to be resync */
  14146. forceRefreshGradients(): void;
  14147. /**
  14148. * Starts the particle system and begins to emit
  14149. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14150. */
  14151. start(delay?: number): void;
  14152. /**
  14153. * Stops the particle system.
  14154. */
  14155. stop(): void;
  14156. /**
  14157. * Remove all active particles
  14158. */
  14159. reset(): void;
  14160. /**
  14161. * Gets a boolean indicating that the system is stopping
  14162. * @returns true if the system is currently stopping
  14163. */
  14164. isStopping(): boolean;
  14165. /**
  14166. * Is this system ready to be used/rendered
  14167. * @return true if the system is ready
  14168. */
  14169. isReady(): boolean;
  14170. /**
  14171. * Returns the string "ParticleSystem"
  14172. * @returns a string containing the class name
  14173. */
  14174. getClassName(): string;
  14175. /**
  14176. * Gets the custom effect used to render the particles
  14177. * @param blendMode Blend mode for which the effect should be retrieved
  14178. * @returns The effect
  14179. */
  14180. getCustomEffect(blendMode: number): Nullable<Effect>;
  14181. /**
  14182. * Sets the custom effect used to render the particles
  14183. * @param effect The effect to set
  14184. * @param blendMode Blend mode for which the effect should be set
  14185. */
  14186. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14187. /**
  14188. * Fill the defines array according to the current settings of the particle system
  14189. * @param defines Array to be updated
  14190. * @param blendMode blend mode to take into account when updating the array
  14191. */
  14192. fillDefines(defines: Array<string>, blendMode: number): void;
  14193. /**
  14194. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14195. * @param uniforms Uniforms array to fill
  14196. * @param attributes Attributes array to fill
  14197. * @param samplers Samplers array to fill
  14198. */
  14199. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14200. /**
  14201. * Observable that will be called just before the particles are drawn
  14202. */
  14203. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14204. /**
  14205. * Gets the name of the particle vertex shader
  14206. */
  14207. vertexShaderName: string;
  14208. /**
  14209. * Adds a new color gradient
  14210. * @param gradient defines the gradient to use (between 0 and 1)
  14211. * @param color1 defines the color to affect to the specified gradient
  14212. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14213. * @returns the current particle system
  14214. */
  14215. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14216. /**
  14217. * Remove a specific color gradient
  14218. * @param gradient defines the gradient to remove
  14219. * @returns the current particle system
  14220. */
  14221. removeColorGradient(gradient: number): IParticleSystem;
  14222. /**
  14223. * Adds a new size gradient
  14224. * @param gradient defines the gradient to use (between 0 and 1)
  14225. * @param factor defines the size factor to affect to the specified gradient
  14226. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14227. * @returns the current particle system
  14228. */
  14229. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14230. /**
  14231. * Remove a specific size gradient
  14232. * @param gradient defines the gradient to remove
  14233. * @returns the current particle system
  14234. */
  14235. removeSizeGradient(gradient: number): IParticleSystem;
  14236. /**
  14237. * Gets the current list of color gradients.
  14238. * You must use addColorGradient and removeColorGradient to udpate this list
  14239. * @returns the list of color gradients
  14240. */
  14241. getColorGradients(): Nullable<Array<ColorGradient>>;
  14242. /**
  14243. * Gets the current list of size gradients.
  14244. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14245. * @returns the list of size gradients
  14246. */
  14247. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14248. /**
  14249. * Gets the current list of angular speed gradients.
  14250. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14251. * @returns the list of angular speed gradients
  14252. */
  14253. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14254. /**
  14255. * Adds a new angular speed gradient
  14256. * @param gradient defines the gradient to use (between 0 and 1)
  14257. * @param factor defines the angular speed to affect to the specified gradient
  14258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14259. * @returns the current particle system
  14260. */
  14261. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14262. /**
  14263. * Remove a specific angular speed gradient
  14264. * @param gradient defines the gradient to remove
  14265. * @returns the current particle system
  14266. */
  14267. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14268. /**
  14269. * Gets the current list of velocity gradients.
  14270. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14271. * @returns the list of velocity gradients
  14272. */
  14273. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14274. /**
  14275. * Adds a new velocity gradient
  14276. * @param gradient defines the gradient to use (between 0 and 1)
  14277. * @param factor defines the velocity to affect to the specified gradient
  14278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14279. * @returns the current particle system
  14280. */
  14281. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14282. /**
  14283. * Remove a specific velocity gradient
  14284. * @param gradient defines the gradient to remove
  14285. * @returns the current particle system
  14286. */
  14287. removeVelocityGradient(gradient: number): IParticleSystem;
  14288. /**
  14289. * Gets the current list of limit velocity gradients.
  14290. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14291. * @returns the list of limit velocity gradients
  14292. */
  14293. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14294. /**
  14295. * Adds a new limit velocity gradient
  14296. * @param gradient defines the gradient to use (between 0 and 1)
  14297. * @param factor defines the limit velocity to affect to the specified gradient
  14298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14299. * @returns the current particle system
  14300. */
  14301. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14302. /**
  14303. * Remove a specific limit velocity gradient
  14304. * @param gradient defines the gradient to remove
  14305. * @returns the current particle system
  14306. */
  14307. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14308. /**
  14309. * Adds a new drag gradient
  14310. * @param gradient defines the gradient to use (between 0 and 1)
  14311. * @param factor defines the drag to affect to the specified gradient
  14312. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14313. * @returns the current particle system
  14314. */
  14315. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14316. /**
  14317. * Remove a specific drag gradient
  14318. * @param gradient defines the gradient to remove
  14319. * @returns the current particle system
  14320. */
  14321. removeDragGradient(gradient: number): IParticleSystem;
  14322. /**
  14323. * Gets the current list of drag gradients.
  14324. * You must use addDragGradient and removeDragGradient to udpate this list
  14325. * @returns the list of drag gradients
  14326. */
  14327. getDragGradients(): Nullable<Array<FactorGradient>>;
  14328. /**
  14329. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14330. * @param gradient defines the gradient to use (between 0 and 1)
  14331. * @param factor defines the emit rate to affect to the specified gradient
  14332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14333. * @returns the current particle system
  14334. */
  14335. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14336. /**
  14337. * Remove a specific emit rate gradient
  14338. * @param gradient defines the gradient to remove
  14339. * @returns the current particle system
  14340. */
  14341. removeEmitRateGradient(gradient: number): IParticleSystem;
  14342. /**
  14343. * Gets the current list of emit rate gradients.
  14344. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14345. * @returns the list of emit rate gradients
  14346. */
  14347. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14348. /**
  14349. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14350. * @param gradient defines the gradient to use (between 0 and 1)
  14351. * @param factor defines the start size to affect to the specified gradient
  14352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14353. * @returns the current particle system
  14354. */
  14355. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14356. /**
  14357. * Remove a specific start size gradient
  14358. * @param gradient defines the gradient to remove
  14359. * @returns the current particle system
  14360. */
  14361. removeStartSizeGradient(gradient: number): IParticleSystem;
  14362. /**
  14363. * Gets the current list of start size gradients.
  14364. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14365. * @returns the list of start size gradients
  14366. */
  14367. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14368. /**
  14369. * Adds a new life time gradient
  14370. * @param gradient defines the gradient to use (between 0 and 1)
  14371. * @param factor defines the life time factor to affect to the specified gradient
  14372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14373. * @returns the current particle system
  14374. */
  14375. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14376. /**
  14377. * Remove a specific life time gradient
  14378. * @param gradient defines the gradient to remove
  14379. * @returns the current particle system
  14380. */
  14381. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14382. /**
  14383. * Gets the current list of life time gradients.
  14384. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14385. * @returns the list of life time gradients
  14386. */
  14387. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14388. /**
  14389. * Gets the current list of color gradients.
  14390. * You must use addColorGradient and removeColorGradient to udpate this list
  14391. * @returns the list of color gradients
  14392. */
  14393. getColorGradients(): Nullable<Array<ColorGradient>>;
  14394. /**
  14395. * Adds a new ramp gradient used to remap particle colors
  14396. * @param gradient defines the gradient to use (between 0 and 1)
  14397. * @param color defines the color to affect to the specified gradient
  14398. * @returns the current particle system
  14399. */
  14400. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14401. /**
  14402. * Gets the current list of ramp gradients.
  14403. * You must use addRampGradient and removeRampGradient to udpate this list
  14404. * @returns the list of ramp gradients
  14405. */
  14406. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14407. /** Gets or sets a boolean indicating that ramp gradients must be used
  14408. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14409. */
  14410. useRampGradients: boolean;
  14411. /**
  14412. * Adds a new color remap gradient
  14413. * @param gradient defines the gradient to use (between 0 and 1)
  14414. * @param min defines the color remap minimal range
  14415. * @param max defines the color remap maximal range
  14416. * @returns the current particle system
  14417. */
  14418. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14419. /**
  14420. * Gets the current list of color remap gradients.
  14421. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14422. * @returns the list of color remap gradients
  14423. */
  14424. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14425. /**
  14426. * Adds a new alpha remap gradient
  14427. * @param gradient defines the gradient to use (between 0 and 1)
  14428. * @param min defines the alpha remap minimal range
  14429. * @param max defines the alpha remap maximal range
  14430. * @returns the current particle system
  14431. */
  14432. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14433. /**
  14434. * Gets the current list of alpha remap gradients.
  14435. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14436. * @returns the list of alpha remap gradients
  14437. */
  14438. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14439. /**
  14440. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14443. * @returns the emitter
  14444. */
  14445. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14446. /**
  14447. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14448. * @param radius The radius of the hemisphere to emit from
  14449. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14450. * @returns the emitter
  14451. */
  14452. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14453. /**
  14454. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14455. * @param radius The radius of the sphere to emit from
  14456. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14457. * @returns the emitter
  14458. */
  14459. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14460. /**
  14461. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14462. * @param radius The radius of the sphere to emit from
  14463. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14464. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14465. * @returns the emitter
  14466. */
  14467. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14468. /**
  14469. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14470. * @param radius The radius of the emission cylinder
  14471. * @param height The height of the emission cylinder
  14472. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14473. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14474. * @returns the emitter
  14475. */
  14476. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14477. /**
  14478. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14479. * @param radius The radius of the cylinder to emit from
  14480. * @param height The height of the emission cylinder
  14481. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14482. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14483. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14484. * @returns the emitter
  14485. */
  14486. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14487. /**
  14488. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14489. * @param radius The radius of the cone to emit from
  14490. * @param angle The base angle of the cone
  14491. * @returns the emitter
  14492. */
  14493. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14494. /**
  14495. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14496. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14497. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14498. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14499. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14500. * @returns the emitter
  14501. */
  14502. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14503. /**
  14504. * Get hosting scene
  14505. * @returns the scene
  14506. */
  14507. getScene(): Scene;
  14508. }
  14509. }
  14510. declare module BABYLON {
  14511. /**
  14512. * 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.
  14513. * @see https://doc.babylonjs.com/how_to/transformnode
  14514. */
  14515. export class TransformNode extends Node {
  14516. /**
  14517. * Object will not rotate to face the camera
  14518. */
  14519. static BILLBOARDMODE_NONE: number;
  14520. /**
  14521. * Object will rotate to face the camera but only on the x axis
  14522. */
  14523. static BILLBOARDMODE_X: number;
  14524. /**
  14525. * Object will rotate to face the camera but only on the y axis
  14526. */
  14527. static BILLBOARDMODE_Y: number;
  14528. /**
  14529. * Object will rotate to face the camera but only on the z axis
  14530. */
  14531. static BILLBOARDMODE_Z: number;
  14532. /**
  14533. * Object will rotate to face the camera
  14534. */
  14535. static BILLBOARDMODE_ALL: number;
  14536. /**
  14537. * Object will rotate to face the camera's position instead of orientation
  14538. */
  14539. static BILLBOARDMODE_USE_POSITION: number;
  14540. private _forward;
  14541. private _forwardInverted;
  14542. private _up;
  14543. private _right;
  14544. private _rightInverted;
  14545. private _position;
  14546. private _rotation;
  14547. private _rotationQuaternion;
  14548. protected _scaling: Vector3;
  14549. protected _isDirty: boolean;
  14550. private _transformToBoneReferal;
  14551. private _isAbsoluteSynced;
  14552. private _billboardMode;
  14553. /**
  14554. * Gets or sets the billboard mode. Default is 0.
  14555. *
  14556. * | Value | Type | Description |
  14557. * | --- | --- | --- |
  14558. * | 0 | BILLBOARDMODE_NONE | |
  14559. * | 1 | BILLBOARDMODE_X | |
  14560. * | 2 | BILLBOARDMODE_Y | |
  14561. * | 4 | BILLBOARDMODE_Z | |
  14562. * | 7 | BILLBOARDMODE_ALL | |
  14563. *
  14564. */
  14565. get billboardMode(): number;
  14566. set billboardMode(value: number);
  14567. private _preserveParentRotationForBillboard;
  14568. /**
  14569. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14570. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14571. */
  14572. get preserveParentRotationForBillboard(): boolean;
  14573. set preserveParentRotationForBillboard(value: boolean);
  14574. /**
  14575. * 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
  14576. */
  14577. scalingDeterminant: number;
  14578. private _infiniteDistance;
  14579. /**
  14580. * Gets or sets the distance of the object to max, often used by skybox
  14581. */
  14582. get infiniteDistance(): boolean;
  14583. set infiniteDistance(value: boolean);
  14584. /**
  14585. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14586. * By default the system will update normals to compensate
  14587. */
  14588. ignoreNonUniformScaling: boolean;
  14589. /**
  14590. * 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
  14591. */
  14592. reIntegrateRotationIntoRotationQuaternion: boolean;
  14593. /** @hidden */
  14594. _poseMatrix: Nullable<Matrix>;
  14595. /** @hidden */
  14596. _localMatrix: Matrix;
  14597. private _usePivotMatrix;
  14598. private _absolutePosition;
  14599. private _absoluteScaling;
  14600. private _absoluteRotationQuaternion;
  14601. private _pivotMatrix;
  14602. private _pivotMatrixInverse;
  14603. protected _postMultiplyPivotMatrix: boolean;
  14604. protected _isWorldMatrixFrozen: boolean;
  14605. /** @hidden */
  14606. _indexInSceneTransformNodesArray: number;
  14607. /**
  14608. * An event triggered after the world matrix is updated
  14609. */
  14610. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14611. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14612. /**
  14613. * Gets a string identifying the name of the class
  14614. * @returns "TransformNode" string
  14615. */
  14616. getClassName(): string;
  14617. /**
  14618. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14619. */
  14620. get position(): Vector3;
  14621. set position(newPosition: Vector3);
  14622. /**
  14623. * 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)).
  14624. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14625. */
  14626. get rotation(): Vector3;
  14627. set rotation(newRotation: Vector3);
  14628. /**
  14629. * 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)).
  14630. */
  14631. get scaling(): Vector3;
  14632. set scaling(newScaling: Vector3);
  14633. /**
  14634. * 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).
  14635. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14636. */
  14637. get rotationQuaternion(): Nullable<Quaternion>;
  14638. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14639. /**
  14640. * The forward direction of that transform in world space.
  14641. */
  14642. get forward(): Vector3;
  14643. /**
  14644. * The up direction of that transform in world space.
  14645. */
  14646. get up(): Vector3;
  14647. /**
  14648. * The right direction of that transform in world space.
  14649. */
  14650. get right(): Vector3;
  14651. /**
  14652. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14653. * @param matrix the matrix to copy the pose from
  14654. * @returns this TransformNode.
  14655. */
  14656. updatePoseMatrix(matrix: Matrix): TransformNode;
  14657. /**
  14658. * Returns the mesh Pose matrix.
  14659. * @returns the pose matrix
  14660. */
  14661. getPoseMatrix(): Matrix;
  14662. /** @hidden */
  14663. _isSynchronized(): boolean;
  14664. /** @hidden */
  14665. _initCache(): void;
  14666. /**
  14667. * Flag the transform node as dirty (Forcing it to update everything)
  14668. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14669. * @returns this transform node
  14670. */
  14671. markAsDirty(property: string): TransformNode;
  14672. /**
  14673. * Returns the current mesh absolute position.
  14674. * Returns a Vector3.
  14675. */
  14676. get absolutePosition(): Vector3;
  14677. /**
  14678. * Returns the current mesh absolute scaling.
  14679. * Returns a Vector3.
  14680. */
  14681. get absoluteScaling(): Vector3;
  14682. /**
  14683. * Returns the current mesh absolute rotation.
  14684. * Returns a Quaternion.
  14685. */
  14686. get absoluteRotationQuaternion(): Quaternion;
  14687. /**
  14688. * Sets a new matrix to apply before all other transformation
  14689. * @param matrix defines the transform matrix
  14690. * @returns the current TransformNode
  14691. */
  14692. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14693. /**
  14694. * Sets a new pivot matrix to the current node
  14695. * @param matrix defines the new pivot matrix to use
  14696. * @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
  14697. * @returns the current TransformNode
  14698. */
  14699. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14700. /**
  14701. * Returns the mesh pivot matrix.
  14702. * Default : Identity.
  14703. * @returns the matrix
  14704. */
  14705. getPivotMatrix(): Matrix;
  14706. /**
  14707. * Instantiate (when possible) or clone that node with its hierarchy
  14708. * @param newParent defines the new parent to use for the instance (or clone)
  14709. * @param options defines options to configure how copy is done
  14710. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14711. * @returns an instance (or a clone) of the current node with its hiearchy
  14712. */
  14713. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14714. doNotInstantiate: boolean;
  14715. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14716. /**
  14717. * Prevents the World matrix to be computed any longer
  14718. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14719. * @returns the TransformNode.
  14720. */
  14721. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14722. /**
  14723. * Allows back the World matrix computation.
  14724. * @returns the TransformNode.
  14725. */
  14726. unfreezeWorldMatrix(): this;
  14727. /**
  14728. * True if the World matrix has been frozen.
  14729. */
  14730. get isWorldMatrixFrozen(): boolean;
  14731. /**
  14732. * Retuns the mesh absolute position in the World.
  14733. * @returns a Vector3.
  14734. */
  14735. getAbsolutePosition(): Vector3;
  14736. /**
  14737. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14738. * @param absolutePosition the absolute position to set
  14739. * @returns the TransformNode.
  14740. */
  14741. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14742. /**
  14743. * Sets the mesh position in its local space.
  14744. * @param vector3 the position to set in localspace
  14745. * @returns the TransformNode.
  14746. */
  14747. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14748. /**
  14749. * Returns the mesh position in the local space from the current World matrix values.
  14750. * @returns a new Vector3.
  14751. */
  14752. getPositionExpressedInLocalSpace(): Vector3;
  14753. /**
  14754. * Translates the mesh along the passed Vector3 in its local space.
  14755. * @param vector3 the distance to translate in localspace
  14756. * @returns the TransformNode.
  14757. */
  14758. locallyTranslate(vector3: Vector3): TransformNode;
  14759. private static _lookAtVectorCache;
  14760. /**
  14761. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14762. * @param targetPoint the position (must be in same space as current mesh) to look at
  14763. * @param yawCor optional yaw (y-axis) correction in radians
  14764. * @param pitchCor optional pitch (x-axis) correction in radians
  14765. * @param rollCor optional roll (z-axis) correction in radians
  14766. * @param space the choosen space of the target
  14767. * @returns the TransformNode.
  14768. */
  14769. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14770. /**
  14771. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14772. * This Vector3 is expressed in the World space.
  14773. * @param localAxis axis to rotate
  14774. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14775. */
  14776. getDirection(localAxis: Vector3): Vector3;
  14777. /**
  14778. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14779. * localAxis is expressed in the mesh local space.
  14780. * result is computed in the Wordl space from the mesh World matrix.
  14781. * @param localAxis axis to rotate
  14782. * @param result the resulting transformnode
  14783. * @returns this TransformNode.
  14784. */
  14785. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14786. /**
  14787. * Sets this transform node rotation to the given local axis.
  14788. * @param localAxis the axis in local space
  14789. * @param yawCor optional yaw (y-axis) correction in radians
  14790. * @param pitchCor optional pitch (x-axis) correction in radians
  14791. * @param rollCor optional roll (z-axis) correction in radians
  14792. * @returns this TransformNode
  14793. */
  14794. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14795. /**
  14796. * Sets a new pivot point to the current node
  14797. * @param point defines the new pivot point to use
  14798. * @param space defines if the point is in world or local space (local by default)
  14799. * @returns the current TransformNode
  14800. */
  14801. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14802. /**
  14803. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14804. * @returns the pivot point
  14805. */
  14806. getPivotPoint(): Vector3;
  14807. /**
  14808. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14809. * @param result the vector3 to store the result
  14810. * @returns this TransformNode.
  14811. */
  14812. getPivotPointToRef(result: Vector3): TransformNode;
  14813. /**
  14814. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14815. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14816. */
  14817. getAbsolutePivotPoint(): Vector3;
  14818. /**
  14819. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14820. * @param result vector3 to store the result
  14821. * @returns this TransformNode.
  14822. */
  14823. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14824. /**
  14825. * Defines the passed node as the parent of the current node.
  14826. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14827. * @see https://doc.babylonjs.com/how_to/parenting
  14828. * @param node the node ot set as the parent
  14829. * @returns this TransformNode.
  14830. */
  14831. setParent(node: Nullable<Node>): TransformNode;
  14832. private _nonUniformScaling;
  14833. /**
  14834. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14835. */
  14836. get nonUniformScaling(): boolean;
  14837. /** @hidden */
  14838. _updateNonUniformScalingState(value: boolean): boolean;
  14839. /**
  14840. * Attach the current TransformNode to another TransformNode associated with a bone
  14841. * @param bone Bone affecting the TransformNode
  14842. * @param affectedTransformNode TransformNode associated with the bone
  14843. * @returns this object
  14844. */
  14845. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14846. /**
  14847. * Detach the transform node if its associated with a bone
  14848. * @returns this object
  14849. */
  14850. detachFromBone(): TransformNode;
  14851. private static _rotationAxisCache;
  14852. /**
  14853. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14854. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14855. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14856. * The passed axis is also normalized.
  14857. * @param axis the axis to rotate around
  14858. * @param amount the amount to rotate in radians
  14859. * @param space Space to rotate in (Default: local)
  14860. * @returns the TransformNode.
  14861. */
  14862. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14863. /**
  14864. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14865. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14866. * The passed axis is also normalized. .
  14867. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14868. * @param point the point to rotate around
  14869. * @param axis the axis to rotate around
  14870. * @param amount the amount to rotate in radians
  14871. * @returns the TransformNode
  14872. */
  14873. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14874. /**
  14875. * Translates the mesh along the axis vector for the passed distance in the given space.
  14876. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14877. * @param axis the axis to translate in
  14878. * @param distance the distance to translate
  14879. * @param space Space to rotate in (Default: local)
  14880. * @returns the TransformNode.
  14881. */
  14882. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14883. /**
  14884. * Adds a rotation step to the mesh current rotation.
  14885. * x, y, z are Euler angles expressed in radians.
  14886. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14887. * This means this rotation is made in the mesh local space only.
  14888. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14889. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14890. * ```javascript
  14891. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14892. * ```
  14893. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14894. * 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.
  14895. * @param x Rotation to add
  14896. * @param y Rotation to add
  14897. * @param z Rotation to add
  14898. * @returns the TransformNode.
  14899. */
  14900. addRotation(x: number, y: number, z: number): TransformNode;
  14901. /**
  14902. * @hidden
  14903. */
  14904. protected _getEffectiveParent(): Nullable<Node>;
  14905. /**
  14906. * Computes the world matrix of the node
  14907. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14908. * @returns the world matrix
  14909. */
  14910. computeWorldMatrix(force?: boolean): Matrix;
  14911. /**
  14912. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14913. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14914. */
  14915. resetLocalMatrix(independentOfChildren?: boolean): void;
  14916. protected _afterComputeWorldMatrix(): void;
  14917. /**
  14918. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14919. * @param func callback function to add
  14920. *
  14921. * @returns the TransformNode.
  14922. */
  14923. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14924. /**
  14925. * Removes a registered callback function.
  14926. * @param func callback function to remove
  14927. * @returns the TransformNode.
  14928. */
  14929. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14930. /**
  14931. * Gets the position of the current mesh in camera space
  14932. * @param camera defines the camera to use
  14933. * @returns a position
  14934. */
  14935. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14936. /**
  14937. * Returns the distance from the mesh to the active camera
  14938. * @param camera defines the camera to use
  14939. * @returns the distance
  14940. */
  14941. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14942. /**
  14943. * Clone the current transform node
  14944. * @param name Name of the new clone
  14945. * @param newParent New parent for the clone
  14946. * @param doNotCloneChildren Do not clone children hierarchy
  14947. * @returns the new transform node
  14948. */
  14949. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14950. /**
  14951. * Serializes the objects information.
  14952. * @param currentSerializationObject defines the object to serialize in
  14953. * @returns the serialized object
  14954. */
  14955. serialize(currentSerializationObject?: any): any;
  14956. /**
  14957. * Returns a new TransformNode object parsed from the source provided.
  14958. * @param parsedTransformNode is the source.
  14959. * @param scene the scne the object belongs to
  14960. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14961. * @returns a new TransformNode object parsed from the source provided.
  14962. */
  14963. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14964. /**
  14965. * Get all child-transformNodes of this node
  14966. * @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
  14967. * @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
  14968. * @returns an array of TransformNode
  14969. */
  14970. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14971. /**
  14972. * Releases resources associated with this transform node.
  14973. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14974. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14975. */
  14976. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14977. /**
  14978. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14979. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14980. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14981. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14982. * @returns the current mesh
  14983. */
  14984. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14985. private _syncAbsoluteScalingAndRotation;
  14986. }
  14987. }
  14988. declare module BABYLON {
  14989. /**
  14990. * Class used to override all child animations of a given target
  14991. */
  14992. export class AnimationPropertiesOverride {
  14993. /**
  14994. * Gets or sets a value indicating if animation blending must be used
  14995. */
  14996. enableBlending: boolean;
  14997. /**
  14998. * Gets or sets the blending speed to use when enableBlending is true
  14999. */
  15000. blendingSpeed: number;
  15001. /**
  15002. * Gets or sets the default loop mode to use
  15003. */
  15004. loopMode: number;
  15005. }
  15006. }
  15007. declare module BABYLON {
  15008. /**
  15009. * Class used to store bone information
  15010. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15011. */
  15012. export class Bone extends Node {
  15013. /**
  15014. * defines the bone name
  15015. */
  15016. name: string;
  15017. private static _tmpVecs;
  15018. private static _tmpQuat;
  15019. private static _tmpMats;
  15020. /**
  15021. * Gets the list of child bones
  15022. */
  15023. children: Bone[];
  15024. /** Gets the animations associated with this bone */
  15025. animations: Animation[];
  15026. /**
  15027. * Gets or sets bone length
  15028. */
  15029. length: number;
  15030. /**
  15031. * @hidden Internal only
  15032. * Set this value to map this bone to a different index in the transform matrices
  15033. * Set this value to -1 to exclude the bone from the transform matrices
  15034. */
  15035. _index: Nullable<number>;
  15036. private _skeleton;
  15037. private _localMatrix;
  15038. private _restPose;
  15039. private _baseMatrix;
  15040. private _absoluteTransform;
  15041. private _invertedAbsoluteTransform;
  15042. private _parent;
  15043. private _scalingDeterminant;
  15044. private _worldTransform;
  15045. private _localScaling;
  15046. private _localRotation;
  15047. private _localPosition;
  15048. private _needToDecompose;
  15049. private _needToCompose;
  15050. /** @hidden */
  15051. _linkedTransformNode: Nullable<TransformNode>;
  15052. /** @hidden */
  15053. _waitingTransformNodeId: Nullable<string>;
  15054. /** @hidden */
  15055. get _matrix(): Matrix;
  15056. /** @hidden */
  15057. set _matrix(value: Matrix);
  15058. /**
  15059. * Create a new bone
  15060. * @param name defines the bone name
  15061. * @param skeleton defines the parent skeleton
  15062. * @param parentBone defines the parent (can be null if the bone is the root)
  15063. * @param localMatrix defines the local matrix
  15064. * @param restPose defines the rest pose matrix
  15065. * @param baseMatrix defines the base matrix
  15066. * @param index defines index of the bone in the hiearchy
  15067. */
  15068. constructor(
  15069. /**
  15070. * defines the bone name
  15071. */
  15072. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15073. /**
  15074. * Gets the current object class name.
  15075. * @return the class name
  15076. */
  15077. getClassName(): string;
  15078. /**
  15079. * Gets the parent skeleton
  15080. * @returns a skeleton
  15081. */
  15082. getSkeleton(): Skeleton;
  15083. /**
  15084. * Gets parent bone
  15085. * @returns a bone or null if the bone is the root of the bone hierarchy
  15086. */
  15087. getParent(): Nullable<Bone>;
  15088. /**
  15089. * Returns an array containing the root bones
  15090. * @returns an array containing the root bones
  15091. */
  15092. getChildren(): Array<Bone>;
  15093. /**
  15094. * Gets the node index in matrix array generated for rendering
  15095. * @returns the node index
  15096. */
  15097. getIndex(): number;
  15098. /**
  15099. * Sets the parent bone
  15100. * @param parent defines the parent (can be null if the bone is the root)
  15101. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15102. */
  15103. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15104. /**
  15105. * Gets the local matrix
  15106. * @returns a matrix
  15107. */
  15108. getLocalMatrix(): Matrix;
  15109. /**
  15110. * Gets the base matrix (initial matrix which remains unchanged)
  15111. * @returns a matrix
  15112. */
  15113. getBaseMatrix(): Matrix;
  15114. /**
  15115. * Gets the rest pose matrix
  15116. * @returns a matrix
  15117. */
  15118. getRestPose(): Matrix;
  15119. /**
  15120. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15121. */
  15122. getWorldMatrix(): Matrix;
  15123. /**
  15124. * Sets the local matrix to rest pose matrix
  15125. */
  15126. returnToRest(): void;
  15127. /**
  15128. * Gets the inverse of the absolute transform matrix.
  15129. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15130. * @returns a matrix
  15131. */
  15132. getInvertedAbsoluteTransform(): Matrix;
  15133. /**
  15134. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15135. * @returns a matrix
  15136. */
  15137. getAbsoluteTransform(): Matrix;
  15138. /**
  15139. * Links with the given transform node.
  15140. * The local matrix of this bone is copied from the transform node every frame.
  15141. * @param transformNode defines the transform node to link to
  15142. */
  15143. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15144. /**
  15145. * Gets the node used to drive the bone's transformation
  15146. * @returns a transform node or null
  15147. */
  15148. getTransformNode(): Nullable<TransformNode>;
  15149. /** Gets or sets current position (in local space) */
  15150. get position(): Vector3;
  15151. set position(newPosition: Vector3);
  15152. /** Gets or sets current rotation (in local space) */
  15153. get rotation(): Vector3;
  15154. set rotation(newRotation: Vector3);
  15155. /** Gets or sets current rotation quaternion (in local space) */
  15156. get rotationQuaternion(): Quaternion;
  15157. set rotationQuaternion(newRotation: Quaternion);
  15158. /** Gets or sets current scaling (in local space) */
  15159. get scaling(): Vector3;
  15160. set scaling(newScaling: Vector3);
  15161. /**
  15162. * Gets the animation properties override
  15163. */
  15164. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15165. private _decompose;
  15166. private _compose;
  15167. /**
  15168. * Update the base and local matrices
  15169. * @param matrix defines the new base or local matrix
  15170. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15171. * @param updateLocalMatrix defines if the local matrix should be updated
  15172. */
  15173. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15174. /** @hidden */
  15175. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15176. /**
  15177. * Flag the bone as dirty (Forcing it to update everything)
  15178. */
  15179. markAsDirty(): void;
  15180. /** @hidden */
  15181. _markAsDirtyAndCompose(): void;
  15182. private _markAsDirtyAndDecompose;
  15183. /**
  15184. * Translate the bone in local or world space
  15185. * @param vec The amount to translate the bone
  15186. * @param space The space that the translation is in
  15187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15188. */
  15189. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15190. /**
  15191. * Set the postion of the bone in local or world space
  15192. * @param position The position to set the bone
  15193. * @param space The space that the position is in
  15194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15195. */
  15196. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15197. /**
  15198. * Set the absolute position of the bone (world space)
  15199. * @param position The position to set the bone
  15200. * @param mesh The mesh that this bone is attached to
  15201. */
  15202. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15203. /**
  15204. * Scale the bone on the x, y and z axes (in local space)
  15205. * @param x The amount to scale the bone on the x axis
  15206. * @param y The amount to scale the bone on the y axis
  15207. * @param z The amount to scale the bone on the z axis
  15208. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15209. */
  15210. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15211. /**
  15212. * Set the bone scaling in local space
  15213. * @param scale defines the scaling vector
  15214. */
  15215. setScale(scale: Vector3): void;
  15216. /**
  15217. * Gets the current scaling in local space
  15218. * @returns the current scaling vector
  15219. */
  15220. getScale(): Vector3;
  15221. /**
  15222. * Gets the current scaling in local space and stores it in a target vector
  15223. * @param result defines the target vector
  15224. */
  15225. getScaleToRef(result: Vector3): void;
  15226. /**
  15227. * Set the yaw, pitch, and roll of the bone in local or world space
  15228. * @param yaw The rotation of the bone on the y axis
  15229. * @param pitch The rotation of the bone on the x axis
  15230. * @param roll The rotation of the bone on the z axis
  15231. * @param space The space that the axes of rotation are in
  15232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15233. */
  15234. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15235. /**
  15236. * Add a rotation to the bone on an axis in local or world space
  15237. * @param axis The axis to rotate the bone on
  15238. * @param amount The amount to rotate the bone
  15239. * @param space The space that the axis is in
  15240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15241. */
  15242. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15243. /**
  15244. * Set the rotation of the bone to a particular axis angle in local or world space
  15245. * @param axis The axis to rotate the bone on
  15246. * @param angle The angle that the bone should be rotated to
  15247. * @param space The space that the axis is in
  15248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15249. */
  15250. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15251. /**
  15252. * Set the euler rotation of the bone in local of world space
  15253. * @param rotation The euler rotation that the bone should be set to
  15254. * @param space The space that the rotation is in
  15255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15256. */
  15257. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15258. /**
  15259. * Set the quaternion rotation of the bone in local of world space
  15260. * @param quat The quaternion rotation that the bone should be set to
  15261. * @param space The space that the rotation is in
  15262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15263. */
  15264. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15265. /**
  15266. * Set the rotation matrix of the bone in local of world space
  15267. * @param rotMat The rotation matrix that the bone should be set to
  15268. * @param space The space that the rotation is in
  15269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15270. */
  15271. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15272. private _rotateWithMatrix;
  15273. private _getNegativeRotationToRef;
  15274. /**
  15275. * Get the position of the bone in local or world space
  15276. * @param space The space that the returned position is in
  15277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15278. * @returns The position of the bone
  15279. */
  15280. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15281. /**
  15282. * Copy the position of the bone to a vector3 in local or world space
  15283. * @param space The space that the returned position is in
  15284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15285. * @param result The vector3 to copy the position to
  15286. */
  15287. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15288. /**
  15289. * Get the absolute position of the bone (world space)
  15290. * @param mesh The mesh that this bone is attached to
  15291. * @returns The absolute position of the bone
  15292. */
  15293. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15294. /**
  15295. * Copy the absolute position of the bone (world space) to the result param
  15296. * @param mesh The mesh that this bone is attached to
  15297. * @param result The vector3 to copy the absolute position to
  15298. */
  15299. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15300. /**
  15301. * Compute the absolute transforms of this bone and its children
  15302. */
  15303. computeAbsoluteTransforms(): void;
  15304. /**
  15305. * Get the world direction from an axis that is in the local space of the bone
  15306. * @param localAxis The local direction that is used to compute the world direction
  15307. * @param mesh The mesh that this bone is attached to
  15308. * @returns The world direction
  15309. */
  15310. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15311. /**
  15312. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15313. * @param localAxis The local direction that is used to compute the world direction
  15314. * @param mesh The mesh that this bone is attached to
  15315. * @param result The vector3 that the world direction will be copied to
  15316. */
  15317. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15318. /**
  15319. * Get the euler rotation of the bone in local or world space
  15320. * @param space The space that the rotation should be in
  15321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15322. * @returns The euler rotation
  15323. */
  15324. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15325. /**
  15326. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15327. * @param space The space that the rotation should be in
  15328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15329. * @param result The vector3 that the rotation should be copied to
  15330. */
  15331. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15332. /**
  15333. * Get the quaternion rotation of the bone in either local or world space
  15334. * @param space The space that the rotation should be in
  15335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15336. * @returns The quaternion rotation
  15337. */
  15338. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15339. /**
  15340. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15341. * @param space The space that the rotation should be in
  15342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15343. * @param result The quaternion that the rotation should be copied to
  15344. */
  15345. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15346. /**
  15347. * Get the rotation matrix of the bone in local or world space
  15348. * @param space The space that the rotation should be in
  15349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15350. * @returns The rotation matrix
  15351. */
  15352. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15353. /**
  15354. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15355. * @param space The space that the rotation should be in
  15356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15357. * @param result The quaternion that the rotation should be copied to
  15358. */
  15359. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15360. /**
  15361. * Get the world position of a point that is in the local space of the bone
  15362. * @param position The local position
  15363. * @param mesh The mesh that this bone is attached to
  15364. * @returns The world position
  15365. */
  15366. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15367. /**
  15368. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15369. * @param position The local position
  15370. * @param mesh The mesh that this bone is attached to
  15371. * @param result The vector3 that the world position should be copied to
  15372. */
  15373. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15374. /**
  15375. * Get the local position of a point that is in world space
  15376. * @param position The world position
  15377. * @param mesh The mesh that this bone is attached to
  15378. * @returns The local position
  15379. */
  15380. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15381. /**
  15382. * Get the local position of a point that is in world space and copy it to the result param
  15383. * @param position The world position
  15384. * @param mesh The mesh that this bone is attached to
  15385. * @param result The vector3 that the local position should be copied to
  15386. */
  15387. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15388. }
  15389. }
  15390. declare module BABYLON {
  15391. /**
  15392. * Defines a runtime animation
  15393. */
  15394. export class RuntimeAnimation {
  15395. private _events;
  15396. /**
  15397. * The current frame of the runtime animation
  15398. */
  15399. private _currentFrame;
  15400. /**
  15401. * The animation used by the runtime animation
  15402. */
  15403. private _animation;
  15404. /**
  15405. * The target of the runtime animation
  15406. */
  15407. private _target;
  15408. /**
  15409. * The initiating animatable
  15410. */
  15411. private _host;
  15412. /**
  15413. * The original value of the runtime animation
  15414. */
  15415. private _originalValue;
  15416. /**
  15417. * The original blend value of the runtime animation
  15418. */
  15419. private _originalBlendValue;
  15420. /**
  15421. * The offsets cache of the runtime animation
  15422. */
  15423. private _offsetsCache;
  15424. /**
  15425. * The high limits cache of the runtime animation
  15426. */
  15427. private _highLimitsCache;
  15428. /**
  15429. * Specifies if the runtime animation has been stopped
  15430. */
  15431. private _stopped;
  15432. /**
  15433. * The blending factor of the runtime animation
  15434. */
  15435. private _blendingFactor;
  15436. /**
  15437. * The BabylonJS scene
  15438. */
  15439. private _scene;
  15440. /**
  15441. * The current value of the runtime animation
  15442. */
  15443. private _currentValue;
  15444. /** @hidden */
  15445. _animationState: _IAnimationState;
  15446. /**
  15447. * The active target of the runtime animation
  15448. */
  15449. private _activeTargets;
  15450. private _currentActiveTarget;
  15451. private _directTarget;
  15452. /**
  15453. * The target path of the runtime animation
  15454. */
  15455. private _targetPath;
  15456. /**
  15457. * The weight of the runtime animation
  15458. */
  15459. private _weight;
  15460. /**
  15461. * The ratio offset of the runtime animation
  15462. */
  15463. private _ratioOffset;
  15464. /**
  15465. * The previous delay of the runtime animation
  15466. */
  15467. private _previousDelay;
  15468. /**
  15469. * The previous ratio of the runtime animation
  15470. */
  15471. private _previousRatio;
  15472. private _enableBlending;
  15473. private _keys;
  15474. private _minFrame;
  15475. private _maxFrame;
  15476. private _minValue;
  15477. private _maxValue;
  15478. private _targetIsArray;
  15479. /**
  15480. * Gets the current frame of the runtime animation
  15481. */
  15482. get currentFrame(): number;
  15483. /**
  15484. * Gets the weight of the runtime animation
  15485. */
  15486. get weight(): number;
  15487. /**
  15488. * Gets the current value of the runtime animation
  15489. */
  15490. get currentValue(): any;
  15491. /**
  15492. * Gets the target path of the runtime animation
  15493. */
  15494. get targetPath(): string;
  15495. /**
  15496. * Gets the actual target of the runtime animation
  15497. */
  15498. get target(): any;
  15499. /**
  15500. * Gets the additive state of the runtime animation
  15501. */
  15502. get isAdditive(): boolean;
  15503. /** @hidden */
  15504. _onLoop: () => void;
  15505. /**
  15506. * Create a new RuntimeAnimation object
  15507. * @param target defines the target of the animation
  15508. * @param animation defines the source animation object
  15509. * @param scene defines the hosting scene
  15510. * @param host defines the initiating Animatable
  15511. */
  15512. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15513. private _preparePath;
  15514. /**
  15515. * Gets the animation from the runtime animation
  15516. */
  15517. get animation(): Animation;
  15518. /**
  15519. * Resets the runtime animation to the beginning
  15520. * @param restoreOriginal defines whether to restore the target property to the original value
  15521. */
  15522. reset(restoreOriginal?: boolean): void;
  15523. /**
  15524. * Specifies if the runtime animation is stopped
  15525. * @returns Boolean specifying if the runtime animation is stopped
  15526. */
  15527. isStopped(): boolean;
  15528. /**
  15529. * Disposes of the runtime animation
  15530. */
  15531. dispose(): void;
  15532. /**
  15533. * Apply the interpolated value to the target
  15534. * @param currentValue defines the value computed by the animation
  15535. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15536. */
  15537. setValue(currentValue: any, weight: number): void;
  15538. private _getOriginalValues;
  15539. private _setValue;
  15540. /**
  15541. * Gets the loop pmode of the runtime animation
  15542. * @returns Loop Mode
  15543. */
  15544. private _getCorrectLoopMode;
  15545. /**
  15546. * Move the current animation to a given frame
  15547. * @param frame defines the frame to move to
  15548. */
  15549. goToFrame(frame: number): void;
  15550. /**
  15551. * @hidden Internal use only
  15552. */
  15553. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15554. /**
  15555. * Execute the current animation
  15556. * @param delay defines the delay to add to the current frame
  15557. * @param from defines the lower bound of the animation range
  15558. * @param to defines the upper bound of the animation range
  15559. * @param loop defines if the current animation must loop
  15560. * @param speedRatio defines the current speed ratio
  15561. * @param weight defines the weight of the animation (default is -1 so no weight)
  15562. * @param onLoop optional callback called when animation loops
  15563. * @returns a boolean indicating if the animation is running
  15564. */
  15565. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15566. }
  15567. }
  15568. declare module BABYLON {
  15569. /**
  15570. * Class used to store an actual running animation
  15571. */
  15572. export class Animatable {
  15573. /** defines the target object */
  15574. target: any;
  15575. /** defines the starting frame number (default is 0) */
  15576. fromFrame: number;
  15577. /** defines the ending frame number (default is 100) */
  15578. toFrame: number;
  15579. /** defines if the animation must loop (default is false) */
  15580. loopAnimation: boolean;
  15581. /** defines a callback to call when animation ends if it is not looping */
  15582. onAnimationEnd?: (() => void) | null | undefined;
  15583. /** defines a callback to call when animation loops */
  15584. onAnimationLoop?: (() => void) | null | undefined;
  15585. /** defines whether the animation should be evaluated additively */
  15586. isAdditive: boolean;
  15587. private _localDelayOffset;
  15588. private _pausedDelay;
  15589. private _runtimeAnimations;
  15590. private _paused;
  15591. private _scene;
  15592. private _speedRatio;
  15593. private _weight;
  15594. private _syncRoot;
  15595. /**
  15596. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15597. * This will only apply for non looping animation (default is true)
  15598. */
  15599. disposeOnEnd: boolean;
  15600. /**
  15601. * Gets a boolean indicating if the animation has started
  15602. */
  15603. animationStarted: boolean;
  15604. /**
  15605. * Observer raised when the animation ends
  15606. */
  15607. onAnimationEndObservable: Observable<Animatable>;
  15608. /**
  15609. * Observer raised when the animation loops
  15610. */
  15611. onAnimationLoopObservable: Observable<Animatable>;
  15612. /**
  15613. * Gets the root Animatable used to synchronize and normalize animations
  15614. */
  15615. get syncRoot(): Nullable<Animatable>;
  15616. /**
  15617. * Gets the current frame of the first RuntimeAnimation
  15618. * Used to synchronize Animatables
  15619. */
  15620. get masterFrame(): number;
  15621. /**
  15622. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15623. */
  15624. get weight(): number;
  15625. set weight(value: number);
  15626. /**
  15627. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15628. */
  15629. get speedRatio(): number;
  15630. set speedRatio(value: number);
  15631. /**
  15632. * Creates a new Animatable
  15633. * @param scene defines the hosting scene
  15634. * @param target defines the target object
  15635. * @param fromFrame defines the starting frame number (default is 0)
  15636. * @param toFrame defines the ending frame number (default is 100)
  15637. * @param loopAnimation defines if the animation must loop (default is false)
  15638. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15639. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15640. * @param animations defines a group of animation to add to the new Animatable
  15641. * @param onAnimationLoop defines a callback to call when animation loops
  15642. * @param isAdditive defines whether the animation should be evaluated additively
  15643. */
  15644. constructor(scene: Scene,
  15645. /** defines the target object */
  15646. target: any,
  15647. /** defines the starting frame number (default is 0) */
  15648. fromFrame?: number,
  15649. /** defines the ending frame number (default is 100) */
  15650. toFrame?: number,
  15651. /** defines if the animation must loop (default is false) */
  15652. loopAnimation?: boolean, speedRatio?: number,
  15653. /** defines a callback to call when animation ends if it is not looping */
  15654. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15655. /** defines a callback to call when animation loops */
  15656. onAnimationLoop?: (() => void) | null | undefined,
  15657. /** defines whether the animation should be evaluated additively */
  15658. isAdditive?: boolean);
  15659. /**
  15660. * Synchronize and normalize current Animatable with a source Animatable
  15661. * This is useful when using animation weights and when animations are not of the same length
  15662. * @param root defines the root Animatable to synchronize with
  15663. * @returns the current Animatable
  15664. */
  15665. syncWith(root: Animatable): Animatable;
  15666. /**
  15667. * Gets the list of runtime animations
  15668. * @returns an array of RuntimeAnimation
  15669. */
  15670. getAnimations(): RuntimeAnimation[];
  15671. /**
  15672. * Adds more animations to the current animatable
  15673. * @param target defines the target of the animations
  15674. * @param animations defines the new animations to add
  15675. */
  15676. appendAnimations(target: any, animations: Animation[]): void;
  15677. /**
  15678. * Gets the source animation for a specific property
  15679. * @param property defines the propertyu to look for
  15680. * @returns null or the source animation for the given property
  15681. */
  15682. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15683. /**
  15684. * Gets the runtime animation for a specific property
  15685. * @param property defines the propertyu to look for
  15686. * @returns null or the runtime animation for the given property
  15687. */
  15688. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15689. /**
  15690. * Resets the animatable to its original state
  15691. */
  15692. reset(): void;
  15693. /**
  15694. * Allows the animatable to blend with current running animations
  15695. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15696. * @param blendingSpeed defines the blending speed to use
  15697. */
  15698. enableBlending(blendingSpeed: number): void;
  15699. /**
  15700. * Disable animation blending
  15701. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15702. */
  15703. disableBlending(): void;
  15704. /**
  15705. * Jump directly to a given frame
  15706. * @param frame defines the frame to jump to
  15707. */
  15708. goToFrame(frame: number): void;
  15709. /**
  15710. * Pause the animation
  15711. */
  15712. pause(): void;
  15713. /**
  15714. * Restart the animation
  15715. */
  15716. restart(): void;
  15717. private _raiseOnAnimationEnd;
  15718. /**
  15719. * Stop and delete the current animation
  15720. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15721. * @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)
  15722. */
  15723. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15724. /**
  15725. * Wait asynchronously for the animation to end
  15726. * @returns a promise which will be fullfilled when the animation ends
  15727. */
  15728. waitAsync(): Promise<Animatable>;
  15729. /** @hidden */
  15730. _animate(delay: number): boolean;
  15731. }
  15732. interface Scene {
  15733. /** @hidden */
  15734. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15735. /** @hidden */
  15736. _processLateAnimationBindingsForMatrices(holder: {
  15737. totalWeight: number;
  15738. totalAdditiveWeight: number;
  15739. animations: RuntimeAnimation[];
  15740. additiveAnimations: RuntimeAnimation[];
  15741. originalValue: Matrix;
  15742. }): any;
  15743. /** @hidden */
  15744. _processLateAnimationBindingsForQuaternions(holder: {
  15745. totalWeight: number;
  15746. totalAdditiveWeight: number;
  15747. animations: RuntimeAnimation[];
  15748. additiveAnimations: RuntimeAnimation[];
  15749. originalValue: Quaternion;
  15750. }, refQuaternion: Quaternion): Quaternion;
  15751. /** @hidden */
  15752. _processLateAnimationBindings(): void;
  15753. /**
  15754. * Will start the animation sequence of a given target
  15755. * @param target defines the target
  15756. * @param from defines from which frame should animation start
  15757. * @param to defines until which frame should animation run.
  15758. * @param weight defines the weight to apply to the animation (1.0 by default)
  15759. * @param loop defines if the animation loops
  15760. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15761. * @param onAnimationEnd defines the function to be executed when the animation ends
  15762. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15763. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15764. * @param onAnimationLoop defines the callback to call when an animation loops
  15765. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15766. * @returns the animatable object created for this animation
  15767. */
  15768. 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;
  15769. /**
  15770. * Will start the animation sequence of a given target
  15771. * @param target defines the target
  15772. * @param from defines from which frame should animation start
  15773. * @param to defines until which frame should animation run.
  15774. * @param loop defines if the animation loops
  15775. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15776. * @param onAnimationEnd defines the function to be executed when the animation ends
  15777. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15778. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15779. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15780. * @param onAnimationLoop defines the callback to call when an animation loops
  15781. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15782. * @returns the animatable object created for this animation
  15783. */
  15784. 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;
  15785. /**
  15786. * Will start the animation sequence of a given target and its hierarchy
  15787. * @param target defines the target
  15788. * @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.
  15789. * @param from defines from which frame should animation start
  15790. * @param to defines until which frame should animation run.
  15791. * @param loop defines if the animation loops
  15792. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15793. * @param onAnimationEnd defines the function to be executed when the animation ends
  15794. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15795. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15796. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15797. * @param onAnimationLoop defines the callback to call when an animation loops
  15798. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15799. * @returns the list of created animatables
  15800. */
  15801. 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[];
  15802. /**
  15803. * Begin a new animation on a given node
  15804. * @param target defines the target where the animation will take place
  15805. * @param animations defines the list of animations to start
  15806. * @param from defines the initial value
  15807. * @param to defines the final value
  15808. * @param loop defines if you want animation to loop (off by default)
  15809. * @param speedRatio defines the speed ratio to apply to all animations
  15810. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15811. * @param onAnimationLoop defines the callback to call when an animation loops
  15812. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15813. * @returns the list of created animatables
  15814. */
  15815. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15816. /**
  15817. * Begin a new animation on a given node and its hierarchy
  15818. * @param target defines the root node where the animation will take place
  15819. * @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.
  15820. * @param animations defines the list of animations to start
  15821. * @param from defines the initial value
  15822. * @param to defines the final value
  15823. * @param loop defines if you want animation to loop (off by default)
  15824. * @param speedRatio defines the speed ratio to apply to all animations
  15825. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15826. * @param onAnimationLoop defines the callback to call when an animation loops
  15827. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15828. * @returns the list of animatables created for all nodes
  15829. */
  15830. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15831. /**
  15832. * Gets the animatable associated with a specific target
  15833. * @param target defines the target of the animatable
  15834. * @returns the required animatable if found
  15835. */
  15836. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15837. /**
  15838. * Gets all animatables associated with a given target
  15839. * @param target defines the target to look animatables for
  15840. * @returns an array of Animatables
  15841. */
  15842. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15843. /**
  15844. * Stops and removes all animations that have been applied to the scene
  15845. */
  15846. stopAllAnimations(): void;
  15847. /**
  15848. * Gets the current delta time used by animation engine
  15849. */
  15850. deltaTime: number;
  15851. }
  15852. interface Bone {
  15853. /**
  15854. * Copy an animation range from another bone
  15855. * @param source defines the source bone
  15856. * @param rangeName defines the range name to copy
  15857. * @param frameOffset defines the frame offset
  15858. * @param rescaleAsRequired defines if rescaling must be applied if required
  15859. * @param skelDimensionsRatio defines the scaling ratio
  15860. * @returns true if operation was successful
  15861. */
  15862. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15863. }
  15864. }
  15865. declare module BABYLON {
  15866. /**
  15867. * Class used to handle skinning animations
  15868. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15869. */
  15870. export class Skeleton implements IAnimatable {
  15871. /** defines the skeleton name */
  15872. name: string;
  15873. /** defines the skeleton Id */
  15874. id: string;
  15875. /**
  15876. * Defines the list of child bones
  15877. */
  15878. bones: Bone[];
  15879. /**
  15880. * Defines an estimate of the dimension of the skeleton at rest
  15881. */
  15882. dimensionsAtRest: Vector3;
  15883. /**
  15884. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15885. */
  15886. needInitialSkinMatrix: boolean;
  15887. /**
  15888. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15889. */
  15890. overrideMesh: Nullable<AbstractMesh>;
  15891. /**
  15892. * Gets the list of animations attached to this skeleton
  15893. */
  15894. animations: Array<Animation>;
  15895. private _scene;
  15896. private _isDirty;
  15897. private _transformMatrices;
  15898. private _transformMatrixTexture;
  15899. private _meshesWithPoseMatrix;
  15900. private _animatables;
  15901. private _identity;
  15902. private _synchronizedWithMesh;
  15903. private _ranges;
  15904. private _lastAbsoluteTransformsUpdateId;
  15905. private _canUseTextureForBones;
  15906. private _uniqueId;
  15907. /** @hidden */
  15908. _numBonesWithLinkedTransformNode: number;
  15909. /** @hidden */
  15910. _hasWaitingData: Nullable<boolean>;
  15911. /**
  15912. * Specifies if the skeleton should be serialized
  15913. */
  15914. doNotSerialize: boolean;
  15915. private _useTextureToStoreBoneMatrices;
  15916. /**
  15917. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15918. * Please note that this option is not available if the hardware does not support it
  15919. */
  15920. get useTextureToStoreBoneMatrices(): boolean;
  15921. set useTextureToStoreBoneMatrices(value: boolean);
  15922. private _animationPropertiesOverride;
  15923. /**
  15924. * Gets or sets the animation properties override
  15925. */
  15926. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15927. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15928. /**
  15929. * List of inspectable custom properties (used by the Inspector)
  15930. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15931. */
  15932. inspectableCustomProperties: IInspectable[];
  15933. /**
  15934. * An observable triggered before computing the skeleton's matrices
  15935. */
  15936. onBeforeComputeObservable: Observable<Skeleton>;
  15937. /**
  15938. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15939. */
  15940. get isUsingTextureForMatrices(): boolean;
  15941. /**
  15942. * Gets the unique ID of this skeleton
  15943. */
  15944. get uniqueId(): number;
  15945. /**
  15946. * Creates a new skeleton
  15947. * @param name defines the skeleton name
  15948. * @param id defines the skeleton Id
  15949. * @param scene defines the hosting scene
  15950. */
  15951. constructor(
  15952. /** defines the skeleton name */
  15953. name: string,
  15954. /** defines the skeleton Id */
  15955. id: string, scene: Scene);
  15956. /**
  15957. * Gets the current object class name.
  15958. * @return the class name
  15959. */
  15960. getClassName(): string;
  15961. /**
  15962. * Returns an array containing the root bones
  15963. * @returns an array containing the root bones
  15964. */
  15965. getChildren(): Array<Bone>;
  15966. /**
  15967. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15968. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15969. * @returns a Float32Array containing matrices data
  15970. */
  15971. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15972. /**
  15973. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15974. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15975. * @returns a raw texture containing the data
  15976. */
  15977. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15978. /**
  15979. * Gets the current hosting scene
  15980. * @returns a scene object
  15981. */
  15982. getScene(): Scene;
  15983. /**
  15984. * Gets a string representing the current skeleton data
  15985. * @param fullDetails defines a boolean indicating if we want a verbose version
  15986. * @returns a string representing the current skeleton data
  15987. */
  15988. toString(fullDetails?: boolean): string;
  15989. /**
  15990. * Get bone's index searching by name
  15991. * @param name defines bone's name to search for
  15992. * @return the indice of the bone. Returns -1 if not found
  15993. */
  15994. getBoneIndexByName(name: string): number;
  15995. /**
  15996. * Creater a new animation range
  15997. * @param name defines the name of the range
  15998. * @param from defines the start key
  15999. * @param to defines the end key
  16000. */
  16001. createAnimationRange(name: string, from: number, to: number): void;
  16002. /**
  16003. * Delete a specific animation range
  16004. * @param name defines the name of the range
  16005. * @param deleteFrames defines if frames must be removed as well
  16006. */
  16007. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16008. /**
  16009. * Gets a specific animation range
  16010. * @param name defines the name of the range to look for
  16011. * @returns the requested animation range or null if not found
  16012. */
  16013. getAnimationRange(name: string): Nullable<AnimationRange>;
  16014. /**
  16015. * Gets the list of all animation ranges defined on this skeleton
  16016. * @returns an array
  16017. */
  16018. getAnimationRanges(): Nullable<AnimationRange>[];
  16019. /**
  16020. * Copy animation range from a source skeleton.
  16021. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16022. * @param source defines the source skeleton
  16023. * @param name defines the name of the range to copy
  16024. * @param rescaleAsRequired defines if rescaling must be applied if required
  16025. * @returns true if operation was successful
  16026. */
  16027. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16028. /**
  16029. * Forces the skeleton to go to rest pose
  16030. */
  16031. returnToRest(): void;
  16032. private _getHighestAnimationFrame;
  16033. /**
  16034. * Begin a specific animation range
  16035. * @param name defines the name of the range to start
  16036. * @param loop defines if looping must be turned on (false by default)
  16037. * @param speedRatio defines the speed ratio to apply (1 by default)
  16038. * @param onAnimationEnd defines a callback which will be called when animation will end
  16039. * @returns a new animatable
  16040. */
  16041. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16042. /**
  16043. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16044. * @param skeleton defines the Skeleton containing the animation range to convert
  16045. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16046. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16047. * @returns the original skeleton
  16048. */
  16049. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16050. /** @hidden */
  16051. _markAsDirty(): void;
  16052. /** @hidden */
  16053. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16054. /** @hidden */
  16055. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16056. private _computeTransformMatrices;
  16057. /**
  16058. * Build all resources required to render a skeleton
  16059. */
  16060. prepare(): void;
  16061. /**
  16062. * Gets the list of animatables currently running for this skeleton
  16063. * @returns an array of animatables
  16064. */
  16065. getAnimatables(): IAnimatable[];
  16066. /**
  16067. * Clone the current skeleton
  16068. * @param name defines the name of the new skeleton
  16069. * @param id defines the id of the new skeleton
  16070. * @returns the new skeleton
  16071. */
  16072. clone(name: string, id?: string): Skeleton;
  16073. /**
  16074. * Enable animation blending for this skeleton
  16075. * @param blendingSpeed defines the blending speed to apply
  16076. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16077. */
  16078. enableBlending(blendingSpeed?: number): void;
  16079. /**
  16080. * Releases all resources associated with the current skeleton
  16081. */
  16082. dispose(): void;
  16083. /**
  16084. * Serialize the skeleton in a JSON object
  16085. * @returns a JSON object
  16086. */
  16087. serialize(): any;
  16088. /**
  16089. * Creates a new skeleton from serialized data
  16090. * @param parsedSkeleton defines the serialized data
  16091. * @param scene defines the hosting scene
  16092. * @returns a new skeleton
  16093. */
  16094. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16095. /**
  16096. * Compute all node absolute transforms
  16097. * @param forceUpdate defines if computation must be done even if cache is up to date
  16098. */
  16099. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16100. /**
  16101. * Gets the root pose matrix
  16102. * @returns a matrix
  16103. */
  16104. getPoseMatrix(): Nullable<Matrix>;
  16105. /**
  16106. * Sorts bones per internal index
  16107. */
  16108. sortBones(): void;
  16109. private _sortBones;
  16110. }
  16111. }
  16112. declare module BABYLON {
  16113. /**
  16114. * Creates an instance based on a source mesh.
  16115. */
  16116. export class InstancedMesh extends AbstractMesh {
  16117. private _sourceMesh;
  16118. private _currentLOD;
  16119. /** @hidden */
  16120. _indexInSourceMeshInstanceArray: number;
  16121. constructor(name: string, source: Mesh);
  16122. /**
  16123. * Returns the string "InstancedMesh".
  16124. */
  16125. getClassName(): string;
  16126. /** Gets the list of lights affecting that mesh */
  16127. get lightSources(): Light[];
  16128. _resyncLightSources(): void;
  16129. _resyncLightSource(light: Light): void;
  16130. _removeLightSource(light: Light, dispose: boolean): void;
  16131. /**
  16132. * If the source mesh receives shadows
  16133. */
  16134. get receiveShadows(): boolean;
  16135. /**
  16136. * The material of the source mesh
  16137. */
  16138. get material(): Nullable<Material>;
  16139. /**
  16140. * Visibility of the source mesh
  16141. */
  16142. get visibility(): number;
  16143. /**
  16144. * Skeleton of the source mesh
  16145. */
  16146. get skeleton(): Nullable<Skeleton>;
  16147. /**
  16148. * Rendering ground id of the source mesh
  16149. */
  16150. get renderingGroupId(): number;
  16151. set renderingGroupId(value: number);
  16152. /**
  16153. * Returns the total number of vertices (integer).
  16154. */
  16155. getTotalVertices(): number;
  16156. /**
  16157. * Returns a positive integer : the total number of indices in this mesh geometry.
  16158. * @returns the numner of indices or zero if the mesh has no geometry.
  16159. */
  16160. getTotalIndices(): number;
  16161. /**
  16162. * The source mesh of the instance
  16163. */
  16164. get sourceMesh(): Mesh;
  16165. /**
  16166. * Creates a new InstancedMesh object from the mesh model.
  16167. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16168. * @param name defines the name of the new instance
  16169. * @returns a new InstancedMesh
  16170. */
  16171. createInstance(name: string): InstancedMesh;
  16172. /**
  16173. * Is this node ready to be used/rendered
  16174. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16175. * @return {boolean} is it ready
  16176. */
  16177. isReady(completeCheck?: boolean): boolean;
  16178. /**
  16179. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16180. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16181. * @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.
  16182. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16183. */
  16184. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16185. /**
  16186. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16187. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16188. * The `data` are either a numeric array either a Float32Array.
  16189. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16190. * 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).
  16191. * Note that a new underlying VertexBuffer object is created each call.
  16192. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16193. *
  16194. * Possible `kind` values :
  16195. * - VertexBuffer.PositionKind
  16196. * - VertexBuffer.UVKind
  16197. * - VertexBuffer.UV2Kind
  16198. * - VertexBuffer.UV3Kind
  16199. * - VertexBuffer.UV4Kind
  16200. * - VertexBuffer.UV5Kind
  16201. * - VertexBuffer.UV6Kind
  16202. * - VertexBuffer.ColorKind
  16203. * - VertexBuffer.MatricesIndicesKind
  16204. * - VertexBuffer.MatricesIndicesExtraKind
  16205. * - VertexBuffer.MatricesWeightsKind
  16206. * - VertexBuffer.MatricesWeightsExtraKind
  16207. *
  16208. * Returns the Mesh.
  16209. */
  16210. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16211. /**
  16212. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16213. * If the mesh has no geometry, it is simply returned as it is.
  16214. * The `data` are either a numeric array either a Float32Array.
  16215. * No new underlying VertexBuffer object is created.
  16216. * 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.
  16217. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16218. *
  16219. * Possible `kind` values :
  16220. * - VertexBuffer.PositionKind
  16221. * - VertexBuffer.UVKind
  16222. * - VertexBuffer.UV2Kind
  16223. * - VertexBuffer.UV3Kind
  16224. * - VertexBuffer.UV4Kind
  16225. * - VertexBuffer.UV5Kind
  16226. * - VertexBuffer.UV6Kind
  16227. * - VertexBuffer.ColorKind
  16228. * - VertexBuffer.MatricesIndicesKind
  16229. * - VertexBuffer.MatricesIndicesExtraKind
  16230. * - VertexBuffer.MatricesWeightsKind
  16231. * - VertexBuffer.MatricesWeightsExtraKind
  16232. *
  16233. * Returns the Mesh.
  16234. */
  16235. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16236. /**
  16237. * Sets the mesh indices.
  16238. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16239. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16240. * This method creates a new index buffer each call.
  16241. * Returns the Mesh.
  16242. */
  16243. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16244. /**
  16245. * Boolean : True if the mesh owns the requested kind of data.
  16246. */
  16247. isVerticesDataPresent(kind: string): boolean;
  16248. /**
  16249. * Returns an array of indices (IndicesArray).
  16250. */
  16251. getIndices(): Nullable<IndicesArray>;
  16252. get _positions(): Nullable<Vector3[]>;
  16253. /**
  16254. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16255. * This means the mesh underlying bounding box and sphere are recomputed.
  16256. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16257. * @returns the current mesh
  16258. */
  16259. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16260. /** @hidden */
  16261. _preActivate(): InstancedMesh;
  16262. /** @hidden */
  16263. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16264. /** @hidden */
  16265. _postActivate(): void;
  16266. getWorldMatrix(): Matrix;
  16267. get isAnInstance(): boolean;
  16268. /**
  16269. * Returns the current associated LOD AbstractMesh.
  16270. */
  16271. getLOD(camera: Camera): AbstractMesh;
  16272. /** @hidden */
  16273. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16274. /** @hidden */
  16275. _syncSubMeshes(): InstancedMesh;
  16276. /** @hidden */
  16277. _generatePointsArray(): boolean;
  16278. /**
  16279. * Creates a new InstancedMesh from the current mesh.
  16280. * - name (string) : the cloned mesh name
  16281. * - newParent (optional Node) : the optional Node to parent the clone to.
  16282. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16283. *
  16284. * Returns the clone.
  16285. */
  16286. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16287. /**
  16288. * Disposes the InstancedMesh.
  16289. * Returns nothing.
  16290. */
  16291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16292. }
  16293. interface Mesh {
  16294. /**
  16295. * Register a custom buffer that will be instanced
  16296. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16297. * @param kind defines the buffer kind
  16298. * @param stride defines the stride in floats
  16299. */
  16300. registerInstancedBuffer(kind: string, stride: number): void;
  16301. /** @hidden */
  16302. _userInstancedBuffersStorage: {
  16303. data: {
  16304. [key: string]: Float32Array;
  16305. };
  16306. sizes: {
  16307. [key: string]: number;
  16308. };
  16309. vertexBuffers: {
  16310. [key: string]: Nullable<VertexBuffer>;
  16311. };
  16312. strides: {
  16313. [key: string]: number;
  16314. };
  16315. };
  16316. }
  16317. interface AbstractMesh {
  16318. /**
  16319. * Object used to store instanced buffers defined by user
  16320. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16321. */
  16322. instancedBuffers: {
  16323. [key: string]: any;
  16324. };
  16325. }
  16326. }
  16327. declare module BABYLON {
  16328. /**
  16329. * Defines the options associated with the creation of a shader material.
  16330. */
  16331. export interface IShaderMaterialOptions {
  16332. /**
  16333. * Does the material work in alpha blend mode
  16334. */
  16335. needAlphaBlending: boolean;
  16336. /**
  16337. * Does the material work in alpha test mode
  16338. */
  16339. needAlphaTesting: boolean;
  16340. /**
  16341. * The list of attribute names used in the shader
  16342. */
  16343. attributes: string[];
  16344. /**
  16345. * The list of unifrom names used in the shader
  16346. */
  16347. uniforms: string[];
  16348. /**
  16349. * The list of UBO names used in the shader
  16350. */
  16351. uniformBuffers: string[];
  16352. /**
  16353. * The list of sampler names used in the shader
  16354. */
  16355. samplers: string[];
  16356. /**
  16357. * The list of defines used in the shader
  16358. */
  16359. defines: string[];
  16360. }
  16361. /**
  16362. * 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.
  16363. *
  16364. * This returned material effects how the mesh will look based on the code in the shaders.
  16365. *
  16366. * @see http://doc.babylonjs.com/how_to/shader_material
  16367. */
  16368. export class ShaderMaterial extends Material {
  16369. private _shaderPath;
  16370. private _options;
  16371. private _textures;
  16372. private _textureArrays;
  16373. private _floats;
  16374. private _ints;
  16375. private _floatsArrays;
  16376. private _colors3;
  16377. private _colors3Arrays;
  16378. private _colors4;
  16379. private _colors4Arrays;
  16380. private _vectors2;
  16381. private _vectors3;
  16382. private _vectors4;
  16383. private _matrices;
  16384. private _matrixArrays;
  16385. private _matrices3x3;
  16386. private _matrices2x2;
  16387. private _vectors2Arrays;
  16388. private _vectors3Arrays;
  16389. private _vectors4Arrays;
  16390. private _cachedWorldViewMatrix;
  16391. private _cachedWorldViewProjectionMatrix;
  16392. private _renderId;
  16393. private _multiview;
  16394. private _cachedDefines;
  16395. /**
  16396. * Instantiate a new shader material.
  16397. * 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.
  16398. * This returned material effects how the mesh will look based on the code in the shaders.
  16399. * @see http://doc.babylonjs.com/how_to/shader_material
  16400. * @param name Define the name of the material in the scene
  16401. * @param scene Define the scene the material belongs to
  16402. * @param shaderPath Defines the route to the shader code in one of three ways:
  16403. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16404. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16405. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16406. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16407. * @param options Define the options used to create the shader
  16408. */
  16409. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16410. /**
  16411. * Gets the shader path used to define the shader code
  16412. * It can be modified to trigger a new compilation
  16413. */
  16414. get shaderPath(): any;
  16415. /**
  16416. * Sets the shader path used to define the shader code
  16417. * It can be modified to trigger a new compilation
  16418. */
  16419. set shaderPath(shaderPath: any);
  16420. /**
  16421. * Gets the options used to compile the shader.
  16422. * They can be modified to trigger a new compilation
  16423. */
  16424. get options(): IShaderMaterialOptions;
  16425. /**
  16426. * Gets the current class name of the material e.g. "ShaderMaterial"
  16427. * Mainly use in serialization.
  16428. * @returns the class name
  16429. */
  16430. getClassName(): string;
  16431. /**
  16432. * Specifies if the material will require alpha blending
  16433. * @returns a boolean specifying if alpha blending is needed
  16434. */
  16435. needAlphaBlending(): boolean;
  16436. /**
  16437. * Specifies if this material should be rendered in alpha test mode
  16438. * @returns a boolean specifying if an alpha test is needed.
  16439. */
  16440. needAlphaTesting(): boolean;
  16441. private _checkUniform;
  16442. /**
  16443. * Set a texture in the shader.
  16444. * @param name Define the name of the uniform samplers as defined in the shader
  16445. * @param texture Define the texture to bind to this sampler
  16446. * @return the material itself allowing "fluent" like uniform updates
  16447. */
  16448. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16449. /**
  16450. * Set a texture array in the shader.
  16451. * @param name Define the name of the uniform sampler array as defined in the shader
  16452. * @param textures Define the list of textures to bind to this sampler
  16453. * @return the material itself allowing "fluent" like uniform updates
  16454. */
  16455. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16456. /**
  16457. * Set a float in the shader.
  16458. * @param name Define the name of the uniform as defined in the shader
  16459. * @param value Define the value to give to the uniform
  16460. * @return the material itself allowing "fluent" like uniform updates
  16461. */
  16462. setFloat(name: string, value: number): ShaderMaterial;
  16463. /**
  16464. * Set a int in the shader.
  16465. * @param name Define the name of the uniform as defined in the shader
  16466. * @param value Define the value to give to the uniform
  16467. * @return the material itself allowing "fluent" like uniform updates
  16468. */
  16469. setInt(name: string, value: number): ShaderMaterial;
  16470. /**
  16471. * Set an array of floats in the shader.
  16472. * @param name Define the name of the uniform as defined in the shader
  16473. * @param value Define the value to give to the uniform
  16474. * @return the material itself allowing "fluent" like uniform updates
  16475. */
  16476. setFloats(name: string, value: number[]): ShaderMaterial;
  16477. /**
  16478. * Set a vec3 in the shader from a Color3.
  16479. * @param name Define the name of the uniform as defined in the shader
  16480. * @param value Define the value to give to the uniform
  16481. * @return the material itself allowing "fluent" like uniform updates
  16482. */
  16483. setColor3(name: string, value: Color3): ShaderMaterial;
  16484. /**
  16485. * Set a vec3 array in the shader from a Color3 array.
  16486. * @param name Define the name of the uniform as defined in the shader
  16487. * @param value Define the value to give to the uniform
  16488. * @return the material itself allowing "fluent" like uniform updates
  16489. */
  16490. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16491. /**
  16492. * Set a vec4 in the shader from a Color4.
  16493. * @param name Define the name of the uniform as defined in the shader
  16494. * @param value Define the value to give to the uniform
  16495. * @return the material itself allowing "fluent" like uniform updates
  16496. */
  16497. setColor4(name: string, value: Color4): ShaderMaterial;
  16498. /**
  16499. * Set a vec4 array in the shader from a Color4 array.
  16500. * @param name Define the name of the uniform as defined in the shader
  16501. * @param value Define the value to give to the uniform
  16502. * @return the material itself allowing "fluent" like uniform updates
  16503. */
  16504. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16505. /**
  16506. * Set a vec2 in the shader from a Vector2.
  16507. * @param name Define the name of the uniform as defined in the shader
  16508. * @param value Define the value to give to the uniform
  16509. * @return the material itself allowing "fluent" like uniform updates
  16510. */
  16511. setVector2(name: string, value: Vector2): ShaderMaterial;
  16512. /**
  16513. * Set a vec3 in the shader from a Vector3.
  16514. * @param name Define the name of the uniform as defined in the shader
  16515. * @param value Define the value to give to the uniform
  16516. * @return the material itself allowing "fluent" like uniform updates
  16517. */
  16518. setVector3(name: string, value: Vector3): ShaderMaterial;
  16519. /**
  16520. * Set a vec4 in the shader from a Vector4.
  16521. * @param name Define the name of the uniform as defined in the shader
  16522. * @param value Define the value to give to the uniform
  16523. * @return the material itself allowing "fluent" like uniform updates
  16524. */
  16525. setVector4(name: string, value: Vector4): ShaderMaterial;
  16526. /**
  16527. * Set a mat4 in the shader from a Matrix.
  16528. * @param name Define the name of the uniform as defined in the shader
  16529. * @param value Define the value to give to the uniform
  16530. * @return the material itself allowing "fluent" like uniform updates
  16531. */
  16532. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16533. /**
  16534. * Set a float32Array in the shader from a matrix array.
  16535. * @param name Define the name of the uniform as defined in the shader
  16536. * @param value Define the value to give to the uniform
  16537. * @return the material itself allowing "fluent" like uniform updates
  16538. */
  16539. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16540. /**
  16541. * Set a mat3 in the shader from a Float32Array.
  16542. * @param name Define the name of the uniform as defined in the shader
  16543. * @param value Define the value to give to the uniform
  16544. * @return the material itself allowing "fluent" like uniform updates
  16545. */
  16546. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16547. /**
  16548. * Set a mat2 in the shader from a Float32Array.
  16549. * @param name Define the name of the uniform as defined in the shader
  16550. * @param value Define the value to give to the uniform
  16551. * @return the material itself allowing "fluent" like uniform updates
  16552. */
  16553. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16554. /**
  16555. * Set a vec2 array in the shader from a number array.
  16556. * @param name Define the name of the uniform as defined in the shader
  16557. * @param value Define the value to give to the uniform
  16558. * @return the material itself allowing "fluent" like uniform updates
  16559. */
  16560. setArray2(name: string, value: number[]): ShaderMaterial;
  16561. /**
  16562. * Set a vec3 array in the shader from a number array.
  16563. * @param name Define the name of the uniform as defined in the shader
  16564. * @param value Define the value to give to the uniform
  16565. * @return the material itself allowing "fluent" like uniform updates
  16566. */
  16567. setArray3(name: string, value: number[]): ShaderMaterial;
  16568. /**
  16569. * Set a vec4 array in the shader from a number array.
  16570. * @param name Define the name of the uniform as defined in the shader
  16571. * @param value Define the value to give to the uniform
  16572. * @return the material itself allowing "fluent" like uniform updates
  16573. */
  16574. setArray4(name: string, value: number[]): ShaderMaterial;
  16575. private _checkCache;
  16576. /**
  16577. * Specifies that the submesh is ready to be used
  16578. * @param mesh defines the mesh to check
  16579. * @param subMesh defines which submesh to check
  16580. * @param useInstances specifies that instances should be used
  16581. * @returns a boolean indicating that the submesh is ready or not
  16582. */
  16583. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16584. /**
  16585. * Checks if the material is ready to render the requested mesh
  16586. * @param mesh Define the mesh to render
  16587. * @param useInstances Define whether or not the material is used with instances
  16588. * @returns true if ready, otherwise false
  16589. */
  16590. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16591. /**
  16592. * Binds the world matrix to the material
  16593. * @param world defines the world transformation matrix
  16594. * @param effectOverride - If provided, use this effect instead of internal effect
  16595. */
  16596. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16597. /**
  16598. * Binds the submesh to this material by preparing the effect and shader to draw
  16599. * @param world defines the world transformation matrix
  16600. * @param mesh defines the mesh containing the submesh
  16601. * @param subMesh defines the submesh to bind the material to
  16602. */
  16603. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16604. /**
  16605. * Binds the material to the mesh
  16606. * @param world defines the world transformation matrix
  16607. * @param mesh defines the mesh to bind the material to
  16608. * @param effectOverride - If provided, use this effect instead of internal effect
  16609. */
  16610. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16611. protected _afterBind(mesh?: Mesh): void;
  16612. /**
  16613. * Gets the active textures from the material
  16614. * @returns an array of textures
  16615. */
  16616. getActiveTextures(): BaseTexture[];
  16617. /**
  16618. * Specifies if the material uses a texture
  16619. * @param texture defines the texture to check against the material
  16620. * @returns a boolean specifying if the material uses the texture
  16621. */
  16622. hasTexture(texture: BaseTexture): boolean;
  16623. /**
  16624. * Makes a duplicate of the material, and gives it a new name
  16625. * @param name defines the new name for the duplicated material
  16626. * @returns the cloned material
  16627. */
  16628. clone(name: string): ShaderMaterial;
  16629. /**
  16630. * Disposes the material
  16631. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16632. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16633. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16634. */
  16635. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16636. /**
  16637. * Serializes this material in a JSON representation
  16638. * @returns the serialized material object
  16639. */
  16640. serialize(): any;
  16641. /**
  16642. * Creates a shader material from parsed shader material data
  16643. * @param source defines the JSON represnetation of the material
  16644. * @param scene defines the hosting scene
  16645. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16646. * @returns a new material
  16647. */
  16648. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16649. }
  16650. }
  16651. declare module BABYLON {
  16652. /** @hidden */
  16653. export var colorPixelShader: {
  16654. name: string;
  16655. shader: string;
  16656. };
  16657. }
  16658. declare module BABYLON {
  16659. /** @hidden */
  16660. export var colorVertexShader: {
  16661. name: string;
  16662. shader: string;
  16663. };
  16664. }
  16665. declare module BABYLON {
  16666. /**
  16667. * Line mesh
  16668. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16669. */
  16670. export class LinesMesh extends Mesh {
  16671. /**
  16672. * If vertex color should be applied to the mesh
  16673. */
  16674. readonly useVertexColor?: boolean | undefined;
  16675. /**
  16676. * If vertex alpha should be applied to the mesh
  16677. */
  16678. readonly useVertexAlpha?: boolean | undefined;
  16679. /**
  16680. * Color of the line (Default: White)
  16681. */
  16682. color: Color3;
  16683. /**
  16684. * Alpha of the line (Default: 1)
  16685. */
  16686. alpha: number;
  16687. /**
  16688. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16689. * This margin is expressed in world space coordinates, so its value may vary.
  16690. * Default value is 0.1
  16691. */
  16692. intersectionThreshold: number;
  16693. private _colorShader;
  16694. private color4;
  16695. /**
  16696. * Creates a new LinesMesh
  16697. * @param name defines the name
  16698. * @param scene defines the hosting scene
  16699. * @param parent defines the parent mesh if any
  16700. * @param source defines the optional source LinesMesh used to clone data from
  16701. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16702. * When false, achieved by calling a clone(), also passing False.
  16703. * This will make creation of children, recursive.
  16704. * @param useVertexColor defines if this LinesMesh supports vertex color
  16705. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16706. */
  16707. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16708. /**
  16709. * If vertex color should be applied to the mesh
  16710. */
  16711. useVertexColor?: boolean | undefined,
  16712. /**
  16713. * If vertex alpha should be applied to the mesh
  16714. */
  16715. useVertexAlpha?: boolean | undefined);
  16716. private _addClipPlaneDefine;
  16717. private _removeClipPlaneDefine;
  16718. isReady(): boolean;
  16719. /**
  16720. * Returns the string "LineMesh"
  16721. */
  16722. getClassName(): string;
  16723. /**
  16724. * @hidden
  16725. */
  16726. get material(): Material;
  16727. /**
  16728. * @hidden
  16729. */
  16730. set material(value: Material);
  16731. /**
  16732. * @hidden
  16733. */
  16734. get checkCollisions(): boolean;
  16735. /** @hidden */
  16736. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16737. /** @hidden */
  16738. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16739. /**
  16740. * Disposes of the line mesh
  16741. * @param doNotRecurse If children should be disposed
  16742. */
  16743. dispose(doNotRecurse?: boolean): void;
  16744. /**
  16745. * Returns a new LineMesh object cloned from the current one.
  16746. */
  16747. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16748. /**
  16749. * Creates a new InstancedLinesMesh object from the mesh model.
  16750. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16751. * @param name defines the name of the new instance
  16752. * @returns a new InstancedLinesMesh
  16753. */
  16754. createInstance(name: string): InstancedLinesMesh;
  16755. }
  16756. /**
  16757. * Creates an instance based on a source LinesMesh
  16758. */
  16759. export class InstancedLinesMesh extends InstancedMesh {
  16760. /**
  16761. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16762. * This margin is expressed in world space coordinates, so its value may vary.
  16763. * Initilized with the intersectionThreshold value of the source LinesMesh
  16764. */
  16765. intersectionThreshold: number;
  16766. constructor(name: string, source: LinesMesh);
  16767. /**
  16768. * Returns the string "InstancedLinesMesh".
  16769. */
  16770. getClassName(): string;
  16771. }
  16772. }
  16773. declare module BABYLON {
  16774. /** @hidden */
  16775. export var linePixelShader: {
  16776. name: string;
  16777. shader: string;
  16778. };
  16779. }
  16780. declare module BABYLON {
  16781. /** @hidden */
  16782. export var lineVertexShader: {
  16783. name: string;
  16784. shader: string;
  16785. };
  16786. }
  16787. declare module BABYLON {
  16788. interface AbstractMesh {
  16789. /**
  16790. * Gets the edgesRenderer associated with the mesh
  16791. */
  16792. edgesRenderer: Nullable<EdgesRenderer>;
  16793. }
  16794. interface LinesMesh {
  16795. /**
  16796. * Enables the edge rendering mode on the mesh.
  16797. * This mode makes the mesh edges visible
  16798. * @param epsilon defines the maximal distance between two angles to detect a face
  16799. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16800. * @returns the currentAbstractMesh
  16801. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16802. */
  16803. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16804. }
  16805. interface InstancedLinesMesh {
  16806. /**
  16807. * Enables the edge rendering mode on the mesh.
  16808. * This mode makes the mesh edges visible
  16809. * @param epsilon defines the maximal distance between two angles to detect a face
  16810. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16811. * @returns the current InstancedLinesMesh
  16812. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16813. */
  16814. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16815. }
  16816. /**
  16817. * Defines the minimum contract an Edges renderer should follow.
  16818. */
  16819. export interface IEdgesRenderer extends IDisposable {
  16820. /**
  16821. * Gets or sets a boolean indicating if the edgesRenderer is active
  16822. */
  16823. isEnabled: boolean;
  16824. /**
  16825. * Renders the edges of the attached mesh,
  16826. */
  16827. render(): void;
  16828. /**
  16829. * Checks wether or not the edges renderer is ready to render.
  16830. * @return true if ready, otherwise false.
  16831. */
  16832. isReady(): boolean;
  16833. }
  16834. /**
  16835. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16836. */
  16837. export class EdgesRenderer implements IEdgesRenderer {
  16838. /**
  16839. * Define the size of the edges with an orthographic camera
  16840. */
  16841. edgesWidthScalerForOrthographic: number;
  16842. /**
  16843. * Define the size of the edges with a perspective camera
  16844. */
  16845. edgesWidthScalerForPerspective: number;
  16846. protected _source: AbstractMesh;
  16847. protected _linesPositions: number[];
  16848. protected _linesNormals: number[];
  16849. protected _linesIndices: number[];
  16850. protected _epsilon: number;
  16851. protected _indicesCount: number;
  16852. protected _lineShader: ShaderMaterial;
  16853. protected _ib: DataBuffer;
  16854. protected _buffers: {
  16855. [key: string]: Nullable<VertexBuffer>;
  16856. };
  16857. protected _checkVerticesInsteadOfIndices: boolean;
  16858. private _meshRebuildObserver;
  16859. private _meshDisposeObserver;
  16860. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16861. isEnabled: boolean;
  16862. /**
  16863. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16864. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16865. * @param source Mesh used to create edges
  16866. * @param epsilon sum of angles in adjacency to check for edge
  16867. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16868. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16869. */
  16870. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16871. protected _prepareRessources(): void;
  16872. /** @hidden */
  16873. _rebuild(): void;
  16874. /**
  16875. * Releases the required resources for the edges renderer
  16876. */
  16877. dispose(): void;
  16878. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16879. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16880. /**
  16881. * Checks if the pair of p0 and p1 is en edge
  16882. * @param faceIndex
  16883. * @param edge
  16884. * @param faceNormals
  16885. * @param p0
  16886. * @param p1
  16887. * @private
  16888. */
  16889. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16890. /**
  16891. * push line into the position, normal and index buffer
  16892. * @protected
  16893. */
  16894. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16895. /**
  16896. * Generates lines edges from adjacencjes
  16897. * @private
  16898. */
  16899. _generateEdgesLines(): void;
  16900. /**
  16901. * Checks wether or not the edges renderer is ready to render.
  16902. * @return true if ready, otherwise false.
  16903. */
  16904. isReady(): boolean;
  16905. /**
  16906. * Renders the edges of the attached mesh,
  16907. */
  16908. render(): void;
  16909. }
  16910. /**
  16911. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16912. */
  16913. export class LineEdgesRenderer extends EdgesRenderer {
  16914. /**
  16915. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16916. * @param source LineMesh used to generate edges
  16917. * @param epsilon not important (specified angle for edge detection)
  16918. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16919. */
  16920. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16921. /**
  16922. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16923. */
  16924. _generateEdgesLines(): void;
  16925. }
  16926. }
  16927. declare module BABYLON {
  16928. /**
  16929. * This represents the object necessary to create a rendering group.
  16930. * This is exclusively used and created by the rendering manager.
  16931. * To modify the behavior, you use the available helpers in your scene or meshes.
  16932. * @hidden
  16933. */
  16934. export class RenderingGroup {
  16935. index: number;
  16936. private static _zeroVector;
  16937. private _scene;
  16938. private _opaqueSubMeshes;
  16939. private _transparentSubMeshes;
  16940. private _alphaTestSubMeshes;
  16941. private _depthOnlySubMeshes;
  16942. private _particleSystems;
  16943. private _spriteManagers;
  16944. private _opaqueSortCompareFn;
  16945. private _alphaTestSortCompareFn;
  16946. private _transparentSortCompareFn;
  16947. private _renderOpaque;
  16948. private _renderAlphaTest;
  16949. private _renderTransparent;
  16950. /** @hidden */
  16951. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16952. onBeforeTransparentRendering: () => void;
  16953. /**
  16954. * Set the opaque sort comparison function.
  16955. * If null the sub meshes will be render in the order they were created
  16956. */
  16957. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16958. /**
  16959. * Set the alpha test sort comparison function.
  16960. * If null the sub meshes will be render in the order they were created
  16961. */
  16962. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16963. /**
  16964. * Set the transparent sort comparison function.
  16965. * If null the sub meshes will be render in the order they were created
  16966. */
  16967. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16968. /**
  16969. * Creates a new rendering group.
  16970. * @param index The rendering group index
  16971. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16972. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16973. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16974. */
  16975. 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>);
  16976. /**
  16977. * Render all the sub meshes contained in the group.
  16978. * @param customRenderFunction Used to override the default render behaviour of the group.
  16979. * @returns true if rendered some submeshes.
  16980. */
  16981. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16982. /**
  16983. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16984. * @param subMeshes The submeshes to render
  16985. */
  16986. private renderOpaqueSorted;
  16987. /**
  16988. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16989. * @param subMeshes The submeshes to render
  16990. */
  16991. private renderAlphaTestSorted;
  16992. /**
  16993. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16994. * @param subMeshes The submeshes to render
  16995. */
  16996. private renderTransparentSorted;
  16997. /**
  16998. * Renders the submeshes in a specified order.
  16999. * @param subMeshes The submeshes to sort before render
  17000. * @param sortCompareFn The comparison function use to sort
  17001. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17002. * @param transparent Specifies to activate blending if true
  17003. */
  17004. private static renderSorted;
  17005. /**
  17006. * Renders the submeshes in the order they were dispatched (no sort applied).
  17007. * @param subMeshes The submeshes to render
  17008. */
  17009. private static renderUnsorted;
  17010. /**
  17011. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17012. * are rendered back to front if in the same alpha index.
  17013. *
  17014. * @param a The first submesh
  17015. * @param b The second submesh
  17016. * @returns The result of the comparison
  17017. */
  17018. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17019. /**
  17020. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17021. * are rendered back to front.
  17022. *
  17023. * @param a The first submesh
  17024. * @param b The second submesh
  17025. * @returns The result of the comparison
  17026. */
  17027. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17028. /**
  17029. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17030. * are rendered front to back (prevent overdraw).
  17031. *
  17032. * @param a The first submesh
  17033. * @param b The second submesh
  17034. * @returns The result of the comparison
  17035. */
  17036. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17037. /**
  17038. * Resets the different lists of submeshes to prepare a new frame.
  17039. */
  17040. prepare(): void;
  17041. dispose(): void;
  17042. /**
  17043. * Inserts the submesh in its correct queue depending on its material.
  17044. * @param subMesh The submesh to dispatch
  17045. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17046. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17047. */
  17048. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17049. dispatchSprites(spriteManager: ISpriteManager): void;
  17050. dispatchParticles(particleSystem: IParticleSystem): void;
  17051. private _renderParticles;
  17052. private _renderSprites;
  17053. }
  17054. }
  17055. declare module BABYLON {
  17056. /**
  17057. * Interface describing the different options available in the rendering manager
  17058. * regarding Auto Clear between groups.
  17059. */
  17060. export interface IRenderingManagerAutoClearSetup {
  17061. /**
  17062. * Defines whether or not autoclear is enable.
  17063. */
  17064. autoClear: boolean;
  17065. /**
  17066. * Defines whether or not to autoclear the depth buffer.
  17067. */
  17068. depth: boolean;
  17069. /**
  17070. * Defines whether or not to autoclear the stencil buffer.
  17071. */
  17072. stencil: boolean;
  17073. }
  17074. /**
  17075. * This class is used by the onRenderingGroupObservable
  17076. */
  17077. export class RenderingGroupInfo {
  17078. /**
  17079. * The Scene that being rendered
  17080. */
  17081. scene: Scene;
  17082. /**
  17083. * The camera currently used for the rendering pass
  17084. */
  17085. camera: Nullable<Camera>;
  17086. /**
  17087. * The ID of the renderingGroup being processed
  17088. */
  17089. renderingGroupId: number;
  17090. }
  17091. /**
  17092. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17093. * It is enable to manage the different groups as well as the different necessary sort functions.
  17094. * This should not be used directly aside of the few static configurations
  17095. */
  17096. export class RenderingManager {
  17097. /**
  17098. * The max id used for rendering groups (not included)
  17099. */
  17100. static MAX_RENDERINGGROUPS: number;
  17101. /**
  17102. * The min id used for rendering groups (included)
  17103. */
  17104. static MIN_RENDERINGGROUPS: number;
  17105. /**
  17106. * Used to globally prevent autoclearing scenes.
  17107. */
  17108. static AUTOCLEAR: boolean;
  17109. /**
  17110. * @hidden
  17111. */
  17112. _useSceneAutoClearSetup: boolean;
  17113. private _scene;
  17114. private _renderingGroups;
  17115. private _depthStencilBufferAlreadyCleaned;
  17116. private _autoClearDepthStencil;
  17117. private _customOpaqueSortCompareFn;
  17118. private _customAlphaTestSortCompareFn;
  17119. private _customTransparentSortCompareFn;
  17120. private _renderingGroupInfo;
  17121. /**
  17122. * Instantiates a new rendering group for a particular scene
  17123. * @param scene Defines the scene the groups belongs to
  17124. */
  17125. constructor(scene: Scene);
  17126. private _clearDepthStencilBuffer;
  17127. /**
  17128. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17129. * @hidden
  17130. */
  17131. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17132. /**
  17133. * Resets the different information of the group to prepare a new frame
  17134. * @hidden
  17135. */
  17136. reset(): void;
  17137. /**
  17138. * Dispose and release the group and its associated resources.
  17139. * @hidden
  17140. */
  17141. dispose(): void;
  17142. /**
  17143. * Clear the info related to rendering groups preventing retention points during dispose.
  17144. */
  17145. freeRenderingGroups(): void;
  17146. private _prepareRenderingGroup;
  17147. /**
  17148. * Add a sprite manager to the rendering manager in order to render it this frame.
  17149. * @param spriteManager Define the sprite manager to render
  17150. */
  17151. dispatchSprites(spriteManager: ISpriteManager): void;
  17152. /**
  17153. * Add a particle system to the rendering manager in order to render it this frame.
  17154. * @param particleSystem Define the particle system to render
  17155. */
  17156. dispatchParticles(particleSystem: IParticleSystem): void;
  17157. /**
  17158. * Add a submesh to the manager in order to render it this frame
  17159. * @param subMesh The submesh to dispatch
  17160. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17161. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17162. */
  17163. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17164. /**
  17165. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17166. * This allowed control for front to back rendering or reversly depending of the special needs.
  17167. *
  17168. * @param renderingGroupId The rendering group id corresponding to its index
  17169. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17170. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17171. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17172. */
  17173. 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;
  17174. /**
  17175. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17176. *
  17177. * @param renderingGroupId The rendering group id corresponding to its index
  17178. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17179. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17180. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17181. */
  17182. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17183. /**
  17184. * Gets the current auto clear configuration for one rendering group of the rendering
  17185. * manager.
  17186. * @param index the rendering group index to get the information for
  17187. * @returns The auto clear setup for the requested rendering group
  17188. */
  17189. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17190. }
  17191. }
  17192. declare module BABYLON {
  17193. /**
  17194. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17195. */
  17196. export interface ICustomShaderOptions {
  17197. /**
  17198. * Gets or sets the custom shader name to use
  17199. */
  17200. shaderName: string;
  17201. /**
  17202. * The list of attribute names used in the shader
  17203. */
  17204. attributes?: string[];
  17205. /**
  17206. * The list of unifrom names used in the shader
  17207. */
  17208. uniforms?: string[];
  17209. /**
  17210. * The list of sampler names used in the shader
  17211. */
  17212. samplers?: string[];
  17213. /**
  17214. * The list of defines used in the shader
  17215. */
  17216. defines?: string[];
  17217. }
  17218. /**
  17219. * Interface to implement to create a shadow generator compatible with BJS.
  17220. */
  17221. export interface IShadowGenerator {
  17222. /**
  17223. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17224. * @returns The render target texture if present otherwise, null
  17225. */
  17226. getShadowMap(): Nullable<RenderTargetTexture>;
  17227. /**
  17228. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17229. * @param subMesh The submesh we want to render in the shadow map
  17230. * @param useInstances Defines wether will draw in the map using instances
  17231. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17232. * @returns true if ready otherwise, false
  17233. */
  17234. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17235. /**
  17236. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17237. * @param defines Defines of the material we want to update
  17238. * @param lightIndex Index of the light in the enabled light list of the material
  17239. */
  17240. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17241. /**
  17242. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17243. * defined in the generator but impacting the effect).
  17244. * It implies the unifroms available on the materials are the standard BJS ones.
  17245. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17246. * @param effect The effect we are binfing the information for
  17247. */
  17248. bindShadowLight(lightIndex: string, effect: Effect): void;
  17249. /**
  17250. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17251. * (eq to shadow prjection matrix * light transform matrix)
  17252. * @returns The transform matrix used to create the shadow map
  17253. */
  17254. getTransformMatrix(): Matrix;
  17255. /**
  17256. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17257. * Cube and 2D textures for instance.
  17258. */
  17259. recreateShadowMap(): void;
  17260. /**
  17261. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17262. * @param onCompiled Callback triggered at the and of the effects compilation
  17263. * @param options Sets of optional options forcing the compilation with different modes
  17264. */
  17265. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17266. useInstances: boolean;
  17267. }>): void;
  17268. /**
  17269. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17270. * @param options Sets of optional options forcing the compilation with different modes
  17271. * @returns A promise that resolves when the compilation completes
  17272. */
  17273. forceCompilationAsync(options?: Partial<{
  17274. useInstances: boolean;
  17275. }>): Promise<void>;
  17276. /**
  17277. * Serializes the shadow generator setup to a json object.
  17278. * @returns The serialized JSON object
  17279. */
  17280. serialize(): any;
  17281. /**
  17282. * Disposes the Shadow map and related Textures and effects.
  17283. */
  17284. dispose(): void;
  17285. }
  17286. /**
  17287. * Default implementation IShadowGenerator.
  17288. * This is the main object responsible of generating shadows in the framework.
  17289. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17290. */
  17291. export class ShadowGenerator implements IShadowGenerator {
  17292. /**
  17293. * Name of the shadow generator class
  17294. */
  17295. static CLASSNAME: string;
  17296. /**
  17297. * Shadow generator mode None: no filtering applied.
  17298. */
  17299. static readonly FILTER_NONE: number;
  17300. /**
  17301. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17302. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17303. */
  17304. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17305. /**
  17306. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17307. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17308. */
  17309. static readonly FILTER_POISSONSAMPLING: number;
  17310. /**
  17311. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17312. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17313. */
  17314. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17315. /**
  17316. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17317. * edge artifacts on steep falloff.
  17318. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17319. */
  17320. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17321. /**
  17322. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17323. * edge artifacts on steep falloff.
  17324. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17325. */
  17326. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17327. /**
  17328. * Shadow generator mode PCF: Percentage Closer Filtering
  17329. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17330. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17331. */
  17332. static readonly FILTER_PCF: number;
  17333. /**
  17334. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17335. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17336. * Contact Hardening
  17337. */
  17338. static readonly FILTER_PCSS: number;
  17339. /**
  17340. * Reserved for PCF and PCSS
  17341. * Highest Quality.
  17342. *
  17343. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17344. *
  17345. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17346. */
  17347. static readonly QUALITY_HIGH: number;
  17348. /**
  17349. * Reserved for PCF and PCSS
  17350. * Good tradeoff for quality/perf cross devices
  17351. *
  17352. * Execute PCF on a 3*3 kernel.
  17353. *
  17354. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17355. */
  17356. static readonly QUALITY_MEDIUM: number;
  17357. /**
  17358. * Reserved for PCF and PCSS
  17359. * The lowest quality but the fastest.
  17360. *
  17361. * Execute PCF on a 1*1 kernel.
  17362. *
  17363. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17364. */
  17365. static readonly QUALITY_LOW: number;
  17366. /** Gets or sets the custom shader name to use */
  17367. customShaderOptions: ICustomShaderOptions;
  17368. /**
  17369. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17370. */
  17371. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17372. /**
  17373. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17374. */
  17375. onAfterShadowMapRenderObservable: Observable<Effect>;
  17376. /**
  17377. * Observable triggered before a mesh is rendered in the shadow map.
  17378. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17379. */
  17380. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17381. /**
  17382. * Observable triggered after a mesh is rendered in the shadow map.
  17383. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17384. */
  17385. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17386. protected _bias: number;
  17387. /**
  17388. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17389. */
  17390. get bias(): number;
  17391. /**
  17392. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17393. */
  17394. set bias(bias: number);
  17395. protected _normalBias: number;
  17396. /**
  17397. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17398. */
  17399. get normalBias(): number;
  17400. /**
  17401. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17402. */
  17403. set normalBias(normalBias: number);
  17404. protected _blurBoxOffset: number;
  17405. /**
  17406. * Gets the blur box offset: offset applied during the blur pass.
  17407. * Only useful if useKernelBlur = false
  17408. */
  17409. get blurBoxOffset(): number;
  17410. /**
  17411. * Sets the blur box offset: offset applied during the blur pass.
  17412. * Only useful if useKernelBlur = false
  17413. */
  17414. set blurBoxOffset(value: number);
  17415. protected _blurScale: number;
  17416. /**
  17417. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17418. * 2 means half of the size.
  17419. */
  17420. get blurScale(): number;
  17421. /**
  17422. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17423. * 2 means half of the size.
  17424. */
  17425. set blurScale(value: number);
  17426. protected _blurKernel: number;
  17427. /**
  17428. * Gets the blur kernel: kernel size of the blur pass.
  17429. * Only useful if useKernelBlur = true
  17430. */
  17431. get blurKernel(): number;
  17432. /**
  17433. * Sets the blur kernel: kernel size of the blur pass.
  17434. * Only useful if useKernelBlur = true
  17435. */
  17436. set blurKernel(value: number);
  17437. protected _useKernelBlur: boolean;
  17438. /**
  17439. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17440. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17441. */
  17442. get useKernelBlur(): boolean;
  17443. /**
  17444. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17445. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17446. */
  17447. set useKernelBlur(value: boolean);
  17448. protected _depthScale: number;
  17449. /**
  17450. * Gets the depth scale used in ESM mode.
  17451. */
  17452. get depthScale(): number;
  17453. /**
  17454. * Sets the depth scale used in ESM mode.
  17455. * This can override the scale stored on the light.
  17456. */
  17457. set depthScale(value: number);
  17458. protected _validateFilter(filter: number): number;
  17459. protected _filter: number;
  17460. /**
  17461. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17462. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17463. */
  17464. get filter(): number;
  17465. /**
  17466. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17467. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17468. */
  17469. set filter(value: number);
  17470. /**
  17471. * Gets if the current filter is set to Poisson Sampling.
  17472. */
  17473. get usePoissonSampling(): boolean;
  17474. /**
  17475. * Sets the current filter to Poisson Sampling.
  17476. */
  17477. set usePoissonSampling(value: boolean);
  17478. /**
  17479. * Gets if the current filter is set to ESM.
  17480. */
  17481. get useExponentialShadowMap(): boolean;
  17482. /**
  17483. * Sets the current filter is to ESM.
  17484. */
  17485. set useExponentialShadowMap(value: boolean);
  17486. /**
  17487. * Gets if the current filter is set to filtered ESM.
  17488. */
  17489. get useBlurExponentialShadowMap(): boolean;
  17490. /**
  17491. * Gets if the current filter is set to filtered ESM.
  17492. */
  17493. set useBlurExponentialShadowMap(value: boolean);
  17494. /**
  17495. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17496. * exponential to prevent steep falloff artifacts).
  17497. */
  17498. get useCloseExponentialShadowMap(): boolean;
  17499. /**
  17500. * Sets the current filter to "close ESM" (using the inverse of the
  17501. * exponential to prevent steep falloff artifacts).
  17502. */
  17503. set useCloseExponentialShadowMap(value: boolean);
  17504. /**
  17505. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17506. * exponential to prevent steep falloff artifacts).
  17507. */
  17508. get useBlurCloseExponentialShadowMap(): boolean;
  17509. /**
  17510. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17511. * exponential to prevent steep falloff artifacts).
  17512. */
  17513. set useBlurCloseExponentialShadowMap(value: boolean);
  17514. /**
  17515. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17516. */
  17517. get usePercentageCloserFiltering(): boolean;
  17518. /**
  17519. * Sets the current filter to "PCF" (percentage closer filtering).
  17520. */
  17521. set usePercentageCloserFiltering(value: boolean);
  17522. protected _filteringQuality: number;
  17523. /**
  17524. * Gets the PCF or PCSS Quality.
  17525. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17526. */
  17527. get filteringQuality(): number;
  17528. /**
  17529. * Sets the PCF or PCSS Quality.
  17530. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17531. */
  17532. set filteringQuality(filteringQuality: number);
  17533. /**
  17534. * Gets if the current filter is set to "PCSS" (contact hardening).
  17535. */
  17536. get useContactHardeningShadow(): boolean;
  17537. /**
  17538. * Sets the current filter to "PCSS" (contact hardening).
  17539. */
  17540. set useContactHardeningShadow(value: boolean);
  17541. protected _contactHardeningLightSizeUVRatio: number;
  17542. /**
  17543. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17544. * Using a ratio helps keeping shape stability independently of the map size.
  17545. *
  17546. * It does not account for the light projection as it was having too much
  17547. * instability during the light setup or during light position changes.
  17548. *
  17549. * Only valid if useContactHardeningShadow is true.
  17550. */
  17551. get contactHardeningLightSizeUVRatio(): number;
  17552. /**
  17553. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17554. * Using a ratio helps keeping shape stability independently of the map size.
  17555. *
  17556. * It does not account for the light projection as it was having too much
  17557. * instability during the light setup or during light position changes.
  17558. *
  17559. * Only valid if useContactHardeningShadow is true.
  17560. */
  17561. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17562. protected _darkness: number;
  17563. /** Gets or sets the actual darkness of a shadow */
  17564. get darkness(): number;
  17565. set darkness(value: number);
  17566. /**
  17567. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17568. * 0 means strongest and 1 would means no shadow.
  17569. * @returns the darkness.
  17570. */
  17571. getDarkness(): number;
  17572. /**
  17573. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17574. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17575. * @returns the shadow generator allowing fluent coding.
  17576. */
  17577. setDarkness(darkness: number): ShadowGenerator;
  17578. protected _transparencyShadow: boolean;
  17579. /** Gets or sets the ability to have transparent shadow */
  17580. get transparencyShadow(): boolean;
  17581. set transparencyShadow(value: boolean);
  17582. /**
  17583. * Sets the ability to have transparent shadow (boolean).
  17584. * @param transparent True if transparent else False
  17585. * @returns the shadow generator allowing fluent coding
  17586. */
  17587. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17588. /**
  17589. * Enables or disables shadows with varying strength based on the transparency
  17590. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17591. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17592. * mesh.visibility * alphaTexture.a
  17593. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17594. */
  17595. enableSoftTransparentShadow: boolean;
  17596. protected _shadowMap: Nullable<RenderTargetTexture>;
  17597. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17598. /**
  17599. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17600. * @returns The render target texture if present otherwise, null
  17601. */
  17602. getShadowMap(): Nullable<RenderTargetTexture>;
  17603. /**
  17604. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17605. * @returns The render target texture if the shadow map is present otherwise, null
  17606. */
  17607. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17608. /**
  17609. * Gets the class name of that object
  17610. * @returns "ShadowGenerator"
  17611. */
  17612. getClassName(): string;
  17613. /**
  17614. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17615. * @param mesh Mesh to add
  17616. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17617. * @returns the Shadow Generator itself
  17618. */
  17619. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17620. /**
  17621. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17622. * @param mesh Mesh to remove
  17623. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17624. * @returns the Shadow Generator itself
  17625. */
  17626. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17627. /**
  17628. * Controls the extent to which the shadows fade out at the edge of the frustum
  17629. */
  17630. frustumEdgeFalloff: number;
  17631. protected _light: IShadowLight;
  17632. /**
  17633. * Returns the associated light object.
  17634. * @returns the light generating the shadow
  17635. */
  17636. getLight(): IShadowLight;
  17637. /**
  17638. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17639. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17640. * It might on the other hand introduce peter panning.
  17641. */
  17642. forceBackFacesOnly: boolean;
  17643. protected _scene: Scene;
  17644. protected _lightDirection: Vector3;
  17645. protected _effect: Effect;
  17646. protected _viewMatrix: Matrix;
  17647. protected _projectionMatrix: Matrix;
  17648. protected _transformMatrix: Matrix;
  17649. protected _cachedPosition: Vector3;
  17650. protected _cachedDirection: Vector3;
  17651. protected _cachedDefines: string;
  17652. protected _currentRenderID: number;
  17653. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17654. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17655. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17656. protected _blurPostProcesses: PostProcess[];
  17657. protected _mapSize: number;
  17658. protected _currentFaceIndex: number;
  17659. protected _currentFaceIndexCache: number;
  17660. protected _textureType: number;
  17661. protected _defaultTextureMatrix: Matrix;
  17662. protected _storedUniqueId: Nullable<number>;
  17663. /** @hidden */
  17664. static _SceneComponentInitialization: (scene: Scene) => void;
  17665. /**
  17666. * Creates a ShadowGenerator object.
  17667. * A ShadowGenerator is the required tool to use the shadows.
  17668. * Each light casting shadows needs to use its own ShadowGenerator.
  17669. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17670. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17671. * @param light The light object generating the shadows.
  17672. * @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.
  17673. */
  17674. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17675. protected _initializeGenerator(): void;
  17676. protected _createTargetRenderTexture(): void;
  17677. protected _initializeShadowMap(): void;
  17678. protected _initializeBlurRTTAndPostProcesses(): void;
  17679. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17680. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17681. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17682. protected _applyFilterValues(): void;
  17683. /**
  17684. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17685. * @param onCompiled Callback triggered at the and of the effects compilation
  17686. * @param options Sets of optional options forcing the compilation with different modes
  17687. */
  17688. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17689. useInstances: boolean;
  17690. }>): void;
  17691. /**
  17692. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17693. * @param options Sets of optional options forcing the compilation with different modes
  17694. * @returns A promise that resolves when the compilation completes
  17695. */
  17696. forceCompilationAsync(options?: Partial<{
  17697. useInstances: boolean;
  17698. }>): Promise<void>;
  17699. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17700. private _prepareShadowDefines;
  17701. /**
  17702. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17703. * @param subMesh The submesh we want to render in the shadow map
  17704. * @param useInstances Defines wether will draw in the map using instances
  17705. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17706. * @returns true if ready otherwise, false
  17707. */
  17708. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17709. /**
  17710. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17711. * @param defines Defines of the material we want to update
  17712. * @param lightIndex Index of the light in the enabled light list of the material
  17713. */
  17714. prepareDefines(defines: any, lightIndex: number): void;
  17715. /**
  17716. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17717. * defined in the generator but impacting the effect).
  17718. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17719. * @param effect The effect we are binfing the information for
  17720. */
  17721. bindShadowLight(lightIndex: string, effect: Effect): void;
  17722. /**
  17723. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17724. * (eq to shadow prjection matrix * light transform matrix)
  17725. * @returns The transform matrix used to create the shadow map
  17726. */
  17727. getTransformMatrix(): Matrix;
  17728. /**
  17729. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17730. * Cube and 2D textures for instance.
  17731. */
  17732. recreateShadowMap(): void;
  17733. protected _disposeBlurPostProcesses(): void;
  17734. protected _disposeRTTandPostProcesses(): void;
  17735. /**
  17736. * Disposes the ShadowGenerator.
  17737. * Returns nothing.
  17738. */
  17739. dispose(): void;
  17740. /**
  17741. * Serializes the shadow generator setup to a json object.
  17742. * @returns The serialized JSON object
  17743. */
  17744. serialize(): any;
  17745. /**
  17746. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17747. * @param parsedShadowGenerator The JSON object to parse
  17748. * @param scene The scene to create the shadow map for
  17749. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17750. * @returns The parsed shadow generator
  17751. */
  17752. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17753. }
  17754. }
  17755. declare module BABYLON {
  17756. /**
  17757. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17758. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17759. * 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.
  17760. */
  17761. export abstract class Light extends Node {
  17762. /**
  17763. * Falloff Default: light is falling off following the material specification:
  17764. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17765. */
  17766. static readonly FALLOFF_DEFAULT: number;
  17767. /**
  17768. * Falloff Physical: light is falling off following the inverse squared distance law.
  17769. */
  17770. static readonly FALLOFF_PHYSICAL: number;
  17771. /**
  17772. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17773. * to enhance interoperability with other engines.
  17774. */
  17775. static readonly FALLOFF_GLTF: number;
  17776. /**
  17777. * Falloff Standard: light is falling off like in the standard material
  17778. * to enhance interoperability with other materials.
  17779. */
  17780. static readonly FALLOFF_STANDARD: number;
  17781. /**
  17782. * If every light affecting the material is in this lightmapMode,
  17783. * material.lightmapTexture adds or multiplies
  17784. * (depends on material.useLightmapAsShadowmap)
  17785. * after every other light calculations.
  17786. */
  17787. static readonly LIGHTMAP_DEFAULT: number;
  17788. /**
  17789. * material.lightmapTexture as only diffuse lighting from this light
  17790. * adds only specular lighting from this light
  17791. * adds dynamic shadows
  17792. */
  17793. static readonly LIGHTMAP_SPECULAR: number;
  17794. /**
  17795. * material.lightmapTexture as only lighting
  17796. * no light calculation from this light
  17797. * only adds dynamic shadows from this light
  17798. */
  17799. static readonly LIGHTMAP_SHADOWSONLY: number;
  17800. /**
  17801. * Each light type uses the default quantity according to its type:
  17802. * point/spot lights use luminous intensity
  17803. * directional lights use illuminance
  17804. */
  17805. static readonly INTENSITYMODE_AUTOMATIC: number;
  17806. /**
  17807. * lumen (lm)
  17808. */
  17809. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17810. /**
  17811. * candela (lm/sr)
  17812. */
  17813. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17814. /**
  17815. * lux (lm/m^2)
  17816. */
  17817. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17818. /**
  17819. * nit (cd/m^2)
  17820. */
  17821. static readonly INTENSITYMODE_LUMINANCE: number;
  17822. /**
  17823. * Light type const id of the point light.
  17824. */
  17825. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17826. /**
  17827. * Light type const id of the directional light.
  17828. */
  17829. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17830. /**
  17831. * Light type const id of the spot light.
  17832. */
  17833. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17834. /**
  17835. * Light type const id of the hemispheric light.
  17836. */
  17837. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17838. /**
  17839. * Diffuse gives the basic color to an object.
  17840. */
  17841. diffuse: Color3;
  17842. /**
  17843. * Specular produces a highlight color on an object.
  17844. * Note: This is note affecting PBR materials.
  17845. */
  17846. specular: Color3;
  17847. /**
  17848. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17849. * falling off base on range or angle.
  17850. * This can be set to any values in Light.FALLOFF_x.
  17851. *
  17852. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17853. * other types of materials.
  17854. */
  17855. falloffType: number;
  17856. /**
  17857. * Strength of the light.
  17858. * Note: By default it is define in the framework own unit.
  17859. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17860. */
  17861. intensity: number;
  17862. private _range;
  17863. protected _inverseSquaredRange: number;
  17864. /**
  17865. * Defines how far from the source the light is impacting in scene units.
  17866. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17867. */
  17868. get range(): number;
  17869. /**
  17870. * Defines how far from the source the light is impacting in scene units.
  17871. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17872. */
  17873. set range(value: number);
  17874. /**
  17875. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17876. * of light.
  17877. */
  17878. private _photometricScale;
  17879. private _intensityMode;
  17880. /**
  17881. * Gets the photometric scale used to interpret the intensity.
  17882. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17883. */
  17884. get intensityMode(): number;
  17885. /**
  17886. * Sets the photometric scale used to interpret the intensity.
  17887. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17888. */
  17889. set intensityMode(value: number);
  17890. private _radius;
  17891. /**
  17892. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17893. */
  17894. get radius(): number;
  17895. /**
  17896. * sets the light radius used by PBR Materials to simulate soft area lights.
  17897. */
  17898. set radius(value: number);
  17899. private _renderPriority;
  17900. /**
  17901. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17902. * exceeding the number allowed of the materials.
  17903. */
  17904. renderPriority: number;
  17905. private _shadowEnabled;
  17906. /**
  17907. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17908. * the current shadow generator.
  17909. */
  17910. get shadowEnabled(): boolean;
  17911. /**
  17912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17913. * the current shadow generator.
  17914. */
  17915. set shadowEnabled(value: boolean);
  17916. private _includedOnlyMeshes;
  17917. /**
  17918. * Gets the only meshes impacted by this light.
  17919. */
  17920. get includedOnlyMeshes(): AbstractMesh[];
  17921. /**
  17922. * Sets the only meshes impacted by this light.
  17923. */
  17924. set includedOnlyMeshes(value: AbstractMesh[]);
  17925. private _excludedMeshes;
  17926. /**
  17927. * Gets the meshes not impacted by this light.
  17928. */
  17929. get excludedMeshes(): AbstractMesh[];
  17930. /**
  17931. * Sets the meshes not impacted by this light.
  17932. */
  17933. set excludedMeshes(value: AbstractMesh[]);
  17934. private _excludeWithLayerMask;
  17935. /**
  17936. * Gets the layer id use to find what meshes are not impacted by the light.
  17937. * Inactive if 0
  17938. */
  17939. get excludeWithLayerMask(): number;
  17940. /**
  17941. * Sets the layer id use to find what meshes are not impacted by the light.
  17942. * Inactive if 0
  17943. */
  17944. set excludeWithLayerMask(value: number);
  17945. private _includeOnlyWithLayerMask;
  17946. /**
  17947. * Gets the layer id use to find what meshes are impacted by the light.
  17948. * Inactive if 0
  17949. */
  17950. get includeOnlyWithLayerMask(): number;
  17951. /**
  17952. * Sets the layer id use to find what meshes are impacted by the light.
  17953. * Inactive if 0
  17954. */
  17955. set includeOnlyWithLayerMask(value: number);
  17956. private _lightmapMode;
  17957. /**
  17958. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17959. */
  17960. get lightmapMode(): number;
  17961. /**
  17962. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17963. */
  17964. set lightmapMode(value: number);
  17965. /**
  17966. * Shadow generator associted to the light.
  17967. * @hidden Internal use only.
  17968. */
  17969. _shadowGenerator: Nullable<IShadowGenerator>;
  17970. /**
  17971. * @hidden Internal use only.
  17972. */
  17973. _excludedMeshesIds: string[];
  17974. /**
  17975. * @hidden Internal use only.
  17976. */
  17977. _includedOnlyMeshesIds: string[];
  17978. /**
  17979. * The current light unifom buffer.
  17980. * @hidden Internal use only.
  17981. */
  17982. _uniformBuffer: UniformBuffer;
  17983. /** @hidden */
  17984. _renderId: number;
  17985. /**
  17986. * Creates a Light object in the scene.
  17987. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17988. * @param name The firendly name of the light
  17989. * @param scene The scene the light belongs too
  17990. */
  17991. constructor(name: string, scene: Scene);
  17992. protected abstract _buildUniformLayout(): void;
  17993. /**
  17994. * Sets the passed Effect "effect" with the Light information.
  17995. * @param effect The effect to update
  17996. * @param lightIndex The index of the light in the effect to update
  17997. * @returns The light
  17998. */
  17999. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18000. /**
  18001. * Sets the passed Effect "effect" with the Light textures.
  18002. * @param effect The effect to update
  18003. * @param lightIndex The index of the light in the effect to update
  18004. * @returns The light
  18005. */
  18006. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18007. /**
  18008. * Binds the lights information from the scene to the effect for the given mesh.
  18009. * @param lightIndex Light index
  18010. * @param scene The scene where the light belongs to
  18011. * @param effect The effect we are binding the data to
  18012. * @param useSpecular Defines if specular is supported
  18013. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18014. */
  18015. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18016. /**
  18017. * Sets the passed Effect "effect" with the Light information.
  18018. * @param effect The effect to update
  18019. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18020. * @returns The light
  18021. */
  18022. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18023. /**
  18024. * Returns the string "Light".
  18025. * @returns the class name
  18026. */
  18027. getClassName(): string;
  18028. /** @hidden */
  18029. readonly _isLight: boolean;
  18030. /**
  18031. * Converts the light information to a readable string for debug purpose.
  18032. * @param fullDetails Supports for multiple levels of logging within scene loading
  18033. * @returns the human readable light info
  18034. */
  18035. toString(fullDetails?: boolean): string;
  18036. /** @hidden */
  18037. protected _syncParentEnabledState(): void;
  18038. /**
  18039. * Set the enabled state of this node.
  18040. * @param value - the new enabled state
  18041. */
  18042. setEnabled(value: boolean): void;
  18043. /**
  18044. * Returns the Light associated shadow generator if any.
  18045. * @return the associated shadow generator.
  18046. */
  18047. getShadowGenerator(): Nullable<IShadowGenerator>;
  18048. /**
  18049. * Returns a Vector3, the absolute light position in the World.
  18050. * @returns the world space position of the light
  18051. */
  18052. getAbsolutePosition(): Vector3;
  18053. /**
  18054. * Specifies if the light will affect the passed mesh.
  18055. * @param mesh The mesh to test against the light
  18056. * @return true the mesh is affected otherwise, false.
  18057. */
  18058. canAffectMesh(mesh: AbstractMesh): boolean;
  18059. /**
  18060. * Sort function to order lights for rendering.
  18061. * @param a First Light object to compare to second.
  18062. * @param b Second Light object to compare first.
  18063. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18064. */
  18065. static CompareLightsPriority(a: Light, b: Light): number;
  18066. /**
  18067. * Releases resources associated with this node.
  18068. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18069. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18070. */
  18071. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18072. /**
  18073. * Returns the light type ID (integer).
  18074. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18075. */
  18076. getTypeID(): number;
  18077. /**
  18078. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18079. * @returns the scaled intensity in intensity mode unit
  18080. */
  18081. getScaledIntensity(): number;
  18082. /**
  18083. * Returns a new Light object, named "name", from the current one.
  18084. * @param name The name of the cloned light
  18085. * @param newParent The parent of this light, if it has one
  18086. * @returns the new created light
  18087. */
  18088. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18089. /**
  18090. * Serializes the current light into a Serialization object.
  18091. * @returns the serialized object.
  18092. */
  18093. serialize(): any;
  18094. /**
  18095. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18096. * This new light is named "name" and added to the passed scene.
  18097. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18098. * @param name The friendly name of the light
  18099. * @param scene The scene the new light will belong to
  18100. * @returns the constructor function
  18101. */
  18102. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18103. /**
  18104. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18105. * @param parsedLight The JSON representation of the light
  18106. * @param scene The scene to create the parsed light in
  18107. * @returns the created light after parsing
  18108. */
  18109. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18110. private _hookArrayForExcluded;
  18111. private _hookArrayForIncludedOnly;
  18112. private _resyncMeshes;
  18113. /**
  18114. * Forces the meshes to update their light related information in their rendering used effects
  18115. * @hidden Internal Use Only
  18116. */
  18117. _markMeshesAsLightDirty(): void;
  18118. /**
  18119. * Recomputes the cached photometric scale if needed.
  18120. */
  18121. private _computePhotometricScale;
  18122. /**
  18123. * Returns the Photometric Scale according to the light type and intensity mode.
  18124. */
  18125. private _getPhotometricScale;
  18126. /**
  18127. * Reorder the light in the scene according to their defined priority.
  18128. * @hidden Internal Use Only
  18129. */
  18130. _reorderLightsInScene(): void;
  18131. /**
  18132. * Prepares the list of defines specific to the light type.
  18133. * @param defines the list of defines
  18134. * @param lightIndex defines the index of the light for the effect
  18135. */
  18136. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18137. }
  18138. }
  18139. declare module BABYLON {
  18140. /**
  18141. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18142. * This is the base of the follow, arc rotate cameras and Free camera
  18143. * @see http://doc.babylonjs.com/features/cameras
  18144. */
  18145. export class TargetCamera extends Camera {
  18146. private static _RigCamTransformMatrix;
  18147. private static _TargetTransformMatrix;
  18148. private static _TargetFocalPoint;
  18149. /**
  18150. * Define the current direction the camera is moving to
  18151. */
  18152. cameraDirection: Vector3;
  18153. /**
  18154. * Define the current rotation the camera is rotating to
  18155. */
  18156. cameraRotation: Vector2;
  18157. /**
  18158. * When set, the up vector of the camera will be updated by the rotation of the camera
  18159. */
  18160. updateUpVectorFromRotation: boolean;
  18161. private _tmpQuaternion;
  18162. /**
  18163. * Define the current rotation of the camera
  18164. */
  18165. rotation: Vector3;
  18166. /**
  18167. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18168. */
  18169. rotationQuaternion: Quaternion;
  18170. /**
  18171. * Define the current speed of the camera
  18172. */
  18173. speed: number;
  18174. /**
  18175. * Add constraint to the camera to prevent it to move freely in all directions and
  18176. * around all axis.
  18177. */
  18178. noRotationConstraint: boolean;
  18179. /**
  18180. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18181. * panning
  18182. */
  18183. invertRotation: boolean;
  18184. /**
  18185. * Speed multiplier for inverse camera panning
  18186. */
  18187. inverseRotationSpeed: number;
  18188. /**
  18189. * Define the current target of the camera as an object or a position.
  18190. */
  18191. lockedTarget: any;
  18192. /** @hidden */
  18193. _currentTarget: Vector3;
  18194. /** @hidden */
  18195. _initialFocalDistance: number;
  18196. /** @hidden */
  18197. _viewMatrix: Matrix;
  18198. /** @hidden */
  18199. _camMatrix: Matrix;
  18200. /** @hidden */
  18201. _cameraTransformMatrix: Matrix;
  18202. /** @hidden */
  18203. _cameraRotationMatrix: Matrix;
  18204. /** @hidden */
  18205. _referencePoint: Vector3;
  18206. /** @hidden */
  18207. _transformedReferencePoint: Vector3;
  18208. protected _globalCurrentTarget: Vector3;
  18209. protected _globalCurrentUpVector: Vector3;
  18210. /** @hidden */
  18211. _reset: () => void;
  18212. private _defaultUp;
  18213. /**
  18214. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18215. * This is the base of the follow, arc rotate cameras and Free camera
  18216. * @see http://doc.babylonjs.com/features/cameras
  18217. * @param name Defines the name of the camera in the scene
  18218. * @param position Defines the start position of the camera in the scene
  18219. * @param scene Defines the scene the camera belongs to
  18220. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18221. */
  18222. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18223. /**
  18224. * Gets the position in front of the camera at a given distance.
  18225. * @param distance The distance from the camera we want the position to be
  18226. * @returns the position
  18227. */
  18228. getFrontPosition(distance: number): Vector3;
  18229. /** @hidden */
  18230. _getLockedTargetPosition(): Nullable<Vector3>;
  18231. private _storedPosition;
  18232. private _storedRotation;
  18233. private _storedRotationQuaternion;
  18234. /**
  18235. * Store current camera state of the camera (fov, position, rotation, etc..)
  18236. * @returns the camera
  18237. */
  18238. storeState(): Camera;
  18239. /**
  18240. * Restored camera state. You must call storeState() first
  18241. * @returns whether it was successful or not
  18242. * @hidden
  18243. */
  18244. _restoreStateValues(): boolean;
  18245. /** @hidden */
  18246. _initCache(): void;
  18247. /** @hidden */
  18248. _updateCache(ignoreParentClass?: boolean): void;
  18249. /** @hidden */
  18250. _isSynchronizedViewMatrix(): boolean;
  18251. /** @hidden */
  18252. _computeLocalCameraSpeed(): number;
  18253. /**
  18254. * Defines the target the camera should look at.
  18255. * @param target Defines the new target as a Vector or a mesh
  18256. */
  18257. setTarget(target: Vector3): void;
  18258. /**
  18259. * Return the current target position of the camera. This value is expressed in local space.
  18260. * @returns the target position
  18261. */
  18262. getTarget(): Vector3;
  18263. /** @hidden */
  18264. _decideIfNeedsToMove(): boolean;
  18265. /** @hidden */
  18266. _updatePosition(): void;
  18267. /** @hidden */
  18268. _checkInputs(): void;
  18269. protected _updateCameraRotationMatrix(): void;
  18270. /**
  18271. * 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)
  18272. * @returns the current camera
  18273. */
  18274. private _rotateUpVectorWithCameraRotationMatrix;
  18275. private _cachedRotationZ;
  18276. private _cachedQuaternionRotationZ;
  18277. /** @hidden */
  18278. _getViewMatrix(): Matrix;
  18279. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18280. /**
  18281. * @hidden
  18282. */
  18283. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18284. /**
  18285. * @hidden
  18286. */
  18287. _updateRigCameras(): void;
  18288. private _getRigCamPositionAndTarget;
  18289. /**
  18290. * Gets the current object class name.
  18291. * @return the class name
  18292. */
  18293. getClassName(): string;
  18294. }
  18295. }
  18296. declare module BABYLON {
  18297. /**
  18298. * Gather the list of keyboard event types as constants.
  18299. */
  18300. export class KeyboardEventTypes {
  18301. /**
  18302. * The keydown event is fired when a key becomes active (pressed).
  18303. */
  18304. static readonly KEYDOWN: number;
  18305. /**
  18306. * The keyup event is fired when a key has been released.
  18307. */
  18308. static readonly KEYUP: number;
  18309. }
  18310. /**
  18311. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18312. */
  18313. export class KeyboardInfo {
  18314. /**
  18315. * Defines the type of event (KeyboardEventTypes)
  18316. */
  18317. type: number;
  18318. /**
  18319. * Defines the related dom event
  18320. */
  18321. event: KeyboardEvent;
  18322. /**
  18323. * Instantiates a new keyboard info.
  18324. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18325. * @param type Defines the type of event (KeyboardEventTypes)
  18326. * @param event Defines the related dom event
  18327. */
  18328. constructor(
  18329. /**
  18330. * Defines the type of event (KeyboardEventTypes)
  18331. */
  18332. type: number,
  18333. /**
  18334. * Defines the related dom event
  18335. */
  18336. event: KeyboardEvent);
  18337. }
  18338. /**
  18339. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18340. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18341. */
  18342. export class KeyboardInfoPre extends KeyboardInfo {
  18343. /**
  18344. * Defines the type of event (KeyboardEventTypes)
  18345. */
  18346. type: number;
  18347. /**
  18348. * Defines the related dom event
  18349. */
  18350. event: KeyboardEvent;
  18351. /**
  18352. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18353. */
  18354. skipOnPointerObservable: boolean;
  18355. /**
  18356. * Instantiates a new keyboard pre info.
  18357. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18358. * @param type Defines the type of event (KeyboardEventTypes)
  18359. * @param event Defines the related dom event
  18360. */
  18361. constructor(
  18362. /**
  18363. * Defines the type of event (KeyboardEventTypes)
  18364. */
  18365. type: number,
  18366. /**
  18367. * Defines the related dom event
  18368. */
  18369. event: KeyboardEvent);
  18370. }
  18371. }
  18372. declare module BABYLON {
  18373. /**
  18374. * Manage the keyboard inputs to control the movement of a free camera.
  18375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18376. */
  18377. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18378. /**
  18379. * Defines the camera the input is attached to.
  18380. */
  18381. camera: FreeCamera;
  18382. /**
  18383. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18384. */
  18385. keysUp: number[];
  18386. /**
  18387. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18388. */
  18389. keysUpward: number[];
  18390. /**
  18391. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18392. */
  18393. keysDown: number[];
  18394. /**
  18395. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18396. */
  18397. keysDownward: number[];
  18398. /**
  18399. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18400. */
  18401. keysLeft: number[];
  18402. /**
  18403. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18404. */
  18405. keysRight: number[];
  18406. private _keys;
  18407. private _onCanvasBlurObserver;
  18408. private _onKeyboardObserver;
  18409. private _engine;
  18410. private _scene;
  18411. /**
  18412. * Attach the input controls to a specific dom element to get the input from.
  18413. * @param element Defines the element the controls should be listened from
  18414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18415. */
  18416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18417. /**
  18418. * Detach the current controls from the specified dom element.
  18419. * @param element Defines the element to stop listening the inputs from
  18420. */
  18421. detachControl(element: Nullable<HTMLElement>): void;
  18422. /**
  18423. * Update the current camera state depending on the inputs that have been used this frame.
  18424. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18425. */
  18426. checkInputs(): void;
  18427. /**
  18428. * Gets the class name of the current intput.
  18429. * @returns the class name
  18430. */
  18431. getClassName(): string;
  18432. /** @hidden */
  18433. _onLostFocus(): void;
  18434. /**
  18435. * Get the friendly name associated with the input class.
  18436. * @returns the input friendly name
  18437. */
  18438. getSimpleName(): string;
  18439. }
  18440. }
  18441. declare module BABYLON {
  18442. /**
  18443. * Gather the list of pointer event types as constants.
  18444. */
  18445. export class PointerEventTypes {
  18446. /**
  18447. * 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.
  18448. */
  18449. static readonly POINTERDOWN: number;
  18450. /**
  18451. * The pointerup event is fired when a pointer is no longer active.
  18452. */
  18453. static readonly POINTERUP: number;
  18454. /**
  18455. * The pointermove event is fired when a pointer changes coordinates.
  18456. */
  18457. static readonly POINTERMOVE: number;
  18458. /**
  18459. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18460. */
  18461. static readonly POINTERWHEEL: number;
  18462. /**
  18463. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18464. */
  18465. static readonly POINTERPICK: number;
  18466. /**
  18467. * The pointertap event is fired when a the object has been touched and released without drag.
  18468. */
  18469. static readonly POINTERTAP: number;
  18470. /**
  18471. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18472. */
  18473. static readonly POINTERDOUBLETAP: number;
  18474. }
  18475. /**
  18476. * Base class of pointer info types.
  18477. */
  18478. export class PointerInfoBase {
  18479. /**
  18480. * Defines the type of event (PointerEventTypes)
  18481. */
  18482. type: number;
  18483. /**
  18484. * Defines the related dom event
  18485. */
  18486. event: PointerEvent | MouseWheelEvent;
  18487. /**
  18488. * Instantiates the base class of pointers info.
  18489. * @param type Defines the type of event (PointerEventTypes)
  18490. * @param event Defines the related dom event
  18491. */
  18492. constructor(
  18493. /**
  18494. * Defines the type of event (PointerEventTypes)
  18495. */
  18496. type: number,
  18497. /**
  18498. * Defines the related dom event
  18499. */
  18500. event: PointerEvent | MouseWheelEvent);
  18501. }
  18502. /**
  18503. * This class is used to store pointer related info for the onPrePointerObservable event.
  18504. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18505. */
  18506. export class PointerInfoPre extends PointerInfoBase {
  18507. /**
  18508. * Ray from a pointer if availible (eg. 6dof controller)
  18509. */
  18510. ray: Nullable<Ray>;
  18511. /**
  18512. * Defines the local position of the pointer on the canvas.
  18513. */
  18514. localPosition: Vector2;
  18515. /**
  18516. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18517. */
  18518. skipOnPointerObservable: boolean;
  18519. /**
  18520. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18521. * @param type Defines the type of event (PointerEventTypes)
  18522. * @param event Defines the related dom event
  18523. * @param localX Defines the local x coordinates of the pointer when the event occured
  18524. * @param localY Defines the local y coordinates of the pointer when the event occured
  18525. */
  18526. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18527. }
  18528. /**
  18529. * This type contains all the data related to a pointer event in Babylon.js.
  18530. * 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.
  18531. */
  18532. export class PointerInfo extends PointerInfoBase {
  18533. /**
  18534. * Defines the picking info associated to the info (if any)\
  18535. */
  18536. pickInfo: Nullable<PickingInfo>;
  18537. /**
  18538. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18539. * @param type Defines the type of event (PointerEventTypes)
  18540. * @param event Defines the related dom event
  18541. * @param pickInfo Defines the picking info associated to the info (if any)\
  18542. */
  18543. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18544. /**
  18545. * Defines the picking info associated to the info (if any)\
  18546. */
  18547. pickInfo: Nullable<PickingInfo>);
  18548. }
  18549. /**
  18550. * Data relating to a touch event on the screen.
  18551. */
  18552. export interface PointerTouch {
  18553. /**
  18554. * X coordinate of touch.
  18555. */
  18556. x: number;
  18557. /**
  18558. * Y coordinate of touch.
  18559. */
  18560. y: number;
  18561. /**
  18562. * Id of touch. Unique for each finger.
  18563. */
  18564. pointerId: number;
  18565. /**
  18566. * Event type passed from DOM.
  18567. */
  18568. type: any;
  18569. }
  18570. }
  18571. declare module BABYLON {
  18572. /**
  18573. * Manage the mouse inputs to control the movement of a free camera.
  18574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18575. */
  18576. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18577. /**
  18578. * Define if touch is enabled in the mouse input
  18579. */
  18580. touchEnabled: boolean;
  18581. /**
  18582. * Defines the camera the input is attached to.
  18583. */
  18584. camera: FreeCamera;
  18585. /**
  18586. * Defines the buttons associated with the input to handle camera move.
  18587. */
  18588. buttons: number[];
  18589. /**
  18590. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18591. */
  18592. angularSensibility: number;
  18593. private _pointerInput;
  18594. private _onMouseMove;
  18595. private _observer;
  18596. private previousPosition;
  18597. /**
  18598. * Observable for when a pointer move event occurs containing the move offset
  18599. */
  18600. onPointerMovedObservable: Observable<{
  18601. offsetX: number;
  18602. offsetY: number;
  18603. }>;
  18604. /**
  18605. * @hidden
  18606. * If the camera should be rotated automatically based on pointer movement
  18607. */
  18608. _allowCameraRotation: boolean;
  18609. /**
  18610. * Manage the mouse inputs to control the movement of a free camera.
  18611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18612. * @param touchEnabled Defines if touch is enabled or not
  18613. */
  18614. constructor(
  18615. /**
  18616. * Define if touch is enabled in the mouse input
  18617. */
  18618. touchEnabled?: boolean);
  18619. /**
  18620. * Attach the input controls to a specific dom element to get the input from.
  18621. * @param element Defines the element the controls should be listened from
  18622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18623. */
  18624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18625. /**
  18626. * Called on JS contextmenu event.
  18627. * Override this method to provide functionality.
  18628. */
  18629. protected onContextMenu(evt: PointerEvent): void;
  18630. /**
  18631. * Detach the current controls from the specified dom element.
  18632. * @param element Defines the element to stop listening the inputs from
  18633. */
  18634. detachControl(element: Nullable<HTMLElement>): void;
  18635. /**
  18636. * Gets the class name of the current intput.
  18637. * @returns the class name
  18638. */
  18639. getClassName(): string;
  18640. /**
  18641. * Get the friendly name associated with the input class.
  18642. * @returns the input friendly name
  18643. */
  18644. getSimpleName(): string;
  18645. }
  18646. }
  18647. declare module BABYLON {
  18648. /**
  18649. * Manage the touch inputs to control the movement of a free camera.
  18650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18651. */
  18652. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18653. /**
  18654. * Defines the camera the input is attached to.
  18655. */
  18656. camera: FreeCamera;
  18657. /**
  18658. * Defines the touch sensibility for rotation.
  18659. * The higher the faster.
  18660. */
  18661. touchAngularSensibility: number;
  18662. /**
  18663. * Defines the touch sensibility for move.
  18664. * The higher the faster.
  18665. */
  18666. touchMoveSensibility: number;
  18667. private _offsetX;
  18668. private _offsetY;
  18669. private _pointerPressed;
  18670. private _pointerInput;
  18671. private _observer;
  18672. private _onLostFocus;
  18673. /**
  18674. * Attach the input controls to a specific dom element to get the input from.
  18675. * @param element Defines the element the controls should be listened from
  18676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18677. */
  18678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18679. /**
  18680. * Detach the current controls from the specified dom element.
  18681. * @param element Defines the element to stop listening the inputs from
  18682. */
  18683. detachControl(element: Nullable<HTMLElement>): void;
  18684. /**
  18685. * Update the current camera state depending on the inputs that have been used this frame.
  18686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18687. */
  18688. checkInputs(): void;
  18689. /**
  18690. * Gets the class name of the current intput.
  18691. * @returns the class name
  18692. */
  18693. getClassName(): string;
  18694. /**
  18695. * Get the friendly name associated with the input class.
  18696. * @returns the input friendly name
  18697. */
  18698. getSimpleName(): string;
  18699. }
  18700. }
  18701. declare module BABYLON {
  18702. /**
  18703. * Default Inputs manager for the FreeCamera.
  18704. * It groups all the default supported inputs for ease of use.
  18705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18706. */
  18707. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18708. /**
  18709. * @hidden
  18710. */
  18711. _mouseInput: Nullable<FreeCameraMouseInput>;
  18712. /**
  18713. * Instantiates a new FreeCameraInputsManager.
  18714. * @param camera Defines the camera the inputs belong to
  18715. */
  18716. constructor(camera: FreeCamera);
  18717. /**
  18718. * Add keyboard input support to the input manager.
  18719. * @returns the current input manager
  18720. */
  18721. addKeyboard(): FreeCameraInputsManager;
  18722. /**
  18723. * Add mouse input support to the input manager.
  18724. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18725. * @returns the current input manager
  18726. */
  18727. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18728. /**
  18729. * Removes the mouse input support from the manager
  18730. * @returns the current input manager
  18731. */
  18732. removeMouse(): FreeCameraInputsManager;
  18733. /**
  18734. * Add touch input support to the input manager.
  18735. * @returns the current input manager
  18736. */
  18737. addTouch(): FreeCameraInputsManager;
  18738. /**
  18739. * Remove all attached input methods from a camera
  18740. */
  18741. clear(): void;
  18742. }
  18743. }
  18744. declare module BABYLON {
  18745. /**
  18746. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18747. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18748. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18749. */
  18750. export class FreeCamera extends TargetCamera {
  18751. /**
  18752. * Define the collision ellipsoid of the camera.
  18753. * This is helpful to simulate a camera body like the player body around the camera
  18754. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18755. */
  18756. ellipsoid: Vector3;
  18757. /**
  18758. * Define an offset for the position of the ellipsoid around the camera.
  18759. * This can be helpful to determine the center of the body near the gravity center of the body
  18760. * instead of its head.
  18761. */
  18762. ellipsoidOffset: Vector3;
  18763. /**
  18764. * Enable or disable collisions of the camera with the rest of the scene objects.
  18765. */
  18766. checkCollisions: boolean;
  18767. /**
  18768. * Enable or disable gravity on the camera.
  18769. */
  18770. applyGravity: boolean;
  18771. /**
  18772. * Define the input manager associated to the camera.
  18773. */
  18774. inputs: FreeCameraInputsManager;
  18775. /**
  18776. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18777. * Higher values reduce sensitivity.
  18778. */
  18779. get angularSensibility(): number;
  18780. /**
  18781. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18782. * Higher values reduce sensitivity.
  18783. */
  18784. set angularSensibility(value: number);
  18785. /**
  18786. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18787. */
  18788. get keysUp(): number[];
  18789. set keysUp(value: number[]);
  18790. /**
  18791. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18792. */
  18793. get keysUpward(): number[];
  18794. set keysUpward(value: number[]);
  18795. /**
  18796. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18797. */
  18798. get keysDown(): number[];
  18799. set keysDown(value: number[]);
  18800. /**
  18801. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18802. */
  18803. get keysDownward(): number[];
  18804. set keysDownward(value: number[]);
  18805. /**
  18806. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18807. */
  18808. get keysLeft(): number[];
  18809. set keysLeft(value: number[]);
  18810. /**
  18811. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18812. */
  18813. get keysRight(): number[];
  18814. set keysRight(value: number[]);
  18815. /**
  18816. * Event raised when the camera collide with a mesh in the scene.
  18817. */
  18818. onCollide: (collidedMesh: AbstractMesh) => void;
  18819. private _collider;
  18820. private _needMoveForGravity;
  18821. private _oldPosition;
  18822. private _diffPosition;
  18823. private _newPosition;
  18824. /** @hidden */
  18825. _localDirection: Vector3;
  18826. /** @hidden */
  18827. _transformedDirection: Vector3;
  18828. /**
  18829. * Instantiates a Free Camera.
  18830. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18831. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18832. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18833. * @param name Define the name of the camera in the scene
  18834. * @param position Define the start position of the camera in the scene
  18835. * @param scene Define the scene the camera belongs to
  18836. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18837. */
  18838. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18839. /**
  18840. * Attached controls to the current camera.
  18841. * @param element Defines the element the controls should be listened from
  18842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18843. */
  18844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18845. /**
  18846. * Detach the current controls from the camera.
  18847. * The camera will stop reacting to inputs.
  18848. * @param element Defines the element to stop listening the inputs from
  18849. */
  18850. detachControl(element: HTMLElement): void;
  18851. private _collisionMask;
  18852. /**
  18853. * Define a collision mask to limit the list of object the camera can collide with
  18854. */
  18855. get collisionMask(): number;
  18856. set collisionMask(mask: number);
  18857. /** @hidden */
  18858. _collideWithWorld(displacement: Vector3): void;
  18859. private _onCollisionPositionChange;
  18860. /** @hidden */
  18861. _checkInputs(): void;
  18862. /** @hidden */
  18863. _decideIfNeedsToMove(): boolean;
  18864. /** @hidden */
  18865. _updatePosition(): void;
  18866. /**
  18867. * Destroy the camera and release the current resources hold by it.
  18868. */
  18869. dispose(): void;
  18870. /**
  18871. * Gets the current object class name.
  18872. * @return the class name
  18873. */
  18874. getClassName(): string;
  18875. }
  18876. }
  18877. declare module BABYLON {
  18878. /**
  18879. * Represents a gamepad control stick position
  18880. */
  18881. export class StickValues {
  18882. /**
  18883. * The x component of the control stick
  18884. */
  18885. x: number;
  18886. /**
  18887. * The y component of the control stick
  18888. */
  18889. y: number;
  18890. /**
  18891. * Initializes the gamepad x and y control stick values
  18892. * @param x The x component of the gamepad control stick value
  18893. * @param y The y component of the gamepad control stick value
  18894. */
  18895. constructor(
  18896. /**
  18897. * The x component of the control stick
  18898. */
  18899. x: number,
  18900. /**
  18901. * The y component of the control stick
  18902. */
  18903. y: number);
  18904. }
  18905. /**
  18906. * An interface which manages callbacks for gamepad button changes
  18907. */
  18908. export interface GamepadButtonChanges {
  18909. /**
  18910. * Called when a gamepad has been changed
  18911. */
  18912. changed: boolean;
  18913. /**
  18914. * Called when a gamepad press event has been triggered
  18915. */
  18916. pressChanged: boolean;
  18917. /**
  18918. * Called when a touch event has been triggered
  18919. */
  18920. touchChanged: boolean;
  18921. /**
  18922. * Called when a value has changed
  18923. */
  18924. valueChanged: boolean;
  18925. }
  18926. /**
  18927. * Represents a gamepad
  18928. */
  18929. export class Gamepad {
  18930. /**
  18931. * The id of the gamepad
  18932. */
  18933. id: string;
  18934. /**
  18935. * The index of the gamepad
  18936. */
  18937. index: number;
  18938. /**
  18939. * The browser gamepad
  18940. */
  18941. browserGamepad: any;
  18942. /**
  18943. * Specifies what type of gamepad this represents
  18944. */
  18945. type: number;
  18946. private _leftStick;
  18947. private _rightStick;
  18948. /** @hidden */
  18949. _isConnected: boolean;
  18950. private _leftStickAxisX;
  18951. private _leftStickAxisY;
  18952. private _rightStickAxisX;
  18953. private _rightStickAxisY;
  18954. /**
  18955. * Triggered when the left control stick has been changed
  18956. */
  18957. private _onleftstickchanged;
  18958. /**
  18959. * Triggered when the right control stick has been changed
  18960. */
  18961. private _onrightstickchanged;
  18962. /**
  18963. * Represents a gamepad controller
  18964. */
  18965. static GAMEPAD: number;
  18966. /**
  18967. * Represents a generic controller
  18968. */
  18969. static GENERIC: number;
  18970. /**
  18971. * Represents an XBox controller
  18972. */
  18973. static XBOX: number;
  18974. /**
  18975. * Represents a pose-enabled controller
  18976. */
  18977. static POSE_ENABLED: number;
  18978. /**
  18979. * Represents an Dual Shock controller
  18980. */
  18981. static DUALSHOCK: number;
  18982. /**
  18983. * Specifies whether the left control stick should be Y-inverted
  18984. */
  18985. protected _invertLeftStickY: boolean;
  18986. /**
  18987. * Specifies if the gamepad has been connected
  18988. */
  18989. get isConnected(): boolean;
  18990. /**
  18991. * Initializes the gamepad
  18992. * @param id The id of the gamepad
  18993. * @param index The index of the gamepad
  18994. * @param browserGamepad The browser gamepad
  18995. * @param leftStickX The x component of the left joystick
  18996. * @param leftStickY The y component of the left joystick
  18997. * @param rightStickX The x component of the right joystick
  18998. * @param rightStickY The y component of the right joystick
  18999. */
  19000. constructor(
  19001. /**
  19002. * The id of the gamepad
  19003. */
  19004. id: string,
  19005. /**
  19006. * The index of the gamepad
  19007. */
  19008. index: number,
  19009. /**
  19010. * The browser gamepad
  19011. */
  19012. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19013. /**
  19014. * Callback triggered when the left joystick has changed
  19015. * @param callback
  19016. */
  19017. onleftstickchanged(callback: (values: StickValues) => void): void;
  19018. /**
  19019. * Callback triggered when the right joystick has changed
  19020. * @param callback
  19021. */
  19022. onrightstickchanged(callback: (values: StickValues) => void): void;
  19023. /**
  19024. * Gets the left joystick
  19025. */
  19026. get leftStick(): StickValues;
  19027. /**
  19028. * Sets the left joystick values
  19029. */
  19030. set leftStick(newValues: StickValues);
  19031. /**
  19032. * Gets the right joystick
  19033. */
  19034. get rightStick(): StickValues;
  19035. /**
  19036. * Sets the right joystick value
  19037. */
  19038. set rightStick(newValues: StickValues);
  19039. /**
  19040. * Updates the gamepad joystick positions
  19041. */
  19042. update(): void;
  19043. /**
  19044. * Disposes the gamepad
  19045. */
  19046. dispose(): void;
  19047. }
  19048. /**
  19049. * Represents a generic gamepad
  19050. */
  19051. export class GenericPad extends Gamepad {
  19052. private _buttons;
  19053. private _onbuttondown;
  19054. private _onbuttonup;
  19055. /**
  19056. * Observable triggered when a button has been pressed
  19057. */
  19058. onButtonDownObservable: Observable<number>;
  19059. /**
  19060. * Observable triggered when a button has been released
  19061. */
  19062. onButtonUpObservable: Observable<number>;
  19063. /**
  19064. * Callback triggered when a button has been pressed
  19065. * @param callback Called when a button has been pressed
  19066. */
  19067. onbuttondown(callback: (buttonPressed: number) => void): void;
  19068. /**
  19069. * Callback triggered when a button has been released
  19070. * @param callback Called when a button has been released
  19071. */
  19072. onbuttonup(callback: (buttonReleased: number) => void): void;
  19073. /**
  19074. * Initializes the generic gamepad
  19075. * @param id The id of the generic gamepad
  19076. * @param index The index of the generic gamepad
  19077. * @param browserGamepad The browser gamepad
  19078. */
  19079. constructor(id: string, index: number, browserGamepad: any);
  19080. private _setButtonValue;
  19081. /**
  19082. * Updates the generic gamepad
  19083. */
  19084. update(): void;
  19085. /**
  19086. * Disposes the generic gamepad
  19087. */
  19088. dispose(): void;
  19089. }
  19090. }
  19091. declare module BABYLON {
  19092. /**
  19093. * Defines the types of pose enabled controllers that are supported
  19094. */
  19095. export enum PoseEnabledControllerType {
  19096. /**
  19097. * HTC Vive
  19098. */
  19099. VIVE = 0,
  19100. /**
  19101. * Oculus Rift
  19102. */
  19103. OCULUS = 1,
  19104. /**
  19105. * Windows mixed reality
  19106. */
  19107. WINDOWS = 2,
  19108. /**
  19109. * Samsung gear VR
  19110. */
  19111. GEAR_VR = 3,
  19112. /**
  19113. * Google Daydream
  19114. */
  19115. DAYDREAM = 4,
  19116. /**
  19117. * Generic
  19118. */
  19119. GENERIC = 5
  19120. }
  19121. /**
  19122. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19123. */
  19124. export interface MutableGamepadButton {
  19125. /**
  19126. * Value of the button/trigger
  19127. */
  19128. value: number;
  19129. /**
  19130. * If the button/trigger is currently touched
  19131. */
  19132. touched: boolean;
  19133. /**
  19134. * If the button/trigger is currently pressed
  19135. */
  19136. pressed: boolean;
  19137. }
  19138. /**
  19139. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19140. * @hidden
  19141. */
  19142. export interface ExtendedGamepadButton extends GamepadButton {
  19143. /**
  19144. * If the button/trigger is currently pressed
  19145. */
  19146. readonly pressed: boolean;
  19147. /**
  19148. * If the button/trigger is currently touched
  19149. */
  19150. readonly touched: boolean;
  19151. /**
  19152. * Value of the button/trigger
  19153. */
  19154. readonly value: number;
  19155. }
  19156. /** @hidden */
  19157. export interface _GamePadFactory {
  19158. /**
  19159. * Returns whether or not the current gamepad can be created for this type of controller.
  19160. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19161. * @returns true if it can be created, otherwise false
  19162. */
  19163. canCreate(gamepadInfo: any): boolean;
  19164. /**
  19165. * Creates a new instance of the Gamepad.
  19166. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19167. * @returns the new gamepad instance
  19168. */
  19169. create(gamepadInfo: any): Gamepad;
  19170. }
  19171. /**
  19172. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19173. */
  19174. export class PoseEnabledControllerHelper {
  19175. /** @hidden */
  19176. static _ControllerFactories: _GamePadFactory[];
  19177. /** @hidden */
  19178. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19179. /**
  19180. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19181. * @param vrGamepad the gamepad to initialized
  19182. * @returns a vr controller of the type the gamepad identified as
  19183. */
  19184. static InitiateController(vrGamepad: any): Gamepad;
  19185. }
  19186. /**
  19187. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19188. */
  19189. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19190. /**
  19191. * If the controller is used in a webXR session
  19192. */
  19193. isXR: boolean;
  19194. private _deviceRoomPosition;
  19195. private _deviceRoomRotationQuaternion;
  19196. /**
  19197. * The device position in babylon space
  19198. */
  19199. devicePosition: Vector3;
  19200. /**
  19201. * The device rotation in babylon space
  19202. */
  19203. deviceRotationQuaternion: Quaternion;
  19204. /**
  19205. * The scale factor of the device in babylon space
  19206. */
  19207. deviceScaleFactor: number;
  19208. /**
  19209. * (Likely devicePosition should be used instead) The device position in its room space
  19210. */
  19211. position: Vector3;
  19212. /**
  19213. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19214. */
  19215. rotationQuaternion: Quaternion;
  19216. /**
  19217. * The type of controller (Eg. Windows mixed reality)
  19218. */
  19219. controllerType: PoseEnabledControllerType;
  19220. protected _calculatedPosition: Vector3;
  19221. private _calculatedRotation;
  19222. /**
  19223. * The raw pose from the device
  19224. */
  19225. rawPose: DevicePose;
  19226. private _trackPosition;
  19227. private _maxRotationDistFromHeadset;
  19228. private _draggedRoomRotation;
  19229. /**
  19230. * @hidden
  19231. */
  19232. _disableTrackPosition(fixedPosition: Vector3): void;
  19233. /**
  19234. * Internal, the mesh attached to the controller
  19235. * @hidden
  19236. */
  19237. _mesh: Nullable<AbstractMesh>;
  19238. private _poseControlledCamera;
  19239. private _leftHandSystemQuaternion;
  19240. /**
  19241. * Internal, matrix used to convert room space to babylon space
  19242. * @hidden
  19243. */
  19244. _deviceToWorld: Matrix;
  19245. /**
  19246. * Node to be used when casting a ray from the controller
  19247. * @hidden
  19248. */
  19249. _pointingPoseNode: Nullable<TransformNode>;
  19250. /**
  19251. * Name of the child mesh that can be used to cast a ray from the controller
  19252. */
  19253. static readonly POINTING_POSE: string;
  19254. /**
  19255. * Creates a new PoseEnabledController from a gamepad
  19256. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19257. */
  19258. constructor(browserGamepad: any);
  19259. private _workingMatrix;
  19260. /**
  19261. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19262. */
  19263. update(): void;
  19264. /**
  19265. * Updates only the pose device and mesh without doing any button event checking
  19266. */
  19267. protected _updatePoseAndMesh(): void;
  19268. /**
  19269. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19270. * @param poseData raw pose fromthe device
  19271. */
  19272. updateFromDevice(poseData: DevicePose): void;
  19273. /**
  19274. * @hidden
  19275. */
  19276. _meshAttachedObservable: Observable<AbstractMesh>;
  19277. /**
  19278. * Attaches a mesh to the controller
  19279. * @param mesh the mesh to be attached
  19280. */
  19281. attachToMesh(mesh: AbstractMesh): void;
  19282. /**
  19283. * Attaches the controllers mesh to a camera
  19284. * @param camera the camera the mesh should be attached to
  19285. */
  19286. attachToPoseControlledCamera(camera: TargetCamera): void;
  19287. /**
  19288. * Disposes of the controller
  19289. */
  19290. dispose(): void;
  19291. /**
  19292. * The mesh that is attached to the controller
  19293. */
  19294. get mesh(): Nullable<AbstractMesh>;
  19295. /**
  19296. * Gets the ray of the controller in the direction the controller is pointing
  19297. * @param length the length the resulting ray should be
  19298. * @returns a ray in the direction the controller is pointing
  19299. */
  19300. getForwardRay(length?: number): Ray;
  19301. }
  19302. }
  19303. declare module BABYLON {
  19304. /**
  19305. * Defines the WebVRController object that represents controllers tracked in 3D space
  19306. */
  19307. export abstract class WebVRController extends PoseEnabledController {
  19308. /**
  19309. * Internal, the default controller model for the controller
  19310. */
  19311. protected _defaultModel: Nullable<AbstractMesh>;
  19312. /**
  19313. * Fired when the trigger state has changed
  19314. */
  19315. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19316. /**
  19317. * Fired when the main button state has changed
  19318. */
  19319. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19320. /**
  19321. * Fired when the secondary button state has changed
  19322. */
  19323. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19324. /**
  19325. * Fired when the pad state has changed
  19326. */
  19327. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19328. /**
  19329. * Fired when controllers stick values have changed
  19330. */
  19331. onPadValuesChangedObservable: Observable<StickValues>;
  19332. /**
  19333. * Array of button availible on the controller
  19334. */
  19335. protected _buttons: Array<MutableGamepadButton>;
  19336. private _onButtonStateChange;
  19337. /**
  19338. * Fired when a controller button's state has changed
  19339. * @param callback the callback containing the button that was modified
  19340. */
  19341. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19342. /**
  19343. * X and Y axis corresponding to the controllers joystick
  19344. */
  19345. pad: StickValues;
  19346. /**
  19347. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19348. */
  19349. hand: string;
  19350. /**
  19351. * The default controller model for the controller
  19352. */
  19353. get defaultModel(): Nullable<AbstractMesh>;
  19354. /**
  19355. * Creates a new WebVRController from a gamepad
  19356. * @param vrGamepad the gamepad that the WebVRController should be created from
  19357. */
  19358. constructor(vrGamepad: any);
  19359. /**
  19360. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19361. */
  19362. update(): void;
  19363. /**
  19364. * Function to be called when a button is modified
  19365. */
  19366. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19367. /**
  19368. * Loads a mesh and attaches it to the controller
  19369. * @param scene the scene the mesh should be added to
  19370. * @param meshLoaded callback for when the mesh has been loaded
  19371. */
  19372. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19373. private _setButtonValue;
  19374. private _changes;
  19375. private _checkChanges;
  19376. /**
  19377. * Disposes of th webVRCOntroller
  19378. */
  19379. dispose(): void;
  19380. }
  19381. }
  19382. declare module BABYLON {
  19383. /**
  19384. * The HemisphericLight simulates the ambient environment light,
  19385. * so the passed direction is the light reflection direction, not the incoming direction.
  19386. */
  19387. export class HemisphericLight extends Light {
  19388. /**
  19389. * The groundColor is the light in the opposite direction to the one specified during creation.
  19390. * 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.
  19391. */
  19392. groundColor: Color3;
  19393. /**
  19394. * The light reflection direction, not the incoming direction.
  19395. */
  19396. direction: Vector3;
  19397. /**
  19398. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19399. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19400. * The HemisphericLight can't cast shadows.
  19401. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19402. * @param name The friendly name of the light
  19403. * @param direction The direction of the light reflection
  19404. * @param scene The scene the light belongs to
  19405. */
  19406. constructor(name: string, direction: Vector3, scene: Scene);
  19407. protected _buildUniformLayout(): void;
  19408. /**
  19409. * Returns the string "HemisphericLight".
  19410. * @return The class name
  19411. */
  19412. getClassName(): string;
  19413. /**
  19414. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19415. * Returns the updated direction.
  19416. * @param target The target the direction should point to
  19417. * @return The computed direction
  19418. */
  19419. setDirectionToTarget(target: Vector3): Vector3;
  19420. /**
  19421. * Returns the shadow generator associated to the light.
  19422. * @returns Always null for hemispheric lights because it does not support shadows.
  19423. */
  19424. getShadowGenerator(): Nullable<IShadowGenerator>;
  19425. /**
  19426. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19427. * @param effect The effect to update
  19428. * @param lightIndex The index of the light in the effect to update
  19429. * @returns The hemispheric light
  19430. */
  19431. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19432. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19433. /**
  19434. * Computes the world matrix of the node
  19435. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19436. * @param useWasUpdatedFlag defines a reserved property
  19437. * @returns the world matrix
  19438. */
  19439. computeWorldMatrix(): Matrix;
  19440. /**
  19441. * Returns the integer 3.
  19442. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19443. */
  19444. getTypeID(): number;
  19445. /**
  19446. * Prepares the list of defines specific to the light type.
  19447. * @param defines the list of defines
  19448. * @param lightIndex defines the index of the light for the effect
  19449. */
  19450. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19451. }
  19452. }
  19453. declare module BABYLON {
  19454. /** @hidden */
  19455. export var vrMultiviewToSingleviewPixelShader: {
  19456. name: string;
  19457. shader: string;
  19458. };
  19459. }
  19460. declare module BABYLON {
  19461. /**
  19462. * Renders to multiple views with a single draw call
  19463. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19464. */
  19465. export class MultiviewRenderTarget extends RenderTargetTexture {
  19466. /**
  19467. * Creates a multiview render target
  19468. * @param scene scene used with the render target
  19469. * @param size the size of the render target (used for each view)
  19470. */
  19471. constructor(scene: Scene, size?: number | {
  19472. width: number;
  19473. height: number;
  19474. } | {
  19475. ratio: number;
  19476. });
  19477. /**
  19478. * @hidden
  19479. * @param faceIndex the face index, if its a cube texture
  19480. */
  19481. _bindFrameBuffer(faceIndex?: number): void;
  19482. /**
  19483. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19484. * @returns the view count
  19485. */
  19486. getViewCount(): number;
  19487. }
  19488. }
  19489. declare module BABYLON {
  19490. interface Engine {
  19491. /**
  19492. * Creates a new multiview render target
  19493. * @param width defines the width of the texture
  19494. * @param height defines the height of the texture
  19495. * @returns the created multiview texture
  19496. */
  19497. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19498. /**
  19499. * Binds a multiview framebuffer to be drawn to
  19500. * @param multiviewTexture texture to bind
  19501. */
  19502. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19503. }
  19504. interface Camera {
  19505. /**
  19506. * @hidden
  19507. * 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)
  19508. */
  19509. _useMultiviewToSingleView: boolean;
  19510. /**
  19511. * @hidden
  19512. * 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)
  19513. */
  19514. _multiviewTexture: Nullable<RenderTargetTexture>;
  19515. /**
  19516. * @hidden
  19517. * ensures the multiview texture of the camera exists and has the specified width/height
  19518. * @param width height to set on the multiview texture
  19519. * @param height width to set on the multiview texture
  19520. */
  19521. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19522. }
  19523. interface Scene {
  19524. /** @hidden */
  19525. _transformMatrixR: Matrix;
  19526. /** @hidden */
  19527. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19528. /** @hidden */
  19529. _createMultiviewUbo(): void;
  19530. /** @hidden */
  19531. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19532. /** @hidden */
  19533. _renderMultiviewToSingleView(camera: Camera): void;
  19534. }
  19535. }
  19536. declare module BABYLON {
  19537. /**
  19538. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19539. * This will not be used for webXR as it supports displaying texture arrays directly
  19540. */
  19541. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19542. /**
  19543. * Initializes a VRMultiviewToSingleview
  19544. * @param name name of the post process
  19545. * @param camera camera to be applied to
  19546. * @param scaleFactor scaling factor to the size of the output texture
  19547. */
  19548. constructor(name: string, camera: Camera, scaleFactor: number);
  19549. }
  19550. }
  19551. declare module BABYLON {
  19552. /**
  19553. * Interface used to define additional presentation attributes
  19554. */
  19555. export interface IVRPresentationAttributes {
  19556. /**
  19557. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19558. */
  19559. highRefreshRate: boolean;
  19560. /**
  19561. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19562. */
  19563. foveationLevel: number;
  19564. }
  19565. interface Engine {
  19566. /** @hidden */
  19567. _vrDisplay: any;
  19568. /** @hidden */
  19569. _vrSupported: boolean;
  19570. /** @hidden */
  19571. _oldSize: Size;
  19572. /** @hidden */
  19573. _oldHardwareScaleFactor: number;
  19574. /** @hidden */
  19575. _vrExclusivePointerMode: boolean;
  19576. /** @hidden */
  19577. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19578. /** @hidden */
  19579. _onVRDisplayPointerRestricted: () => void;
  19580. /** @hidden */
  19581. _onVRDisplayPointerUnrestricted: () => void;
  19582. /** @hidden */
  19583. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19584. /** @hidden */
  19585. _onVrDisplayDisconnect: Nullable<() => void>;
  19586. /** @hidden */
  19587. _onVrDisplayPresentChange: Nullable<() => void>;
  19588. /**
  19589. * Observable signaled when VR display mode changes
  19590. */
  19591. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19592. /**
  19593. * Observable signaled when VR request present is complete
  19594. */
  19595. onVRRequestPresentComplete: Observable<boolean>;
  19596. /**
  19597. * Observable signaled when VR request present starts
  19598. */
  19599. onVRRequestPresentStart: Observable<Engine>;
  19600. /**
  19601. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19602. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19603. */
  19604. isInVRExclusivePointerMode: boolean;
  19605. /**
  19606. * Gets a boolean indicating if a webVR device was detected
  19607. * @returns true if a webVR device was detected
  19608. */
  19609. isVRDevicePresent(): boolean;
  19610. /**
  19611. * Gets the current webVR device
  19612. * @returns the current webVR device (or null)
  19613. */
  19614. getVRDevice(): any;
  19615. /**
  19616. * Initializes a webVR display and starts listening to display change events
  19617. * The onVRDisplayChangedObservable will be notified upon these changes
  19618. * @returns A promise containing a VRDisplay and if vr is supported
  19619. */
  19620. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19621. /** @hidden */
  19622. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19623. /**
  19624. * Gets or sets the presentation attributes used to configure VR rendering
  19625. */
  19626. vrPresentationAttributes?: IVRPresentationAttributes;
  19627. /**
  19628. * Call this function to switch to webVR mode
  19629. * Will do nothing if webVR is not supported or if there is no webVR device
  19630. * @param options the webvr options provided to the camera. mainly used for multiview
  19631. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19632. */
  19633. enableVR(options: WebVROptions): void;
  19634. /** @hidden */
  19635. _onVRFullScreenTriggered(): void;
  19636. }
  19637. }
  19638. declare module BABYLON {
  19639. /**
  19640. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19641. * IMPORTANT!! The data is right-hand data.
  19642. * @export
  19643. * @interface DevicePose
  19644. */
  19645. export interface DevicePose {
  19646. /**
  19647. * The position of the device, values in array are [x,y,z].
  19648. */
  19649. readonly position: Nullable<Float32Array>;
  19650. /**
  19651. * The linearVelocity of the device, values in array are [x,y,z].
  19652. */
  19653. readonly linearVelocity: Nullable<Float32Array>;
  19654. /**
  19655. * The linearAcceleration of the device, values in array are [x,y,z].
  19656. */
  19657. readonly linearAcceleration: Nullable<Float32Array>;
  19658. /**
  19659. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19660. */
  19661. readonly orientation: Nullable<Float32Array>;
  19662. /**
  19663. * The angularVelocity of the device, values in array are [x,y,z].
  19664. */
  19665. readonly angularVelocity: Nullable<Float32Array>;
  19666. /**
  19667. * The angularAcceleration of the device, values in array are [x,y,z].
  19668. */
  19669. readonly angularAcceleration: Nullable<Float32Array>;
  19670. }
  19671. /**
  19672. * Interface representing a pose controlled object in Babylon.
  19673. * A pose controlled object has both regular pose values as well as pose values
  19674. * from an external device such as a VR head mounted display
  19675. */
  19676. export interface PoseControlled {
  19677. /**
  19678. * The position of the object in babylon space.
  19679. */
  19680. position: Vector3;
  19681. /**
  19682. * The rotation quaternion of the object in babylon space.
  19683. */
  19684. rotationQuaternion: Quaternion;
  19685. /**
  19686. * The position of the device in babylon space.
  19687. */
  19688. devicePosition?: Vector3;
  19689. /**
  19690. * The rotation quaternion of the device in babylon space.
  19691. */
  19692. deviceRotationQuaternion: Quaternion;
  19693. /**
  19694. * The raw pose coming from the device.
  19695. */
  19696. rawPose: Nullable<DevicePose>;
  19697. /**
  19698. * The scale of the device to be used when translating from device space to babylon space.
  19699. */
  19700. deviceScaleFactor: number;
  19701. /**
  19702. * Updates the poseControlled values based on the input device pose.
  19703. * @param poseData the pose data to update the object with
  19704. */
  19705. updateFromDevice(poseData: DevicePose): void;
  19706. }
  19707. /**
  19708. * Set of options to customize the webVRCamera
  19709. */
  19710. export interface WebVROptions {
  19711. /**
  19712. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19713. */
  19714. trackPosition?: boolean;
  19715. /**
  19716. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19717. */
  19718. positionScale?: number;
  19719. /**
  19720. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19721. */
  19722. displayName?: string;
  19723. /**
  19724. * Should the native controller meshes be initialized. (default: true)
  19725. */
  19726. controllerMeshes?: boolean;
  19727. /**
  19728. * Creating a default HemiLight only on controllers. (default: true)
  19729. */
  19730. defaultLightingOnControllers?: boolean;
  19731. /**
  19732. * If you don't want to use the default VR button of the helper. (default: false)
  19733. */
  19734. useCustomVRButton?: boolean;
  19735. /**
  19736. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19737. */
  19738. customVRButton?: HTMLButtonElement;
  19739. /**
  19740. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19741. */
  19742. rayLength?: number;
  19743. /**
  19744. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19745. */
  19746. defaultHeight?: number;
  19747. /**
  19748. * If multiview should be used if availible (default: false)
  19749. */
  19750. useMultiview?: boolean;
  19751. }
  19752. /**
  19753. * This represents a WebVR camera.
  19754. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19755. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19756. */
  19757. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19758. private webVROptions;
  19759. /**
  19760. * @hidden
  19761. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19762. */
  19763. _vrDevice: any;
  19764. /**
  19765. * The rawPose of the vrDevice.
  19766. */
  19767. rawPose: Nullable<DevicePose>;
  19768. private _onVREnabled;
  19769. private _specsVersion;
  19770. private _attached;
  19771. private _frameData;
  19772. protected _descendants: Array<Node>;
  19773. private _deviceRoomPosition;
  19774. /** @hidden */
  19775. _deviceRoomRotationQuaternion: Quaternion;
  19776. private _standingMatrix;
  19777. /**
  19778. * Represents device position in babylon space.
  19779. */
  19780. devicePosition: Vector3;
  19781. /**
  19782. * Represents device rotation in babylon space.
  19783. */
  19784. deviceRotationQuaternion: Quaternion;
  19785. /**
  19786. * The scale of the device to be used when translating from device space to babylon space.
  19787. */
  19788. deviceScaleFactor: number;
  19789. private _deviceToWorld;
  19790. private _worldToDevice;
  19791. /**
  19792. * References to the webVR controllers for the vrDevice.
  19793. */
  19794. controllers: Array<WebVRController>;
  19795. /**
  19796. * Emits an event when a controller is attached.
  19797. */
  19798. onControllersAttachedObservable: Observable<WebVRController[]>;
  19799. /**
  19800. * Emits an event when a controller's mesh has been loaded;
  19801. */
  19802. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19803. /**
  19804. * Emits an event when the HMD's pose has been updated.
  19805. */
  19806. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19807. private _poseSet;
  19808. /**
  19809. * If the rig cameras be used as parent instead of this camera.
  19810. */
  19811. rigParenting: boolean;
  19812. private _lightOnControllers;
  19813. private _defaultHeight?;
  19814. /**
  19815. * Instantiates a WebVRFreeCamera.
  19816. * @param name The name of the WebVRFreeCamera
  19817. * @param position The starting anchor position for the camera
  19818. * @param scene The scene the camera belongs to
  19819. * @param webVROptions a set of customizable options for the webVRCamera
  19820. */
  19821. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19822. /**
  19823. * Gets the device distance from the ground in meters.
  19824. * @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.
  19825. */
  19826. deviceDistanceToRoomGround(): number;
  19827. /**
  19828. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19829. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19830. */
  19831. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19832. /**
  19833. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19834. * @returns A promise with a boolean set to if the standing matrix is supported.
  19835. */
  19836. useStandingMatrixAsync(): Promise<boolean>;
  19837. /**
  19838. * Disposes the camera
  19839. */
  19840. dispose(): void;
  19841. /**
  19842. * Gets a vrController by name.
  19843. * @param name The name of the controller to retreive
  19844. * @returns the controller matching the name specified or null if not found
  19845. */
  19846. getControllerByName(name: string): Nullable<WebVRController>;
  19847. private _leftController;
  19848. /**
  19849. * The controller corresponding to the users left hand.
  19850. */
  19851. get leftController(): Nullable<WebVRController>;
  19852. private _rightController;
  19853. /**
  19854. * The controller corresponding to the users right hand.
  19855. */
  19856. get rightController(): Nullable<WebVRController>;
  19857. /**
  19858. * Casts a ray forward from the vrCamera's gaze.
  19859. * @param length Length of the ray (default: 100)
  19860. * @returns the ray corresponding to the gaze
  19861. */
  19862. getForwardRay(length?: number): Ray;
  19863. /**
  19864. * @hidden
  19865. * Updates the camera based on device's frame data
  19866. */
  19867. _checkInputs(): void;
  19868. /**
  19869. * Updates the poseControlled values based on the input device pose.
  19870. * @param poseData Pose coming from the device
  19871. */
  19872. updateFromDevice(poseData: DevicePose): void;
  19873. private _htmlElementAttached;
  19874. private _detachIfAttached;
  19875. /**
  19876. * WebVR's attach control will start broadcasting frames to the device.
  19877. * Note that in certain browsers (chrome for example) this function must be called
  19878. * within a user-interaction callback. Example:
  19879. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19880. *
  19881. * @param element html element to attach the vrDevice to
  19882. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19883. */
  19884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19885. /**
  19886. * Detaches the camera from the html element and disables VR
  19887. *
  19888. * @param element html element to detach from
  19889. */
  19890. detachControl(element: HTMLElement): void;
  19891. /**
  19892. * @returns the name of this class
  19893. */
  19894. getClassName(): string;
  19895. /**
  19896. * Calls resetPose on the vrDisplay
  19897. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19898. */
  19899. resetToCurrentRotation(): void;
  19900. /**
  19901. * @hidden
  19902. * Updates the rig cameras (left and right eye)
  19903. */
  19904. _updateRigCameras(): void;
  19905. private _workingVector;
  19906. private _oneVector;
  19907. private _workingMatrix;
  19908. private updateCacheCalled;
  19909. private _correctPositionIfNotTrackPosition;
  19910. /**
  19911. * @hidden
  19912. * Updates the cached values of the camera
  19913. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19914. */
  19915. _updateCache(ignoreParentClass?: boolean): void;
  19916. /**
  19917. * @hidden
  19918. * Get current device position in babylon world
  19919. */
  19920. _computeDevicePosition(): void;
  19921. /**
  19922. * Updates the current device position and rotation in the babylon world
  19923. */
  19924. update(): void;
  19925. /**
  19926. * @hidden
  19927. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19928. * @returns an identity matrix
  19929. */
  19930. _getViewMatrix(): Matrix;
  19931. private _tmpMatrix;
  19932. /**
  19933. * This function is called by the two RIG cameras.
  19934. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19935. * @hidden
  19936. */
  19937. _getWebVRViewMatrix(): Matrix;
  19938. /** @hidden */
  19939. _getWebVRProjectionMatrix(): Matrix;
  19940. private _onGamepadConnectedObserver;
  19941. private _onGamepadDisconnectedObserver;
  19942. private _updateCacheWhenTrackingDisabledObserver;
  19943. /**
  19944. * Initializes the controllers and their meshes
  19945. */
  19946. initControllers(): void;
  19947. }
  19948. }
  19949. declare module BABYLON {
  19950. /**
  19951. * "Static Class" containing the most commonly used helper while dealing with material for
  19952. * rendering purpose.
  19953. *
  19954. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19955. *
  19956. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19957. */
  19958. export class MaterialHelper {
  19959. /**
  19960. * Bind the current view position to an effect.
  19961. * @param effect The effect to be bound
  19962. * @param scene The scene the eyes position is used from
  19963. * @param variableName name of the shader variable that will hold the eye position
  19964. */
  19965. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19966. /**
  19967. * Helps preparing the defines values about the UVs in used in the effect.
  19968. * UVs are shared as much as we can accross channels in the shaders.
  19969. * @param texture The texture we are preparing the UVs for
  19970. * @param defines The defines to update
  19971. * @param key The channel key "diffuse", "specular"... used in the shader
  19972. */
  19973. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19974. /**
  19975. * Binds a texture matrix value to its corrsponding uniform
  19976. * @param texture The texture to bind the matrix for
  19977. * @param uniformBuffer The uniform buffer receivin the data
  19978. * @param key The channel key "diffuse", "specular"... used in the shader
  19979. */
  19980. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19981. /**
  19982. * Gets the current status of the fog (should it be enabled?)
  19983. * @param mesh defines the mesh to evaluate for fog support
  19984. * @param scene defines the hosting scene
  19985. * @returns true if fog must be enabled
  19986. */
  19987. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19988. /**
  19989. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19990. * @param mesh defines the current mesh
  19991. * @param scene defines the current scene
  19992. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19993. * @param pointsCloud defines if point cloud rendering has to be turned on
  19994. * @param fogEnabled defines if fog has to be turned on
  19995. * @param alphaTest defines if alpha testing has to be turned on
  19996. * @param defines defines the current list of defines
  19997. */
  19998. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19999. /**
  20000. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20001. * @param scene defines the current scene
  20002. * @param engine defines the current engine
  20003. * @param defines specifies the list of active defines
  20004. * @param useInstances defines if instances have to be turned on
  20005. * @param useClipPlane defines if clip plane have to be turned on
  20006. */
  20007. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  20008. /**
  20009. * Prepares the defines for bones
  20010. * @param mesh The mesh containing the geometry data we will draw
  20011. * @param defines The defines to update
  20012. */
  20013. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20014. /**
  20015. * Prepares the defines for morph targets
  20016. * @param mesh The mesh containing the geometry data we will draw
  20017. * @param defines The defines to update
  20018. */
  20019. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20020. /**
  20021. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20022. * @param mesh The mesh containing the geometry data we will draw
  20023. * @param defines The defines to update
  20024. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20025. * @param useBones Precise whether bones should be used or not (override mesh info)
  20026. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20027. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20028. * @returns false if defines are considered not dirty and have not been checked
  20029. */
  20030. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20031. /**
  20032. * Prepares the defines related to multiview
  20033. * @param scene The scene we are intending to draw
  20034. * @param defines The defines to update
  20035. */
  20036. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20037. /**
  20038. * Prepares the defines related to the light information passed in parameter
  20039. * @param scene The scene we are intending to draw
  20040. * @param mesh The mesh the effect is compiling for
  20041. * @param light The light the effect is compiling for
  20042. * @param lightIndex The index of the light
  20043. * @param defines The defines to update
  20044. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20045. * @param state Defines the current state regarding what is needed (normals, etc...)
  20046. */
  20047. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20048. needNormals: boolean;
  20049. needRebuild: boolean;
  20050. shadowEnabled: boolean;
  20051. specularEnabled: boolean;
  20052. lightmapMode: boolean;
  20053. }): void;
  20054. /**
  20055. * Prepares the defines related to the light information passed in parameter
  20056. * @param scene The scene we are intending to draw
  20057. * @param mesh The mesh the effect is compiling for
  20058. * @param defines The defines to update
  20059. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20060. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20061. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20062. * @returns true if normals will be required for the rest of the effect
  20063. */
  20064. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20065. /**
  20066. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20067. * @param lightIndex defines the light index
  20068. * @param uniformsList The uniform list
  20069. * @param samplersList The sampler list
  20070. * @param projectedLightTexture defines if projected texture must be used
  20071. * @param uniformBuffersList defines an optional list of uniform buffers
  20072. */
  20073. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20074. /**
  20075. * Prepares the uniforms and samplers list to be used in the effect
  20076. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20077. * @param samplersList The sampler list
  20078. * @param defines The defines helping in the list generation
  20079. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20080. */
  20081. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20082. /**
  20083. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20084. * @param defines The defines to update while falling back
  20085. * @param fallbacks The authorized effect fallbacks
  20086. * @param maxSimultaneousLights The maximum number of lights allowed
  20087. * @param rank the current rank of the Effect
  20088. * @returns The newly affected rank
  20089. */
  20090. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20091. private static _TmpMorphInfluencers;
  20092. /**
  20093. * Prepares the list of attributes required for morph targets according to the effect defines.
  20094. * @param attribs The current list of supported attribs
  20095. * @param mesh The mesh to prepare the morph targets attributes for
  20096. * @param influencers The number of influencers
  20097. */
  20098. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20099. /**
  20100. * Prepares the list of attributes required for morph targets according to the effect defines.
  20101. * @param attribs The current list of supported attribs
  20102. * @param mesh The mesh to prepare the morph targets attributes for
  20103. * @param defines The current Defines of the effect
  20104. */
  20105. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20106. /**
  20107. * Prepares the list of attributes required for bones according to the effect defines.
  20108. * @param attribs The current list of supported attribs
  20109. * @param mesh The mesh to prepare the bones attributes for
  20110. * @param defines The current Defines of the effect
  20111. * @param fallbacks The current efffect fallback strategy
  20112. */
  20113. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20114. /**
  20115. * Check and prepare the list of attributes required for instances according to the effect defines.
  20116. * @param attribs The current list of supported attribs
  20117. * @param defines The current MaterialDefines of the effect
  20118. */
  20119. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20120. /**
  20121. * Add the list of attributes required for instances to the attribs array.
  20122. * @param attribs The current list of supported attribs
  20123. */
  20124. static PushAttributesForInstances(attribs: string[]): void;
  20125. /**
  20126. * Binds the light information to the effect.
  20127. * @param light The light containing the generator
  20128. * @param effect The effect we are binding the data to
  20129. * @param lightIndex The light index in the effect used to render
  20130. */
  20131. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20132. /**
  20133. * Binds the lights information from the scene to the effect for the given mesh.
  20134. * @param light Light to bind
  20135. * @param lightIndex Light index
  20136. * @param scene The scene where the light belongs to
  20137. * @param effect The effect we are binding the data to
  20138. * @param useSpecular Defines if specular is supported
  20139. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20140. */
  20141. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20142. /**
  20143. * Binds the lights information from the scene to the effect for the given mesh.
  20144. * @param scene The scene the lights belongs to
  20145. * @param mesh The mesh we are binding the information to render
  20146. * @param effect The effect we are binding the data to
  20147. * @param defines The generated defines for the effect
  20148. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20149. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20150. */
  20151. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20152. private static _tempFogColor;
  20153. /**
  20154. * Binds the fog information from the scene to the effect for the given mesh.
  20155. * @param scene The scene the lights belongs to
  20156. * @param mesh The mesh we are binding the information to render
  20157. * @param effect The effect we are binding the data to
  20158. * @param linearSpace Defines if the fog effect is applied in linear space
  20159. */
  20160. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20161. /**
  20162. * Binds the bones information from the mesh to the effect.
  20163. * @param mesh The mesh we are binding the information to render
  20164. * @param effect The effect we are binding the data to
  20165. */
  20166. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20167. /**
  20168. * Binds the morph targets information from the mesh to the effect.
  20169. * @param abstractMesh The mesh we are binding the information to render
  20170. * @param effect The effect we are binding the data to
  20171. */
  20172. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20173. /**
  20174. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20175. * @param defines The generated defines used in the effect
  20176. * @param effect The effect we are binding the data to
  20177. * @param scene The scene we are willing to render with logarithmic scale for
  20178. */
  20179. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20180. /**
  20181. * Binds the clip plane information from the scene to the effect.
  20182. * @param scene The scene the clip plane information are extracted from
  20183. * @param effect The effect we are binding the data to
  20184. */
  20185. static BindClipPlane(effect: Effect, scene: Scene): void;
  20186. }
  20187. }
  20188. declare module BABYLON {
  20189. /**
  20190. * Block used to expose an input value
  20191. */
  20192. export class InputBlock extends NodeMaterialBlock {
  20193. private _mode;
  20194. private _associatedVariableName;
  20195. private _storedValue;
  20196. private _valueCallback;
  20197. private _type;
  20198. private _animationType;
  20199. /** Gets or set a value used to limit the range of float values */
  20200. min: number;
  20201. /** Gets or set a value used to limit the range of float values */
  20202. max: number;
  20203. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20204. isBoolean: boolean;
  20205. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20206. matrixMode: number;
  20207. /** @hidden */
  20208. _systemValue: Nullable<NodeMaterialSystemValues>;
  20209. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20210. visibleInInspector: boolean;
  20211. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20212. isConstant: boolean;
  20213. /** Gets or sets the group to use to display this block in the Inspector */
  20214. groupInInspector: string;
  20215. /** Gets an observable raised when the value is changed */
  20216. onValueChangedObservable: Observable<InputBlock>;
  20217. /**
  20218. * Gets or sets the connection point type (default is float)
  20219. */
  20220. get type(): NodeMaterialBlockConnectionPointTypes;
  20221. /**
  20222. * Creates a new InputBlock
  20223. * @param name defines the block name
  20224. * @param target defines the target of that block (Vertex by default)
  20225. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20226. */
  20227. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20228. /**
  20229. * Gets the output component
  20230. */
  20231. get output(): NodeMaterialConnectionPoint;
  20232. /**
  20233. * Set the source of this connection point to a vertex attribute
  20234. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20235. * @returns the current connection point
  20236. */
  20237. setAsAttribute(attributeName?: string): InputBlock;
  20238. /**
  20239. * Set the source of this connection point to a system value
  20240. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20241. * @returns the current connection point
  20242. */
  20243. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20244. /**
  20245. * Gets or sets the value of that point.
  20246. * Please note that this value will be ignored if valueCallback is defined
  20247. */
  20248. get value(): any;
  20249. set value(value: any);
  20250. /**
  20251. * Gets or sets a callback used to get the value of that point.
  20252. * Please note that setting this value will force the connection point to ignore the value property
  20253. */
  20254. get valueCallback(): () => any;
  20255. set valueCallback(value: () => any);
  20256. /**
  20257. * Gets or sets the associated variable name in the shader
  20258. */
  20259. get associatedVariableName(): string;
  20260. set associatedVariableName(value: string);
  20261. /** Gets or sets the type of animation applied to the input */
  20262. get animationType(): AnimatedInputBlockTypes;
  20263. set animationType(value: AnimatedInputBlockTypes);
  20264. /**
  20265. * Gets a boolean indicating that this connection point not defined yet
  20266. */
  20267. get isUndefined(): boolean;
  20268. /**
  20269. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20270. * In this case the connection point name must be the name of the uniform to use.
  20271. * Can only be set on inputs
  20272. */
  20273. get isUniform(): boolean;
  20274. set isUniform(value: boolean);
  20275. /**
  20276. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20277. * In this case the connection point name must be the name of the attribute to use
  20278. * Can only be set on inputs
  20279. */
  20280. get isAttribute(): boolean;
  20281. set isAttribute(value: boolean);
  20282. /**
  20283. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20284. * Can only be set on exit points
  20285. */
  20286. get isVarying(): boolean;
  20287. set isVarying(value: boolean);
  20288. /**
  20289. * Gets a boolean indicating that the current connection point is a system value
  20290. */
  20291. get isSystemValue(): boolean;
  20292. /**
  20293. * Gets or sets the current well known value or null if not defined as a system value
  20294. */
  20295. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20296. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20297. /**
  20298. * Gets the current class name
  20299. * @returns the class name
  20300. */
  20301. getClassName(): string;
  20302. /**
  20303. * Animate the input if animationType !== None
  20304. * @param scene defines the rendering scene
  20305. */
  20306. animate(scene: Scene): void;
  20307. private _emitDefine;
  20308. initialize(state: NodeMaterialBuildState): void;
  20309. /**
  20310. * Set the input block to its default value (based on its type)
  20311. */
  20312. setDefaultValue(): void;
  20313. private _emitConstant;
  20314. /** @hidden */
  20315. get _noContextSwitch(): boolean;
  20316. private _emit;
  20317. /** @hidden */
  20318. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20319. /** @hidden */
  20320. _transmit(effect: Effect, scene: Scene): void;
  20321. protected _buildBlock(state: NodeMaterialBuildState): void;
  20322. protected _dumpPropertiesCode(): string;
  20323. dispose(): void;
  20324. serialize(): any;
  20325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20326. }
  20327. }
  20328. declare module BABYLON {
  20329. /**
  20330. * Enum used to define the compatibility state between two connection points
  20331. */
  20332. export enum NodeMaterialConnectionPointCompatibilityStates {
  20333. /** Points are compatibles */
  20334. Compatible = 0,
  20335. /** Points are incompatible because of their types */
  20336. TypeIncompatible = 1,
  20337. /** Points are incompatible because of their targets (vertex vs fragment) */
  20338. TargetIncompatible = 2
  20339. }
  20340. /**
  20341. * Defines the direction of a connection point
  20342. */
  20343. export enum NodeMaterialConnectionPointDirection {
  20344. /** Input */
  20345. Input = 0,
  20346. /** Output */
  20347. Output = 1
  20348. }
  20349. /**
  20350. * Defines a connection point for a block
  20351. */
  20352. export class NodeMaterialConnectionPoint {
  20353. /** @hidden */
  20354. _ownerBlock: NodeMaterialBlock;
  20355. /** @hidden */
  20356. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20357. private _endpoints;
  20358. private _associatedVariableName;
  20359. private _direction;
  20360. /** @hidden */
  20361. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20362. /** @hidden */
  20363. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20364. private _type;
  20365. /** @hidden */
  20366. _enforceAssociatedVariableName: boolean;
  20367. /** Gets the direction of the point */
  20368. get direction(): NodeMaterialConnectionPointDirection;
  20369. /** Indicates that this connection point needs dual validation before being connected to another point */
  20370. needDualDirectionValidation: boolean;
  20371. /**
  20372. * Gets or sets the additional types supported by this connection point
  20373. */
  20374. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20375. /**
  20376. * Gets or sets the additional types excluded by this connection point
  20377. */
  20378. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20379. /**
  20380. * Observable triggered when this point is connected
  20381. */
  20382. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20383. /**
  20384. * Gets or sets the associated variable name in the shader
  20385. */
  20386. get associatedVariableName(): string;
  20387. set associatedVariableName(value: string);
  20388. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20389. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20390. /**
  20391. * Gets or sets the connection point type (default is float)
  20392. */
  20393. get type(): NodeMaterialBlockConnectionPointTypes;
  20394. set type(value: NodeMaterialBlockConnectionPointTypes);
  20395. /**
  20396. * Gets or sets the connection point name
  20397. */
  20398. name: string;
  20399. /**
  20400. * Gets or sets the connection point name
  20401. */
  20402. displayName: string;
  20403. /**
  20404. * Gets or sets a boolean indicating that this connection point can be omitted
  20405. */
  20406. isOptional: boolean;
  20407. /**
  20408. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20409. */
  20410. define: string;
  20411. /** @hidden */
  20412. _prioritizeVertex: boolean;
  20413. private _target;
  20414. /** Gets or sets the target of that connection point */
  20415. get target(): NodeMaterialBlockTargets;
  20416. set target(value: NodeMaterialBlockTargets);
  20417. /**
  20418. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20419. */
  20420. get isConnected(): boolean;
  20421. /**
  20422. * Gets a boolean indicating that the current point is connected to an input block
  20423. */
  20424. get isConnectedToInputBlock(): boolean;
  20425. /**
  20426. * Gets a the connected input block (if any)
  20427. */
  20428. get connectInputBlock(): Nullable<InputBlock>;
  20429. /** Get the other side of the connection (if any) */
  20430. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20431. /** Get the block that owns this connection point */
  20432. get ownerBlock(): NodeMaterialBlock;
  20433. /** Get the block connected on the other side of this connection (if any) */
  20434. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20435. /** Get the block connected on the endpoints of this connection (if any) */
  20436. get connectedBlocks(): Array<NodeMaterialBlock>;
  20437. /** Gets the list of connected endpoints */
  20438. get endpoints(): NodeMaterialConnectionPoint[];
  20439. /** Gets a boolean indicating if that output point is connected to at least one input */
  20440. get hasEndpoints(): boolean;
  20441. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20442. get isConnectedInVertexShader(): boolean;
  20443. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20444. get isConnectedInFragmentShader(): boolean;
  20445. /**
  20446. * Creates a block suitable to be used as an input for this input point.
  20447. * If null is returned, a block based on the point type will be created.
  20448. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20449. */
  20450. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20451. /**
  20452. * Creates a new connection point
  20453. * @param name defines the connection point name
  20454. * @param ownerBlock defines the block hosting this connection point
  20455. * @param direction defines the direction of the connection point
  20456. */
  20457. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20458. /**
  20459. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20460. * @returns the class name
  20461. */
  20462. getClassName(): string;
  20463. /**
  20464. * Gets a boolean indicating if the current point can be connected to another point
  20465. * @param connectionPoint defines the other connection point
  20466. * @returns a boolean
  20467. */
  20468. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20469. /**
  20470. * Gets a number indicating if the current point can be connected to another point
  20471. * @param connectionPoint defines the other connection point
  20472. * @returns a number defining the compatibility state
  20473. */
  20474. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20475. /**
  20476. * Connect this point to another connection point
  20477. * @param connectionPoint defines the other connection point
  20478. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20479. * @returns the current connection point
  20480. */
  20481. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20482. /**
  20483. * Disconnect this point from one of his endpoint
  20484. * @param endpoint defines the other connection point
  20485. * @returns the current connection point
  20486. */
  20487. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20488. /**
  20489. * Serializes this point in a JSON representation
  20490. * @param isInput defines if the connection point is an input (default is true)
  20491. * @returns the serialized point object
  20492. */
  20493. serialize(isInput?: boolean): any;
  20494. /**
  20495. * Release resources
  20496. */
  20497. dispose(): void;
  20498. }
  20499. }
  20500. declare module BABYLON {
  20501. /**
  20502. * Enum used to define the material modes
  20503. */
  20504. export enum NodeMaterialModes {
  20505. /** Regular material */
  20506. Material = 0,
  20507. /** For post process */
  20508. PostProcess = 1,
  20509. /** For particle system */
  20510. Particle = 2
  20511. }
  20512. }
  20513. declare module BABYLON {
  20514. /**
  20515. * Block used to read a texture from a sampler
  20516. */
  20517. export class TextureBlock extends NodeMaterialBlock {
  20518. private _defineName;
  20519. private _linearDefineName;
  20520. private _gammaDefineName;
  20521. private _tempTextureRead;
  20522. private _samplerName;
  20523. private _transformedUVName;
  20524. private _textureTransformName;
  20525. private _textureInfoName;
  20526. private _mainUVName;
  20527. private _mainUVDefineName;
  20528. private _fragmentOnly;
  20529. /**
  20530. * Gets or sets the texture associated with the node
  20531. */
  20532. texture: Nullable<Texture>;
  20533. /**
  20534. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20535. */
  20536. convertToGammaSpace: boolean;
  20537. /**
  20538. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20539. */
  20540. convertToLinearSpace: boolean;
  20541. /**
  20542. * Create a new TextureBlock
  20543. * @param name defines the block name
  20544. */
  20545. constructor(name: string, fragmentOnly?: boolean);
  20546. /**
  20547. * Gets the current class name
  20548. * @returns the class name
  20549. */
  20550. getClassName(): string;
  20551. /**
  20552. * Gets the uv input component
  20553. */
  20554. get uv(): NodeMaterialConnectionPoint;
  20555. /**
  20556. * Gets the rgba output component
  20557. */
  20558. get rgba(): NodeMaterialConnectionPoint;
  20559. /**
  20560. * Gets the rgb output component
  20561. */
  20562. get rgb(): NodeMaterialConnectionPoint;
  20563. /**
  20564. * Gets the r output component
  20565. */
  20566. get r(): NodeMaterialConnectionPoint;
  20567. /**
  20568. * Gets the g output component
  20569. */
  20570. get g(): NodeMaterialConnectionPoint;
  20571. /**
  20572. * Gets the b output component
  20573. */
  20574. get b(): NodeMaterialConnectionPoint;
  20575. /**
  20576. * Gets the a output component
  20577. */
  20578. get a(): NodeMaterialConnectionPoint;
  20579. get target(): NodeMaterialBlockTargets;
  20580. autoConfigure(material: NodeMaterial): void;
  20581. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20583. isReady(): boolean;
  20584. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20585. private get _isMixed();
  20586. private _injectVertexCode;
  20587. private _writeTextureRead;
  20588. private _writeOutput;
  20589. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20590. protected _dumpPropertiesCode(): string;
  20591. serialize(): any;
  20592. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20593. }
  20594. }
  20595. declare module BABYLON {
  20596. /** @hidden */
  20597. export var reflectionFunction: {
  20598. name: string;
  20599. shader: string;
  20600. };
  20601. }
  20602. declare module BABYLON {
  20603. /**
  20604. * Base block used to read a reflection texture from a sampler
  20605. */
  20606. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20607. /** @hidden */
  20608. _define3DName: string;
  20609. /** @hidden */
  20610. _defineCubicName: string;
  20611. /** @hidden */
  20612. _defineExplicitName: string;
  20613. /** @hidden */
  20614. _defineProjectionName: string;
  20615. /** @hidden */
  20616. _defineLocalCubicName: string;
  20617. /** @hidden */
  20618. _defineSphericalName: string;
  20619. /** @hidden */
  20620. _definePlanarName: string;
  20621. /** @hidden */
  20622. _defineEquirectangularName: string;
  20623. /** @hidden */
  20624. _defineMirroredEquirectangularFixedName: string;
  20625. /** @hidden */
  20626. _defineEquirectangularFixedName: string;
  20627. /** @hidden */
  20628. _defineSkyboxName: string;
  20629. /** @hidden */
  20630. _defineOppositeZ: string;
  20631. /** @hidden */
  20632. _cubeSamplerName: string;
  20633. /** @hidden */
  20634. _2DSamplerName: string;
  20635. protected _positionUVWName: string;
  20636. protected _directionWName: string;
  20637. protected _reflectionVectorName: string;
  20638. /** @hidden */
  20639. _reflectionCoordsName: string;
  20640. /** @hidden */
  20641. _reflectionMatrixName: string;
  20642. protected _reflectionColorName: string;
  20643. /**
  20644. * Gets or sets the texture associated with the node
  20645. */
  20646. texture: Nullable<BaseTexture>;
  20647. /**
  20648. * Create a new ReflectionTextureBaseBlock
  20649. * @param name defines the block name
  20650. */
  20651. constructor(name: string);
  20652. /**
  20653. * Gets the current class name
  20654. * @returns the class name
  20655. */
  20656. getClassName(): string;
  20657. /**
  20658. * Gets the world position input component
  20659. */
  20660. abstract get position(): NodeMaterialConnectionPoint;
  20661. /**
  20662. * Gets the world position input component
  20663. */
  20664. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20665. /**
  20666. * Gets the world normal input component
  20667. */
  20668. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20669. /**
  20670. * Gets the world input component
  20671. */
  20672. abstract get world(): NodeMaterialConnectionPoint;
  20673. /**
  20674. * Gets the camera (or eye) position component
  20675. */
  20676. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20677. /**
  20678. * Gets the view input component
  20679. */
  20680. abstract get view(): NodeMaterialConnectionPoint;
  20681. protected _getTexture(): Nullable<BaseTexture>;
  20682. autoConfigure(material: NodeMaterial): void;
  20683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20684. isReady(): boolean;
  20685. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20686. /**
  20687. * Gets the code to inject in the vertex shader
  20688. * @param state current state of the node material building
  20689. * @returns the shader code
  20690. */
  20691. handleVertexSide(state: NodeMaterialBuildState): string;
  20692. /**
  20693. * Handles the inits for the fragment code path
  20694. * @param state node material build state
  20695. */
  20696. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20697. /**
  20698. * Generates the reflection coords code for the fragment code path
  20699. * @param worldNormalVarName name of the world normal variable
  20700. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20701. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20702. * @returns the shader code
  20703. */
  20704. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20705. /**
  20706. * Generates the reflection color code for the fragment code path
  20707. * @param lodVarName name of the lod variable
  20708. * @param swizzleLookupTexture swizzle to use for the final color variable
  20709. * @returns the shader code
  20710. */
  20711. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20712. /**
  20713. * Generates the code corresponding to the connected output points
  20714. * @param state node material build state
  20715. * @param varName name of the variable to output
  20716. * @returns the shader code
  20717. */
  20718. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20719. protected _buildBlock(state: NodeMaterialBuildState): this;
  20720. protected _dumpPropertiesCode(): string;
  20721. serialize(): any;
  20722. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20723. }
  20724. }
  20725. declare module BABYLON {
  20726. /**
  20727. * Defines a connection point to be used for points with a custom object type
  20728. */
  20729. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20730. private _blockType;
  20731. private _blockName;
  20732. private _nameForCheking?;
  20733. /**
  20734. * Creates a new connection point
  20735. * @param name defines the connection point name
  20736. * @param ownerBlock defines the block hosting this connection point
  20737. * @param direction defines the direction of the connection point
  20738. */
  20739. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20740. /**
  20741. * Gets a number indicating if the current point can be connected to another point
  20742. * @param connectionPoint defines the other connection point
  20743. * @returns a number defining the compatibility state
  20744. */
  20745. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20746. /**
  20747. * Creates a block suitable to be used as an input for this input point.
  20748. * If null is returned, a block based on the point type will be created.
  20749. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20750. */
  20751. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20752. }
  20753. }
  20754. declare module BABYLON {
  20755. /**
  20756. * Enum defining the type of properties that can be edited in the property pages in the NME
  20757. */
  20758. export enum PropertyTypeForEdition {
  20759. /** property is a boolean */
  20760. Boolean = 0,
  20761. /** property is a float */
  20762. Float = 1,
  20763. /** property is a Vector2 */
  20764. Vector2 = 2,
  20765. /** property is a list of values */
  20766. List = 3
  20767. }
  20768. /**
  20769. * Interface that defines an option in a variable of type list
  20770. */
  20771. export interface IEditablePropertyListOption {
  20772. /** label of the option */
  20773. "label": string;
  20774. /** value of the option */
  20775. "value": number;
  20776. }
  20777. /**
  20778. * Interface that defines the options available for an editable property
  20779. */
  20780. export interface IEditablePropertyOption {
  20781. /** min value */
  20782. "min"?: number;
  20783. /** max value */
  20784. "max"?: number;
  20785. /** notifiers: indicates which actions to take when the property is changed */
  20786. "notifiers"?: {
  20787. /** the material should be rebuilt */
  20788. "rebuild"?: boolean;
  20789. /** the preview should be updated */
  20790. "update"?: boolean;
  20791. };
  20792. /** list of the options for a variable of type list */
  20793. "options"?: IEditablePropertyListOption[];
  20794. }
  20795. /**
  20796. * Interface that describes an editable property
  20797. */
  20798. export interface IPropertyDescriptionForEdition {
  20799. /** name of the property */
  20800. "propertyName": string;
  20801. /** display name of the property */
  20802. "displayName": string;
  20803. /** type of the property */
  20804. "type": PropertyTypeForEdition;
  20805. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20806. "groupName": string;
  20807. /** options for the property */
  20808. "options": IEditablePropertyOption;
  20809. }
  20810. /**
  20811. * Decorator that flags a property in a node material block as being editable
  20812. */
  20813. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20814. }
  20815. declare module BABYLON {
  20816. /**
  20817. * Block used to implement the refraction part of the sub surface module of the PBR material
  20818. */
  20819. export class RefractionBlock extends NodeMaterialBlock {
  20820. /** @hidden */
  20821. _define3DName: string;
  20822. /** @hidden */
  20823. _refractionMatrixName: string;
  20824. /** @hidden */
  20825. _defineLODRefractionAlpha: string;
  20826. /** @hidden */
  20827. _defineLinearSpecularRefraction: string;
  20828. /** @hidden */
  20829. _defineOppositeZ: string;
  20830. /** @hidden */
  20831. _cubeSamplerName: string;
  20832. /** @hidden */
  20833. _2DSamplerName: string;
  20834. /** @hidden */
  20835. _vRefractionMicrosurfaceInfosName: string;
  20836. /** @hidden */
  20837. _vRefractionInfosName: string;
  20838. private _scene;
  20839. /**
  20840. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20841. * Materials half opaque for instance using refraction could benefit from this control.
  20842. */
  20843. linkRefractionWithTransparency: boolean;
  20844. /**
  20845. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20846. */
  20847. invertRefractionY: boolean;
  20848. /**
  20849. * Gets or sets the texture associated with the node
  20850. */
  20851. texture: Nullable<BaseTexture>;
  20852. /**
  20853. * Create a new RefractionBlock
  20854. * @param name defines the block name
  20855. */
  20856. constructor(name: string);
  20857. /**
  20858. * Gets the current class name
  20859. * @returns the class name
  20860. */
  20861. getClassName(): string;
  20862. /**
  20863. * Gets the intensity input component
  20864. */
  20865. get intensity(): NodeMaterialConnectionPoint;
  20866. /**
  20867. * Gets the index of refraction input component
  20868. */
  20869. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20870. /**
  20871. * Gets the tint at distance input component
  20872. */
  20873. get tintAtDistance(): NodeMaterialConnectionPoint;
  20874. /**
  20875. * Gets the view input component
  20876. */
  20877. get view(): NodeMaterialConnectionPoint;
  20878. /**
  20879. * Gets the refraction object output component
  20880. */
  20881. get refraction(): NodeMaterialConnectionPoint;
  20882. /**
  20883. * Returns true if the block has a texture
  20884. */
  20885. get hasTexture(): boolean;
  20886. protected _getTexture(): Nullable<BaseTexture>;
  20887. autoConfigure(material: NodeMaterial): void;
  20888. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20889. isReady(): boolean;
  20890. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20891. /**
  20892. * Gets the main code of the block (fragment side)
  20893. * @param state current state of the node material building
  20894. * @returns the shader code
  20895. */
  20896. getCode(state: NodeMaterialBuildState): string;
  20897. protected _buildBlock(state: NodeMaterialBuildState): this;
  20898. protected _dumpPropertiesCode(): string;
  20899. serialize(): any;
  20900. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20901. }
  20902. }
  20903. declare module BABYLON {
  20904. /**
  20905. * Base block used as input for post process
  20906. */
  20907. export class CurrentScreenBlock extends NodeMaterialBlock {
  20908. private _samplerName;
  20909. private _linearDefineName;
  20910. private _gammaDefineName;
  20911. private _mainUVName;
  20912. private _tempTextureRead;
  20913. /**
  20914. * Gets or sets the texture associated with the node
  20915. */
  20916. texture: Nullable<BaseTexture>;
  20917. /**
  20918. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20919. */
  20920. convertToGammaSpace: boolean;
  20921. /**
  20922. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20923. */
  20924. convertToLinearSpace: boolean;
  20925. /**
  20926. * Create a new CurrentScreenBlock
  20927. * @param name defines the block name
  20928. */
  20929. constructor(name: string);
  20930. /**
  20931. * Gets the current class name
  20932. * @returns the class name
  20933. */
  20934. getClassName(): string;
  20935. /**
  20936. * Gets the uv input component
  20937. */
  20938. get uv(): NodeMaterialConnectionPoint;
  20939. /**
  20940. * Gets the rgba output component
  20941. */
  20942. get rgba(): NodeMaterialConnectionPoint;
  20943. /**
  20944. * Gets the rgb output component
  20945. */
  20946. get rgb(): NodeMaterialConnectionPoint;
  20947. /**
  20948. * Gets the r output component
  20949. */
  20950. get r(): NodeMaterialConnectionPoint;
  20951. /**
  20952. * Gets the g output component
  20953. */
  20954. get g(): NodeMaterialConnectionPoint;
  20955. /**
  20956. * Gets the b output component
  20957. */
  20958. get b(): NodeMaterialConnectionPoint;
  20959. /**
  20960. * Gets the a output component
  20961. */
  20962. get a(): NodeMaterialConnectionPoint;
  20963. /**
  20964. * Initialize the block and prepare the context for build
  20965. * @param state defines the state that will be used for the build
  20966. */
  20967. initialize(state: NodeMaterialBuildState): void;
  20968. get target(): NodeMaterialBlockTargets;
  20969. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20970. isReady(): boolean;
  20971. private _injectVertexCode;
  20972. private _writeTextureRead;
  20973. private _writeOutput;
  20974. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20975. serialize(): any;
  20976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20977. }
  20978. }
  20979. declare module BABYLON {
  20980. /**
  20981. * Base block used for the particle texture
  20982. */
  20983. export class ParticleTextureBlock extends NodeMaterialBlock {
  20984. private _samplerName;
  20985. private _linearDefineName;
  20986. private _gammaDefineName;
  20987. private _tempTextureRead;
  20988. /**
  20989. * Gets or sets the texture associated with the node
  20990. */
  20991. texture: Nullable<BaseTexture>;
  20992. /**
  20993. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20994. */
  20995. convertToGammaSpace: boolean;
  20996. /**
  20997. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20998. */
  20999. convertToLinearSpace: boolean;
  21000. /**
  21001. * Create a new ParticleTextureBlock
  21002. * @param name defines the block name
  21003. */
  21004. constructor(name: string);
  21005. /**
  21006. * Gets the current class name
  21007. * @returns the class name
  21008. */
  21009. getClassName(): string;
  21010. /**
  21011. * Gets the uv input component
  21012. */
  21013. get uv(): NodeMaterialConnectionPoint;
  21014. /**
  21015. * Gets the rgba output component
  21016. */
  21017. get rgba(): NodeMaterialConnectionPoint;
  21018. /**
  21019. * Gets the rgb output component
  21020. */
  21021. get rgb(): NodeMaterialConnectionPoint;
  21022. /**
  21023. * Gets the r output component
  21024. */
  21025. get r(): NodeMaterialConnectionPoint;
  21026. /**
  21027. * Gets the g output component
  21028. */
  21029. get g(): NodeMaterialConnectionPoint;
  21030. /**
  21031. * Gets the b output component
  21032. */
  21033. get b(): NodeMaterialConnectionPoint;
  21034. /**
  21035. * Gets the a output component
  21036. */
  21037. get a(): NodeMaterialConnectionPoint;
  21038. /**
  21039. * Initialize the block and prepare the context for build
  21040. * @param state defines the state that will be used for the build
  21041. */
  21042. initialize(state: NodeMaterialBuildState): void;
  21043. autoConfigure(material: NodeMaterial): void;
  21044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21045. isReady(): boolean;
  21046. private _writeOutput;
  21047. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21048. serialize(): any;
  21049. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21050. }
  21051. }
  21052. declare module BABYLON {
  21053. /**
  21054. * Class used to store shared data between 2 NodeMaterialBuildState
  21055. */
  21056. export class NodeMaterialBuildStateSharedData {
  21057. /**
  21058. * Gets the list of emitted varyings
  21059. */
  21060. temps: string[];
  21061. /**
  21062. * Gets the list of emitted varyings
  21063. */
  21064. varyings: string[];
  21065. /**
  21066. * Gets the varying declaration string
  21067. */
  21068. varyingDeclaration: string;
  21069. /**
  21070. * Input blocks
  21071. */
  21072. inputBlocks: InputBlock[];
  21073. /**
  21074. * Input blocks
  21075. */
  21076. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21077. /**
  21078. * Bindable blocks (Blocks that need to set data to the effect)
  21079. */
  21080. bindableBlocks: NodeMaterialBlock[];
  21081. /**
  21082. * List of blocks that can provide a compilation fallback
  21083. */
  21084. blocksWithFallbacks: NodeMaterialBlock[];
  21085. /**
  21086. * List of blocks that can provide a define update
  21087. */
  21088. blocksWithDefines: NodeMaterialBlock[];
  21089. /**
  21090. * List of blocks that can provide a repeatable content
  21091. */
  21092. repeatableContentBlocks: NodeMaterialBlock[];
  21093. /**
  21094. * List of blocks that can provide a dynamic list of uniforms
  21095. */
  21096. dynamicUniformBlocks: NodeMaterialBlock[];
  21097. /**
  21098. * List of blocks that can block the isReady function for the material
  21099. */
  21100. blockingBlocks: NodeMaterialBlock[];
  21101. /**
  21102. * Gets the list of animated inputs
  21103. */
  21104. animatedInputs: InputBlock[];
  21105. /**
  21106. * Build Id used to avoid multiple recompilations
  21107. */
  21108. buildId: number;
  21109. /** List of emitted variables */
  21110. variableNames: {
  21111. [key: string]: number;
  21112. };
  21113. /** List of emitted defines */
  21114. defineNames: {
  21115. [key: string]: number;
  21116. };
  21117. /** Should emit comments? */
  21118. emitComments: boolean;
  21119. /** Emit build activity */
  21120. verbose: boolean;
  21121. /** Gets or sets the hosting scene */
  21122. scene: Scene;
  21123. /**
  21124. * Gets the compilation hints emitted at compilation time
  21125. */
  21126. hints: {
  21127. needWorldViewMatrix: boolean;
  21128. needWorldViewProjectionMatrix: boolean;
  21129. needAlphaBlending: boolean;
  21130. needAlphaTesting: boolean;
  21131. };
  21132. /**
  21133. * List of compilation checks
  21134. */
  21135. checks: {
  21136. emitVertex: boolean;
  21137. emitFragment: boolean;
  21138. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21139. };
  21140. /**
  21141. * Is vertex program allowed to be empty?
  21142. */
  21143. allowEmptyVertexProgram: boolean;
  21144. /** Creates a new shared data */
  21145. constructor();
  21146. /**
  21147. * Emits console errors and exceptions if there is a failing check
  21148. */
  21149. emitErrors(): void;
  21150. }
  21151. }
  21152. declare module BABYLON {
  21153. /**
  21154. * Class used to store node based material build state
  21155. */
  21156. export class NodeMaterialBuildState {
  21157. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21158. supportUniformBuffers: boolean;
  21159. /**
  21160. * Gets the list of emitted attributes
  21161. */
  21162. attributes: string[];
  21163. /**
  21164. * Gets the list of emitted uniforms
  21165. */
  21166. uniforms: string[];
  21167. /**
  21168. * Gets the list of emitted constants
  21169. */
  21170. constants: string[];
  21171. /**
  21172. * Gets the list of emitted samplers
  21173. */
  21174. samplers: string[];
  21175. /**
  21176. * Gets the list of emitted functions
  21177. */
  21178. functions: {
  21179. [key: string]: string;
  21180. };
  21181. /**
  21182. * Gets the list of emitted extensions
  21183. */
  21184. extensions: {
  21185. [key: string]: string;
  21186. };
  21187. /**
  21188. * Gets the target of the compilation state
  21189. */
  21190. target: NodeMaterialBlockTargets;
  21191. /**
  21192. * Gets the list of emitted counters
  21193. */
  21194. counters: {
  21195. [key: string]: number;
  21196. };
  21197. /**
  21198. * Shared data between multiple NodeMaterialBuildState instances
  21199. */
  21200. sharedData: NodeMaterialBuildStateSharedData;
  21201. /** @hidden */
  21202. _vertexState: NodeMaterialBuildState;
  21203. /** @hidden */
  21204. _attributeDeclaration: string;
  21205. /** @hidden */
  21206. _uniformDeclaration: string;
  21207. /** @hidden */
  21208. _constantDeclaration: string;
  21209. /** @hidden */
  21210. _samplerDeclaration: string;
  21211. /** @hidden */
  21212. _varyingTransfer: string;
  21213. /** @hidden */
  21214. _injectAtEnd: string;
  21215. private _repeatableContentAnchorIndex;
  21216. /** @hidden */
  21217. _builtCompilationString: string;
  21218. /**
  21219. * Gets the emitted compilation strings
  21220. */
  21221. compilationString: string;
  21222. /**
  21223. * Finalize the compilation strings
  21224. * @param state defines the current compilation state
  21225. */
  21226. finalize(state: NodeMaterialBuildState): void;
  21227. /** @hidden */
  21228. get _repeatableContentAnchor(): string;
  21229. /** @hidden */
  21230. _getFreeVariableName(prefix: string): string;
  21231. /** @hidden */
  21232. _getFreeDefineName(prefix: string): string;
  21233. /** @hidden */
  21234. _excludeVariableName(name: string): void;
  21235. /** @hidden */
  21236. _emit2DSampler(name: string): void;
  21237. /** @hidden */
  21238. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21239. /** @hidden */
  21240. _emitExtension(name: string, extension: string, define?: string): void;
  21241. /** @hidden */
  21242. _emitFunction(name: string, code: string, comments: string): void;
  21243. /** @hidden */
  21244. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21245. replaceStrings?: {
  21246. search: RegExp;
  21247. replace: string;
  21248. }[];
  21249. repeatKey?: string;
  21250. }): string;
  21251. /** @hidden */
  21252. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21253. repeatKey?: string;
  21254. removeAttributes?: boolean;
  21255. removeUniforms?: boolean;
  21256. removeVaryings?: boolean;
  21257. removeIfDef?: boolean;
  21258. replaceStrings?: {
  21259. search: RegExp;
  21260. replace: string;
  21261. }[];
  21262. }, storeKey?: string): void;
  21263. /** @hidden */
  21264. _registerTempVariable(name: string): boolean;
  21265. /** @hidden */
  21266. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21267. /** @hidden */
  21268. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21269. /** @hidden */
  21270. _emitFloat(value: number): string;
  21271. }
  21272. }
  21273. declare module BABYLON {
  21274. /**
  21275. * Helper class used to generate session unique ID
  21276. */
  21277. export class UniqueIdGenerator {
  21278. private static _UniqueIdCounter;
  21279. /**
  21280. * Gets an unique (relatively to the current scene) Id
  21281. */
  21282. static get UniqueId(): number;
  21283. }
  21284. }
  21285. declare module BABYLON {
  21286. /**
  21287. * Defines a block that can be used inside a node based material
  21288. */
  21289. export class NodeMaterialBlock {
  21290. private _buildId;
  21291. private _buildTarget;
  21292. private _target;
  21293. private _isFinalMerger;
  21294. private _isInput;
  21295. protected _isUnique: boolean;
  21296. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21297. inputsAreExclusive: boolean;
  21298. /** @hidden */
  21299. _codeVariableName: string;
  21300. /** @hidden */
  21301. _inputs: NodeMaterialConnectionPoint[];
  21302. /** @hidden */
  21303. _outputs: NodeMaterialConnectionPoint[];
  21304. /** @hidden */
  21305. _preparationId: number;
  21306. /**
  21307. * Gets or sets the name of the block
  21308. */
  21309. name: string;
  21310. /**
  21311. * Gets or sets the unique id of the node
  21312. */
  21313. uniqueId: number;
  21314. /**
  21315. * Gets or sets the comments associated with this block
  21316. */
  21317. comments: string;
  21318. /**
  21319. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21320. */
  21321. get isUnique(): boolean;
  21322. /**
  21323. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21324. */
  21325. get isFinalMerger(): boolean;
  21326. /**
  21327. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21328. */
  21329. get isInput(): boolean;
  21330. /**
  21331. * Gets or sets the build Id
  21332. */
  21333. get buildId(): number;
  21334. set buildId(value: number);
  21335. /**
  21336. * Gets or sets the target of the block
  21337. */
  21338. get target(): NodeMaterialBlockTargets;
  21339. set target(value: NodeMaterialBlockTargets);
  21340. /**
  21341. * Gets the list of input points
  21342. */
  21343. get inputs(): NodeMaterialConnectionPoint[];
  21344. /** Gets the list of output points */
  21345. get outputs(): NodeMaterialConnectionPoint[];
  21346. /**
  21347. * Find an input by its name
  21348. * @param name defines the name of the input to look for
  21349. * @returns the input or null if not found
  21350. */
  21351. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21352. /**
  21353. * Find an output by its name
  21354. * @param name defines the name of the outputto look for
  21355. * @returns the output or null if not found
  21356. */
  21357. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21358. /**
  21359. * Creates a new NodeMaterialBlock
  21360. * @param name defines the block name
  21361. * @param target defines the target of that block (Vertex by default)
  21362. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21363. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21364. */
  21365. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21366. /**
  21367. * Initialize the block and prepare the context for build
  21368. * @param state defines the state that will be used for the build
  21369. */
  21370. initialize(state: NodeMaterialBuildState): void;
  21371. /**
  21372. * Bind data to effect. Will only be called for blocks with isBindable === true
  21373. * @param effect defines the effect to bind data to
  21374. * @param nodeMaterial defines the hosting NodeMaterial
  21375. * @param mesh defines the mesh that will be rendered
  21376. * @param subMesh defines the submesh that will be rendered
  21377. */
  21378. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21379. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21380. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21381. protected _writeFloat(value: number): string;
  21382. /**
  21383. * Gets the current class name e.g. "NodeMaterialBlock"
  21384. * @returns the class name
  21385. */
  21386. getClassName(): string;
  21387. /**
  21388. * Register a new input. Must be called inside a block constructor
  21389. * @param name defines the connection point name
  21390. * @param type defines the connection point type
  21391. * @param isOptional defines a boolean indicating that this input can be omitted
  21392. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21393. * @param point an already created connection point. If not provided, create a new one
  21394. * @returns the current block
  21395. */
  21396. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21397. /**
  21398. * Register a new output. Must be called inside a block constructor
  21399. * @param name defines the connection point name
  21400. * @param type defines the connection point type
  21401. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21402. * @param point an already created connection point. If not provided, create a new one
  21403. * @returns the current block
  21404. */
  21405. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21406. /**
  21407. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21408. * @param forOutput defines an optional connection point to check compatibility with
  21409. * @returns the first available input or null
  21410. */
  21411. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21412. /**
  21413. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21414. * @param forBlock defines an optional block to check compatibility with
  21415. * @returns the first available input or null
  21416. */
  21417. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21418. /**
  21419. * Gets the sibling of the given output
  21420. * @param current defines the current output
  21421. * @returns the next output in the list or null
  21422. */
  21423. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21424. /**
  21425. * Connect current block with another block
  21426. * @param other defines the block to connect with
  21427. * @param options define the various options to help pick the right connections
  21428. * @returns the current block
  21429. */
  21430. connectTo(other: NodeMaterialBlock, options?: {
  21431. input?: string;
  21432. output?: string;
  21433. outputSwizzle?: string;
  21434. }): this | undefined;
  21435. protected _buildBlock(state: NodeMaterialBuildState): void;
  21436. /**
  21437. * Add uniforms, samplers and uniform buffers at compilation time
  21438. * @param state defines the state to update
  21439. * @param nodeMaterial defines the node material requesting the update
  21440. * @param defines defines the material defines to update
  21441. * @param uniformBuffers defines the list of uniform buffer names
  21442. */
  21443. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21444. /**
  21445. * Add potential fallbacks if shader compilation fails
  21446. * @param mesh defines the mesh to be rendered
  21447. * @param fallbacks defines the current prioritized list of fallbacks
  21448. */
  21449. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21450. /**
  21451. * Initialize defines for shader compilation
  21452. * @param mesh defines the mesh to be rendered
  21453. * @param nodeMaterial defines the node material requesting the update
  21454. * @param defines defines the material defines to update
  21455. * @param useInstances specifies that instances should be used
  21456. */
  21457. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21458. /**
  21459. * Update defines for shader compilation
  21460. * @param mesh defines the mesh to be rendered
  21461. * @param nodeMaterial defines the node material requesting the update
  21462. * @param defines defines the material defines to update
  21463. * @param useInstances specifies that instances should be used
  21464. */
  21465. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21466. /**
  21467. * Lets the block try to connect some inputs automatically
  21468. * @param material defines the hosting NodeMaterial
  21469. */
  21470. autoConfigure(material: NodeMaterial): void;
  21471. /**
  21472. * Function called when a block is declared as repeatable content generator
  21473. * @param vertexShaderState defines the current compilation state for the vertex shader
  21474. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21475. * @param mesh defines the mesh to be rendered
  21476. * @param defines defines the material defines to update
  21477. */
  21478. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21479. /**
  21480. * Checks if the block is ready
  21481. * @param mesh defines the mesh to be rendered
  21482. * @param nodeMaterial defines the node material requesting the update
  21483. * @param defines defines the material defines to update
  21484. * @param useInstances specifies that instances should be used
  21485. * @returns true if the block is ready
  21486. */
  21487. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21488. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21489. private _processBuild;
  21490. /**
  21491. * Compile the current node and generate the shader code
  21492. * @param state defines the current compilation state (uniforms, samplers, current string)
  21493. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21494. * @returns true if already built
  21495. */
  21496. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21497. protected _inputRename(name: string): string;
  21498. protected _outputRename(name: string): string;
  21499. protected _dumpPropertiesCode(): string;
  21500. /** @hidden */
  21501. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21502. /** @hidden */
  21503. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21504. /**
  21505. * Clone the current block to a new identical block
  21506. * @param scene defines the hosting scene
  21507. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21508. * @returns a copy of the current block
  21509. */
  21510. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21511. /**
  21512. * Serializes this block in a JSON representation
  21513. * @returns the serialized block object
  21514. */
  21515. serialize(): any;
  21516. /** @hidden */
  21517. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21518. private _deserializePortDisplayNames;
  21519. /**
  21520. * Release resources
  21521. */
  21522. dispose(): void;
  21523. }
  21524. }
  21525. declare module BABYLON {
  21526. /**
  21527. * Base class of materials working in push mode in babylon JS
  21528. * @hidden
  21529. */
  21530. export class PushMaterial extends Material {
  21531. protected _activeEffect: Effect;
  21532. protected _normalMatrix: Matrix;
  21533. /**
  21534. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21535. * This means that the material can keep using a previous shader while a new one is being compiled.
  21536. * This is mostly used when shader parallel compilation is supported (true by default)
  21537. */
  21538. allowShaderHotSwapping: boolean;
  21539. constructor(name: string, scene: Scene);
  21540. getEffect(): Effect;
  21541. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21542. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21543. /**
  21544. * Binds the given world matrix to the active effect
  21545. *
  21546. * @param world the matrix to bind
  21547. */
  21548. bindOnlyWorldMatrix(world: Matrix): void;
  21549. /**
  21550. * Binds the given normal matrix to the active effect
  21551. *
  21552. * @param normalMatrix the matrix to bind
  21553. */
  21554. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21555. bind(world: Matrix, mesh?: Mesh): void;
  21556. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21557. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21558. }
  21559. }
  21560. declare module BABYLON {
  21561. /**
  21562. * Root class for all node material optimizers
  21563. */
  21564. export class NodeMaterialOptimizer {
  21565. /**
  21566. * Function used to optimize a NodeMaterial graph
  21567. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21568. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21569. */
  21570. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21571. }
  21572. }
  21573. declare module BABYLON {
  21574. /**
  21575. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21576. */
  21577. export class TransformBlock extends NodeMaterialBlock {
  21578. /**
  21579. * Defines the value to use to complement W value to transform it to a Vector4
  21580. */
  21581. complementW: number;
  21582. /**
  21583. * Defines the value to use to complement z value to transform it to a Vector4
  21584. */
  21585. complementZ: number;
  21586. /**
  21587. * Creates a new TransformBlock
  21588. * @param name defines the block name
  21589. */
  21590. constructor(name: string);
  21591. /**
  21592. * Gets the current class name
  21593. * @returns the class name
  21594. */
  21595. getClassName(): string;
  21596. /**
  21597. * Gets the vector input
  21598. */
  21599. get vector(): NodeMaterialConnectionPoint;
  21600. /**
  21601. * Gets the output component
  21602. */
  21603. get output(): NodeMaterialConnectionPoint;
  21604. /**
  21605. * Gets the xyz output component
  21606. */
  21607. get xyz(): NodeMaterialConnectionPoint;
  21608. /**
  21609. * Gets the matrix transform input
  21610. */
  21611. get transform(): NodeMaterialConnectionPoint;
  21612. protected _buildBlock(state: NodeMaterialBuildState): this;
  21613. serialize(): any;
  21614. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21615. protected _dumpPropertiesCode(): string;
  21616. }
  21617. }
  21618. declare module BABYLON {
  21619. /**
  21620. * Block used to output the vertex position
  21621. */
  21622. export class VertexOutputBlock extends NodeMaterialBlock {
  21623. /**
  21624. * Creates a new VertexOutputBlock
  21625. * @param name defines the block name
  21626. */
  21627. constructor(name: string);
  21628. /**
  21629. * Gets the current class name
  21630. * @returns the class name
  21631. */
  21632. getClassName(): string;
  21633. /**
  21634. * Gets the vector input component
  21635. */
  21636. get vector(): NodeMaterialConnectionPoint;
  21637. protected _buildBlock(state: NodeMaterialBuildState): this;
  21638. }
  21639. }
  21640. declare module BABYLON {
  21641. /**
  21642. * Block used to output the final color
  21643. */
  21644. export class FragmentOutputBlock extends NodeMaterialBlock {
  21645. /**
  21646. * Create a new FragmentOutputBlock
  21647. * @param name defines the block name
  21648. */
  21649. constructor(name: string);
  21650. /**
  21651. * Gets the current class name
  21652. * @returns the class name
  21653. */
  21654. getClassName(): string;
  21655. /**
  21656. * Gets the rgba input component
  21657. */
  21658. get rgba(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Gets the rgb input component
  21661. */
  21662. get rgb(): NodeMaterialConnectionPoint;
  21663. /**
  21664. * Gets the a input component
  21665. */
  21666. get a(): NodeMaterialConnectionPoint;
  21667. protected _buildBlock(state: NodeMaterialBuildState): this;
  21668. }
  21669. }
  21670. declare module BABYLON {
  21671. /**
  21672. * Block used for the particle ramp gradient section
  21673. */
  21674. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21675. /**
  21676. * Create a new ParticleRampGradientBlock
  21677. * @param name defines the block name
  21678. */
  21679. constructor(name: string);
  21680. /**
  21681. * Gets the current class name
  21682. * @returns the class name
  21683. */
  21684. getClassName(): string;
  21685. /**
  21686. * Gets the color input component
  21687. */
  21688. get color(): NodeMaterialConnectionPoint;
  21689. /**
  21690. * Gets the rampColor output component
  21691. */
  21692. get rampColor(): NodeMaterialConnectionPoint;
  21693. /**
  21694. * Initialize the block and prepare the context for build
  21695. * @param state defines the state that will be used for the build
  21696. */
  21697. initialize(state: NodeMaterialBuildState): void;
  21698. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21699. }
  21700. }
  21701. declare module BABYLON {
  21702. /**
  21703. * Block used for the particle blend multiply section
  21704. */
  21705. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21706. /**
  21707. * Create a new ParticleBlendMultiplyBlock
  21708. * @param name defines the block name
  21709. */
  21710. constructor(name: string);
  21711. /**
  21712. * Gets the current class name
  21713. * @returns the class name
  21714. */
  21715. getClassName(): string;
  21716. /**
  21717. * Gets the color input component
  21718. */
  21719. get color(): NodeMaterialConnectionPoint;
  21720. /**
  21721. * Gets the alphaTexture input component
  21722. */
  21723. get alphaTexture(): NodeMaterialConnectionPoint;
  21724. /**
  21725. * Gets the alphaColor input component
  21726. */
  21727. get alphaColor(): NodeMaterialConnectionPoint;
  21728. /**
  21729. * Gets the blendColor output component
  21730. */
  21731. get blendColor(): NodeMaterialConnectionPoint;
  21732. /**
  21733. * Initialize the block and prepare the context for build
  21734. * @param state defines the state that will be used for the build
  21735. */
  21736. initialize(state: NodeMaterialBuildState): void;
  21737. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21738. }
  21739. }
  21740. declare module BABYLON {
  21741. /**
  21742. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21743. */
  21744. export class VectorMergerBlock extends NodeMaterialBlock {
  21745. /**
  21746. * Create a new VectorMergerBlock
  21747. * @param name defines the block name
  21748. */
  21749. constructor(name: string);
  21750. /**
  21751. * Gets the current class name
  21752. * @returns the class name
  21753. */
  21754. getClassName(): string;
  21755. /**
  21756. * Gets the xyz component (input)
  21757. */
  21758. get xyzIn(): NodeMaterialConnectionPoint;
  21759. /**
  21760. * Gets the xy component (input)
  21761. */
  21762. get xyIn(): NodeMaterialConnectionPoint;
  21763. /**
  21764. * Gets the x component (input)
  21765. */
  21766. get x(): NodeMaterialConnectionPoint;
  21767. /**
  21768. * Gets the y component (input)
  21769. */
  21770. get y(): NodeMaterialConnectionPoint;
  21771. /**
  21772. * Gets the z component (input)
  21773. */
  21774. get z(): NodeMaterialConnectionPoint;
  21775. /**
  21776. * Gets the w component (input)
  21777. */
  21778. get w(): NodeMaterialConnectionPoint;
  21779. /**
  21780. * Gets the xyzw component (output)
  21781. */
  21782. get xyzw(): NodeMaterialConnectionPoint;
  21783. /**
  21784. * Gets the xyz component (output)
  21785. */
  21786. get xyzOut(): NodeMaterialConnectionPoint;
  21787. /**
  21788. * Gets the xy component (output)
  21789. */
  21790. get xyOut(): NodeMaterialConnectionPoint;
  21791. /**
  21792. * Gets the xy component (output)
  21793. * @deprecated Please use xyOut instead.
  21794. */
  21795. get xy(): NodeMaterialConnectionPoint;
  21796. /**
  21797. * Gets the xyz component (output)
  21798. * @deprecated Please use xyzOut instead.
  21799. */
  21800. get xyz(): NodeMaterialConnectionPoint;
  21801. protected _buildBlock(state: NodeMaterialBuildState): this;
  21802. }
  21803. }
  21804. declare module BABYLON {
  21805. /**
  21806. * Block used to remap a float from a range to a new one
  21807. */
  21808. export class RemapBlock extends NodeMaterialBlock {
  21809. /**
  21810. * Gets or sets the source range
  21811. */
  21812. sourceRange: Vector2;
  21813. /**
  21814. * Gets or sets the target range
  21815. */
  21816. targetRange: Vector2;
  21817. /**
  21818. * Creates a new RemapBlock
  21819. * @param name defines the block name
  21820. */
  21821. constructor(name: string);
  21822. /**
  21823. * Gets the current class name
  21824. * @returns the class name
  21825. */
  21826. getClassName(): string;
  21827. /**
  21828. * Gets the input component
  21829. */
  21830. get input(): NodeMaterialConnectionPoint;
  21831. /**
  21832. * Gets the source min input component
  21833. */
  21834. get sourceMin(): NodeMaterialConnectionPoint;
  21835. /**
  21836. * Gets the source max input component
  21837. */
  21838. get sourceMax(): NodeMaterialConnectionPoint;
  21839. /**
  21840. * Gets the target min input component
  21841. */
  21842. get targetMin(): NodeMaterialConnectionPoint;
  21843. /**
  21844. * Gets the target max input component
  21845. */
  21846. get targetMax(): NodeMaterialConnectionPoint;
  21847. /**
  21848. * Gets the output component
  21849. */
  21850. get output(): NodeMaterialConnectionPoint;
  21851. protected _buildBlock(state: NodeMaterialBuildState): this;
  21852. protected _dumpPropertiesCode(): string;
  21853. serialize(): any;
  21854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21855. }
  21856. }
  21857. declare module BABYLON {
  21858. /**
  21859. * Block used to multiply 2 values
  21860. */
  21861. export class MultiplyBlock extends NodeMaterialBlock {
  21862. /**
  21863. * Creates a new MultiplyBlock
  21864. * @param name defines the block name
  21865. */
  21866. constructor(name: string);
  21867. /**
  21868. * Gets the current class name
  21869. * @returns the class name
  21870. */
  21871. getClassName(): string;
  21872. /**
  21873. * Gets the left operand input component
  21874. */
  21875. get left(): NodeMaterialConnectionPoint;
  21876. /**
  21877. * Gets the right operand input component
  21878. */
  21879. get right(): NodeMaterialConnectionPoint;
  21880. /**
  21881. * Gets the output component
  21882. */
  21883. get output(): NodeMaterialConnectionPoint;
  21884. protected _buildBlock(state: NodeMaterialBuildState): this;
  21885. }
  21886. }
  21887. declare module BABYLON {
  21888. /**
  21889. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21890. */
  21891. export class ColorSplitterBlock extends NodeMaterialBlock {
  21892. /**
  21893. * Create a new ColorSplitterBlock
  21894. * @param name defines the block name
  21895. */
  21896. constructor(name: string);
  21897. /**
  21898. * Gets the current class name
  21899. * @returns the class name
  21900. */
  21901. getClassName(): string;
  21902. /**
  21903. * Gets the rgba component (input)
  21904. */
  21905. get rgba(): NodeMaterialConnectionPoint;
  21906. /**
  21907. * Gets the rgb component (input)
  21908. */
  21909. get rgbIn(): NodeMaterialConnectionPoint;
  21910. /**
  21911. * Gets the rgb component (output)
  21912. */
  21913. get rgbOut(): NodeMaterialConnectionPoint;
  21914. /**
  21915. * Gets the r component (output)
  21916. */
  21917. get r(): NodeMaterialConnectionPoint;
  21918. /**
  21919. * Gets the g component (output)
  21920. */
  21921. get g(): NodeMaterialConnectionPoint;
  21922. /**
  21923. * Gets the b component (output)
  21924. */
  21925. get b(): NodeMaterialConnectionPoint;
  21926. /**
  21927. * Gets the a component (output)
  21928. */
  21929. get a(): NodeMaterialConnectionPoint;
  21930. protected _inputRename(name: string): string;
  21931. protected _outputRename(name: string): string;
  21932. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21933. }
  21934. }
  21935. declare module BABYLON {
  21936. /**
  21937. * Interface used to configure the node material editor
  21938. */
  21939. export interface INodeMaterialEditorOptions {
  21940. /** Define the URl to load node editor script */
  21941. editorURL?: string;
  21942. }
  21943. /** @hidden */
  21944. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21945. NORMAL: boolean;
  21946. TANGENT: boolean;
  21947. UV1: boolean;
  21948. /** BONES */
  21949. NUM_BONE_INFLUENCERS: number;
  21950. BonesPerMesh: number;
  21951. BONETEXTURE: boolean;
  21952. /** MORPH TARGETS */
  21953. MORPHTARGETS: boolean;
  21954. MORPHTARGETS_NORMAL: boolean;
  21955. MORPHTARGETS_TANGENT: boolean;
  21956. MORPHTARGETS_UV: boolean;
  21957. NUM_MORPH_INFLUENCERS: number;
  21958. /** IMAGE PROCESSING */
  21959. IMAGEPROCESSING: boolean;
  21960. VIGNETTE: boolean;
  21961. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21962. VIGNETTEBLENDMODEOPAQUE: boolean;
  21963. TONEMAPPING: boolean;
  21964. TONEMAPPING_ACES: boolean;
  21965. CONTRAST: boolean;
  21966. EXPOSURE: boolean;
  21967. COLORCURVES: boolean;
  21968. COLORGRADING: boolean;
  21969. COLORGRADING3D: boolean;
  21970. SAMPLER3DGREENDEPTH: boolean;
  21971. SAMPLER3DBGRMAP: boolean;
  21972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21973. /** MISC. */
  21974. BUMPDIRECTUV: number;
  21975. constructor();
  21976. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21977. }
  21978. /**
  21979. * Class used to configure NodeMaterial
  21980. */
  21981. export interface INodeMaterialOptions {
  21982. /**
  21983. * Defines if blocks should emit comments
  21984. */
  21985. emitComments: boolean;
  21986. }
  21987. /**
  21988. * Class used to create a node based material built by assembling shader blocks
  21989. */
  21990. export class NodeMaterial extends PushMaterial {
  21991. private static _BuildIdGenerator;
  21992. private _options;
  21993. private _vertexCompilationState;
  21994. private _fragmentCompilationState;
  21995. private _sharedData;
  21996. private _buildId;
  21997. private _buildWasSuccessful;
  21998. private _cachedWorldViewMatrix;
  21999. private _cachedWorldViewProjectionMatrix;
  22000. private _optimizers;
  22001. private _animationFrame;
  22002. /** Define the Url to load node editor script */
  22003. static EditorURL: string;
  22004. /** Define the Url to load snippets */
  22005. static SnippetUrl: string;
  22006. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22007. static IgnoreTexturesAtLoadTime: boolean;
  22008. private BJSNODEMATERIALEDITOR;
  22009. /** Get the inspector from bundle or global */
  22010. private _getGlobalNodeMaterialEditor;
  22011. /**
  22012. * Snippet ID if the material was created from the snippet server
  22013. */
  22014. snippetId: string;
  22015. /**
  22016. * Gets or sets data used by visual editor
  22017. * @see https://nme.babylonjs.com
  22018. */
  22019. editorData: any;
  22020. /**
  22021. * 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)
  22022. */
  22023. ignoreAlpha: boolean;
  22024. /**
  22025. * Defines the maximum number of lights that can be used in the material
  22026. */
  22027. maxSimultaneousLights: number;
  22028. /**
  22029. * Observable raised when the material is built
  22030. */
  22031. onBuildObservable: Observable<NodeMaterial>;
  22032. /**
  22033. * Gets or sets the root nodes of the material vertex shader
  22034. */
  22035. _vertexOutputNodes: NodeMaterialBlock[];
  22036. /**
  22037. * Gets or sets the root nodes of the material fragment (pixel) shader
  22038. */
  22039. _fragmentOutputNodes: NodeMaterialBlock[];
  22040. /** Gets or sets options to control the node material overall behavior */
  22041. get options(): INodeMaterialOptions;
  22042. set options(options: INodeMaterialOptions);
  22043. /**
  22044. * Default configuration related to image processing available in the standard Material.
  22045. */
  22046. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22047. /**
  22048. * Gets the image processing configuration used either in this material.
  22049. */
  22050. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22051. /**
  22052. * Sets the Default image processing configuration used either in the this material.
  22053. *
  22054. * If sets to null, the scene one is in use.
  22055. */
  22056. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22057. /**
  22058. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22059. */
  22060. attachedBlocks: NodeMaterialBlock[];
  22061. /**
  22062. * Specifies the mode of the node material
  22063. * @hidden
  22064. */
  22065. _mode: NodeMaterialModes;
  22066. /**
  22067. * Gets the mode property
  22068. */
  22069. get mode(): NodeMaterialModes;
  22070. /**
  22071. * Create a new node based material
  22072. * @param name defines the material name
  22073. * @param scene defines the hosting scene
  22074. * @param options defines creation option
  22075. */
  22076. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22077. /**
  22078. * Gets the current class name of the material e.g. "NodeMaterial"
  22079. * @returns the class name
  22080. */
  22081. getClassName(): string;
  22082. /**
  22083. * Keep track of the image processing observer to allow dispose and replace.
  22084. */
  22085. private _imageProcessingObserver;
  22086. /**
  22087. * Attaches a new image processing configuration to the Standard Material.
  22088. * @param configuration
  22089. */
  22090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22091. /**
  22092. * Get a block by its name
  22093. * @param name defines the name of the block to retrieve
  22094. * @returns the required block or null if not found
  22095. */
  22096. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22097. /**
  22098. * Get a block by its name
  22099. * @param predicate defines the predicate used to find the good candidate
  22100. * @returns the required block or null if not found
  22101. */
  22102. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22103. /**
  22104. * Get an input block by its name
  22105. * @param predicate defines the predicate used to find the good candidate
  22106. * @returns the required input block or null if not found
  22107. */
  22108. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22109. /**
  22110. * Gets the list of input blocks attached to this material
  22111. * @returns an array of InputBlocks
  22112. */
  22113. getInputBlocks(): InputBlock[];
  22114. /**
  22115. * Adds a new optimizer to the list of optimizers
  22116. * @param optimizer defines the optimizers to add
  22117. * @returns the current material
  22118. */
  22119. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22120. /**
  22121. * Remove an optimizer from the list of optimizers
  22122. * @param optimizer defines the optimizers to remove
  22123. * @returns the current material
  22124. */
  22125. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22126. /**
  22127. * Add a new block to the list of output nodes
  22128. * @param node defines the node to add
  22129. * @returns the current material
  22130. */
  22131. addOutputNode(node: NodeMaterialBlock): this;
  22132. /**
  22133. * Remove a block from the list of root nodes
  22134. * @param node defines the node to remove
  22135. * @returns the current material
  22136. */
  22137. removeOutputNode(node: NodeMaterialBlock): this;
  22138. private _addVertexOutputNode;
  22139. private _removeVertexOutputNode;
  22140. private _addFragmentOutputNode;
  22141. private _removeFragmentOutputNode;
  22142. /**
  22143. * Specifies if the material will require alpha blending
  22144. * @returns a boolean specifying if alpha blending is needed
  22145. */
  22146. needAlphaBlending(): boolean;
  22147. /**
  22148. * Specifies if this material should be rendered in alpha test mode
  22149. * @returns a boolean specifying if an alpha test is needed.
  22150. */
  22151. needAlphaTesting(): boolean;
  22152. private _initializeBlock;
  22153. private _resetDualBlocks;
  22154. /**
  22155. * Remove a block from the current node material
  22156. * @param block defines the block to remove
  22157. */
  22158. removeBlock(block: NodeMaterialBlock): void;
  22159. /**
  22160. * Build the material and generates the inner effect
  22161. * @param verbose defines if the build should log activity
  22162. */
  22163. build(verbose?: boolean): void;
  22164. /**
  22165. * Runs an otpimization phase to try to improve the shader code
  22166. */
  22167. optimize(): void;
  22168. private _prepareDefinesForAttributes;
  22169. /**
  22170. * Create a post process from the material
  22171. * @param camera The camera to apply the render pass to.
  22172. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22174. * @param engine The engine which the post process will be applied. (default: current engine)
  22175. * @param reusable If the post process can be reused on the same frame. (default: false)
  22176. * @param textureType Type of textures used when performing the post process. (default: 0)
  22177. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22178. * @returns the post process created
  22179. */
  22180. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22181. private _createEffectForParticles;
  22182. /**
  22183. * Create the effect to be used as the custom effect for a particle system
  22184. * @param particleSystem Particle system to create the effect for
  22185. * @param onCompiled defines a function to call when the effect creation is successful
  22186. * @param onError defines a function to call when the effect creation has failed
  22187. */
  22188. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22189. private _processDefines;
  22190. /**
  22191. * Get if the submesh is ready to be used and all its information available.
  22192. * Child classes can use it to update shaders
  22193. * @param mesh defines the mesh to check
  22194. * @param subMesh defines which submesh to check
  22195. * @param useInstances specifies that instances should be used
  22196. * @returns a boolean indicating that the submesh is ready or not
  22197. */
  22198. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22199. /**
  22200. * Get a string representing the shaders built by the current node graph
  22201. */
  22202. get compiledShaders(): string;
  22203. /**
  22204. * Binds the world matrix to the material
  22205. * @param world defines the world transformation matrix
  22206. */
  22207. bindOnlyWorldMatrix(world: Matrix): void;
  22208. /**
  22209. * Binds the submesh to this material by preparing the effect and shader to draw
  22210. * @param world defines the world transformation matrix
  22211. * @param mesh defines the mesh containing the submesh
  22212. * @param subMesh defines the submesh to bind the material to
  22213. */
  22214. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22215. /**
  22216. * Gets the active textures from the material
  22217. * @returns an array of textures
  22218. */
  22219. getActiveTextures(): BaseTexture[];
  22220. /**
  22221. * Gets the list of texture blocks
  22222. * @returns an array of texture blocks
  22223. */
  22224. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22225. /**
  22226. * Specifies if the material uses a texture
  22227. * @param texture defines the texture to check against the material
  22228. * @returns a boolean specifying if the material uses the texture
  22229. */
  22230. hasTexture(texture: BaseTexture): boolean;
  22231. /**
  22232. * Disposes the material
  22233. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22234. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22235. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22236. */
  22237. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22238. /** Creates the node editor window. */
  22239. private _createNodeEditor;
  22240. /**
  22241. * Launch the node material editor
  22242. * @param config Define the configuration of the editor
  22243. * @return a promise fulfilled when the node editor is visible
  22244. */
  22245. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22246. /**
  22247. * Clear the current material
  22248. */
  22249. clear(): void;
  22250. /**
  22251. * Clear the current material and set it to a default state
  22252. */
  22253. setToDefault(): void;
  22254. /**
  22255. * Clear the current material and set it to a default state for post process
  22256. */
  22257. setToDefaultPostProcess(): void;
  22258. /**
  22259. * Clear the current material and set it to a default state for particle
  22260. */
  22261. setToDefaultParticle(): void;
  22262. /**
  22263. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22264. * @param url defines the url to load from
  22265. * @returns a promise that will fullfil when the material is fully loaded
  22266. */
  22267. loadAsync(url: string): Promise<void>;
  22268. private _gatherBlocks;
  22269. /**
  22270. * Generate a string containing the code declaration required to create an equivalent of this material
  22271. * @returns a string
  22272. */
  22273. generateCode(): string;
  22274. /**
  22275. * Serializes this material in a JSON representation
  22276. * @returns the serialized material object
  22277. */
  22278. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22279. private _restoreConnections;
  22280. /**
  22281. * Clear the current graph and load a new one from a serialization object
  22282. * @param source defines the JSON representation of the material
  22283. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22284. */
  22285. loadFromSerialization(source: any, rootUrl?: string): void;
  22286. /**
  22287. * Makes a duplicate of the current material.
  22288. * @param name - name to use for the new material.
  22289. */
  22290. clone(name: string): NodeMaterial;
  22291. /**
  22292. * Creates a node material from parsed material data
  22293. * @param source defines the JSON representation of the material
  22294. * @param scene defines the hosting scene
  22295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22296. * @returns a new node material
  22297. */
  22298. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22299. /**
  22300. * Creates a node material from a snippet saved in a remote file
  22301. * @param name defines the name of the material to create
  22302. * @param url defines the url to load from
  22303. * @param scene defines the hosting scene
  22304. * @returns a promise that will resolve to the new node material
  22305. */
  22306. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22307. /**
  22308. * Creates a node material from a snippet saved by the node material editor
  22309. * @param snippetId defines the snippet to load
  22310. * @param scene defines the hosting scene
  22311. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22312. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22313. * @returns a promise that will resolve to the new node material
  22314. */
  22315. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22316. /**
  22317. * Creates a new node material set to default basic configuration
  22318. * @param name defines the name of the material
  22319. * @param scene defines the hosting scene
  22320. * @returns a new NodeMaterial
  22321. */
  22322. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22323. }
  22324. }
  22325. declare module BABYLON {
  22326. /**
  22327. * Size options for a post process
  22328. */
  22329. export type PostProcessOptions = {
  22330. width: number;
  22331. height: number;
  22332. };
  22333. /**
  22334. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22335. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22336. */
  22337. export class PostProcess {
  22338. /** Name of the PostProcess. */
  22339. name: string;
  22340. /**
  22341. * Gets or sets the unique id of the post process
  22342. */
  22343. uniqueId: number;
  22344. /**
  22345. * Width of the texture to apply the post process on
  22346. */
  22347. width: number;
  22348. /**
  22349. * Height of the texture to apply the post process on
  22350. */
  22351. height: number;
  22352. /**
  22353. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22354. */
  22355. nodeMaterialSource: Nullable<NodeMaterial>;
  22356. /**
  22357. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22358. * @hidden
  22359. */
  22360. _outputTexture: Nullable<InternalTexture>;
  22361. /**
  22362. * Sampling mode used by the shader
  22363. * See https://doc.babylonjs.com/classes/3.1/texture
  22364. */
  22365. renderTargetSamplingMode: number;
  22366. /**
  22367. * Clear color to use when screen clearing
  22368. */
  22369. clearColor: Color4;
  22370. /**
  22371. * If the buffer needs to be cleared before applying the post process. (default: true)
  22372. * Should be set to false if shader will overwrite all previous pixels.
  22373. */
  22374. autoClear: boolean;
  22375. /**
  22376. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22377. */
  22378. alphaMode: number;
  22379. /**
  22380. * Sets the setAlphaBlendConstants of the babylon engine
  22381. */
  22382. alphaConstants: Color4;
  22383. /**
  22384. * Animations to be used for the post processing
  22385. */
  22386. animations: Animation[];
  22387. /**
  22388. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22389. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22390. */
  22391. enablePixelPerfectMode: boolean;
  22392. /**
  22393. * Force the postprocess to be applied without taking in account viewport
  22394. */
  22395. forceFullscreenViewport: boolean;
  22396. /**
  22397. * List of inspectable custom properties (used by the Inspector)
  22398. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22399. */
  22400. inspectableCustomProperties: IInspectable[];
  22401. /**
  22402. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22403. *
  22404. * | Value | Type | Description |
  22405. * | ----- | ----------------------------------- | ----------- |
  22406. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22407. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22408. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22409. *
  22410. */
  22411. scaleMode: number;
  22412. /**
  22413. * Force textures to be a power of two (default: false)
  22414. */
  22415. alwaysForcePOT: boolean;
  22416. private _samples;
  22417. /**
  22418. * Number of sample textures (default: 1)
  22419. */
  22420. get samples(): number;
  22421. set samples(n: number);
  22422. /**
  22423. * Modify the scale of the post process to be the same as the viewport (default: false)
  22424. */
  22425. adaptScaleToCurrentViewport: boolean;
  22426. private _camera;
  22427. private _scene;
  22428. private _engine;
  22429. private _options;
  22430. private _reusable;
  22431. private _textureType;
  22432. private _textureFormat;
  22433. /**
  22434. * Smart array of input and output textures for the post process.
  22435. * @hidden
  22436. */
  22437. _textures: SmartArray<InternalTexture>;
  22438. /**
  22439. * The index in _textures that corresponds to the output texture.
  22440. * @hidden
  22441. */
  22442. _currentRenderTextureInd: number;
  22443. private _effect;
  22444. private _samplers;
  22445. private _fragmentUrl;
  22446. private _vertexUrl;
  22447. private _parameters;
  22448. private _scaleRatio;
  22449. protected _indexParameters: any;
  22450. private _shareOutputWithPostProcess;
  22451. private _texelSize;
  22452. private _forcedOutputTexture;
  22453. /**
  22454. * Returns the fragment url or shader name used in the post process.
  22455. * @returns the fragment url or name in the shader store.
  22456. */
  22457. getEffectName(): string;
  22458. /**
  22459. * An event triggered when the postprocess is activated.
  22460. */
  22461. onActivateObservable: Observable<Camera>;
  22462. private _onActivateObserver;
  22463. /**
  22464. * A function that is added to the onActivateObservable
  22465. */
  22466. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22467. /**
  22468. * An event triggered when the postprocess changes its size.
  22469. */
  22470. onSizeChangedObservable: Observable<PostProcess>;
  22471. private _onSizeChangedObserver;
  22472. /**
  22473. * A function that is added to the onSizeChangedObservable
  22474. */
  22475. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22476. /**
  22477. * An event triggered when the postprocess applies its effect.
  22478. */
  22479. onApplyObservable: Observable<Effect>;
  22480. private _onApplyObserver;
  22481. /**
  22482. * A function that is added to the onApplyObservable
  22483. */
  22484. set onApply(callback: (effect: Effect) => void);
  22485. /**
  22486. * An event triggered before rendering the postprocess
  22487. */
  22488. onBeforeRenderObservable: Observable<Effect>;
  22489. private _onBeforeRenderObserver;
  22490. /**
  22491. * A function that is added to the onBeforeRenderObservable
  22492. */
  22493. set onBeforeRender(callback: (effect: Effect) => void);
  22494. /**
  22495. * An event triggered after rendering the postprocess
  22496. */
  22497. onAfterRenderObservable: Observable<Effect>;
  22498. private _onAfterRenderObserver;
  22499. /**
  22500. * A function that is added to the onAfterRenderObservable
  22501. */
  22502. set onAfterRender(callback: (efect: Effect) => void);
  22503. /**
  22504. * 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
  22505. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22506. */
  22507. get inputTexture(): InternalTexture;
  22508. set inputTexture(value: InternalTexture);
  22509. /**
  22510. * Gets the camera which post process is applied to.
  22511. * @returns The camera the post process is applied to.
  22512. */
  22513. getCamera(): Camera;
  22514. /**
  22515. * Gets the texel size of the postprocess.
  22516. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22517. */
  22518. get texelSize(): Vector2;
  22519. /**
  22520. * Creates a new instance PostProcess
  22521. * @param name The name of the PostProcess.
  22522. * @param fragmentUrl The url of the fragment shader to be used.
  22523. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22524. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22525. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22526. * @param camera The camera to apply the render pass to.
  22527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22528. * @param engine The engine which the post process will be applied. (default: current engine)
  22529. * @param reusable If the post process can be reused on the same frame. (default: false)
  22530. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22531. * @param textureType Type of textures used when performing the post process. (default: 0)
  22532. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22533. * @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
  22534. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22535. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22536. */
  22537. constructor(
  22538. /** Name of the PostProcess. */
  22539. 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);
  22540. /**
  22541. * Gets a string idenfifying the name of the class
  22542. * @returns "PostProcess" string
  22543. */
  22544. getClassName(): string;
  22545. /**
  22546. * Gets the engine which this post process belongs to.
  22547. * @returns The engine the post process was enabled with.
  22548. */
  22549. getEngine(): Engine;
  22550. /**
  22551. * The effect that is created when initializing the post process.
  22552. * @returns The created effect corresponding the the postprocess.
  22553. */
  22554. getEffect(): Effect;
  22555. /**
  22556. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22557. * @param postProcess The post process to share the output with.
  22558. * @returns This post process.
  22559. */
  22560. shareOutputWith(postProcess: PostProcess): PostProcess;
  22561. /**
  22562. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22563. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22564. */
  22565. useOwnOutput(): void;
  22566. /**
  22567. * Updates the effect with the current post process compile time values and recompiles the shader.
  22568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22571. * @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
  22572. * @param onCompiled Called when the shader has been compiled.
  22573. * @param onError Called if there is an error when compiling a shader.
  22574. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22575. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22576. */
  22577. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  22578. /**
  22579. * The post process is reusable if it can be used multiple times within one frame.
  22580. * @returns If the post process is reusable
  22581. */
  22582. isReusable(): boolean;
  22583. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22584. markTextureDirty(): void;
  22585. /**
  22586. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22587. * 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.
  22588. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22589. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22590. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22591. * @returns The target texture that was bound to be written to.
  22592. */
  22593. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22594. /**
  22595. * If the post process is supported.
  22596. */
  22597. get isSupported(): boolean;
  22598. /**
  22599. * The aspect ratio of the output texture.
  22600. */
  22601. get aspectRatio(): number;
  22602. /**
  22603. * Get a value indicating if the post-process is ready to be used
  22604. * @returns true if the post-process is ready (shader is compiled)
  22605. */
  22606. isReady(): boolean;
  22607. /**
  22608. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22609. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22610. */
  22611. apply(): Nullable<Effect>;
  22612. private _disposeTextures;
  22613. /**
  22614. * Disposes the post process.
  22615. * @param camera The camera to dispose the post process on.
  22616. */
  22617. dispose(camera?: Camera): void;
  22618. }
  22619. }
  22620. declare module BABYLON {
  22621. /** @hidden */
  22622. export var kernelBlurVaryingDeclaration: {
  22623. name: string;
  22624. shader: string;
  22625. };
  22626. }
  22627. declare module BABYLON {
  22628. /** @hidden */
  22629. export var kernelBlurFragment: {
  22630. name: string;
  22631. shader: string;
  22632. };
  22633. }
  22634. declare module BABYLON {
  22635. /** @hidden */
  22636. export var kernelBlurFragment2: {
  22637. name: string;
  22638. shader: string;
  22639. };
  22640. }
  22641. declare module BABYLON {
  22642. /** @hidden */
  22643. export var kernelBlurPixelShader: {
  22644. name: string;
  22645. shader: string;
  22646. };
  22647. }
  22648. declare module BABYLON {
  22649. /** @hidden */
  22650. export var kernelBlurVertex: {
  22651. name: string;
  22652. shader: string;
  22653. };
  22654. }
  22655. declare module BABYLON {
  22656. /** @hidden */
  22657. export var kernelBlurVertexShader: {
  22658. name: string;
  22659. shader: string;
  22660. };
  22661. }
  22662. declare module BABYLON {
  22663. /**
  22664. * The Blur Post Process which blurs an image based on a kernel and direction.
  22665. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22666. */
  22667. export class BlurPostProcess extends PostProcess {
  22668. /** The direction in which to blur the image. */
  22669. direction: Vector2;
  22670. private blockCompilation;
  22671. protected _kernel: number;
  22672. protected _idealKernel: number;
  22673. protected _packedFloat: boolean;
  22674. private _staticDefines;
  22675. /**
  22676. * Sets the length in pixels of the blur sample region
  22677. */
  22678. set kernel(v: number);
  22679. /**
  22680. * Gets the length in pixels of the blur sample region
  22681. */
  22682. get kernel(): number;
  22683. /**
  22684. * Sets wether or not the blur needs to unpack/repack floats
  22685. */
  22686. set packedFloat(v: boolean);
  22687. /**
  22688. * Gets wether or not the blur is unpacking/repacking floats
  22689. */
  22690. get packedFloat(): boolean;
  22691. /**
  22692. * Creates a new instance BlurPostProcess
  22693. * @param name The name of the effect.
  22694. * @param direction The direction in which to blur the image.
  22695. * @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.
  22696. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22697. * @param camera The camera to apply the render pass to.
  22698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22699. * @param engine The engine which the post process will be applied. (default: current engine)
  22700. * @param reusable If the post process can be reused on the same frame. (default: false)
  22701. * @param textureType Type of textures used when performing the post process. (default: 0)
  22702. * @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)
  22703. */
  22704. constructor(name: string,
  22705. /** The direction in which to blur the image. */
  22706. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22707. /**
  22708. * Updates the effect with the current post process compile time values and recompiles the shader.
  22709. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22710. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22711. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22712. * @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
  22713. * @param onCompiled Called when the shader has been compiled.
  22714. * @param onError Called if there is an error when compiling a shader.
  22715. */
  22716. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22717. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22718. /**
  22719. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22720. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22721. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22722. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22723. * The gaps between physical kernels are compensated for in the weighting of the samples
  22724. * @param idealKernel Ideal blur kernel.
  22725. * @return Nearest best kernel.
  22726. */
  22727. protected _nearestBestKernel(idealKernel: number): number;
  22728. /**
  22729. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22730. * @param x The point on the Gaussian distribution to sample.
  22731. * @return the value of the Gaussian function at x.
  22732. */
  22733. protected _gaussianWeight(x: number): number;
  22734. /**
  22735. * Generates a string that can be used as a floating point number in GLSL.
  22736. * @param x Value to print.
  22737. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22738. * @return GLSL float string.
  22739. */
  22740. protected _glslFloat(x: number, decimalFigures?: number): string;
  22741. }
  22742. }
  22743. declare module BABYLON {
  22744. /**
  22745. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22746. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22747. * You can then easily use it as a reflectionTexture on a flat surface.
  22748. * In case the surface is not a plane, please consider relying on reflection probes.
  22749. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22750. */
  22751. export class MirrorTexture extends RenderTargetTexture {
  22752. private scene;
  22753. /**
  22754. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22755. * 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.
  22756. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22757. */
  22758. mirrorPlane: Plane;
  22759. /**
  22760. * Define the blur ratio used to blur the reflection if needed.
  22761. */
  22762. set blurRatio(value: number);
  22763. get blurRatio(): number;
  22764. /**
  22765. * Define the adaptive blur kernel used to blur the reflection if needed.
  22766. * This will autocompute the closest best match for the `blurKernel`
  22767. */
  22768. set adaptiveBlurKernel(value: number);
  22769. /**
  22770. * Define the blur kernel used to blur the reflection if needed.
  22771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22772. */
  22773. set blurKernel(value: number);
  22774. /**
  22775. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22776. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22777. */
  22778. set blurKernelX(value: number);
  22779. get blurKernelX(): number;
  22780. /**
  22781. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22782. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22783. */
  22784. set blurKernelY(value: number);
  22785. get blurKernelY(): number;
  22786. private _autoComputeBlurKernel;
  22787. protected _onRatioRescale(): void;
  22788. private _updateGammaSpace;
  22789. private _imageProcessingConfigChangeObserver;
  22790. private _transformMatrix;
  22791. private _mirrorMatrix;
  22792. private _savedViewMatrix;
  22793. private _blurX;
  22794. private _blurY;
  22795. private _adaptiveBlurKernel;
  22796. private _blurKernelX;
  22797. private _blurKernelY;
  22798. private _blurRatio;
  22799. /**
  22800. * Instantiates a Mirror Texture.
  22801. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22802. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22803. * You can then easily use it as a reflectionTexture on a flat surface.
  22804. * In case the surface is not a plane, please consider relying on reflection probes.
  22805. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22806. * @param name
  22807. * @param size
  22808. * @param scene
  22809. * @param generateMipMaps
  22810. * @param type
  22811. * @param samplingMode
  22812. * @param generateDepthBuffer
  22813. */
  22814. constructor(name: string, size: number | {
  22815. width: number;
  22816. height: number;
  22817. } | {
  22818. ratio: number;
  22819. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22820. private _preparePostProcesses;
  22821. /**
  22822. * Clone the mirror texture.
  22823. * @returns the cloned texture
  22824. */
  22825. clone(): MirrorTexture;
  22826. /**
  22827. * Serialize the texture to a JSON representation you could use in Parse later on
  22828. * @returns the serialized JSON representation
  22829. */
  22830. serialize(): any;
  22831. /**
  22832. * Dispose the texture and release its associated resources.
  22833. */
  22834. dispose(): void;
  22835. }
  22836. }
  22837. declare module BABYLON {
  22838. /**
  22839. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22840. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22841. */
  22842. export class Texture extends BaseTexture {
  22843. /**
  22844. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22845. */
  22846. static SerializeBuffers: boolean;
  22847. /** @hidden */
  22848. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22849. /** @hidden */
  22850. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22851. /** @hidden */
  22852. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22853. /** nearest is mag = nearest and min = nearest and mip = linear */
  22854. static readonly NEAREST_SAMPLINGMODE: number;
  22855. /** nearest is mag = nearest and min = nearest and mip = linear */
  22856. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22857. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22858. static readonly BILINEAR_SAMPLINGMODE: number;
  22859. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22860. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22861. /** Trilinear is mag = linear and min = linear and mip = linear */
  22862. static readonly TRILINEAR_SAMPLINGMODE: number;
  22863. /** Trilinear is mag = linear and min = linear and mip = linear */
  22864. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22865. /** mag = nearest and min = nearest and mip = nearest */
  22866. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22867. /** mag = nearest and min = linear and mip = nearest */
  22868. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22869. /** mag = nearest and min = linear and mip = linear */
  22870. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22871. /** mag = nearest and min = linear and mip = none */
  22872. static readonly NEAREST_LINEAR: number;
  22873. /** mag = nearest and min = nearest and mip = none */
  22874. static readonly NEAREST_NEAREST: number;
  22875. /** mag = linear and min = nearest and mip = nearest */
  22876. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22877. /** mag = linear and min = nearest and mip = linear */
  22878. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22879. /** mag = linear and min = linear and mip = none */
  22880. static readonly LINEAR_LINEAR: number;
  22881. /** mag = linear and min = nearest and mip = none */
  22882. static readonly LINEAR_NEAREST: number;
  22883. /** Explicit coordinates mode */
  22884. static readonly EXPLICIT_MODE: number;
  22885. /** Spherical coordinates mode */
  22886. static readonly SPHERICAL_MODE: number;
  22887. /** Planar coordinates mode */
  22888. static readonly PLANAR_MODE: number;
  22889. /** Cubic coordinates mode */
  22890. static readonly CUBIC_MODE: number;
  22891. /** Projection coordinates mode */
  22892. static readonly PROJECTION_MODE: number;
  22893. /** Inverse Cubic coordinates mode */
  22894. static readonly SKYBOX_MODE: number;
  22895. /** Inverse Cubic coordinates mode */
  22896. static readonly INVCUBIC_MODE: number;
  22897. /** Equirectangular coordinates mode */
  22898. static readonly EQUIRECTANGULAR_MODE: number;
  22899. /** Equirectangular Fixed coordinates mode */
  22900. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22901. /** Equirectangular Fixed Mirrored coordinates mode */
  22902. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22903. /** Texture is not repeating outside of 0..1 UVs */
  22904. static readonly CLAMP_ADDRESSMODE: number;
  22905. /** Texture is repeating outside of 0..1 UVs */
  22906. static readonly WRAP_ADDRESSMODE: number;
  22907. /** Texture is repeating and mirrored */
  22908. static readonly MIRROR_ADDRESSMODE: number;
  22909. /**
  22910. * 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
  22911. */
  22912. static UseSerializedUrlIfAny: boolean;
  22913. /**
  22914. * Define the url of the texture.
  22915. */
  22916. url: Nullable<string>;
  22917. /**
  22918. * Define an offset on the texture to offset the u coordinates of the UVs
  22919. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22920. */
  22921. uOffset: number;
  22922. /**
  22923. * Define an offset on the texture to offset the v coordinates of the UVs
  22924. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22925. */
  22926. vOffset: number;
  22927. /**
  22928. * Define an offset on the texture to scale the u coordinates of the UVs
  22929. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22930. */
  22931. uScale: number;
  22932. /**
  22933. * Define an offset on the texture to scale the v coordinates of the UVs
  22934. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22935. */
  22936. vScale: number;
  22937. /**
  22938. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22939. * @see http://doc.babylonjs.com/how_to/more_materials
  22940. */
  22941. uAng: number;
  22942. /**
  22943. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22944. * @see http://doc.babylonjs.com/how_to/more_materials
  22945. */
  22946. vAng: number;
  22947. /**
  22948. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22949. * @see http://doc.babylonjs.com/how_to/more_materials
  22950. */
  22951. wAng: number;
  22952. /**
  22953. * Defines the center of rotation (U)
  22954. */
  22955. uRotationCenter: number;
  22956. /**
  22957. * Defines the center of rotation (V)
  22958. */
  22959. vRotationCenter: number;
  22960. /**
  22961. * Defines the center of rotation (W)
  22962. */
  22963. wRotationCenter: number;
  22964. /**
  22965. * Are mip maps generated for this texture or not.
  22966. */
  22967. get noMipmap(): boolean;
  22968. /**
  22969. * List of inspectable custom properties (used by the Inspector)
  22970. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22971. */
  22972. inspectableCustomProperties: Nullable<IInspectable[]>;
  22973. private _noMipmap;
  22974. /** @hidden */
  22975. _invertY: boolean;
  22976. private _rowGenerationMatrix;
  22977. private _cachedTextureMatrix;
  22978. private _projectionModeMatrix;
  22979. private _t0;
  22980. private _t1;
  22981. private _t2;
  22982. private _cachedUOffset;
  22983. private _cachedVOffset;
  22984. private _cachedUScale;
  22985. private _cachedVScale;
  22986. private _cachedUAng;
  22987. private _cachedVAng;
  22988. private _cachedWAng;
  22989. private _cachedProjectionMatrixId;
  22990. private _cachedCoordinatesMode;
  22991. /** @hidden */
  22992. protected _initialSamplingMode: number;
  22993. /** @hidden */
  22994. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  22995. private _deleteBuffer;
  22996. protected _format: Nullable<number>;
  22997. private _delayedOnLoad;
  22998. private _delayedOnError;
  22999. private _mimeType?;
  23000. /**
  23001. * Observable triggered once the texture has been loaded.
  23002. */
  23003. onLoadObservable: Observable<Texture>;
  23004. protected _isBlocking: boolean;
  23005. /**
  23006. * Is the texture preventing material to render while loading.
  23007. * If false, a default texture will be used instead of the loading one during the preparation step.
  23008. */
  23009. set isBlocking(value: boolean);
  23010. get isBlocking(): boolean;
  23011. /**
  23012. * Get the current sampling mode associated with the texture.
  23013. */
  23014. get samplingMode(): number;
  23015. /**
  23016. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23017. */
  23018. get invertY(): boolean;
  23019. /**
  23020. * Instantiates a new texture.
  23021. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23022. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23023. * @param url defines the url of the picture to load as a texture
  23024. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23025. * @param noMipmap defines if the texture will require mip maps or not
  23026. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23027. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23028. * @param onLoad defines a callback triggered when the texture has been loaded
  23029. * @param onError defines a callback triggered when an error occurred during the loading session
  23030. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23031. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23032. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23033. * @param mimeType defines an optional mime type information
  23034. */
  23035. 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);
  23036. /**
  23037. * Update the url (and optional buffer) of this texture if url was null during construction.
  23038. * @param url the url of the texture
  23039. * @param buffer the buffer of the texture (defaults to null)
  23040. * @param onLoad callback called when the texture is loaded (defaults to null)
  23041. */
  23042. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23043. /**
  23044. * Finish the loading sequence of a texture flagged as delayed load.
  23045. * @hidden
  23046. */
  23047. delayLoad(): void;
  23048. private _prepareRowForTextureGeneration;
  23049. /**
  23050. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23051. * @returns the transform matrix of the texture.
  23052. */
  23053. getTextureMatrix(uBase?: number): Matrix;
  23054. /**
  23055. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23056. * @returns The reflection texture transform
  23057. */
  23058. getReflectionTextureMatrix(): Matrix;
  23059. /**
  23060. * Clones the texture.
  23061. * @returns the cloned texture
  23062. */
  23063. clone(): Texture;
  23064. /**
  23065. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23066. * @returns The JSON representation of the texture
  23067. */
  23068. serialize(): any;
  23069. /**
  23070. * Get the current class name of the texture useful for serialization or dynamic coding.
  23071. * @returns "Texture"
  23072. */
  23073. getClassName(): string;
  23074. /**
  23075. * Dispose the texture and release its associated resources.
  23076. */
  23077. dispose(): void;
  23078. /**
  23079. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23080. * @param parsedTexture Define the JSON representation of the texture
  23081. * @param scene Define the scene the parsed texture should be instantiated in
  23082. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23083. * @returns The parsed texture if successful
  23084. */
  23085. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23086. /**
  23087. * Creates a texture from its base 64 representation.
  23088. * @param data Define the base64 payload without the data: prefix
  23089. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23090. * @param scene Define the scene the texture should belong to
  23091. * @param noMipmap Forces the texture to not create mip map information if true
  23092. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23093. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23094. * @param onLoad define a callback triggered when the texture has been loaded
  23095. * @param onError define a callback triggered when an error occurred during the loading session
  23096. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23097. * @returns the created texture
  23098. */
  23099. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23100. /**
  23101. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23102. * @param data Define the base64 payload without the data: prefix
  23103. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23104. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23105. * @param scene Define the scene the texture should belong to
  23106. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23107. * @param noMipmap Forces the texture to not create mip map information if true
  23108. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23109. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23110. * @param onLoad define a callback triggered when the texture has been loaded
  23111. * @param onError define a callback triggered when an error occurred during the loading session
  23112. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23113. * @returns the created texture
  23114. */
  23115. 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;
  23116. }
  23117. }
  23118. declare module BABYLON {
  23119. /**
  23120. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23121. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23122. */
  23123. export class PostProcessManager {
  23124. private _scene;
  23125. private _indexBuffer;
  23126. private _vertexBuffers;
  23127. /**
  23128. * Creates a new instance PostProcess
  23129. * @param scene The scene that the post process is associated with.
  23130. */
  23131. constructor(scene: Scene);
  23132. private _prepareBuffers;
  23133. private _buildIndexBuffer;
  23134. /**
  23135. * Rebuilds the vertex buffers of the manager.
  23136. * @hidden
  23137. */
  23138. _rebuild(): void;
  23139. /**
  23140. * Prepares a frame to be run through a post process.
  23141. * @param sourceTexture The input texture to the post procesess. (default: null)
  23142. * @param postProcesses An array of post processes to be run. (default: null)
  23143. * @returns True if the post processes were able to be run.
  23144. * @hidden
  23145. */
  23146. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23147. /**
  23148. * Manually render a set of post processes to a texture.
  23149. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23150. * @param postProcesses An array of post processes to be run.
  23151. * @param targetTexture The target texture to render to.
  23152. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23153. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23154. * @param lodLevel defines which lod of the texture to render to
  23155. */
  23156. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23157. /**
  23158. * Finalize the result of the output of the postprocesses.
  23159. * @param doNotPresent If true the result will not be displayed to the screen.
  23160. * @param targetTexture The target texture to render to.
  23161. * @param faceIndex The index of the face to bind the target texture to.
  23162. * @param postProcesses The array of post processes to render.
  23163. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23164. * @hidden
  23165. */
  23166. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23167. /**
  23168. * Disposes of the post process manager.
  23169. */
  23170. dispose(): void;
  23171. }
  23172. }
  23173. declare module BABYLON {
  23174. /**
  23175. * This Helps creating a texture that will be created from a camera in your scene.
  23176. * It is basically a dynamic texture that could be used to create special effects for instance.
  23177. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23178. */
  23179. export class RenderTargetTexture extends Texture {
  23180. isCube: boolean;
  23181. /**
  23182. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23183. */
  23184. static readonly REFRESHRATE_RENDER_ONCE: number;
  23185. /**
  23186. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23187. */
  23188. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23189. /**
  23190. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23191. * the central point of your effect and can save a lot of performances.
  23192. */
  23193. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23194. /**
  23195. * Use this predicate to dynamically define the list of mesh you want to render.
  23196. * If set, the renderList property will be overwritten.
  23197. */
  23198. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23199. private _renderList;
  23200. /**
  23201. * Use this list to define the list of mesh you want to render.
  23202. */
  23203. get renderList(): Nullable<Array<AbstractMesh>>;
  23204. set renderList(value: Nullable<Array<AbstractMesh>>);
  23205. /**
  23206. * Use this function to overload the renderList array at rendering time.
  23207. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23208. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23209. * the cube (if the RTT is a cube, else layerOrFace=0).
  23210. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23211. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23212. * hold dummy elements!
  23213. */
  23214. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23215. private _hookArray;
  23216. /**
  23217. * Define if particles should be rendered in your texture.
  23218. */
  23219. renderParticles: boolean;
  23220. /**
  23221. * Define if sprites should be rendered in your texture.
  23222. */
  23223. renderSprites: boolean;
  23224. /**
  23225. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23226. */
  23227. coordinatesMode: number;
  23228. /**
  23229. * Define the camera used to render the texture.
  23230. */
  23231. activeCamera: Nullable<Camera>;
  23232. /**
  23233. * Override the mesh isReady function with your own one.
  23234. */
  23235. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23236. /**
  23237. * Override the render function of the texture with your own one.
  23238. */
  23239. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23240. /**
  23241. * Define if camera post processes should be use while rendering the texture.
  23242. */
  23243. useCameraPostProcesses: boolean;
  23244. /**
  23245. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23246. */
  23247. ignoreCameraViewport: boolean;
  23248. private _postProcessManager;
  23249. private _postProcesses;
  23250. private _resizeObserver;
  23251. /**
  23252. * An event triggered when the texture is unbind.
  23253. */
  23254. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23255. /**
  23256. * An event triggered when the texture is unbind.
  23257. */
  23258. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23259. private _onAfterUnbindObserver;
  23260. /**
  23261. * Set a after unbind callback in the texture.
  23262. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23263. */
  23264. set onAfterUnbind(callback: () => void);
  23265. /**
  23266. * An event triggered before rendering the texture
  23267. */
  23268. onBeforeRenderObservable: Observable<number>;
  23269. private _onBeforeRenderObserver;
  23270. /**
  23271. * Set a before render callback in the texture.
  23272. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23273. */
  23274. set onBeforeRender(callback: (faceIndex: number) => void);
  23275. /**
  23276. * An event triggered after rendering the texture
  23277. */
  23278. onAfterRenderObservable: Observable<number>;
  23279. private _onAfterRenderObserver;
  23280. /**
  23281. * Set a after render callback in the texture.
  23282. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23283. */
  23284. set onAfterRender(callback: (faceIndex: number) => void);
  23285. /**
  23286. * An event triggered after the texture clear
  23287. */
  23288. onClearObservable: Observable<Engine>;
  23289. private _onClearObserver;
  23290. /**
  23291. * Set a clear callback in the texture.
  23292. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23293. */
  23294. set onClear(callback: (Engine: Engine) => void);
  23295. /**
  23296. * An event triggered when the texture is resized.
  23297. */
  23298. onResizeObservable: Observable<RenderTargetTexture>;
  23299. /**
  23300. * Define the clear color of the Render Target if it should be different from the scene.
  23301. */
  23302. clearColor: Color4;
  23303. protected _size: number | {
  23304. width: number;
  23305. height: number;
  23306. layers?: number;
  23307. };
  23308. protected _initialSizeParameter: number | {
  23309. width: number;
  23310. height: number;
  23311. } | {
  23312. ratio: number;
  23313. };
  23314. protected _sizeRatio: Nullable<number>;
  23315. /** @hidden */
  23316. _generateMipMaps: boolean;
  23317. protected _renderingManager: RenderingManager;
  23318. /** @hidden */
  23319. _waitingRenderList: string[];
  23320. protected _doNotChangeAspectRatio: boolean;
  23321. protected _currentRefreshId: number;
  23322. protected _refreshRate: number;
  23323. protected _textureMatrix: Matrix;
  23324. protected _samples: number;
  23325. protected _renderTargetOptions: RenderTargetCreationOptions;
  23326. /**
  23327. * Gets render target creation options that were used.
  23328. */
  23329. get renderTargetOptions(): RenderTargetCreationOptions;
  23330. protected _onRatioRescale(): void;
  23331. /**
  23332. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23333. * It must define where the camera used to render the texture is set
  23334. */
  23335. boundingBoxPosition: Vector3;
  23336. private _boundingBoxSize;
  23337. /**
  23338. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23339. * When defined, the cubemap will switch to local mode
  23340. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23341. * @example https://www.babylonjs-playground.com/#RNASML
  23342. */
  23343. set boundingBoxSize(value: Vector3);
  23344. get boundingBoxSize(): Vector3;
  23345. /**
  23346. * In case the RTT has been created with a depth texture, get the associated
  23347. * depth texture.
  23348. * Otherwise, return null.
  23349. */
  23350. get depthStencilTexture(): Nullable<InternalTexture>;
  23351. /**
  23352. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23353. * or used a shadow, depth texture...
  23354. * @param name The friendly name of the texture
  23355. * @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)
  23356. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23357. * @param generateMipMaps True if mip maps need to be generated after render.
  23358. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23359. * @param type The type of the buffer in the RTT (int, half float, float...)
  23360. * @param isCube True if a cube texture needs to be created
  23361. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23362. * @param generateDepthBuffer True to generate a depth buffer
  23363. * @param generateStencilBuffer True to generate a stencil buffer
  23364. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23365. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23366. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23367. */
  23368. constructor(name: string, size: number | {
  23369. width: number;
  23370. height: number;
  23371. layers?: number;
  23372. } | {
  23373. ratio: number;
  23374. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23375. /**
  23376. * Creates a depth stencil texture.
  23377. * This is only available in WebGL 2 or with the depth texture extension available.
  23378. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23379. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23380. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23381. */
  23382. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23383. private _processSizeParameter;
  23384. /**
  23385. * Define the number of samples to use in case of MSAA.
  23386. * It defaults to one meaning no MSAA has been enabled.
  23387. */
  23388. get samples(): number;
  23389. set samples(value: number);
  23390. /**
  23391. * Resets the refresh counter of the texture and start bak from scratch.
  23392. * Could be useful to regenerate the texture if it is setup to render only once.
  23393. */
  23394. resetRefreshCounter(): void;
  23395. /**
  23396. * Define the refresh rate of the texture or the rendering frequency.
  23397. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23398. */
  23399. get refreshRate(): number;
  23400. set refreshRate(value: number);
  23401. /**
  23402. * Adds a post process to the render target rendering passes.
  23403. * @param postProcess define the post process to add
  23404. */
  23405. addPostProcess(postProcess: PostProcess): void;
  23406. /**
  23407. * Clear all the post processes attached to the render target
  23408. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23409. */
  23410. clearPostProcesses(dispose?: boolean): void;
  23411. /**
  23412. * Remove one of the post process from the list of attached post processes to the texture
  23413. * @param postProcess define the post process to remove from the list
  23414. */
  23415. removePostProcess(postProcess: PostProcess): void;
  23416. /** @hidden */
  23417. _shouldRender(): boolean;
  23418. /**
  23419. * Gets the actual render size of the texture.
  23420. * @returns the width of the render size
  23421. */
  23422. getRenderSize(): number;
  23423. /**
  23424. * Gets the actual render width of the texture.
  23425. * @returns the width of the render size
  23426. */
  23427. getRenderWidth(): number;
  23428. /**
  23429. * Gets the actual render height of the texture.
  23430. * @returns the height of the render size
  23431. */
  23432. getRenderHeight(): number;
  23433. /**
  23434. * Gets the actual number of layers of the texture.
  23435. * @returns the number of layers
  23436. */
  23437. getRenderLayers(): number;
  23438. /**
  23439. * Get if the texture can be rescaled or not.
  23440. */
  23441. get canRescale(): boolean;
  23442. /**
  23443. * Resize the texture using a ratio.
  23444. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23445. */
  23446. scale(ratio: number): void;
  23447. /**
  23448. * Get the texture reflection matrix used to rotate/transform the reflection.
  23449. * @returns the reflection matrix
  23450. */
  23451. getReflectionTextureMatrix(): Matrix;
  23452. /**
  23453. * Resize the texture to a new desired size.
  23454. * Be carrefull as it will recreate all the data in the new texture.
  23455. * @param size Define the new size. It can be:
  23456. * - a number for squared texture,
  23457. * - an object containing { width: number, height: number }
  23458. * - or an object containing a ratio { ratio: number }
  23459. */
  23460. resize(size: number | {
  23461. width: number;
  23462. height: number;
  23463. } | {
  23464. ratio: number;
  23465. }): void;
  23466. private _defaultRenderListPrepared;
  23467. /**
  23468. * Renders all the objects from the render list into the texture.
  23469. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23470. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23471. */
  23472. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23473. private _bestReflectionRenderTargetDimension;
  23474. private _prepareRenderingManager;
  23475. /**
  23476. * @hidden
  23477. * @param faceIndex face index to bind to if this is a cubetexture
  23478. * @param layer defines the index of the texture to bind in the array
  23479. */
  23480. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23481. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23482. private renderToTarget;
  23483. /**
  23484. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23485. * This allowed control for front to back rendering or reversly depending of the special needs.
  23486. *
  23487. * @param renderingGroupId The rendering group id corresponding to its index
  23488. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23489. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23490. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23491. */
  23492. 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;
  23493. /**
  23494. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23495. *
  23496. * @param renderingGroupId The rendering group id corresponding to its index
  23497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23498. */
  23499. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23500. /**
  23501. * Clones the texture.
  23502. * @returns the cloned texture
  23503. */
  23504. clone(): RenderTargetTexture;
  23505. /**
  23506. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23507. * @returns The JSON representation of the texture
  23508. */
  23509. serialize(): any;
  23510. /**
  23511. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23512. */
  23513. disposeFramebufferObjects(): void;
  23514. /**
  23515. * Dispose the texture and release its associated resources.
  23516. */
  23517. dispose(): void;
  23518. /** @hidden */
  23519. _rebuild(): void;
  23520. /**
  23521. * Clear the info related to rendering groups preventing retention point in material dispose.
  23522. */
  23523. freeRenderingGroups(): void;
  23524. /**
  23525. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23526. * @returns the view count
  23527. */
  23528. getViewCount(): number;
  23529. }
  23530. }
  23531. declare module BABYLON {
  23532. /**
  23533. * Class used to manipulate GUIDs
  23534. */
  23535. export class GUID {
  23536. /**
  23537. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23538. * Be aware Math.random() could cause collisions, but:
  23539. * "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"
  23540. * @returns a pseudo random id
  23541. */
  23542. static RandomId(): string;
  23543. }
  23544. }
  23545. declare module BABYLON {
  23546. /**
  23547. * Options to be used when creating a shadow depth material
  23548. */
  23549. export interface IIOptionShadowDepthMaterial {
  23550. /** Variables in the vertex shader code that need to have their names remapped.
  23551. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23552. * "var_name" should be either: worldPos or vNormalW
  23553. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23554. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23555. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23556. */
  23557. remappedVariables?: string[];
  23558. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23559. standalone?: boolean;
  23560. }
  23561. /**
  23562. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23563. */
  23564. export class ShadowDepthWrapper {
  23565. private _scene;
  23566. private _options?;
  23567. private _baseMaterial;
  23568. private _onEffectCreatedObserver;
  23569. private _subMeshToEffect;
  23570. private _subMeshToDepthEffect;
  23571. private _meshes;
  23572. /** @hidden */
  23573. _matriceNames: any;
  23574. /** Gets the standalone status of the wrapper */
  23575. get standalone(): boolean;
  23576. /** Gets the base material the wrapper is built upon */
  23577. get baseMaterial(): Material;
  23578. /**
  23579. * Instantiate a new shadow depth wrapper.
  23580. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23581. * generate the shadow depth map. For more information, please refer to the documentation:
  23582. * https://doc.babylonjs.com/babylon101/shadows
  23583. * @param baseMaterial Material to wrap
  23584. * @param scene Define the scene the material belongs to
  23585. * @param options Options used to create the wrapper
  23586. */
  23587. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23588. /**
  23589. * Gets the effect to use to generate the depth map
  23590. * @param subMesh subMesh to get the effect for
  23591. * @param shadowGenerator shadow generator to get the effect for
  23592. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23593. */
  23594. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23595. /**
  23596. * Specifies that the submesh is ready to be used for depth rendering
  23597. * @param subMesh submesh to check
  23598. * @param defines the list of defines to take into account when checking the effect
  23599. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23600. * @param useInstances specifies that instances should be used
  23601. * @returns a boolean indicating that the submesh is ready or not
  23602. */
  23603. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23604. /**
  23605. * Disposes the resources
  23606. */
  23607. dispose(): void;
  23608. private _makeEffect;
  23609. }
  23610. }
  23611. declare module BABYLON {
  23612. /**
  23613. * Options for compiling materials.
  23614. */
  23615. export interface IMaterialCompilationOptions {
  23616. /**
  23617. * Defines whether clip planes are enabled.
  23618. */
  23619. clipPlane: boolean;
  23620. /**
  23621. * Defines whether instances are enabled.
  23622. */
  23623. useInstances: boolean;
  23624. }
  23625. /**
  23626. * Base class for the main features of a material in Babylon.js
  23627. */
  23628. export class Material implements IAnimatable {
  23629. /**
  23630. * Returns the triangle fill mode
  23631. */
  23632. static readonly TriangleFillMode: number;
  23633. /**
  23634. * Returns the wireframe mode
  23635. */
  23636. static readonly WireFrameFillMode: number;
  23637. /**
  23638. * Returns the point fill mode
  23639. */
  23640. static readonly PointFillMode: number;
  23641. /**
  23642. * Returns the point list draw mode
  23643. */
  23644. static readonly PointListDrawMode: number;
  23645. /**
  23646. * Returns the line list draw mode
  23647. */
  23648. static readonly LineListDrawMode: number;
  23649. /**
  23650. * Returns the line loop draw mode
  23651. */
  23652. static readonly LineLoopDrawMode: number;
  23653. /**
  23654. * Returns the line strip draw mode
  23655. */
  23656. static readonly LineStripDrawMode: number;
  23657. /**
  23658. * Returns the triangle strip draw mode
  23659. */
  23660. static readonly TriangleStripDrawMode: number;
  23661. /**
  23662. * Returns the triangle fan draw mode
  23663. */
  23664. static readonly TriangleFanDrawMode: number;
  23665. /**
  23666. * Stores the clock-wise side orientation
  23667. */
  23668. static readonly ClockWiseSideOrientation: number;
  23669. /**
  23670. * Stores the counter clock-wise side orientation
  23671. */
  23672. static readonly CounterClockWiseSideOrientation: number;
  23673. /**
  23674. * The dirty texture flag value
  23675. */
  23676. static readonly TextureDirtyFlag: number;
  23677. /**
  23678. * The dirty light flag value
  23679. */
  23680. static readonly LightDirtyFlag: number;
  23681. /**
  23682. * The dirty fresnel flag value
  23683. */
  23684. static readonly FresnelDirtyFlag: number;
  23685. /**
  23686. * The dirty attribute flag value
  23687. */
  23688. static readonly AttributesDirtyFlag: number;
  23689. /**
  23690. * The dirty misc flag value
  23691. */
  23692. static readonly MiscDirtyFlag: number;
  23693. /**
  23694. * The all dirty flag value
  23695. */
  23696. static readonly AllDirtyFlag: number;
  23697. /**
  23698. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23699. */
  23700. static readonly MATERIAL_OPAQUE: number;
  23701. /**
  23702. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23703. */
  23704. static readonly MATERIAL_ALPHATEST: number;
  23705. /**
  23706. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23707. */
  23708. static readonly MATERIAL_ALPHABLEND: number;
  23709. /**
  23710. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23711. * They are also discarded below the alpha cutoff threshold to improve performances.
  23712. */
  23713. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23714. /**
  23715. * Custom callback helping to override the default shader used in the material.
  23716. */
  23717. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  23718. /**
  23719. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23720. */
  23721. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23722. /**
  23723. * The ID of the material
  23724. */
  23725. id: string;
  23726. /**
  23727. * Gets or sets the unique id of the material
  23728. */
  23729. uniqueId: number;
  23730. /**
  23731. * The name of the material
  23732. */
  23733. name: string;
  23734. /**
  23735. * Gets or sets user defined metadata
  23736. */
  23737. metadata: any;
  23738. /**
  23739. * For internal use only. Please do not use.
  23740. */
  23741. reservedDataStore: any;
  23742. /**
  23743. * Specifies if the ready state should be checked on each call
  23744. */
  23745. checkReadyOnEveryCall: boolean;
  23746. /**
  23747. * Specifies if the ready state should be checked once
  23748. */
  23749. checkReadyOnlyOnce: boolean;
  23750. /**
  23751. * The state of the material
  23752. */
  23753. state: string;
  23754. /**
  23755. * The alpha value of the material
  23756. */
  23757. protected _alpha: number;
  23758. /**
  23759. * List of inspectable custom properties (used by the Inspector)
  23760. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23761. */
  23762. inspectableCustomProperties: IInspectable[];
  23763. /**
  23764. * Sets the alpha value of the material
  23765. */
  23766. set alpha(value: number);
  23767. /**
  23768. * Gets the alpha value of the material
  23769. */
  23770. get alpha(): number;
  23771. /**
  23772. * Specifies if back face culling is enabled
  23773. */
  23774. protected _backFaceCulling: boolean;
  23775. /**
  23776. * Sets the back-face culling state
  23777. */
  23778. set backFaceCulling(value: boolean);
  23779. /**
  23780. * Gets the back-face culling state
  23781. */
  23782. get backFaceCulling(): boolean;
  23783. /**
  23784. * Stores the value for side orientation
  23785. */
  23786. sideOrientation: number;
  23787. /**
  23788. * Callback triggered when the material is compiled
  23789. */
  23790. onCompiled: Nullable<(effect: Effect) => void>;
  23791. /**
  23792. * Callback triggered when an error occurs
  23793. */
  23794. onError: Nullable<(effect: Effect, errors: string) => void>;
  23795. /**
  23796. * Callback triggered to get the render target textures
  23797. */
  23798. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23799. /**
  23800. * Gets a boolean indicating that current material needs to register RTT
  23801. */
  23802. get hasRenderTargetTextures(): boolean;
  23803. /**
  23804. * Specifies if the material should be serialized
  23805. */
  23806. doNotSerialize: boolean;
  23807. /**
  23808. * @hidden
  23809. */
  23810. _storeEffectOnSubMeshes: boolean;
  23811. /**
  23812. * Stores the animations for the material
  23813. */
  23814. animations: Nullable<Array<Animation>>;
  23815. /**
  23816. * An event triggered when the material is disposed
  23817. */
  23818. onDisposeObservable: Observable<Material>;
  23819. /**
  23820. * An observer which watches for dispose events
  23821. */
  23822. private _onDisposeObserver;
  23823. private _onUnBindObservable;
  23824. /**
  23825. * Called during a dispose event
  23826. */
  23827. set onDispose(callback: () => void);
  23828. private _onBindObservable;
  23829. /**
  23830. * An event triggered when the material is bound
  23831. */
  23832. get onBindObservable(): Observable<AbstractMesh>;
  23833. /**
  23834. * An observer which watches for bind events
  23835. */
  23836. private _onBindObserver;
  23837. /**
  23838. * Called during a bind event
  23839. */
  23840. set onBind(callback: (Mesh: AbstractMesh) => void);
  23841. /**
  23842. * An event triggered when the material is unbound
  23843. */
  23844. get onUnBindObservable(): Observable<Material>;
  23845. protected _onEffectCreatedObservable: Nullable<Observable<{
  23846. effect: Effect;
  23847. subMesh: Nullable<SubMesh>;
  23848. }>>;
  23849. /**
  23850. * An event triggered when the effect is (re)created
  23851. */
  23852. get onEffectCreatedObservable(): Observable<{
  23853. effect: Effect;
  23854. subMesh: Nullable<SubMesh>;
  23855. }>;
  23856. /**
  23857. * Stores the value of the alpha mode
  23858. */
  23859. private _alphaMode;
  23860. /**
  23861. * Sets the value of the alpha mode.
  23862. *
  23863. * | Value | Type | Description |
  23864. * | --- | --- | --- |
  23865. * | 0 | ALPHA_DISABLE | |
  23866. * | 1 | ALPHA_ADD | |
  23867. * | 2 | ALPHA_COMBINE | |
  23868. * | 3 | ALPHA_SUBTRACT | |
  23869. * | 4 | ALPHA_MULTIPLY | |
  23870. * | 5 | ALPHA_MAXIMIZED | |
  23871. * | 6 | ALPHA_ONEONE | |
  23872. * | 7 | ALPHA_PREMULTIPLIED | |
  23873. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23874. * | 9 | ALPHA_INTERPOLATE | |
  23875. * | 10 | ALPHA_SCREENMODE | |
  23876. *
  23877. */
  23878. set alphaMode(value: number);
  23879. /**
  23880. * Gets the value of the alpha mode
  23881. */
  23882. get alphaMode(): number;
  23883. /**
  23884. * Stores the state of the need depth pre-pass value
  23885. */
  23886. private _needDepthPrePass;
  23887. /**
  23888. * Sets the need depth pre-pass value
  23889. */
  23890. set needDepthPrePass(value: boolean);
  23891. /**
  23892. * Gets the depth pre-pass value
  23893. */
  23894. get needDepthPrePass(): boolean;
  23895. /**
  23896. * Specifies if depth writing should be disabled
  23897. */
  23898. disableDepthWrite: boolean;
  23899. /**
  23900. * Specifies if color writing should be disabled
  23901. */
  23902. disableColorWrite: boolean;
  23903. /**
  23904. * Specifies if depth writing should be forced
  23905. */
  23906. forceDepthWrite: boolean;
  23907. /**
  23908. * Specifies the depth function that should be used. 0 means the default engine function
  23909. */
  23910. depthFunction: number;
  23911. /**
  23912. * Specifies if there should be a separate pass for culling
  23913. */
  23914. separateCullingPass: boolean;
  23915. /**
  23916. * Stores the state specifing if fog should be enabled
  23917. */
  23918. private _fogEnabled;
  23919. /**
  23920. * Sets the state for enabling fog
  23921. */
  23922. set fogEnabled(value: boolean);
  23923. /**
  23924. * Gets the value of the fog enabled state
  23925. */
  23926. get fogEnabled(): boolean;
  23927. /**
  23928. * Stores the size of points
  23929. */
  23930. pointSize: number;
  23931. /**
  23932. * Stores the z offset value
  23933. */
  23934. zOffset: number;
  23935. get wireframe(): boolean;
  23936. /**
  23937. * Sets the state of wireframe mode
  23938. */
  23939. set wireframe(value: boolean);
  23940. /**
  23941. * Gets the value specifying if point clouds are enabled
  23942. */
  23943. get pointsCloud(): boolean;
  23944. /**
  23945. * Sets the state of point cloud mode
  23946. */
  23947. set pointsCloud(value: boolean);
  23948. /**
  23949. * Gets the material fill mode
  23950. */
  23951. get fillMode(): number;
  23952. /**
  23953. * Sets the material fill mode
  23954. */
  23955. set fillMode(value: number);
  23956. /**
  23957. * @hidden
  23958. * Stores the effects for the material
  23959. */
  23960. _effect: Nullable<Effect>;
  23961. /**
  23962. * Specifies if uniform buffers should be used
  23963. */
  23964. private _useUBO;
  23965. /**
  23966. * Stores a reference to the scene
  23967. */
  23968. private _scene;
  23969. /**
  23970. * Stores the fill mode state
  23971. */
  23972. private _fillMode;
  23973. /**
  23974. * Specifies if the depth write state should be cached
  23975. */
  23976. private _cachedDepthWriteState;
  23977. /**
  23978. * Specifies if the color write state should be cached
  23979. */
  23980. private _cachedColorWriteState;
  23981. /**
  23982. * Specifies if the depth function state should be cached
  23983. */
  23984. private _cachedDepthFunctionState;
  23985. /**
  23986. * Stores the uniform buffer
  23987. */
  23988. protected _uniformBuffer: UniformBuffer;
  23989. /** @hidden */
  23990. _indexInSceneMaterialArray: number;
  23991. /** @hidden */
  23992. meshMap: Nullable<{
  23993. [id: string]: AbstractMesh | undefined;
  23994. }>;
  23995. /**
  23996. * Creates a material instance
  23997. * @param name defines the name of the material
  23998. * @param scene defines the scene to reference
  23999. * @param doNotAdd specifies if the material should be added to the scene
  24000. */
  24001. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24002. /**
  24003. * Returns a string representation of the current material
  24004. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24005. * @returns a string with material information
  24006. */
  24007. toString(fullDetails?: boolean): string;
  24008. /**
  24009. * Gets the class name of the material
  24010. * @returns a string with the class name of the material
  24011. */
  24012. getClassName(): string;
  24013. /**
  24014. * Specifies if updates for the material been locked
  24015. */
  24016. get isFrozen(): boolean;
  24017. /**
  24018. * Locks updates for the material
  24019. */
  24020. freeze(): void;
  24021. /**
  24022. * Unlocks updates for the material
  24023. */
  24024. unfreeze(): void;
  24025. /**
  24026. * Specifies if the material is ready to be used
  24027. * @param mesh defines the mesh to check
  24028. * @param useInstances specifies if instances should be used
  24029. * @returns a boolean indicating if the material is ready to be used
  24030. */
  24031. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24032. /**
  24033. * Specifies that the submesh is ready to be used
  24034. * @param mesh defines the mesh to check
  24035. * @param subMesh defines which submesh to check
  24036. * @param useInstances specifies that instances should be used
  24037. * @returns a boolean indicating that the submesh is ready or not
  24038. */
  24039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24040. /**
  24041. * Returns the material effect
  24042. * @returns the effect associated with the material
  24043. */
  24044. getEffect(): Nullable<Effect>;
  24045. /**
  24046. * Returns the current scene
  24047. * @returns a Scene
  24048. */
  24049. getScene(): Scene;
  24050. /**
  24051. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24052. */
  24053. protected _forceAlphaTest: boolean;
  24054. /**
  24055. * The transparency mode of the material.
  24056. */
  24057. protected _transparencyMode: Nullable<number>;
  24058. /**
  24059. * Gets the current transparency mode.
  24060. */
  24061. get transparencyMode(): Nullable<number>;
  24062. /**
  24063. * Sets the transparency mode of the material.
  24064. *
  24065. * | Value | Type | Description |
  24066. * | ----- | ----------------------------------- | ----------- |
  24067. * | 0 | OPAQUE | |
  24068. * | 1 | ALPHATEST | |
  24069. * | 2 | ALPHABLEND | |
  24070. * | 3 | ALPHATESTANDBLEND | |
  24071. *
  24072. */
  24073. set transparencyMode(value: Nullable<number>);
  24074. /**
  24075. * Returns true if alpha blending should be disabled.
  24076. */
  24077. protected get _disableAlphaBlending(): boolean;
  24078. /**
  24079. * Specifies whether or not this material should be rendered in alpha blend mode.
  24080. * @returns a boolean specifying if alpha blending is needed
  24081. */
  24082. needAlphaBlending(): boolean;
  24083. /**
  24084. * Specifies if the mesh will require alpha blending
  24085. * @param mesh defines the mesh to check
  24086. * @returns a boolean specifying if alpha blending is needed for the mesh
  24087. */
  24088. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24089. /**
  24090. * Specifies whether or not this material should be rendered in alpha test mode.
  24091. * @returns a boolean specifying if an alpha test is needed.
  24092. */
  24093. needAlphaTesting(): boolean;
  24094. /**
  24095. * Specifies if material alpha testing should be turned on for the mesh
  24096. * @param mesh defines the mesh to check
  24097. */
  24098. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24099. /**
  24100. * Gets the texture used for the alpha test
  24101. * @returns the texture to use for alpha testing
  24102. */
  24103. getAlphaTestTexture(): Nullable<BaseTexture>;
  24104. /**
  24105. * Marks the material to indicate that it needs to be re-calculated
  24106. */
  24107. markDirty(): void;
  24108. /** @hidden */
  24109. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24110. /**
  24111. * Binds the material to the mesh
  24112. * @param world defines the world transformation matrix
  24113. * @param mesh defines the mesh to bind the material to
  24114. */
  24115. bind(world: Matrix, mesh?: Mesh): void;
  24116. /**
  24117. * Binds the submesh to the material
  24118. * @param world defines the world transformation matrix
  24119. * @param mesh defines the mesh containing the submesh
  24120. * @param subMesh defines the submesh to bind the material to
  24121. */
  24122. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24123. /**
  24124. * Binds the world matrix to the material
  24125. * @param world defines the world transformation matrix
  24126. */
  24127. bindOnlyWorldMatrix(world: Matrix): void;
  24128. /**
  24129. * Binds the scene's uniform buffer to the effect.
  24130. * @param effect defines the effect to bind to the scene uniform buffer
  24131. * @param sceneUbo defines the uniform buffer storing scene data
  24132. */
  24133. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24134. /**
  24135. * Binds the view matrix to the effect
  24136. * @param effect defines the effect to bind the view matrix to
  24137. */
  24138. bindView(effect: Effect): void;
  24139. /**
  24140. * Binds the view projection matrix to the effect
  24141. * @param effect defines the effect to bind the view projection matrix to
  24142. */
  24143. bindViewProjection(effect: Effect): void;
  24144. /**
  24145. * Processes to execute after binding the material to a mesh
  24146. * @param mesh defines the rendered mesh
  24147. */
  24148. protected _afterBind(mesh?: Mesh): void;
  24149. /**
  24150. * Unbinds the material from the mesh
  24151. */
  24152. unbind(): void;
  24153. /**
  24154. * Gets the active textures from the material
  24155. * @returns an array of textures
  24156. */
  24157. getActiveTextures(): BaseTexture[];
  24158. /**
  24159. * Specifies if the material uses a texture
  24160. * @param texture defines the texture to check against the material
  24161. * @returns a boolean specifying if the material uses the texture
  24162. */
  24163. hasTexture(texture: BaseTexture): boolean;
  24164. /**
  24165. * Makes a duplicate of the material, and gives it a new name
  24166. * @param name defines the new name for the duplicated material
  24167. * @returns the cloned material
  24168. */
  24169. clone(name: string): Nullable<Material>;
  24170. /**
  24171. * Gets the meshes bound to the material
  24172. * @returns an array of meshes bound to the material
  24173. */
  24174. getBindedMeshes(): AbstractMesh[];
  24175. /**
  24176. * Force shader compilation
  24177. * @param mesh defines the mesh associated with this material
  24178. * @param onCompiled defines a function to execute once the material is compiled
  24179. * @param options defines the options to configure the compilation
  24180. * @param onError defines a function to execute if the material fails compiling
  24181. */
  24182. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24183. /**
  24184. * Force shader compilation
  24185. * @param mesh defines the mesh that will use this material
  24186. * @param options defines additional options for compiling the shaders
  24187. * @returns a promise that resolves when the compilation completes
  24188. */
  24189. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24190. private static readonly _AllDirtyCallBack;
  24191. private static readonly _ImageProcessingDirtyCallBack;
  24192. private static readonly _TextureDirtyCallBack;
  24193. private static readonly _FresnelDirtyCallBack;
  24194. private static readonly _MiscDirtyCallBack;
  24195. private static readonly _LightsDirtyCallBack;
  24196. private static readonly _AttributeDirtyCallBack;
  24197. private static _FresnelAndMiscDirtyCallBack;
  24198. private static _TextureAndMiscDirtyCallBack;
  24199. private static readonly _DirtyCallbackArray;
  24200. private static readonly _RunDirtyCallBacks;
  24201. /**
  24202. * Marks a define in the material to indicate that it needs to be re-computed
  24203. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24204. */
  24205. markAsDirty(flag: number): void;
  24206. /**
  24207. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24208. * @param func defines a function which checks material defines against the submeshes
  24209. */
  24210. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24211. /**
  24212. * Indicates that we need to re-calculated for all submeshes
  24213. */
  24214. protected _markAllSubMeshesAsAllDirty(): void;
  24215. /**
  24216. * Indicates that image processing needs to be re-calculated for all submeshes
  24217. */
  24218. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24219. /**
  24220. * Indicates that textures need to be re-calculated for all submeshes
  24221. */
  24222. protected _markAllSubMeshesAsTexturesDirty(): void;
  24223. /**
  24224. * Indicates that fresnel needs to be re-calculated for all submeshes
  24225. */
  24226. protected _markAllSubMeshesAsFresnelDirty(): void;
  24227. /**
  24228. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24229. */
  24230. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24231. /**
  24232. * Indicates that lights need to be re-calculated for all submeshes
  24233. */
  24234. protected _markAllSubMeshesAsLightsDirty(): void;
  24235. /**
  24236. * Indicates that attributes need to be re-calculated for all submeshes
  24237. */
  24238. protected _markAllSubMeshesAsAttributesDirty(): void;
  24239. /**
  24240. * Indicates that misc needs to be re-calculated for all submeshes
  24241. */
  24242. protected _markAllSubMeshesAsMiscDirty(): void;
  24243. /**
  24244. * Indicates that textures and misc need to be re-calculated for all submeshes
  24245. */
  24246. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24247. /**
  24248. * Disposes the material
  24249. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24250. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24251. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24252. */
  24253. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24254. /** @hidden */
  24255. private releaseVertexArrayObject;
  24256. /**
  24257. * Serializes this material
  24258. * @returns the serialized material object
  24259. */
  24260. serialize(): any;
  24261. /**
  24262. * Creates a material from parsed material data
  24263. * @param parsedMaterial defines parsed material data
  24264. * @param scene defines the hosting scene
  24265. * @param rootUrl defines the root URL to use to load textures
  24266. * @returns a new material
  24267. */
  24268. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24269. }
  24270. }
  24271. declare module BABYLON {
  24272. /**
  24273. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24274. * separate meshes. This can be use to improve performances.
  24275. * @see http://doc.babylonjs.com/how_to/multi_materials
  24276. */
  24277. export class MultiMaterial extends Material {
  24278. private _subMaterials;
  24279. /**
  24280. * Gets or Sets the list of Materials used within the multi material.
  24281. * They need to be ordered according to the submeshes order in the associated mesh
  24282. */
  24283. get subMaterials(): Nullable<Material>[];
  24284. set subMaterials(value: Nullable<Material>[]);
  24285. /**
  24286. * Function used to align with Node.getChildren()
  24287. * @returns the list of Materials used within the multi material
  24288. */
  24289. getChildren(): Nullable<Material>[];
  24290. /**
  24291. * Instantiates a new Multi Material
  24292. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24293. * separate meshes. This can be use to improve performances.
  24294. * @see http://doc.babylonjs.com/how_to/multi_materials
  24295. * @param name Define the name in the scene
  24296. * @param scene Define the scene the material belongs to
  24297. */
  24298. constructor(name: string, scene: Scene);
  24299. private _hookArray;
  24300. /**
  24301. * Get one of the submaterial by its index in the submaterials array
  24302. * @param index The index to look the sub material at
  24303. * @returns The Material if the index has been defined
  24304. */
  24305. getSubMaterial(index: number): Nullable<Material>;
  24306. /**
  24307. * Get the list of active textures for the whole sub materials list.
  24308. * @returns All the textures that will be used during the rendering
  24309. */
  24310. getActiveTextures(): BaseTexture[];
  24311. /**
  24312. * Gets the current class name of the material e.g. "MultiMaterial"
  24313. * Mainly use in serialization.
  24314. * @returns the class name
  24315. */
  24316. getClassName(): string;
  24317. /**
  24318. * Checks if the material is ready to render the requested sub mesh
  24319. * @param mesh Define the mesh the submesh belongs to
  24320. * @param subMesh Define the sub mesh to look readyness for
  24321. * @param useInstances Define whether or not the material is used with instances
  24322. * @returns true if ready, otherwise false
  24323. */
  24324. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  24325. /**
  24326. * Clones the current material and its related sub materials
  24327. * @param name Define the name of the newly cloned material
  24328. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24329. * @returns the cloned material
  24330. */
  24331. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24332. /**
  24333. * Serializes the materials into a JSON representation.
  24334. * @returns the JSON representation
  24335. */
  24336. serialize(): any;
  24337. /**
  24338. * Dispose the material and release its associated resources
  24339. * @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)
  24340. * @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)
  24341. * @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)
  24342. */
  24343. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24344. /**
  24345. * Creates a MultiMaterial from parsed MultiMaterial data.
  24346. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24347. * @param scene defines the hosting scene
  24348. * @returns a new MultiMaterial
  24349. */
  24350. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24351. }
  24352. }
  24353. declare module BABYLON {
  24354. /**
  24355. * Base class for submeshes
  24356. */
  24357. export class BaseSubMesh {
  24358. /** @hidden */
  24359. _materialDefines: Nullable<MaterialDefines>;
  24360. /** @hidden */
  24361. _materialEffect: Nullable<Effect>;
  24362. /** @hidden */
  24363. _effectOverride: Nullable<Effect>;
  24364. /**
  24365. * Gets material defines used by the effect associated to the sub mesh
  24366. */
  24367. get materialDefines(): Nullable<MaterialDefines>;
  24368. /**
  24369. * Sets material defines used by the effect associated to the sub mesh
  24370. */
  24371. set materialDefines(defines: Nullable<MaterialDefines>);
  24372. /**
  24373. * Gets associated effect
  24374. */
  24375. get effect(): Nullable<Effect>;
  24376. /**
  24377. * Sets associated effect (effect used to render this submesh)
  24378. * @param effect defines the effect to associate with
  24379. * @param defines defines the set of defines used to compile this effect
  24380. */
  24381. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24382. }
  24383. /**
  24384. * Defines a subdivision inside a mesh
  24385. */
  24386. export class SubMesh extends BaseSubMesh implements ICullable {
  24387. /** the material index to use */
  24388. materialIndex: number;
  24389. /** vertex index start */
  24390. verticesStart: number;
  24391. /** vertices count */
  24392. verticesCount: number;
  24393. /** index start */
  24394. indexStart: number;
  24395. /** indices count */
  24396. indexCount: number;
  24397. /** @hidden */
  24398. _linesIndexCount: number;
  24399. private _mesh;
  24400. private _renderingMesh;
  24401. private _boundingInfo;
  24402. private _linesIndexBuffer;
  24403. /** @hidden */
  24404. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24405. /** @hidden */
  24406. _trianglePlanes: Plane[];
  24407. /** @hidden */
  24408. _lastColliderTransformMatrix: Nullable<Matrix>;
  24409. /** @hidden */
  24410. _renderId: number;
  24411. /** @hidden */
  24412. _alphaIndex: number;
  24413. /** @hidden */
  24414. _distanceToCamera: number;
  24415. /** @hidden */
  24416. _id: number;
  24417. private _currentMaterial;
  24418. /**
  24419. * Add a new submesh to a mesh
  24420. * @param materialIndex defines the material index to use
  24421. * @param verticesStart defines vertex index start
  24422. * @param verticesCount defines vertices count
  24423. * @param indexStart defines index start
  24424. * @param indexCount defines indices count
  24425. * @param mesh defines the parent mesh
  24426. * @param renderingMesh defines an optional rendering mesh
  24427. * @param createBoundingBox defines if bounding box should be created for this submesh
  24428. * @returns the new submesh
  24429. */
  24430. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24431. /**
  24432. * Creates a new submesh
  24433. * @param materialIndex defines the material index to use
  24434. * @param verticesStart defines vertex index start
  24435. * @param verticesCount defines vertices count
  24436. * @param indexStart defines index start
  24437. * @param indexCount defines indices count
  24438. * @param mesh defines the parent mesh
  24439. * @param renderingMesh defines an optional rendering mesh
  24440. * @param createBoundingBox defines if bounding box should be created for this submesh
  24441. */
  24442. constructor(
  24443. /** the material index to use */
  24444. materialIndex: number,
  24445. /** vertex index start */
  24446. verticesStart: number,
  24447. /** vertices count */
  24448. verticesCount: number,
  24449. /** index start */
  24450. indexStart: number,
  24451. /** indices count */
  24452. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24453. /**
  24454. * Returns true if this submesh covers the entire parent mesh
  24455. * @ignorenaming
  24456. */
  24457. get IsGlobal(): boolean;
  24458. /**
  24459. * Returns the submesh BoudingInfo object
  24460. * @returns current bounding info (or mesh's one if the submesh is global)
  24461. */
  24462. getBoundingInfo(): BoundingInfo;
  24463. /**
  24464. * Sets the submesh BoundingInfo
  24465. * @param boundingInfo defines the new bounding info to use
  24466. * @returns the SubMesh
  24467. */
  24468. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24469. /**
  24470. * Returns the mesh of the current submesh
  24471. * @return the parent mesh
  24472. */
  24473. getMesh(): AbstractMesh;
  24474. /**
  24475. * Returns the rendering mesh of the submesh
  24476. * @returns the rendering mesh (could be different from parent mesh)
  24477. */
  24478. getRenderingMesh(): Mesh;
  24479. /**
  24480. * Returns the submesh material
  24481. * @returns null or the current material
  24482. */
  24483. getMaterial(): Nullable<Material>;
  24484. /**
  24485. * Sets a new updated BoundingInfo object to the submesh
  24486. * @param data defines an optional position array to use to determine the bounding info
  24487. * @returns the SubMesh
  24488. */
  24489. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24490. /** @hidden */
  24491. _checkCollision(collider: Collider): boolean;
  24492. /**
  24493. * Updates the submesh BoundingInfo
  24494. * @param world defines the world matrix to use to update the bounding info
  24495. * @returns the submesh
  24496. */
  24497. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24498. /**
  24499. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24500. * @param frustumPlanes defines the frustum planes
  24501. * @returns true if the submesh is intersecting with the frustum
  24502. */
  24503. isInFrustum(frustumPlanes: Plane[]): boolean;
  24504. /**
  24505. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24506. * @param frustumPlanes defines the frustum planes
  24507. * @returns true if the submesh is inside the frustum
  24508. */
  24509. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24510. /**
  24511. * Renders the submesh
  24512. * @param enableAlphaMode defines if alpha needs to be used
  24513. * @returns the submesh
  24514. */
  24515. render(enableAlphaMode: boolean): SubMesh;
  24516. /**
  24517. * @hidden
  24518. */
  24519. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24520. /**
  24521. * Checks if the submesh intersects with a ray
  24522. * @param ray defines the ray to test
  24523. * @returns true is the passed ray intersects the submesh bounding box
  24524. */
  24525. canIntersects(ray: Ray): boolean;
  24526. /**
  24527. * Intersects current submesh with a ray
  24528. * @param ray defines the ray to test
  24529. * @param positions defines mesh's positions array
  24530. * @param indices defines mesh's indices array
  24531. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24532. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24533. * @returns intersection info or null if no intersection
  24534. */
  24535. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24536. /** @hidden */
  24537. private _intersectLines;
  24538. /** @hidden */
  24539. private _intersectUnIndexedLines;
  24540. /** @hidden */
  24541. private _intersectTriangles;
  24542. /** @hidden */
  24543. private _intersectUnIndexedTriangles;
  24544. /** @hidden */
  24545. _rebuild(): void;
  24546. /**
  24547. * Creates a new submesh from the passed mesh
  24548. * @param newMesh defines the new hosting mesh
  24549. * @param newRenderingMesh defines an optional rendering mesh
  24550. * @returns the new submesh
  24551. */
  24552. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24553. /**
  24554. * Release associated resources
  24555. */
  24556. dispose(): void;
  24557. /**
  24558. * Gets the class name
  24559. * @returns the string "SubMesh".
  24560. */
  24561. getClassName(): string;
  24562. /**
  24563. * Creates a new submesh from indices data
  24564. * @param materialIndex the index of the main mesh material
  24565. * @param startIndex the index where to start the copy in the mesh indices array
  24566. * @param indexCount the number of indices to copy then from the startIndex
  24567. * @param mesh the main mesh to create the submesh from
  24568. * @param renderingMesh the optional rendering mesh
  24569. * @returns a new submesh
  24570. */
  24571. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24572. }
  24573. }
  24574. declare module BABYLON {
  24575. /**
  24576. * Class used to represent data loading progression
  24577. */
  24578. export class SceneLoaderFlags {
  24579. private static _ForceFullSceneLoadingForIncremental;
  24580. private static _ShowLoadingScreen;
  24581. private static _CleanBoneMatrixWeights;
  24582. private static _loggingLevel;
  24583. /**
  24584. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24585. */
  24586. static get ForceFullSceneLoadingForIncremental(): boolean;
  24587. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24588. /**
  24589. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24590. */
  24591. static get ShowLoadingScreen(): boolean;
  24592. static set ShowLoadingScreen(value: boolean);
  24593. /**
  24594. * Defines the current logging level (while loading the scene)
  24595. * @ignorenaming
  24596. */
  24597. static get loggingLevel(): number;
  24598. static set loggingLevel(value: number);
  24599. /**
  24600. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24601. */
  24602. static get CleanBoneMatrixWeights(): boolean;
  24603. static set CleanBoneMatrixWeights(value: boolean);
  24604. }
  24605. }
  24606. declare module BABYLON {
  24607. /**
  24608. * Class used to store geometry data (vertex buffers + index buffer)
  24609. */
  24610. export class Geometry implements IGetSetVerticesData {
  24611. /**
  24612. * Gets or sets the ID of the geometry
  24613. */
  24614. id: string;
  24615. /**
  24616. * Gets or sets the unique ID of the geometry
  24617. */
  24618. uniqueId: number;
  24619. /**
  24620. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24621. */
  24622. delayLoadState: number;
  24623. /**
  24624. * Gets the file containing the data to load when running in delay load state
  24625. */
  24626. delayLoadingFile: Nullable<string>;
  24627. /**
  24628. * Callback called when the geometry is updated
  24629. */
  24630. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24631. private _scene;
  24632. private _engine;
  24633. private _meshes;
  24634. private _totalVertices;
  24635. /** @hidden */
  24636. _indices: IndicesArray;
  24637. /** @hidden */
  24638. _vertexBuffers: {
  24639. [key: string]: VertexBuffer;
  24640. };
  24641. private _isDisposed;
  24642. private _extend;
  24643. private _boundingBias;
  24644. /** @hidden */
  24645. _delayInfo: Array<string>;
  24646. private _indexBuffer;
  24647. private _indexBufferIsUpdatable;
  24648. /** @hidden */
  24649. _boundingInfo: Nullable<BoundingInfo>;
  24650. /** @hidden */
  24651. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24652. /** @hidden */
  24653. _softwareSkinningFrameId: number;
  24654. private _vertexArrayObjects;
  24655. private _updatable;
  24656. /** @hidden */
  24657. _positions: Nullable<Vector3[]>;
  24658. /**
  24659. * 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
  24660. */
  24661. get boundingBias(): Vector2;
  24662. /**
  24663. * 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
  24664. */
  24665. set boundingBias(value: Vector2);
  24666. /**
  24667. * Static function used to attach a new empty geometry to a mesh
  24668. * @param mesh defines the mesh to attach the geometry to
  24669. * @returns the new Geometry
  24670. */
  24671. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24672. /** Get the list of meshes using this geometry */
  24673. get meshes(): Mesh[];
  24674. /**
  24675. * Creates a new geometry
  24676. * @param id defines the unique ID
  24677. * @param scene defines the hosting scene
  24678. * @param vertexData defines the VertexData used to get geometry data
  24679. * @param updatable defines if geometry must be updatable (false by default)
  24680. * @param mesh defines the mesh that will be associated with the geometry
  24681. */
  24682. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24683. /**
  24684. * Gets the current extend of the geometry
  24685. */
  24686. get extend(): {
  24687. minimum: Vector3;
  24688. maximum: Vector3;
  24689. };
  24690. /**
  24691. * Gets the hosting scene
  24692. * @returns the hosting Scene
  24693. */
  24694. getScene(): Scene;
  24695. /**
  24696. * Gets the hosting engine
  24697. * @returns the hosting Engine
  24698. */
  24699. getEngine(): Engine;
  24700. /**
  24701. * Defines if the geometry is ready to use
  24702. * @returns true if the geometry is ready to be used
  24703. */
  24704. isReady(): boolean;
  24705. /**
  24706. * Gets a value indicating that the geometry should not be serialized
  24707. */
  24708. get doNotSerialize(): boolean;
  24709. /** @hidden */
  24710. _rebuild(): void;
  24711. /**
  24712. * Affects all geometry data in one call
  24713. * @param vertexData defines the geometry data
  24714. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24715. */
  24716. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24717. /**
  24718. * Set specific vertex data
  24719. * @param kind defines the data kind (Position, normal, etc...)
  24720. * @param data defines the vertex data to use
  24721. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24722. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24723. */
  24724. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24725. /**
  24726. * Removes a specific vertex data
  24727. * @param kind defines the data kind (Position, normal, etc...)
  24728. */
  24729. removeVerticesData(kind: string): void;
  24730. /**
  24731. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24732. * @param buffer defines the vertex buffer to use
  24733. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24734. */
  24735. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24736. /**
  24737. * Update a specific vertex buffer
  24738. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24739. * It will do nothing if the buffer is not updatable
  24740. * @param kind defines the data kind (Position, normal, etc...)
  24741. * @param data defines the data to use
  24742. * @param offset defines the offset in the target buffer where to store the data
  24743. * @param useBytes set to true if the offset is in bytes
  24744. */
  24745. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24746. /**
  24747. * Update a specific vertex buffer
  24748. * This function will create a new buffer if the current one is not updatable
  24749. * @param kind defines the data kind (Position, normal, etc...)
  24750. * @param data defines the data to use
  24751. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24752. */
  24753. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24754. private _updateBoundingInfo;
  24755. /** @hidden */
  24756. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24757. /**
  24758. * Gets total number of vertices
  24759. * @returns the total number of vertices
  24760. */
  24761. getTotalVertices(): number;
  24762. /**
  24763. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24764. * @param kind defines the data kind (Position, normal, etc...)
  24765. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24766. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24767. * @returns a float array containing vertex data
  24768. */
  24769. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24770. /**
  24771. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24772. * @param kind defines the data kind (Position, normal, etc...)
  24773. * @returns true if the vertex buffer with the specified kind is updatable
  24774. */
  24775. isVertexBufferUpdatable(kind: string): boolean;
  24776. /**
  24777. * Gets a specific vertex buffer
  24778. * @param kind defines the data kind (Position, normal, etc...)
  24779. * @returns a VertexBuffer
  24780. */
  24781. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24782. /**
  24783. * Returns all vertex buffers
  24784. * @return an object holding all vertex buffers indexed by kind
  24785. */
  24786. getVertexBuffers(): Nullable<{
  24787. [key: string]: VertexBuffer;
  24788. }>;
  24789. /**
  24790. * Gets a boolean indicating if specific vertex buffer is present
  24791. * @param kind defines the data kind (Position, normal, etc...)
  24792. * @returns true if data is present
  24793. */
  24794. isVerticesDataPresent(kind: string): boolean;
  24795. /**
  24796. * Gets a list of all attached data kinds (Position, normal, etc...)
  24797. * @returns a list of string containing all kinds
  24798. */
  24799. getVerticesDataKinds(): string[];
  24800. /**
  24801. * Update index buffer
  24802. * @param indices defines the indices to store in the index buffer
  24803. * @param offset defines the offset in the target buffer where to store the data
  24804. * @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)
  24805. */
  24806. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24807. /**
  24808. * Creates a new index buffer
  24809. * @param indices defines the indices to store in the index buffer
  24810. * @param totalVertices defines the total number of vertices (could be null)
  24811. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24812. */
  24813. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24814. /**
  24815. * Return the total number of indices
  24816. * @returns the total number of indices
  24817. */
  24818. getTotalIndices(): number;
  24819. /**
  24820. * Gets the index buffer array
  24821. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24822. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24823. * @returns the index buffer array
  24824. */
  24825. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24826. /**
  24827. * Gets the index buffer
  24828. * @return the index buffer
  24829. */
  24830. getIndexBuffer(): Nullable<DataBuffer>;
  24831. /** @hidden */
  24832. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24833. /**
  24834. * Release the associated resources for a specific mesh
  24835. * @param mesh defines the source mesh
  24836. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24837. */
  24838. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24839. /**
  24840. * Apply current geometry to a given mesh
  24841. * @param mesh defines the mesh to apply geometry to
  24842. */
  24843. applyToMesh(mesh: Mesh): void;
  24844. private _updateExtend;
  24845. private _applyToMesh;
  24846. private notifyUpdate;
  24847. /**
  24848. * Load the geometry if it was flagged as delay loaded
  24849. * @param scene defines the hosting scene
  24850. * @param onLoaded defines a callback called when the geometry is loaded
  24851. */
  24852. load(scene: Scene, onLoaded?: () => void): void;
  24853. private _queueLoad;
  24854. /**
  24855. * Invert the geometry to move from a right handed system to a left handed one.
  24856. */
  24857. toLeftHanded(): void;
  24858. /** @hidden */
  24859. _resetPointsArrayCache(): void;
  24860. /** @hidden */
  24861. _generatePointsArray(): boolean;
  24862. /**
  24863. * Gets a value indicating if the geometry is disposed
  24864. * @returns true if the geometry was disposed
  24865. */
  24866. isDisposed(): boolean;
  24867. private _disposeVertexArrayObjects;
  24868. /**
  24869. * Free all associated resources
  24870. */
  24871. dispose(): void;
  24872. /**
  24873. * Clone the current geometry into a new geometry
  24874. * @param id defines the unique ID of the new geometry
  24875. * @returns a new geometry object
  24876. */
  24877. copy(id: string): Geometry;
  24878. /**
  24879. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24880. * @return a JSON representation of the current geometry data (without the vertices data)
  24881. */
  24882. serialize(): any;
  24883. private toNumberArray;
  24884. /**
  24885. * Serialize all vertices data into a JSON oject
  24886. * @returns a JSON representation of the current geometry data
  24887. */
  24888. serializeVerticeData(): any;
  24889. /**
  24890. * Extracts a clone of a mesh geometry
  24891. * @param mesh defines the source mesh
  24892. * @param id defines the unique ID of the new geometry object
  24893. * @returns the new geometry object
  24894. */
  24895. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24896. /**
  24897. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24898. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24899. * Be aware Math.random() could cause collisions, but:
  24900. * "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"
  24901. * @returns a string containing a new GUID
  24902. */
  24903. static RandomId(): string;
  24904. /** @hidden */
  24905. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24906. private static _CleanMatricesWeights;
  24907. /**
  24908. * Create a new geometry from persisted data (Using .babylon file format)
  24909. * @param parsedVertexData defines the persisted data
  24910. * @param scene defines the hosting scene
  24911. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24912. * @returns the new geometry object
  24913. */
  24914. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24915. }
  24916. }
  24917. declare module BABYLON {
  24918. /**
  24919. * Define an interface for all classes that will get and set the data on vertices
  24920. */
  24921. export interface IGetSetVerticesData {
  24922. /**
  24923. * Gets a boolean indicating if specific vertex data is present
  24924. * @param kind defines the vertex data kind to use
  24925. * @returns true is data kind is present
  24926. */
  24927. isVerticesDataPresent(kind: string): boolean;
  24928. /**
  24929. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24930. * @param kind defines the data kind (Position, normal, etc...)
  24931. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24932. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24933. * @returns a float array containing vertex data
  24934. */
  24935. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24936. /**
  24937. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24938. * @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.
  24939. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24940. * @returns the indices array or an empty array if the mesh has no geometry
  24941. */
  24942. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24943. /**
  24944. * Set specific vertex data
  24945. * @param kind defines the data kind (Position, normal, etc...)
  24946. * @param data defines the vertex data to use
  24947. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24948. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24949. */
  24950. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24951. /**
  24952. * Update a specific associated vertex buffer
  24953. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24954. * - VertexBuffer.PositionKind
  24955. * - VertexBuffer.UVKind
  24956. * - VertexBuffer.UV2Kind
  24957. * - VertexBuffer.UV3Kind
  24958. * - VertexBuffer.UV4Kind
  24959. * - VertexBuffer.UV5Kind
  24960. * - VertexBuffer.UV6Kind
  24961. * - VertexBuffer.ColorKind
  24962. * - VertexBuffer.MatricesIndicesKind
  24963. * - VertexBuffer.MatricesIndicesExtraKind
  24964. * - VertexBuffer.MatricesWeightsKind
  24965. * - VertexBuffer.MatricesWeightsExtraKind
  24966. * @param data defines the data source
  24967. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24968. * @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)
  24969. */
  24970. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24971. /**
  24972. * Creates a new index buffer
  24973. * @param indices defines the indices to store in the index buffer
  24974. * @param totalVertices defines the total number of vertices (could be null)
  24975. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24976. */
  24977. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  24978. }
  24979. /**
  24980. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  24981. */
  24982. export class VertexData {
  24983. /**
  24984. * Mesh side orientation : usually the external or front surface
  24985. */
  24986. static readonly FRONTSIDE: number;
  24987. /**
  24988. * Mesh side orientation : usually the internal or back surface
  24989. */
  24990. static readonly BACKSIDE: number;
  24991. /**
  24992. * Mesh side orientation : both internal and external or front and back surfaces
  24993. */
  24994. static readonly DOUBLESIDE: number;
  24995. /**
  24996. * Mesh side orientation : by default, `FRONTSIDE`
  24997. */
  24998. static readonly DEFAULTSIDE: number;
  24999. /**
  25000. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25001. */
  25002. positions: Nullable<FloatArray>;
  25003. /**
  25004. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25005. */
  25006. normals: Nullable<FloatArray>;
  25007. /**
  25008. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25009. */
  25010. tangents: Nullable<FloatArray>;
  25011. /**
  25012. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25013. */
  25014. uvs: Nullable<FloatArray>;
  25015. /**
  25016. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25017. */
  25018. uvs2: Nullable<FloatArray>;
  25019. /**
  25020. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25021. */
  25022. uvs3: Nullable<FloatArray>;
  25023. /**
  25024. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25025. */
  25026. uvs4: Nullable<FloatArray>;
  25027. /**
  25028. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25029. */
  25030. uvs5: Nullable<FloatArray>;
  25031. /**
  25032. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25033. */
  25034. uvs6: Nullable<FloatArray>;
  25035. /**
  25036. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25037. */
  25038. colors: Nullable<FloatArray>;
  25039. /**
  25040. * 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).
  25041. */
  25042. matricesIndices: Nullable<FloatArray>;
  25043. /**
  25044. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25045. */
  25046. matricesWeights: Nullable<FloatArray>;
  25047. /**
  25048. * An array extending the number of possible indices
  25049. */
  25050. matricesIndicesExtra: Nullable<FloatArray>;
  25051. /**
  25052. * An array extending the number of possible weights when the number of indices is extended
  25053. */
  25054. matricesWeightsExtra: Nullable<FloatArray>;
  25055. /**
  25056. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25057. */
  25058. indices: Nullable<IndicesArray>;
  25059. /**
  25060. * Uses the passed data array to set the set the values for the specified kind of data
  25061. * @param data a linear array of floating numbers
  25062. * @param kind the type of data that is being set, eg positions, colors etc
  25063. */
  25064. set(data: FloatArray, kind: string): void;
  25065. /**
  25066. * Associates the vertexData to the passed Mesh.
  25067. * Sets it as updatable or not (default `false`)
  25068. * @param mesh the mesh the vertexData is applied to
  25069. * @param updatable when used and having the value true allows new data to update the vertexData
  25070. * @returns the VertexData
  25071. */
  25072. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25073. /**
  25074. * Associates the vertexData to the passed Geometry.
  25075. * Sets it as updatable or not (default `false`)
  25076. * @param geometry the geometry the vertexData is applied to
  25077. * @param updatable when used and having the value true allows new data to update the vertexData
  25078. * @returns VertexData
  25079. */
  25080. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25081. /**
  25082. * Updates the associated mesh
  25083. * @param mesh the mesh to be updated
  25084. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25085. * @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
  25086. * @returns VertexData
  25087. */
  25088. updateMesh(mesh: Mesh): VertexData;
  25089. /**
  25090. * Updates the associated geometry
  25091. * @param geometry the geometry to be updated
  25092. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25093. * @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
  25094. * @returns VertexData.
  25095. */
  25096. updateGeometry(geometry: Geometry): VertexData;
  25097. private _applyTo;
  25098. private _update;
  25099. /**
  25100. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25101. * @param matrix the transforming matrix
  25102. * @returns the VertexData
  25103. */
  25104. transform(matrix: Matrix): VertexData;
  25105. /**
  25106. * Merges the passed VertexData into the current one
  25107. * @param other the VertexData to be merged into the current one
  25108. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25109. * @returns the modified VertexData
  25110. */
  25111. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25112. private _mergeElement;
  25113. private _validate;
  25114. /**
  25115. * Serializes the VertexData
  25116. * @returns a serialized object
  25117. */
  25118. serialize(): any;
  25119. /**
  25120. * Extracts the vertexData from a mesh
  25121. * @param mesh the mesh from which to extract the VertexData
  25122. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25123. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25124. * @returns the object VertexData associated to the passed mesh
  25125. */
  25126. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25127. /**
  25128. * Extracts the vertexData from the geometry
  25129. * @param geometry the geometry from which to extract the VertexData
  25130. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25131. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25132. * @returns the object VertexData associated to the passed mesh
  25133. */
  25134. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25135. private static _ExtractFrom;
  25136. /**
  25137. * Creates the VertexData for a Ribbon
  25138. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25139. * * pathArray array of paths, each of which an array of successive Vector3
  25140. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25141. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25142. * * 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
  25143. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25144. * * 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)
  25145. * * 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)
  25146. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25147. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25148. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25149. * @returns the VertexData of the ribbon
  25150. */
  25151. static CreateRibbon(options: {
  25152. pathArray: Vector3[][];
  25153. closeArray?: boolean;
  25154. closePath?: boolean;
  25155. offset?: number;
  25156. sideOrientation?: number;
  25157. frontUVs?: Vector4;
  25158. backUVs?: Vector4;
  25159. invertUV?: boolean;
  25160. uvs?: Vector2[];
  25161. colors?: Color4[];
  25162. }): VertexData;
  25163. /**
  25164. * Creates the VertexData for a box
  25165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25166. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25167. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25168. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25169. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25170. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25171. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25173. * * 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)
  25174. * * 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)
  25175. * @returns the VertexData of the box
  25176. */
  25177. static CreateBox(options: {
  25178. size?: number;
  25179. width?: number;
  25180. height?: number;
  25181. depth?: number;
  25182. faceUV?: Vector4[];
  25183. faceColors?: Color4[];
  25184. sideOrientation?: number;
  25185. frontUVs?: Vector4;
  25186. backUVs?: Vector4;
  25187. }): VertexData;
  25188. /**
  25189. * Creates the VertexData for a tiled box
  25190. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25191. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25192. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25193. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25194. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25195. * @returns the VertexData of the box
  25196. */
  25197. static CreateTiledBox(options: {
  25198. pattern?: number;
  25199. width?: number;
  25200. height?: number;
  25201. depth?: number;
  25202. tileSize?: number;
  25203. tileWidth?: number;
  25204. tileHeight?: number;
  25205. alignHorizontal?: number;
  25206. alignVertical?: number;
  25207. faceUV?: Vector4[];
  25208. faceColors?: Color4[];
  25209. sideOrientation?: number;
  25210. }): VertexData;
  25211. /**
  25212. * Creates the VertexData for a tiled plane
  25213. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25214. * * pattern a limited pattern arrangement depending on the number
  25215. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25216. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25217. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25219. * * 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)
  25220. * * 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)
  25221. * @returns the VertexData of the tiled plane
  25222. */
  25223. static CreateTiledPlane(options: {
  25224. pattern?: number;
  25225. tileSize?: number;
  25226. tileWidth?: number;
  25227. tileHeight?: number;
  25228. size?: number;
  25229. width?: number;
  25230. height?: number;
  25231. alignHorizontal?: number;
  25232. alignVertical?: number;
  25233. sideOrientation?: number;
  25234. frontUVs?: Vector4;
  25235. backUVs?: Vector4;
  25236. }): VertexData;
  25237. /**
  25238. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25239. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25240. * * segments sets the number of horizontal strips optional, default 32
  25241. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25242. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25243. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25244. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25245. * * 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
  25246. * * 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
  25247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25248. * * 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)
  25249. * * 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)
  25250. * @returns the VertexData of the ellipsoid
  25251. */
  25252. static CreateSphere(options: {
  25253. segments?: number;
  25254. diameter?: number;
  25255. diameterX?: number;
  25256. diameterY?: number;
  25257. diameterZ?: number;
  25258. arc?: number;
  25259. slice?: number;
  25260. sideOrientation?: number;
  25261. frontUVs?: Vector4;
  25262. backUVs?: Vector4;
  25263. }): VertexData;
  25264. /**
  25265. * Creates the VertexData for a cylinder, cone or prism
  25266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25267. * * height sets the height (y direction) of the cylinder, optional, default 2
  25268. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25269. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25270. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25271. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25272. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25273. * * 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
  25274. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25275. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25276. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25277. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25279. * * 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)
  25280. * * 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)
  25281. * @returns the VertexData of the cylinder, cone or prism
  25282. */
  25283. static CreateCylinder(options: {
  25284. height?: number;
  25285. diameterTop?: number;
  25286. diameterBottom?: number;
  25287. diameter?: number;
  25288. tessellation?: number;
  25289. subdivisions?: number;
  25290. arc?: number;
  25291. faceColors?: Color4[];
  25292. faceUV?: Vector4[];
  25293. hasRings?: boolean;
  25294. enclose?: boolean;
  25295. sideOrientation?: number;
  25296. frontUVs?: Vector4;
  25297. backUVs?: Vector4;
  25298. }): VertexData;
  25299. /**
  25300. * Creates the VertexData for a torus
  25301. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25302. * * diameter the diameter of the torus, optional default 1
  25303. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25304. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25306. * * 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)
  25307. * * 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)
  25308. * @returns the VertexData of the torus
  25309. */
  25310. static CreateTorus(options: {
  25311. diameter?: number;
  25312. thickness?: number;
  25313. tessellation?: number;
  25314. sideOrientation?: number;
  25315. frontUVs?: Vector4;
  25316. backUVs?: Vector4;
  25317. }): VertexData;
  25318. /**
  25319. * Creates the VertexData of the LineSystem
  25320. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25321. * - lines an array of lines, each line being an array of successive Vector3
  25322. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25323. * @returns the VertexData of the LineSystem
  25324. */
  25325. static CreateLineSystem(options: {
  25326. lines: Vector3[][];
  25327. colors?: Nullable<Color4[][]>;
  25328. }): VertexData;
  25329. /**
  25330. * Create the VertexData for a DashedLines
  25331. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25332. * - points an array successive Vector3
  25333. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25334. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25335. * - dashNb the intended total number of dashes, optional, default 200
  25336. * @returns the VertexData for the DashedLines
  25337. */
  25338. static CreateDashedLines(options: {
  25339. points: Vector3[];
  25340. dashSize?: number;
  25341. gapSize?: number;
  25342. dashNb?: number;
  25343. }): VertexData;
  25344. /**
  25345. * Creates the VertexData for a Ground
  25346. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25347. * - width the width (x direction) of the ground, optional, default 1
  25348. * - height the height (z direction) of the ground, optional, default 1
  25349. * - subdivisions the number of subdivisions per side, optional, default 1
  25350. * @returns the VertexData of the Ground
  25351. */
  25352. static CreateGround(options: {
  25353. width?: number;
  25354. height?: number;
  25355. subdivisions?: number;
  25356. subdivisionsX?: number;
  25357. subdivisionsY?: number;
  25358. }): VertexData;
  25359. /**
  25360. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25361. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25362. * * xmin the ground minimum X coordinate, optional, default -1
  25363. * * zmin the ground minimum Z coordinate, optional, default -1
  25364. * * xmax the ground maximum X coordinate, optional, default 1
  25365. * * zmax the ground maximum Z coordinate, optional, default 1
  25366. * * 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}
  25367. * * 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}
  25368. * @returns the VertexData of the TiledGround
  25369. */
  25370. static CreateTiledGround(options: {
  25371. xmin: number;
  25372. zmin: number;
  25373. xmax: number;
  25374. zmax: number;
  25375. subdivisions?: {
  25376. w: number;
  25377. h: number;
  25378. };
  25379. precision?: {
  25380. w: number;
  25381. h: number;
  25382. };
  25383. }): VertexData;
  25384. /**
  25385. * Creates the VertexData of the Ground designed from a heightmap
  25386. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25387. * * width the width (x direction) of the ground
  25388. * * height the height (z direction) of the ground
  25389. * * subdivisions the number of subdivisions per side
  25390. * * minHeight the minimum altitude on the ground, optional, default 0
  25391. * * maxHeight the maximum altitude on the ground, optional default 1
  25392. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25393. * * buffer the array holding the image color data
  25394. * * bufferWidth the width of image
  25395. * * bufferHeight the height of image
  25396. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25397. * @returns the VertexData of the Ground designed from a heightmap
  25398. */
  25399. static CreateGroundFromHeightMap(options: {
  25400. width: number;
  25401. height: number;
  25402. subdivisions: number;
  25403. minHeight: number;
  25404. maxHeight: number;
  25405. colorFilter: Color3;
  25406. buffer: Uint8Array;
  25407. bufferWidth: number;
  25408. bufferHeight: number;
  25409. alphaFilter: number;
  25410. }): VertexData;
  25411. /**
  25412. * Creates the VertexData for a Plane
  25413. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25414. * * size sets the width and height of the plane to the value of size, optional default 1
  25415. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25416. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25418. * * 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)
  25419. * * 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)
  25420. * @returns the VertexData of the box
  25421. */
  25422. static CreatePlane(options: {
  25423. size?: number;
  25424. width?: number;
  25425. height?: number;
  25426. sideOrientation?: number;
  25427. frontUVs?: Vector4;
  25428. backUVs?: Vector4;
  25429. }): VertexData;
  25430. /**
  25431. * Creates the VertexData of the Disc or regular Polygon
  25432. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25433. * * radius the radius of the disc, optional default 0.5
  25434. * * tessellation the number of polygon sides, optional, default 64
  25435. * * 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
  25436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25437. * * 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)
  25438. * * 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)
  25439. * @returns the VertexData of the box
  25440. */
  25441. static CreateDisc(options: {
  25442. radius?: number;
  25443. tessellation?: number;
  25444. arc?: number;
  25445. sideOrientation?: number;
  25446. frontUVs?: Vector4;
  25447. backUVs?: Vector4;
  25448. }): VertexData;
  25449. /**
  25450. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25451. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25452. * @param polygon a mesh built from polygonTriangulation.build()
  25453. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25454. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25455. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25456. * @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)
  25457. * @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)
  25458. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25459. * @returns the VertexData of the Polygon
  25460. */
  25461. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25462. /**
  25463. * Creates the VertexData of the IcoSphere
  25464. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25465. * * radius the radius of the IcoSphere, optional default 1
  25466. * * radiusX allows stretching in the x direction, optional, default radius
  25467. * * radiusY allows stretching in the y direction, optional, default radius
  25468. * * radiusZ allows stretching in the z direction, optional, default radius
  25469. * * flat when true creates a flat shaded mesh, optional, default true
  25470. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25472. * * 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)
  25473. * * 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)
  25474. * @returns the VertexData of the IcoSphere
  25475. */
  25476. static CreateIcoSphere(options: {
  25477. radius?: number;
  25478. radiusX?: number;
  25479. radiusY?: number;
  25480. radiusZ?: number;
  25481. flat?: boolean;
  25482. subdivisions?: number;
  25483. sideOrientation?: number;
  25484. frontUVs?: Vector4;
  25485. backUVs?: Vector4;
  25486. }): VertexData;
  25487. /**
  25488. * Creates the VertexData for a Polyhedron
  25489. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25490. * * type provided types are:
  25491. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25492. * * 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)
  25493. * * size the size of the IcoSphere, optional default 1
  25494. * * sizeX allows stretching in the x direction, optional, default size
  25495. * * sizeY allows stretching in the y direction, optional, default size
  25496. * * sizeZ allows stretching in the z direction, optional, default size
  25497. * * 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
  25498. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25499. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25500. * * flat when true creates a flat shaded mesh, optional, default true
  25501. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25503. * * 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)
  25504. * * 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)
  25505. * @returns the VertexData of the Polyhedron
  25506. */
  25507. static CreatePolyhedron(options: {
  25508. type?: number;
  25509. size?: number;
  25510. sizeX?: number;
  25511. sizeY?: number;
  25512. sizeZ?: number;
  25513. custom?: any;
  25514. faceUV?: Vector4[];
  25515. faceColors?: Color4[];
  25516. flat?: boolean;
  25517. sideOrientation?: number;
  25518. frontUVs?: Vector4;
  25519. backUVs?: Vector4;
  25520. }): VertexData;
  25521. /**
  25522. * Creates the VertexData for a TorusKnot
  25523. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25524. * * radius the radius of the torus knot, optional, default 2
  25525. * * tube the thickness of the tube, optional, default 0.5
  25526. * * radialSegments the number of sides on each tube segments, optional, default 32
  25527. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25528. * * p the number of windings around the z axis, optional, default 2
  25529. * * q the number of windings around the x axis, optional, default 3
  25530. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25531. * * 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)
  25532. * * 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)
  25533. * @returns the VertexData of the Torus Knot
  25534. */
  25535. static CreateTorusKnot(options: {
  25536. radius?: number;
  25537. tube?: number;
  25538. radialSegments?: number;
  25539. tubularSegments?: number;
  25540. p?: number;
  25541. q?: number;
  25542. sideOrientation?: number;
  25543. frontUVs?: Vector4;
  25544. backUVs?: Vector4;
  25545. }): VertexData;
  25546. /**
  25547. * Compute normals for given positions and indices
  25548. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25549. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25550. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25551. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25552. * * facetNormals : optional array of facet normals (vector3)
  25553. * * facetPositions : optional array of facet positions (vector3)
  25554. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25555. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25556. * * bInfo : optional bounding info, required for facetPartitioning computation
  25557. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25558. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25559. * * useRightHandedSystem: optional boolean to for right handed system computation
  25560. * * depthSort : optional boolean to enable the facet depth sort computation
  25561. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25562. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25563. */
  25564. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25565. facetNormals?: any;
  25566. facetPositions?: any;
  25567. facetPartitioning?: any;
  25568. ratio?: number;
  25569. bInfo?: any;
  25570. bbSize?: Vector3;
  25571. subDiv?: any;
  25572. useRightHandedSystem?: boolean;
  25573. depthSort?: boolean;
  25574. distanceTo?: Vector3;
  25575. depthSortedFacets?: any;
  25576. }): void;
  25577. /** @hidden */
  25578. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25579. /**
  25580. * Applies VertexData created from the imported parameters to the geometry
  25581. * @param parsedVertexData the parsed data from an imported file
  25582. * @param geometry the geometry to apply the VertexData to
  25583. */
  25584. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25585. }
  25586. }
  25587. declare module BABYLON {
  25588. /**
  25589. * Defines a target to use with MorphTargetManager
  25590. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25591. */
  25592. export class MorphTarget implements IAnimatable {
  25593. /** defines the name of the target */
  25594. name: string;
  25595. /**
  25596. * Gets or sets the list of animations
  25597. */
  25598. animations: Animation[];
  25599. private _scene;
  25600. private _positions;
  25601. private _normals;
  25602. private _tangents;
  25603. private _uvs;
  25604. private _influence;
  25605. private _uniqueId;
  25606. /**
  25607. * Observable raised when the influence changes
  25608. */
  25609. onInfluenceChanged: Observable<boolean>;
  25610. /** @hidden */
  25611. _onDataLayoutChanged: Observable<void>;
  25612. /**
  25613. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25614. */
  25615. get influence(): number;
  25616. set influence(influence: number);
  25617. /**
  25618. * Gets or sets the id of the morph Target
  25619. */
  25620. id: string;
  25621. private _animationPropertiesOverride;
  25622. /**
  25623. * Gets or sets the animation properties override
  25624. */
  25625. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25626. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25627. /**
  25628. * Creates a new MorphTarget
  25629. * @param name defines the name of the target
  25630. * @param influence defines the influence to use
  25631. * @param scene defines the scene the morphtarget belongs to
  25632. */
  25633. constructor(
  25634. /** defines the name of the target */
  25635. name: string, influence?: number, scene?: Nullable<Scene>);
  25636. /**
  25637. * Gets the unique ID of this manager
  25638. */
  25639. get uniqueId(): number;
  25640. /**
  25641. * Gets a boolean defining if the target contains position data
  25642. */
  25643. get hasPositions(): boolean;
  25644. /**
  25645. * Gets a boolean defining if the target contains normal data
  25646. */
  25647. get hasNormals(): boolean;
  25648. /**
  25649. * Gets a boolean defining if the target contains tangent data
  25650. */
  25651. get hasTangents(): boolean;
  25652. /**
  25653. * Gets a boolean defining if the target contains texture coordinates data
  25654. */
  25655. get hasUVs(): boolean;
  25656. /**
  25657. * Affects position data to this target
  25658. * @param data defines the position data to use
  25659. */
  25660. setPositions(data: Nullable<FloatArray>): void;
  25661. /**
  25662. * Gets the position data stored in this target
  25663. * @returns a FloatArray containing the position data (or null if not present)
  25664. */
  25665. getPositions(): Nullable<FloatArray>;
  25666. /**
  25667. * Affects normal data to this target
  25668. * @param data defines the normal data to use
  25669. */
  25670. setNormals(data: Nullable<FloatArray>): void;
  25671. /**
  25672. * Gets the normal data stored in this target
  25673. * @returns a FloatArray containing the normal data (or null if not present)
  25674. */
  25675. getNormals(): Nullable<FloatArray>;
  25676. /**
  25677. * Affects tangent data to this target
  25678. * @param data defines the tangent data to use
  25679. */
  25680. setTangents(data: Nullable<FloatArray>): void;
  25681. /**
  25682. * Gets the tangent data stored in this target
  25683. * @returns a FloatArray containing the tangent data (or null if not present)
  25684. */
  25685. getTangents(): Nullable<FloatArray>;
  25686. /**
  25687. * Affects texture coordinates data to this target
  25688. * @param data defines the texture coordinates data to use
  25689. */
  25690. setUVs(data: Nullable<FloatArray>): void;
  25691. /**
  25692. * Gets the texture coordinates data stored in this target
  25693. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25694. */
  25695. getUVs(): Nullable<FloatArray>;
  25696. /**
  25697. * Clone the current target
  25698. * @returns a new MorphTarget
  25699. */
  25700. clone(): MorphTarget;
  25701. /**
  25702. * Serializes the current target into a Serialization object
  25703. * @returns the serialized object
  25704. */
  25705. serialize(): any;
  25706. /**
  25707. * Returns the string "MorphTarget"
  25708. * @returns "MorphTarget"
  25709. */
  25710. getClassName(): string;
  25711. /**
  25712. * Creates a new target from serialized data
  25713. * @param serializationObject defines the serialized data to use
  25714. * @returns a new MorphTarget
  25715. */
  25716. static Parse(serializationObject: any): MorphTarget;
  25717. /**
  25718. * Creates a MorphTarget from mesh data
  25719. * @param mesh defines the source mesh
  25720. * @param name defines the name to use for the new target
  25721. * @param influence defines the influence to attach to the target
  25722. * @returns a new MorphTarget
  25723. */
  25724. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25725. }
  25726. }
  25727. declare module BABYLON {
  25728. /**
  25729. * This class is used to deform meshes using morphing between different targets
  25730. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25731. */
  25732. export class MorphTargetManager {
  25733. private _targets;
  25734. private _targetInfluenceChangedObservers;
  25735. private _targetDataLayoutChangedObservers;
  25736. private _activeTargets;
  25737. private _scene;
  25738. private _influences;
  25739. private _supportsNormals;
  25740. private _supportsTangents;
  25741. private _supportsUVs;
  25742. private _vertexCount;
  25743. private _uniqueId;
  25744. private _tempInfluences;
  25745. /**
  25746. * Gets or sets a boolean indicating if normals must be morphed
  25747. */
  25748. enableNormalMorphing: boolean;
  25749. /**
  25750. * Gets or sets a boolean indicating if tangents must be morphed
  25751. */
  25752. enableTangentMorphing: boolean;
  25753. /**
  25754. * Gets or sets a boolean indicating if UV must be morphed
  25755. */
  25756. enableUVMorphing: boolean;
  25757. /**
  25758. * Creates a new MorphTargetManager
  25759. * @param scene defines the current scene
  25760. */
  25761. constructor(scene?: Nullable<Scene>);
  25762. /**
  25763. * Gets the unique ID of this manager
  25764. */
  25765. get uniqueId(): number;
  25766. /**
  25767. * Gets the number of vertices handled by this manager
  25768. */
  25769. get vertexCount(): number;
  25770. /**
  25771. * Gets a boolean indicating if this manager supports morphing of normals
  25772. */
  25773. get supportsNormals(): boolean;
  25774. /**
  25775. * Gets a boolean indicating if this manager supports morphing of tangents
  25776. */
  25777. get supportsTangents(): boolean;
  25778. /**
  25779. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25780. */
  25781. get supportsUVs(): boolean;
  25782. /**
  25783. * Gets the number of targets stored in this manager
  25784. */
  25785. get numTargets(): number;
  25786. /**
  25787. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25788. */
  25789. get numInfluencers(): number;
  25790. /**
  25791. * Gets the list of influences (one per target)
  25792. */
  25793. get influences(): Float32Array;
  25794. /**
  25795. * Gets the active target at specified index. An active target is a target with an influence > 0
  25796. * @param index defines the index to check
  25797. * @returns the requested target
  25798. */
  25799. getActiveTarget(index: number): MorphTarget;
  25800. /**
  25801. * Gets the target at specified index
  25802. * @param index defines the index to check
  25803. * @returns the requested target
  25804. */
  25805. getTarget(index: number): MorphTarget;
  25806. /**
  25807. * Add a new target to this manager
  25808. * @param target defines the target to add
  25809. */
  25810. addTarget(target: MorphTarget): void;
  25811. /**
  25812. * Removes a target from the manager
  25813. * @param target defines the target to remove
  25814. */
  25815. removeTarget(target: MorphTarget): void;
  25816. /**
  25817. * Clone the current manager
  25818. * @returns a new MorphTargetManager
  25819. */
  25820. clone(): MorphTargetManager;
  25821. /**
  25822. * Serializes the current manager into a Serialization object
  25823. * @returns the serialized object
  25824. */
  25825. serialize(): any;
  25826. private _syncActiveTargets;
  25827. /**
  25828. * Syncrhonize the targets with all the meshes using this morph target manager
  25829. */
  25830. synchronize(): void;
  25831. /**
  25832. * Creates a new MorphTargetManager from serialized data
  25833. * @param serializationObject defines the serialized data
  25834. * @param scene defines the hosting scene
  25835. * @returns the new MorphTargetManager
  25836. */
  25837. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25838. }
  25839. }
  25840. declare module BABYLON {
  25841. /**
  25842. * Class used to represent a specific level of detail of a mesh
  25843. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25844. */
  25845. export class MeshLODLevel {
  25846. /** Defines the distance where this level should start being displayed */
  25847. distance: number;
  25848. /** Defines the mesh to use to render this level */
  25849. mesh: Nullable<Mesh>;
  25850. /**
  25851. * Creates a new LOD level
  25852. * @param distance defines the distance where this level should star being displayed
  25853. * @param mesh defines the mesh to use to render this level
  25854. */
  25855. constructor(
  25856. /** Defines the distance where this level should start being displayed */
  25857. distance: number,
  25858. /** Defines the mesh to use to render this level */
  25859. mesh: Nullable<Mesh>);
  25860. }
  25861. }
  25862. declare module BABYLON {
  25863. /**
  25864. * Mesh representing the gorund
  25865. */
  25866. export class GroundMesh extends Mesh {
  25867. /** If octree should be generated */
  25868. generateOctree: boolean;
  25869. private _heightQuads;
  25870. /** @hidden */
  25871. _subdivisionsX: number;
  25872. /** @hidden */
  25873. _subdivisionsY: number;
  25874. /** @hidden */
  25875. _width: number;
  25876. /** @hidden */
  25877. _height: number;
  25878. /** @hidden */
  25879. _minX: number;
  25880. /** @hidden */
  25881. _maxX: number;
  25882. /** @hidden */
  25883. _minZ: number;
  25884. /** @hidden */
  25885. _maxZ: number;
  25886. constructor(name: string, scene: Scene);
  25887. /**
  25888. * "GroundMesh"
  25889. * @returns "GroundMesh"
  25890. */
  25891. getClassName(): string;
  25892. /**
  25893. * The minimum of x and y subdivisions
  25894. */
  25895. get subdivisions(): number;
  25896. /**
  25897. * X subdivisions
  25898. */
  25899. get subdivisionsX(): number;
  25900. /**
  25901. * Y subdivisions
  25902. */
  25903. get subdivisionsY(): number;
  25904. /**
  25905. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25906. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25907. * @param chunksCount the number of subdivisions for x and y
  25908. * @param octreeBlocksSize (Default: 32)
  25909. */
  25910. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25911. /**
  25912. * Returns a height (y) value in the Worl system :
  25913. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25914. * @param x x coordinate
  25915. * @param z z coordinate
  25916. * @returns the ground y position if (x, z) are outside the ground surface.
  25917. */
  25918. getHeightAtCoordinates(x: number, z: number): number;
  25919. /**
  25920. * Returns a normalized vector (Vector3) orthogonal to the ground
  25921. * at the ground coordinates (x, z) expressed in the World system.
  25922. * @param x x coordinate
  25923. * @param z z coordinate
  25924. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25925. */
  25926. getNormalAtCoordinates(x: number, z: number): Vector3;
  25927. /**
  25928. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25929. * at the ground coordinates (x, z) expressed in the World system.
  25930. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25931. * @param x x coordinate
  25932. * @param z z coordinate
  25933. * @param ref vector to store the result
  25934. * @returns the GroundMesh.
  25935. */
  25936. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25937. /**
  25938. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25939. * if the ground has been updated.
  25940. * This can be used in the render loop.
  25941. * @returns the GroundMesh.
  25942. */
  25943. updateCoordinateHeights(): GroundMesh;
  25944. private _getFacetAt;
  25945. private _initHeightQuads;
  25946. private _computeHeightQuads;
  25947. /**
  25948. * Serializes this ground mesh
  25949. * @param serializationObject object to write serialization to
  25950. */
  25951. serialize(serializationObject: any): void;
  25952. /**
  25953. * Parses a serialized ground mesh
  25954. * @param parsedMesh the serialized mesh
  25955. * @param scene the scene to create the ground mesh in
  25956. * @returns the created ground mesh
  25957. */
  25958. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25959. }
  25960. }
  25961. declare module BABYLON {
  25962. /**
  25963. * Interface for Physics-Joint data
  25964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25965. */
  25966. export interface PhysicsJointData {
  25967. /**
  25968. * The main pivot of the joint
  25969. */
  25970. mainPivot?: Vector3;
  25971. /**
  25972. * The connected pivot of the joint
  25973. */
  25974. connectedPivot?: Vector3;
  25975. /**
  25976. * The main axis of the joint
  25977. */
  25978. mainAxis?: Vector3;
  25979. /**
  25980. * The connected axis of the joint
  25981. */
  25982. connectedAxis?: Vector3;
  25983. /**
  25984. * The collision of the joint
  25985. */
  25986. collision?: boolean;
  25987. /**
  25988. * Native Oimo/Cannon/Energy data
  25989. */
  25990. nativeParams?: any;
  25991. }
  25992. /**
  25993. * This is a holder class for the physics joint created by the physics plugin
  25994. * It holds a set of functions to control the underlying joint
  25995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25996. */
  25997. export class PhysicsJoint {
  25998. /**
  25999. * The type of the physics joint
  26000. */
  26001. type: number;
  26002. /**
  26003. * The data for the physics joint
  26004. */
  26005. jointData: PhysicsJointData;
  26006. private _physicsJoint;
  26007. protected _physicsPlugin: IPhysicsEnginePlugin;
  26008. /**
  26009. * Initializes the physics joint
  26010. * @param type The type of the physics joint
  26011. * @param jointData The data for the physics joint
  26012. */
  26013. constructor(
  26014. /**
  26015. * The type of the physics joint
  26016. */
  26017. type: number,
  26018. /**
  26019. * The data for the physics joint
  26020. */
  26021. jointData: PhysicsJointData);
  26022. /**
  26023. * Gets the physics joint
  26024. */
  26025. get physicsJoint(): any;
  26026. /**
  26027. * Sets the physics joint
  26028. */
  26029. set physicsJoint(newJoint: any);
  26030. /**
  26031. * Sets the physics plugin
  26032. */
  26033. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26034. /**
  26035. * Execute a function that is physics-plugin specific.
  26036. * @param {Function} func the function that will be executed.
  26037. * It accepts two parameters: the physics world and the physics joint
  26038. */
  26039. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26040. /**
  26041. * Distance-Joint type
  26042. */
  26043. static DistanceJoint: number;
  26044. /**
  26045. * Hinge-Joint type
  26046. */
  26047. static HingeJoint: number;
  26048. /**
  26049. * Ball-and-Socket joint type
  26050. */
  26051. static BallAndSocketJoint: number;
  26052. /**
  26053. * Wheel-Joint type
  26054. */
  26055. static WheelJoint: number;
  26056. /**
  26057. * Slider-Joint type
  26058. */
  26059. static SliderJoint: number;
  26060. /**
  26061. * Prismatic-Joint type
  26062. */
  26063. static PrismaticJoint: number;
  26064. /**
  26065. * Universal-Joint type
  26066. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26067. */
  26068. static UniversalJoint: number;
  26069. /**
  26070. * Hinge-Joint 2 type
  26071. */
  26072. static Hinge2Joint: number;
  26073. /**
  26074. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26075. */
  26076. static PointToPointJoint: number;
  26077. /**
  26078. * Spring-Joint type
  26079. */
  26080. static SpringJoint: number;
  26081. /**
  26082. * Lock-Joint type
  26083. */
  26084. static LockJoint: number;
  26085. }
  26086. /**
  26087. * A class representing a physics distance joint
  26088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26089. */
  26090. export class DistanceJoint extends PhysicsJoint {
  26091. /**
  26092. *
  26093. * @param jointData The data for the Distance-Joint
  26094. */
  26095. constructor(jointData: DistanceJointData);
  26096. /**
  26097. * Update the predefined distance.
  26098. * @param maxDistance The maximum preferred distance
  26099. * @param minDistance The minimum preferred distance
  26100. */
  26101. updateDistance(maxDistance: number, minDistance?: number): void;
  26102. }
  26103. /**
  26104. * Represents a Motor-Enabled Joint
  26105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26106. */
  26107. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26108. /**
  26109. * Initializes the Motor-Enabled Joint
  26110. * @param type The type of the joint
  26111. * @param jointData The physica joint data for the joint
  26112. */
  26113. constructor(type: number, jointData: PhysicsJointData);
  26114. /**
  26115. * Set the motor values.
  26116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26117. * @param force the force to apply
  26118. * @param maxForce max force for this motor.
  26119. */
  26120. setMotor(force?: number, maxForce?: number): void;
  26121. /**
  26122. * Set the motor's limits.
  26123. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26124. * @param upperLimit The upper limit of the motor
  26125. * @param lowerLimit The lower limit of the motor
  26126. */
  26127. setLimit(upperLimit: number, lowerLimit?: number): void;
  26128. }
  26129. /**
  26130. * This class represents a single physics Hinge-Joint
  26131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26132. */
  26133. export class HingeJoint extends MotorEnabledJoint {
  26134. /**
  26135. * Initializes the Hinge-Joint
  26136. * @param jointData The joint data for the Hinge-Joint
  26137. */
  26138. constructor(jointData: PhysicsJointData);
  26139. /**
  26140. * Set the motor values.
  26141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26142. * @param {number} force the force to apply
  26143. * @param {number} maxForce max force for this motor.
  26144. */
  26145. setMotor(force?: number, maxForce?: number): void;
  26146. /**
  26147. * Set the motor's limits.
  26148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26149. * @param upperLimit The upper limit of the motor
  26150. * @param lowerLimit The lower limit of the motor
  26151. */
  26152. setLimit(upperLimit: number, lowerLimit?: number): void;
  26153. }
  26154. /**
  26155. * This class represents a dual hinge physics joint (same as wheel joint)
  26156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26157. */
  26158. export class Hinge2Joint extends MotorEnabledJoint {
  26159. /**
  26160. * Initializes the Hinge2-Joint
  26161. * @param jointData The joint data for the Hinge2-Joint
  26162. */
  26163. constructor(jointData: PhysicsJointData);
  26164. /**
  26165. * Set the motor values.
  26166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26167. * @param {number} targetSpeed the speed the motor is to reach
  26168. * @param {number} maxForce max force for this motor.
  26169. * @param {motorIndex} the motor's index, 0 or 1.
  26170. */
  26171. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26172. /**
  26173. * Set the motor limits.
  26174. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26175. * @param {number} upperLimit the upper limit
  26176. * @param {number} lowerLimit lower limit
  26177. * @param {motorIndex} the motor's index, 0 or 1.
  26178. */
  26179. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26180. }
  26181. /**
  26182. * Interface for a motor enabled joint
  26183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26184. */
  26185. export interface IMotorEnabledJoint {
  26186. /**
  26187. * Physics joint
  26188. */
  26189. physicsJoint: any;
  26190. /**
  26191. * Sets the motor of the motor-enabled joint
  26192. * @param force The force of the motor
  26193. * @param maxForce The maximum force of the motor
  26194. * @param motorIndex The index of the motor
  26195. */
  26196. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26197. /**
  26198. * Sets the limit of the motor
  26199. * @param upperLimit The upper limit of the motor
  26200. * @param lowerLimit The lower limit of the motor
  26201. * @param motorIndex The index of the motor
  26202. */
  26203. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26204. }
  26205. /**
  26206. * Joint data for a Distance-Joint
  26207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26208. */
  26209. export interface DistanceJointData extends PhysicsJointData {
  26210. /**
  26211. * Max distance the 2 joint objects can be apart
  26212. */
  26213. maxDistance: number;
  26214. }
  26215. /**
  26216. * Joint data from a spring joint
  26217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26218. */
  26219. export interface SpringJointData extends PhysicsJointData {
  26220. /**
  26221. * Length of the spring
  26222. */
  26223. length: number;
  26224. /**
  26225. * Stiffness of the spring
  26226. */
  26227. stiffness: number;
  26228. /**
  26229. * Damping of the spring
  26230. */
  26231. damping: number;
  26232. /** this callback will be called when applying the force to the impostors. */
  26233. forceApplicationCallback: () => void;
  26234. }
  26235. }
  26236. declare module BABYLON {
  26237. /**
  26238. * Holds the data for the raycast result
  26239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26240. */
  26241. export class PhysicsRaycastResult {
  26242. private _hasHit;
  26243. private _hitDistance;
  26244. private _hitNormalWorld;
  26245. private _hitPointWorld;
  26246. private _rayFromWorld;
  26247. private _rayToWorld;
  26248. /**
  26249. * Gets if there was a hit
  26250. */
  26251. get hasHit(): boolean;
  26252. /**
  26253. * Gets the distance from the hit
  26254. */
  26255. get hitDistance(): number;
  26256. /**
  26257. * Gets the hit normal/direction in the world
  26258. */
  26259. get hitNormalWorld(): Vector3;
  26260. /**
  26261. * Gets the hit point in the world
  26262. */
  26263. get hitPointWorld(): Vector3;
  26264. /**
  26265. * Gets the ray "start point" of the ray in the world
  26266. */
  26267. get rayFromWorld(): Vector3;
  26268. /**
  26269. * Gets the ray "end point" of the ray in the world
  26270. */
  26271. get rayToWorld(): Vector3;
  26272. /**
  26273. * Sets the hit data (normal & point in world space)
  26274. * @param hitNormalWorld defines the normal in world space
  26275. * @param hitPointWorld defines the point in world space
  26276. */
  26277. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26278. /**
  26279. * Sets the distance from the start point to the hit point
  26280. * @param distance
  26281. */
  26282. setHitDistance(distance: number): void;
  26283. /**
  26284. * Calculates the distance manually
  26285. */
  26286. calculateHitDistance(): void;
  26287. /**
  26288. * Resets all the values to default
  26289. * @param from The from point on world space
  26290. * @param to The to point on world space
  26291. */
  26292. reset(from?: Vector3, to?: Vector3): void;
  26293. }
  26294. /**
  26295. * Interface for the size containing width and height
  26296. */
  26297. interface IXYZ {
  26298. /**
  26299. * X
  26300. */
  26301. x: number;
  26302. /**
  26303. * Y
  26304. */
  26305. y: number;
  26306. /**
  26307. * Z
  26308. */
  26309. z: number;
  26310. }
  26311. }
  26312. declare module BABYLON {
  26313. /**
  26314. * Interface used to describe a physics joint
  26315. */
  26316. export interface PhysicsImpostorJoint {
  26317. /** Defines the main impostor to which the joint is linked */
  26318. mainImpostor: PhysicsImpostor;
  26319. /** Defines the impostor that is connected to the main impostor using this joint */
  26320. connectedImpostor: PhysicsImpostor;
  26321. /** Defines the joint itself */
  26322. joint: PhysicsJoint;
  26323. }
  26324. /** @hidden */
  26325. export interface IPhysicsEnginePlugin {
  26326. world: any;
  26327. name: string;
  26328. setGravity(gravity: Vector3): void;
  26329. setTimeStep(timeStep: number): void;
  26330. getTimeStep(): number;
  26331. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26332. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26333. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26334. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26335. removePhysicsBody(impostor: PhysicsImpostor): void;
  26336. generateJoint(joint: PhysicsImpostorJoint): void;
  26337. removeJoint(joint: PhysicsImpostorJoint): void;
  26338. isSupported(): boolean;
  26339. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26340. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26341. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26342. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26343. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26344. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26345. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26346. getBodyMass(impostor: PhysicsImpostor): number;
  26347. getBodyFriction(impostor: PhysicsImpostor): number;
  26348. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26349. getBodyRestitution(impostor: PhysicsImpostor): number;
  26350. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26351. getBodyPressure?(impostor: PhysicsImpostor): number;
  26352. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26353. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26354. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26355. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26356. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26357. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26358. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26359. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26360. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26361. sleepBody(impostor: PhysicsImpostor): void;
  26362. wakeUpBody(impostor: PhysicsImpostor): void;
  26363. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26364. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26365. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26366. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26367. getRadius(impostor: PhysicsImpostor): number;
  26368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26370. dispose(): void;
  26371. }
  26372. /**
  26373. * Interface used to define a physics engine
  26374. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26375. */
  26376. export interface IPhysicsEngine {
  26377. /**
  26378. * Gets the gravity vector used by the simulation
  26379. */
  26380. gravity: Vector3;
  26381. /**
  26382. * Sets the gravity vector used by the simulation
  26383. * @param gravity defines the gravity vector to use
  26384. */
  26385. setGravity(gravity: Vector3): void;
  26386. /**
  26387. * Set the time step of the physics engine.
  26388. * Default is 1/60.
  26389. * To slow it down, enter 1/600 for example.
  26390. * To speed it up, 1/30
  26391. * @param newTimeStep the new timestep to apply to this world.
  26392. */
  26393. setTimeStep(newTimeStep: number): void;
  26394. /**
  26395. * Get the time step of the physics engine.
  26396. * @returns the current time step
  26397. */
  26398. getTimeStep(): number;
  26399. /**
  26400. * Set the sub time step of the physics engine.
  26401. * Default is 0 meaning there is no sub steps
  26402. * To increase physics resolution precision, set a small value (like 1 ms)
  26403. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26404. */
  26405. setSubTimeStep(subTimeStep: number): void;
  26406. /**
  26407. * Get the sub time step of the physics engine.
  26408. * @returns the current sub time step
  26409. */
  26410. getSubTimeStep(): number;
  26411. /**
  26412. * Release all resources
  26413. */
  26414. dispose(): void;
  26415. /**
  26416. * Gets the name of the current physics plugin
  26417. * @returns the name of the plugin
  26418. */
  26419. getPhysicsPluginName(): string;
  26420. /**
  26421. * Adding a new impostor for the impostor tracking.
  26422. * This will be done by the impostor itself.
  26423. * @param impostor the impostor to add
  26424. */
  26425. addImpostor(impostor: PhysicsImpostor): void;
  26426. /**
  26427. * Remove an impostor from the engine.
  26428. * This impostor and its mesh will not longer be updated by the physics engine.
  26429. * @param impostor the impostor to remove
  26430. */
  26431. removeImpostor(impostor: PhysicsImpostor): void;
  26432. /**
  26433. * Add a joint to the physics engine
  26434. * @param mainImpostor defines the main impostor to which the joint is added.
  26435. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26436. * @param joint defines the joint that will connect both impostors.
  26437. */
  26438. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26439. /**
  26440. * Removes a joint from the simulation
  26441. * @param mainImpostor defines the impostor used with the joint
  26442. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26443. * @param joint defines the joint to remove
  26444. */
  26445. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26446. /**
  26447. * Gets the current plugin used to run the simulation
  26448. * @returns current plugin
  26449. */
  26450. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26451. /**
  26452. * Gets the list of physic impostors
  26453. * @returns an array of PhysicsImpostor
  26454. */
  26455. getImpostors(): Array<PhysicsImpostor>;
  26456. /**
  26457. * Gets the impostor for a physics enabled object
  26458. * @param object defines the object impersonated by the impostor
  26459. * @returns the PhysicsImpostor or null if not found
  26460. */
  26461. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26462. /**
  26463. * Gets the impostor for a physics body object
  26464. * @param body defines physics body used by the impostor
  26465. * @returns the PhysicsImpostor or null if not found
  26466. */
  26467. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26468. /**
  26469. * Does a raycast in the physics world
  26470. * @param from when should the ray start?
  26471. * @param to when should the ray end?
  26472. * @returns PhysicsRaycastResult
  26473. */
  26474. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26475. /**
  26476. * Called by the scene. No need to call it.
  26477. * @param delta defines the timespam between frames
  26478. */
  26479. _step(delta: number): void;
  26480. }
  26481. }
  26482. declare module BABYLON {
  26483. /**
  26484. * The interface for the physics imposter parameters
  26485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26486. */
  26487. export interface PhysicsImpostorParameters {
  26488. /**
  26489. * The mass of the physics imposter
  26490. */
  26491. mass: number;
  26492. /**
  26493. * The friction of the physics imposter
  26494. */
  26495. friction?: number;
  26496. /**
  26497. * The coefficient of restitution of the physics imposter
  26498. */
  26499. restitution?: number;
  26500. /**
  26501. * The native options of the physics imposter
  26502. */
  26503. nativeOptions?: any;
  26504. /**
  26505. * Specifies if the parent should be ignored
  26506. */
  26507. ignoreParent?: boolean;
  26508. /**
  26509. * Specifies if bi-directional transformations should be disabled
  26510. */
  26511. disableBidirectionalTransformation?: boolean;
  26512. /**
  26513. * The pressure inside the physics imposter, soft object only
  26514. */
  26515. pressure?: number;
  26516. /**
  26517. * The stiffness the physics imposter, soft object only
  26518. */
  26519. stiffness?: number;
  26520. /**
  26521. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26522. */
  26523. velocityIterations?: number;
  26524. /**
  26525. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26526. */
  26527. positionIterations?: number;
  26528. /**
  26529. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26530. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26531. * Add to fix multiple points
  26532. */
  26533. fixedPoints?: number;
  26534. /**
  26535. * The collision margin around a soft object
  26536. */
  26537. margin?: number;
  26538. /**
  26539. * The collision margin around a soft object
  26540. */
  26541. damping?: number;
  26542. /**
  26543. * The path for a rope based on an extrusion
  26544. */
  26545. path?: any;
  26546. /**
  26547. * The shape of an extrusion used for a rope based on an extrusion
  26548. */
  26549. shape?: any;
  26550. }
  26551. /**
  26552. * Interface for a physics-enabled object
  26553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26554. */
  26555. export interface IPhysicsEnabledObject {
  26556. /**
  26557. * The position of the physics-enabled object
  26558. */
  26559. position: Vector3;
  26560. /**
  26561. * The rotation of the physics-enabled object
  26562. */
  26563. rotationQuaternion: Nullable<Quaternion>;
  26564. /**
  26565. * The scale of the physics-enabled object
  26566. */
  26567. scaling: Vector3;
  26568. /**
  26569. * The rotation of the physics-enabled object
  26570. */
  26571. rotation?: Vector3;
  26572. /**
  26573. * The parent of the physics-enabled object
  26574. */
  26575. parent?: any;
  26576. /**
  26577. * The bounding info of the physics-enabled object
  26578. * @returns The bounding info of the physics-enabled object
  26579. */
  26580. getBoundingInfo(): BoundingInfo;
  26581. /**
  26582. * Computes the world matrix
  26583. * @param force Specifies if the world matrix should be computed by force
  26584. * @returns A world matrix
  26585. */
  26586. computeWorldMatrix(force: boolean): Matrix;
  26587. /**
  26588. * Gets the world matrix
  26589. * @returns A world matrix
  26590. */
  26591. getWorldMatrix?(): Matrix;
  26592. /**
  26593. * Gets the child meshes
  26594. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26595. * @returns An array of abstract meshes
  26596. */
  26597. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26598. /**
  26599. * Gets the vertex data
  26600. * @param kind The type of vertex data
  26601. * @returns A nullable array of numbers, or a float32 array
  26602. */
  26603. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26604. /**
  26605. * Gets the indices from the mesh
  26606. * @returns A nullable array of index arrays
  26607. */
  26608. getIndices?(): Nullable<IndicesArray>;
  26609. /**
  26610. * Gets the scene from the mesh
  26611. * @returns the indices array or null
  26612. */
  26613. getScene?(): Scene;
  26614. /**
  26615. * Gets the absolute position from the mesh
  26616. * @returns the absolute position
  26617. */
  26618. getAbsolutePosition(): Vector3;
  26619. /**
  26620. * Gets the absolute pivot point from the mesh
  26621. * @returns the absolute pivot point
  26622. */
  26623. getAbsolutePivotPoint(): Vector3;
  26624. /**
  26625. * Rotates the mesh
  26626. * @param axis The axis of rotation
  26627. * @param amount The amount of rotation
  26628. * @param space The space of the rotation
  26629. * @returns The rotation transform node
  26630. */
  26631. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26632. /**
  26633. * Translates the mesh
  26634. * @param axis The axis of translation
  26635. * @param distance The distance of translation
  26636. * @param space The space of the translation
  26637. * @returns The transform node
  26638. */
  26639. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26640. /**
  26641. * Sets the absolute position of the mesh
  26642. * @param absolutePosition The absolute position of the mesh
  26643. * @returns The transform node
  26644. */
  26645. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26646. /**
  26647. * Gets the class name of the mesh
  26648. * @returns The class name
  26649. */
  26650. getClassName(): string;
  26651. }
  26652. /**
  26653. * Represents a physics imposter
  26654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26655. */
  26656. export class PhysicsImpostor {
  26657. /**
  26658. * The physics-enabled object used as the physics imposter
  26659. */
  26660. object: IPhysicsEnabledObject;
  26661. /**
  26662. * The type of the physics imposter
  26663. */
  26664. type: number;
  26665. private _options;
  26666. private _scene?;
  26667. /**
  26668. * The default object size of the imposter
  26669. */
  26670. static DEFAULT_OBJECT_SIZE: Vector3;
  26671. /**
  26672. * The identity quaternion of the imposter
  26673. */
  26674. static IDENTITY_QUATERNION: Quaternion;
  26675. /** @hidden */
  26676. _pluginData: any;
  26677. private _physicsEngine;
  26678. private _physicsBody;
  26679. private _bodyUpdateRequired;
  26680. private _onBeforePhysicsStepCallbacks;
  26681. private _onAfterPhysicsStepCallbacks;
  26682. /** @hidden */
  26683. _onPhysicsCollideCallbacks: Array<{
  26684. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26685. otherImpostors: Array<PhysicsImpostor>;
  26686. }>;
  26687. private _deltaPosition;
  26688. private _deltaRotation;
  26689. private _deltaRotationConjugated;
  26690. /** @hidden */
  26691. _isFromLine: boolean;
  26692. private _parent;
  26693. private _isDisposed;
  26694. private static _tmpVecs;
  26695. private static _tmpQuat;
  26696. /**
  26697. * Specifies if the physics imposter is disposed
  26698. */
  26699. get isDisposed(): boolean;
  26700. /**
  26701. * Gets the mass of the physics imposter
  26702. */
  26703. get mass(): number;
  26704. set mass(value: number);
  26705. /**
  26706. * Gets the coefficient of friction
  26707. */
  26708. get friction(): number;
  26709. /**
  26710. * Sets the coefficient of friction
  26711. */
  26712. set friction(value: number);
  26713. /**
  26714. * Gets the coefficient of restitution
  26715. */
  26716. get restitution(): number;
  26717. /**
  26718. * Sets the coefficient of restitution
  26719. */
  26720. set restitution(value: number);
  26721. /**
  26722. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26723. */
  26724. get pressure(): number;
  26725. /**
  26726. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26727. */
  26728. set pressure(value: number);
  26729. /**
  26730. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26731. */
  26732. get stiffness(): number;
  26733. /**
  26734. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26735. */
  26736. set stiffness(value: number);
  26737. /**
  26738. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26739. */
  26740. get velocityIterations(): number;
  26741. /**
  26742. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26743. */
  26744. set velocityIterations(value: number);
  26745. /**
  26746. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26747. */
  26748. get positionIterations(): number;
  26749. /**
  26750. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26751. */
  26752. set positionIterations(value: number);
  26753. /**
  26754. * The unique id of the physics imposter
  26755. * set by the physics engine when adding this impostor to the array
  26756. */
  26757. uniqueId: number;
  26758. /**
  26759. * @hidden
  26760. */
  26761. soft: boolean;
  26762. /**
  26763. * @hidden
  26764. */
  26765. segments: number;
  26766. private _joints;
  26767. /**
  26768. * Initializes the physics imposter
  26769. * @param object The physics-enabled object used as the physics imposter
  26770. * @param type The type of the physics imposter
  26771. * @param _options The options for the physics imposter
  26772. * @param _scene The Babylon scene
  26773. */
  26774. constructor(
  26775. /**
  26776. * The physics-enabled object used as the physics imposter
  26777. */
  26778. object: IPhysicsEnabledObject,
  26779. /**
  26780. * The type of the physics imposter
  26781. */
  26782. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26783. /**
  26784. * This function will completly initialize this impostor.
  26785. * It will create a new body - but only if this mesh has no parent.
  26786. * If it has, this impostor will not be used other than to define the impostor
  26787. * of the child mesh.
  26788. * @hidden
  26789. */
  26790. _init(): void;
  26791. private _getPhysicsParent;
  26792. /**
  26793. * Should a new body be generated.
  26794. * @returns boolean specifying if body initialization is required
  26795. */
  26796. isBodyInitRequired(): boolean;
  26797. /**
  26798. * Sets the updated scaling
  26799. * @param updated Specifies if the scaling is updated
  26800. */
  26801. setScalingUpdated(): void;
  26802. /**
  26803. * Force a regeneration of this or the parent's impostor's body.
  26804. * Use under cautious - This will remove all joints already implemented.
  26805. */
  26806. forceUpdate(): void;
  26807. /**
  26808. * Gets the body that holds this impostor. Either its own, or its parent.
  26809. */
  26810. get physicsBody(): any;
  26811. /**
  26812. * Get the parent of the physics imposter
  26813. * @returns Physics imposter or null
  26814. */
  26815. get parent(): Nullable<PhysicsImpostor>;
  26816. /**
  26817. * Sets the parent of the physics imposter
  26818. */
  26819. set parent(value: Nullable<PhysicsImpostor>);
  26820. /**
  26821. * Set the physics body. Used mainly by the physics engine/plugin
  26822. */
  26823. set physicsBody(physicsBody: any);
  26824. /**
  26825. * Resets the update flags
  26826. */
  26827. resetUpdateFlags(): void;
  26828. /**
  26829. * Gets the object extend size
  26830. * @returns the object extend size
  26831. */
  26832. getObjectExtendSize(): Vector3;
  26833. /**
  26834. * Gets the object center
  26835. * @returns The object center
  26836. */
  26837. getObjectCenter(): Vector3;
  26838. /**
  26839. * Get a specific parameter from the options parameters
  26840. * @param paramName The object parameter name
  26841. * @returns The object parameter
  26842. */
  26843. getParam(paramName: string): any;
  26844. /**
  26845. * Sets a specific parameter in the options given to the physics plugin
  26846. * @param paramName The parameter name
  26847. * @param value The value of the parameter
  26848. */
  26849. setParam(paramName: string, value: number): void;
  26850. /**
  26851. * Specifically change the body's mass option. Won't recreate the physics body object
  26852. * @param mass The mass of the physics imposter
  26853. */
  26854. setMass(mass: number): void;
  26855. /**
  26856. * Gets the linear velocity
  26857. * @returns linear velocity or null
  26858. */
  26859. getLinearVelocity(): Nullable<Vector3>;
  26860. /**
  26861. * Sets the linear velocity
  26862. * @param velocity linear velocity or null
  26863. */
  26864. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26865. /**
  26866. * Gets the angular velocity
  26867. * @returns angular velocity or null
  26868. */
  26869. getAngularVelocity(): Nullable<Vector3>;
  26870. /**
  26871. * Sets the angular velocity
  26872. * @param velocity The velocity or null
  26873. */
  26874. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26875. /**
  26876. * Execute a function with the physics plugin native code
  26877. * Provide a function the will have two variables - the world object and the physics body object
  26878. * @param func The function to execute with the physics plugin native code
  26879. */
  26880. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26881. /**
  26882. * Register a function that will be executed before the physics world is stepping forward
  26883. * @param func The function to execute before the physics world is stepped forward
  26884. */
  26885. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26886. /**
  26887. * Unregister a function that will be executed before the physics world is stepping forward
  26888. * @param func The function to execute before the physics world is stepped forward
  26889. */
  26890. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26891. /**
  26892. * Register a function that will be executed after the physics step
  26893. * @param func The function to execute after physics step
  26894. */
  26895. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26896. /**
  26897. * Unregisters a function that will be executed after the physics step
  26898. * @param func The function to execute after physics step
  26899. */
  26900. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26901. /**
  26902. * register a function that will be executed when this impostor collides against a different body
  26903. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26904. * @param func Callback that is executed on collision
  26905. */
  26906. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26907. /**
  26908. * Unregisters the physics imposter on contact
  26909. * @param collideAgainst The physics object to collide against
  26910. * @param func Callback to execute on collision
  26911. */
  26912. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26913. private _tmpQuat;
  26914. private _tmpQuat2;
  26915. /**
  26916. * Get the parent rotation
  26917. * @returns The parent rotation
  26918. */
  26919. getParentsRotation(): Quaternion;
  26920. /**
  26921. * this function is executed by the physics engine.
  26922. */
  26923. beforeStep: () => void;
  26924. /**
  26925. * this function is executed by the physics engine
  26926. */
  26927. afterStep: () => void;
  26928. /**
  26929. * Legacy collision detection event support
  26930. */
  26931. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26932. /**
  26933. * event and body object due to cannon's event-based architecture.
  26934. */
  26935. onCollide: (e: {
  26936. body: any;
  26937. }) => void;
  26938. /**
  26939. * Apply a force
  26940. * @param force The force to apply
  26941. * @param contactPoint The contact point for the force
  26942. * @returns The physics imposter
  26943. */
  26944. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26945. /**
  26946. * Apply an impulse
  26947. * @param force The impulse force
  26948. * @param contactPoint The contact point for the impulse force
  26949. * @returns The physics imposter
  26950. */
  26951. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26952. /**
  26953. * A help function to create a joint
  26954. * @param otherImpostor A physics imposter used to create a joint
  26955. * @param jointType The type of joint
  26956. * @param jointData The data for the joint
  26957. * @returns The physics imposter
  26958. */
  26959. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26960. /**
  26961. * Add a joint to this impostor with a different impostor
  26962. * @param otherImpostor A physics imposter used to add a joint
  26963. * @param joint The joint to add
  26964. * @returns The physics imposter
  26965. */
  26966. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26967. /**
  26968. * Add an anchor to a cloth impostor
  26969. * @param otherImpostor rigid impostor to anchor to
  26970. * @param width ratio across width from 0 to 1
  26971. * @param height ratio up height from 0 to 1
  26972. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26973. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  26974. * @returns impostor the soft imposter
  26975. */
  26976. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26977. /**
  26978. * Add a hook to a rope impostor
  26979. * @param otherImpostor rigid impostor to anchor to
  26980. * @param length ratio across rope from 0 to 1
  26981. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  26982. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  26983. * @returns impostor the rope imposter
  26984. */
  26985. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  26986. /**
  26987. * Will keep this body still, in a sleep mode.
  26988. * @returns the physics imposter
  26989. */
  26990. sleep(): PhysicsImpostor;
  26991. /**
  26992. * Wake the body up.
  26993. * @returns The physics imposter
  26994. */
  26995. wakeUp(): PhysicsImpostor;
  26996. /**
  26997. * Clones the physics imposter
  26998. * @param newObject The physics imposter clones to this physics-enabled object
  26999. * @returns A nullable physics imposter
  27000. */
  27001. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27002. /**
  27003. * Disposes the physics imposter
  27004. */
  27005. dispose(): void;
  27006. /**
  27007. * Sets the delta position
  27008. * @param position The delta position amount
  27009. */
  27010. setDeltaPosition(position: Vector3): void;
  27011. /**
  27012. * Sets the delta rotation
  27013. * @param rotation The delta rotation amount
  27014. */
  27015. setDeltaRotation(rotation: Quaternion): void;
  27016. /**
  27017. * Gets the box size of the physics imposter and stores the result in the input parameter
  27018. * @param result Stores the box size
  27019. * @returns The physics imposter
  27020. */
  27021. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27022. /**
  27023. * Gets the radius of the physics imposter
  27024. * @returns Radius of the physics imposter
  27025. */
  27026. getRadius(): number;
  27027. /**
  27028. * Sync a bone with this impostor
  27029. * @param bone The bone to sync to the impostor.
  27030. * @param boneMesh The mesh that the bone is influencing.
  27031. * @param jointPivot The pivot of the joint / bone in local space.
  27032. * @param distToJoint Optional distance from the impostor to the joint.
  27033. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27034. */
  27035. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27036. /**
  27037. * Sync impostor to a bone
  27038. * @param bone The bone that the impostor will be synced to.
  27039. * @param boneMesh The mesh that the bone is influencing.
  27040. * @param jointPivot The pivot of the joint / bone in local space.
  27041. * @param distToJoint Optional distance from the impostor to the joint.
  27042. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27043. * @param boneAxis Optional vector3 axis the bone is aligned with
  27044. */
  27045. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27046. /**
  27047. * No-Imposter type
  27048. */
  27049. static NoImpostor: number;
  27050. /**
  27051. * Sphere-Imposter type
  27052. */
  27053. static SphereImpostor: number;
  27054. /**
  27055. * Box-Imposter type
  27056. */
  27057. static BoxImpostor: number;
  27058. /**
  27059. * Plane-Imposter type
  27060. */
  27061. static PlaneImpostor: number;
  27062. /**
  27063. * Mesh-imposter type
  27064. */
  27065. static MeshImpostor: number;
  27066. /**
  27067. * Capsule-Impostor type (Ammo.js plugin only)
  27068. */
  27069. static CapsuleImpostor: number;
  27070. /**
  27071. * Cylinder-Imposter type
  27072. */
  27073. static CylinderImpostor: number;
  27074. /**
  27075. * Particle-Imposter type
  27076. */
  27077. static ParticleImpostor: number;
  27078. /**
  27079. * Heightmap-Imposter type
  27080. */
  27081. static HeightmapImpostor: number;
  27082. /**
  27083. * ConvexHull-Impostor type (Ammo.js plugin only)
  27084. */
  27085. static ConvexHullImpostor: number;
  27086. /**
  27087. * Custom-Imposter type (Ammo.js plugin only)
  27088. */
  27089. static CustomImpostor: number;
  27090. /**
  27091. * Rope-Imposter type
  27092. */
  27093. static RopeImpostor: number;
  27094. /**
  27095. * Cloth-Imposter type
  27096. */
  27097. static ClothImpostor: number;
  27098. /**
  27099. * Softbody-Imposter type
  27100. */
  27101. static SoftbodyImpostor: number;
  27102. }
  27103. }
  27104. declare module BABYLON {
  27105. /**
  27106. * @hidden
  27107. **/
  27108. export class _CreationDataStorage {
  27109. closePath?: boolean;
  27110. closeArray?: boolean;
  27111. idx: number[];
  27112. dashSize: number;
  27113. gapSize: number;
  27114. path3D: Path3D;
  27115. pathArray: Vector3[][];
  27116. arc: number;
  27117. radius: number;
  27118. cap: number;
  27119. tessellation: number;
  27120. }
  27121. /**
  27122. * @hidden
  27123. **/
  27124. class _InstanceDataStorage {
  27125. visibleInstances: any;
  27126. batchCache: _InstancesBatch;
  27127. instancesBufferSize: number;
  27128. instancesBuffer: Nullable<Buffer>;
  27129. instancesData: Float32Array;
  27130. overridenInstanceCount: number;
  27131. isFrozen: boolean;
  27132. previousBatch: Nullable<_InstancesBatch>;
  27133. hardwareInstancedRendering: boolean;
  27134. sideOrientation: number;
  27135. manualUpdate: boolean;
  27136. }
  27137. /**
  27138. * @hidden
  27139. **/
  27140. export class _InstancesBatch {
  27141. mustReturn: boolean;
  27142. visibleInstances: Nullable<InstancedMesh[]>[];
  27143. renderSelf: boolean[];
  27144. hardwareInstancedRendering: boolean[];
  27145. }
  27146. /**
  27147. * Class used to represent renderable models
  27148. */
  27149. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27150. /**
  27151. * Mesh side orientation : usually the external or front surface
  27152. */
  27153. static readonly FRONTSIDE: number;
  27154. /**
  27155. * Mesh side orientation : usually the internal or back surface
  27156. */
  27157. static readonly BACKSIDE: number;
  27158. /**
  27159. * Mesh side orientation : both internal and external or front and back surfaces
  27160. */
  27161. static readonly DOUBLESIDE: number;
  27162. /**
  27163. * Mesh side orientation : by default, `FRONTSIDE`
  27164. */
  27165. static readonly DEFAULTSIDE: number;
  27166. /**
  27167. * Mesh cap setting : no cap
  27168. */
  27169. static readonly NO_CAP: number;
  27170. /**
  27171. * Mesh cap setting : one cap at the beginning of the mesh
  27172. */
  27173. static readonly CAP_START: number;
  27174. /**
  27175. * Mesh cap setting : one cap at the end of the mesh
  27176. */
  27177. static readonly CAP_END: number;
  27178. /**
  27179. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27180. */
  27181. static readonly CAP_ALL: number;
  27182. /**
  27183. * Mesh pattern setting : no flip or rotate
  27184. */
  27185. static readonly NO_FLIP: number;
  27186. /**
  27187. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27188. */
  27189. static readonly FLIP_TILE: number;
  27190. /**
  27191. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27192. */
  27193. static readonly ROTATE_TILE: number;
  27194. /**
  27195. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27196. */
  27197. static readonly FLIP_ROW: number;
  27198. /**
  27199. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27200. */
  27201. static readonly ROTATE_ROW: number;
  27202. /**
  27203. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27204. */
  27205. static readonly FLIP_N_ROTATE_TILE: number;
  27206. /**
  27207. * Mesh pattern setting : rotate pattern and rotate
  27208. */
  27209. static readonly FLIP_N_ROTATE_ROW: number;
  27210. /**
  27211. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27212. */
  27213. static readonly CENTER: number;
  27214. /**
  27215. * Mesh tile positioning : part tiles on left
  27216. */
  27217. static readonly LEFT: number;
  27218. /**
  27219. * Mesh tile positioning : part tiles on right
  27220. */
  27221. static readonly RIGHT: number;
  27222. /**
  27223. * Mesh tile positioning : part tiles on top
  27224. */
  27225. static readonly TOP: number;
  27226. /**
  27227. * Mesh tile positioning : part tiles on bottom
  27228. */
  27229. static readonly BOTTOM: number;
  27230. /**
  27231. * Gets the default side orientation.
  27232. * @param orientation the orientation to value to attempt to get
  27233. * @returns the default orientation
  27234. * @hidden
  27235. */
  27236. static _GetDefaultSideOrientation(orientation?: number): number;
  27237. private _internalMeshDataInfo;
  27238. /**
  27239. * An event triggered before rendering the mesh
  27240. */
  27241. get onBeforeRenderObservable(): Observable<Mesh>;
  27242. /**
  27243. * An event triggered before binding the mesh
  27244. */
  27245. get onBeforeBindObservable(): Observable<Mesh>;
  27246. /**
  27247. * An event triggered after rendering the mesh
  27248. */
  27249. get onAfterRenderObservable(): Observable<Mesh>;
  27250. /**
  27251. * An event triggered before drawing the mesh
  27252. */
  27253. get onBeforeDrawObservable(): Observable<Mesh>;
  27254. private _onBeforeDrawObserver;
  27255. /**
  27256. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27257. */
  27258. set onBeforeDraw(callback: () => void);
  27259. get hasInstances(): boolean;
  27260. /**
  27261. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27262. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27263. */
  27264. delayLoadState: number;
  27265. /**
  27266. * Gets the list of instances created from this mesh
  27267. * it is not supposed to be modified manually.
  27268. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27269. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27270. */
  27271. instances: InstancedMesh[];
  27272. /**
  27273. * Gets the file containing delay loading data for this mesh
  27274. */
  27275. delayLoadingFile: string;
  27276. /** @hidden */
  27277. _binaryInfo: any;
  27278. /**
  27279. * User defined function used to change how LOD level selection is done
  27280. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27281. */
  27282. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27283. /**
  27284. * Gets or sets the morph target manager
  27285. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27286. */
  27287. get morphTargetManager(): Nullable<MorphTargetManager>;
  27288. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27289. /** @hidden */
  27290. _creationDataStorage: Nullable<_CreationDataStorage>;
  27291. /** @hidden */
  27292. _geometry: Nullable<Geometry>;
  27293. /** @hidden */
  27294. _delayInfo: Array<string>;
  27295. /** @hidden */
  27296. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27297. /** @hidden */
  27298. _instanceDataStorage: _InstanceDataStorage;
  27299. private _effectiveMaterial;
  27300. /** @hidden */
  27301. _shouldGenerateFlatShading: boolean;
  27302. /** @hidden */
  27303. _originalBuilderSideOrientation: number;
  27304. /**
  27305. * Use this property to change the original side orientation defined at construction time
  27306. */
  27307. overrideMaterialSideOrientation: Nullable<number>;
  27308. /**
  27309. * Gets the source mesh (the one used to clone this one from)
  27310. */
  27311. get source(): Nullable<Mesh>;
  27312. /**
  27313. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27314. */
  27315. get isUnIndexed(): boolean;
  27316. set isUnIndexed(value: boolean);
  27317. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27318. get worldMatrixInstancedBuffer(): Float32Array;
  27319. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27320. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27321. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27322. /**
  27323. * @constructor
  27324. * @param name The value used by scene.getMeshByName() to do a lookup.
  27325. * @param scene The scene to add this mesh to.
  27326. * @param parent The parent of this mesh, if it has one
  27327. * @param source An optional Mesh from which geometry is shared, cloned.
  27328. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27329. * When false, achieved by calling a clone(), also passing False.
  27330. * This will make creation of children, recursive.
  27331. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27332. */
  27333. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27334. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27335. doNotInstantiate: boolean;
  27336. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27337. /**
  27338. * Gets the class name
  27339. * @returns the string "Mesh".
  27340. */
  27341. getClassName(): string;
  27342. /** @hidden */
  27343. get _isMesh(): boolean;
  27344. /**
  27345. * Returns a description of this mesh
  27346. * @param fullDetails define if full details about this mesh must be used
  27347. * @returns a descriptive string representing this mesh
  27348. */
  27349. toString(fullDetails?: boolean): string;
  27350. /** @hidden */
  27351. _unBindEffect(): void;
  27352. /**
  27353. * Gets a boolean indicating if this mesh has LOD
  27354. */
  27355. get hasLODLevels(): boolean;
  27356. /**
  27357. * Gets the list of MeshLODLevel associated with the current mesh
  27358. * @returns an array of MeshLODLevel
  27359. */
  27360. getLODLevels(): MeshLODLevel[];
  27361. private _sortLODLevels;
  27362. /**
  27363. * Add a mesh as LOD level triggered at the given distance.
  27364. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27365. * @param distance The distance from the center of the object to show this level
  27366. * @param mesh The mesh to be added as LOD level (can be null)
  27367. * @return This mesh (for chaining)
  27368. */
  27369. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27370. /**
  27371. * Returns the LOD level mesh at the passed distance or null if not found.
  27372. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27373. * @param distance The distance from the center of the object to show this level
  27374. * @returns a Mesh or `null`
  27375. */
  27376. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27377. /**
  27378. * Remove a mesh from the LOD array
  27379. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27380. * @param mesh defines the mesh to be removed
  27381. * @return This mesh (for chaining)
  27382. */
  27383. removeLODLevel(mesh: Mesh): Mesh;
  27384. /**
  27385. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27386. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27387. * @param camera defines the camera to use to compute distance
  27388. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27389. * @return This mesh (for chaining)
  27390. */
  27391. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27392. /**
  27393. * Gets the mesh internal Geometry object
  27394. */
  27395. get geometry(): Nullable<Geometry>;
  27396. /**
  27397. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27398. * @returns the total number of vertices
  27399. */
  27400. getTotalVertices(): number;
  27401. /**
  27402. * Returns the content of an associated vertex buffer
  27403. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27404. * - VertexBuffer.PositionKind
  27405. * - VertexBuffer.UVKind
  27406. * - VertexBuffer.UV2Kind
  27407. * - VertexBuffer.UV3Kind
  27408. * - VertexBuffer.UV4Kind
  27409. * - VertexBuffer.UV5Kind
  27410. * - VertexBuffer.UV6Kind
  27411. * - VertexBuffer.ColorKind
  27412. * - VertexBuffer.MatricesIndicesKind
  27413. * - VertexBuffer.MatricesIndicesExtraKind
  27414. * - VertexBuffer.MatricesWeightsKind
  27415. * - VertexBuffer.MatricesWeightsExtraKind
  27416. * @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
  27417. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27418. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27419. */
  27420. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27421. /**
  27422. * Returns the mesh VertexBuffer object from the requested `kind`
  27423. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27424. * - VertexBuffer.PositionKind
  27425. * - VertexBuffer.NormalKind
  27426. * - VertexBuffer.UVKind
  27427. * - VertexBuffer.UV2Kind
  27428. * - VertexBuffer.UV3Kind
  27429. * - VertexBuffer.UV4Kind
  27430. * - VertexBuffer.UV5Kind
  27431. * - VertexBuffer.UV6Kind
  27432. * - VertexBuffer.ColorKind
  27433. * - VertexBuffer.MatricesIndicesKind
  27434. * - VertexBuffer.MatricesIndicesExtraKind
  27435. * - VertexBuffer.MatricesWeightsKind
  27436. * - VertexBuffer.MatricesWeightsExtraKind
  27437. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27438. */
  27439. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27440. /**
  27441. * Tests if a specific vertex buffer is associated with this mesh
  27442. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27443. * - VertexBuffer.PositionKind
  27444. * - VertexBuffer.NormalKind
  27445. * - VertexBuffer.UVKind
  27446. * - VertexBuffer.UV2Kind
  27447. * - VertexBuffer.UV3Kind
  27448. * - VertexBuffer.UV4Kind
  27449. * - VertexBuffer.UV5Kind
  27450. * - VertexBuffer.UV6Kind
  27451. * - VertexBuffer.ColorKind
  27452. * - VertexBuffer.MatricesIndicesKind
  27453. * - VertexBuffer.MatricesIndicesExtraKind
  27454. * - VertexBuffer.MatricesWeightsKind
  27455. * - VertexBuffer.MatricesWeightsExtraKind
  27456. * @returns a boolean
  27457. */
  27458. isVerticesDataPresent(kind: string): boolean;
  27459. /**
  27460. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27461. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27462. * - VertexBuffer.PositionKind
  27463. * - VertexBuffer.UVKind
  27464. * - VertexBuffer.UV2Kind
  27465. * - VertexBuffer.UV3Kind
  27466. * - VertexBuffer.UV4Kind
  27467. * - VertexBuffer.UV5Kind
  27468. * - VertexBuffer.UV6Kind
  27469. * - VertexBuffer.ColorKind
  27470. * - VertexBuffer.MatricesIndicesKind
  27471. * - VertexBuffer.MatricesIndicesExtraKind
  27472. * - VertexBuffer.MatricesWeightsKind
  27473. * - VertexBuffer.MatricesWeightsExtraKind
  27474. * @returns a boolean
  27475. */
  27476. isVertexBufferUpdatable(kind: string): boolean;
  27477. /**
  27478. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27479. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27480. * - VertexBuffer.PositionKind
  27481. * - VertexBuffer.NormalKind
  27482. * - VertexBuffer.UVKind
  27483. * - VertexBuffer.UV2Kind
  27484. * - VertexBuffer.UV3Kind
  27485. * - VertexBuffer.UV4Kind
  27486. * - VertexBuffer.UV5Kind
  27487. * - VertexBuffer.UV6Kind
  27488. * - VertexBuffer.ColorKind
  27489. * - VertexBuffer.MatricesIndicesKind
  27490. * - VertexBuffer.MatricesIndicesExtraKind
  27491. * - VertexBuffer.MatricesWeightsKind
  27492. * - VertexBuffer.MatricesWeightsExtraKind
  27493. * @returns an array of strings
  27494. */
  27495. getVerticesDataKinds(): string[];
  27496. /**
  27497. * Returns a positive integer : the total number of indices in this mesh geometry.
  27498. * @returns the numner of indices or zero if the mesh has no geometry.
  27499. */
  27500. getTotalIndices(): number;
  27501. /**
  27502. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27503. * @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.
  27504. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27505. * @returns the indices array or an empty array if the mesh has no geometry
  27506. */
  27507. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27508. get isBlocked(): boolean;
  27509. /**
  27510. * Determine if the current mesh is ready to be rendered
  27511. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27512. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27513. * @returns true if all associated assets are ready (material, textures, shaders)
  27514. */
  27515. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27516. /**
  27517. * 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.
  27518. */
  27519. get areNormalsFrozen(): boolean;
  27520. /**
  27521. * 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.
  27522. * @returns the current mesh
  27523. */
  27524. freezeNormals(): Mesh;
  27525. /**
  27526. * 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
  27527. * @returns the current mesh
  27528. */
  27529. unfreezeNormals(): Mesh;
  27530. /**
  27531. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27532. */
  27533. set overridenInstanceCount(count: number);
  27534. /** @hidden */
  27535. _preActivate(): Mesh;
  27536. /** @hidden */
  27537. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27538. /** @hidden */
  27539. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27540. /**
  27541. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27542. * This means the mesh underlying bounding box and sphere are recomputed.
  27543. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27544. * @returns the current mesh
  27545. */
  27546. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27547. /** @hidden */
  27548. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27549. /**
  27550. * This function will subdivide the mesh into multiple submeshes
  27551. * @param count defines the expected number of submeshes
  27552. */
  27553. subdivide(count: number): void;
  27554. /**
  27555. * Copy a FloatArray into a specific associated vertex buffer
  27556. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27557. * - VertexBuffer.PositionKind
  27558. * - VertexBuffer.UVKind
  27559. * - VertexBuffer.UV2Kind
  27560. * - VertexBuffer.UV3Kind
  27561. * - VertexBuffer.UV4Kind
  27562. * - VertexBuffer.UV5Kind
  27563. * - VertexBuffer.UV6Kind
  27564. * - VertexBuffer.ColorKind
  27565. * - VertexBuffer.MatricesIndicesKind
  27566. * - VertexBuffer.MatricesIndicesExtraKind
  27567. * - VertexBuffer.MatricesWeightsKind
  27568. * - VertexBuffer.MatricesWeightsExtraKind
  27569. * @param data defines the data source
  27570. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27571. * @param stride defines the data stride size (can be null)
  27572. * @returns the current mesh
  27573. */
  27574. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27575. /**
  27576. * Delete a vertex buffer associated with this mesh
  27577. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27578. * - VertexBuffer.PositionKind
  27579. * - VertexBuffer.UVKind
  27580. * - VertexBuffer.UV2Kind
  27581. * - VertexBuffer.UV3Kind
  27582. * - VertexBuffer.UV4Kind
  27583. * - VertexBuffer.UV5Kind
  27584. * - VertexBuffer.UV6Kind
  27585. * - VertexBuffer.ColorKind
  27586. * - VertexBuffer.MatricesIndicesKind
  27587. * - VertexBuffer.MatricesIndicesExtraKind
  27588. * - VertexBuffer.MatricesWeightsKind
  27589. * - VertexBuffer.MatricesWeightsExtraKind
  27590. */
  27591. removeVerticesData(kind: string): void;
  27592. /**
  27593. * Flags an associated vertex buffer as updatable
  27594. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27595. * - VertexBuffer.PositionKind
  27596. * - VertexBuffer.UVKind
  27597. * - VertexBuffer.UV2Kind
  27598. * - VertexBuffer.UV3Kind
  27599. * - VertexBuffer.UV4Kind
  27600. * - VertexBuffer.UV5Kind
  27601. * - VertexBuffer.UV6Kind
  27602. * - VertexBuffer.ColorKind
  27603. * - VertexBuffer.MatricesIndicesKind
  27604. * - VertexBuffer.MatricesIndicesExtraKind
  27605. * - VertexBuffer.MatricesWeightsKind
  27606. * - VertexBuffer.MatricesWeightsExtraKind
  27607. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27608. */
  27609. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27610. /**
  27611. * Sets the mesh global Vertex Buffer
  27612. * @param buffer defines the buffer to use
  27613. * @returns the current mesh
  27614. */
  27615. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27616. /**
  27617. * Update a specific associated vertex buffer
  27618. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27619. * - VertexBuffer.PositionKind
  27620. * - VertexBuffer.UVKind
  27621. * - VertexBuffer.UV2Kind
  27622. * - VertexBuffer.UV3Kind
  27623. * - VertexBuffer.UV4Kind
  27624. * - VertexBuffer.UV5Kind
  27625. * - VertexBuffer.UV6Kind
  27626. * - VertexBuffer.ColorKind
  27627. * - VertexBuffer.MatricesIndicesKind
  27628. * - VertexBuffer.MatricesIndicesExtraKind
  27629. * - VertexBuffer.MatricesWeightsKind
  27630. * - VertexBuffer.MatricesWeightsExtraKind
  27631. * @param data defines the data source
  27632. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27633. * @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)
  27634. * @returns the current mesh
  27635. */
  27636. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27637. /**
  27638. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27639. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27640. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27641. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27642. * @returns the current mesh
  27643. */
  27644. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27645. /**
  27646. * Creates a un-shared specific occurence of the geometry for the mesh.
  27647. * @returns the current mesh
  27648. */
  27649. makeGeometryUnique(): Mesh;
  27650. /**
  27651. * Set the index buffer of this mesh
  27652. * @param indices defines the source data
  27653. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27654. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27655. * @returns the current mesh
  27656. */
  27657. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27658. /**
  27659. * Update the current index buffer
  27660. * @param indices defines the source data
  27661. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27662. * @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)
  27663. * @returns the current mesh
  27664. */
  27665. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27666. /**
  27667. * Invert the geometry to move from a right handed system to a left handed one.
  27668. * @returns the current mesh
  27669. */
  27670. toLeftHanded(): Mesh;
  27671. /** @hidden */
  27672. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27673. /** @hidden */
  27674. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27675. /**
  27676. * Registers for this mesh a javascript function called just before the rendering process
  27677. * @param func defines the function to call before rendering this mesh
  27678. * @returns the current mesh
  27679. */
  27680. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27681. /**
  27682. * Disposes a previously registered javascript function called before the rendering
  27683. * @param func defines the function to remove
  27684. * @returns the current mesh
  27685. */
  27686. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27687. /**
  27688. * Registers for this mesh a javascript function called just after the rendering is complete
  27689. * @param func defines the function to call after rendering this mesh
  27690. * @returns the current mesh
  27691. */
  27692. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27693. /**
  27694. * Disposes a previously registered javascript function called after the rendering.
  27695. * @param func defines the function to remove
  27696. * @returns the current mesh
  27697. */
  27698. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27699. /** @hidden */
  27700. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27701. /** @hidden */
  27702. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27703. /** @hidden */
  27704. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27705. /** @hidden */
  27706. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27707. /** @hidden */
  27708. _rebuild(): void;
  27709. /** @hidden */
  27710. _freeze(): void;
  27711. /** @hidden */
  27712. _unFreeze(): void;
  27713. /**
  27714. * 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
  27715. * @param subMesh defines the subMesh to render
  27716. * @param enableAlphaMode defines if alpha mode can be changed
  27717. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27718. * @returns the current mesh
  27719. */
  27720. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27721. private _onBeforeDraw;
  27722. /**
  27723. * Renormalize the mesh and patch it up if there are no weights
  27724. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27725. * However in the case of zero weights then we set just a single influence to 1.
  27726. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27727. */
  27728. cleanMatrixWeights(): void;
  27729. private normalizeSkinFourWeights;
  27730. private normalizeSkinWeightsAndExtra;
  27731. /**
  27732. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27733. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27734. * the user know there was an issue with importing the mesh
  27735. * @returns a validation object with skinned, valid and report string
  27736. */
  27737. validateSkinning(): {
  27738. skinned: boolean;
  27739. valid: boolean;
  27740. report: string;
  27741. };
  27742. /** @hidden */
  27743. _checkDelayState(): Mesh;
  27744. private _queueLoad;
  27745. /**
  27746. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27747. * A mesh is in the frustum if its bounding box intersects the frustum
  27748. * @param frustumPlanes defines the frustum to test
  27749. * @returns true if the mesh is in the frustum planes
  27750. */
  27751. isInFrustum(frustumPlanes: Plane[]): boolean;
  27752. /**
  27753. * Sets the mesh material by the material or multiMaterial `id` property
  27754. * @param id is a string identifying the material or the multiMaterial
  27755. * @returns the current mesh
  27756. */
  27757. setMaterialByID(id: string): Mesh;
  27758. /**
  27759. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27760. * @returns an array of IAnimatable
  27761. */
  27762. getAnimatables(): IAnimatable[];
  27763. /**
  27764. * Modifies the mesh geometry according to the passed transformation matrix.
  27765. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27766. * The mesh normals are modified using the same transformation.
  27767. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27768. * @param transform defines the transform matrix to use
  27769. * @see http://doc.babylonjs.com/resources/baking_transformations
  27770. * @returns the current mesh
  27771. */
  27772. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27773. /**
  27774. * Modifies the mesh geometry according to its own current World Matrix.
  27775. * The mesh World Matrix is then reset.
  27776. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27777. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27778. * @see http://doc.babylonjs.com/resources/baking_transformations
  27779. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27780. * @returns the current mesh
  27781. */
  27782. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27783. /** @hidden */
  27784. get _positions(): Nullable<Vector3[]>;
  27785. /** @hidden */
  27786. _resetPointsArrayCache(): Mesh;
  27787. /** @hidden */
  27788. _generatePointsArray(): boolean;
  27789. /**
  27790. * Returns a new Mesh object generated from the current mesh properties.
  27791. * This method must not get confused with createInstance()
  27792. * @param name is a string, the name given to the new mesh
  27793. * @param newParent can be any Node object (default `null`)
  27794. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27795. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27796. * @returns a new mesh
  27797. */
  27798. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27799. /**
  27800. * Releases resources associated with this mesh.
  27801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27803. */
  27804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27805. /** @hidden */
  27806. _disposeInstanceSpecificData(): void;
  27807. /**
  27808. * Modifies the mesh geometry according to a displacement map.
  27809. * 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.
  27810. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27811. * @param url is a string, the URL from the image file is to be downloaded.
  27812. * @param minHeight is the lower limit of the displacement.
  27813. * @param maxHeight is the upper limit of the displacement.
  27814. * @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.
  27815. * @param uvOffset is an optional vector2 used to offset UV.
  27816. * @param uvScale is an optional vector2 used to scale UV.
  27817. * @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.
  27818. * @returns the Mesh.
  27819. */
  27820. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27821. /**
  27822. * Modifies the mesh geometry according to a displacementMap buffer.
  27823. * 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.
  27824. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27825. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27826. * @param heightMapWidth is the width of the buffer image.
  27827. * @param heightMapHeight is the height of the buffer image.
  27828. * @param minHeight is the lower limit of the displacement.
  27829. * @param maxHeight is the upper limit of the displacement.
  27830. * @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.
  27831. * @param uvOffset is an optional vector2 used to offset UV.
  27832. * @param uvScale is an optional vector2 used to scale UV.
  27833. * @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.
  27834. * @returns the Mesh.
  27835. */
  27836. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27837. /**
  27838. * Modify the mesh to get a flat shading rendering.
  27839. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27840. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27841. * @returns current mesh
  27842. */
  27843. convertToFlatShadedMesh(): Mesh;
  27844. /**
  27845. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27846. * In other words, more vertices, no more indices and a single bigger VBO.
  27847. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27848. * @returns current mesh
  27849. */
  27850. convertToUnIndexedMesh(): Mesh;
  27851. /**
  27852. * Inverses facet orientations.
  27853. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27854. * @param flipNormals will also inverts the normals
  27855. * @returns current mesh
  27856. */
  27857. flipFaces(flipNormals?: boolean): Mesh;
  27858. /**
  27859. * Increase the number of facets and hence vertices in a mesh
  27860. * Vertex normals are interpolated from existing vertex normals
  27861. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27862. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27863. */
  27864. increaseVertices(numberPerEdge: number): void;
  27865. /**
  27866. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27867. * This will undo any application of covertToFlatShadedMesh
  27868. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27869. */
  27870. forceSharedVertices(): void;
  27871. /** @hidden */
  27872. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27873. /** @hidden */
  27874. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27875. /**
  27876. * Creates a new InstancedMesh object from the mesh model.
  27877. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27878. * @param name defines the name of the new instance
  27879. * @returns a new InstancedMesh
  27880. */
  27881. createInstance(name: string): InstancedMesh;
  27882. /**
  27883. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27884. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27885. * @returns the current mesh
  27886. */
  27887. synchronizeInstances(): Mesh;
  27888. /**
  27889. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27890. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27891. * This should be used together with the simplification to avoid disappearing triangles.
  27892. * @param successCallback an optional success callback to be called after the optimization finished.
  27893. * @returns the current mesh
  27894. */
  27895. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27896. /**
  27897. * Serialize current mesh
  27898. * @param serializationObject defines the object which will receive the serialization data
  27899. */
  27900. serialize(serializationObject: any): void;
  27901. /** @hidden */
  27902. _syncGeometryWithMorphTargetManager(): void;
  27903. /** @hidden */
  27904. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27905. /**
  27906. * Returns a new Mesh object parsed from the source provided.
  27907. * @param parsedMesh is the source
  27908. * @param scene defines the hosting scene
  27909. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27910. * @returns a new Mesh
  27911. */
  27912. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27913. /**
  27914. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27915. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27916. * @param name defines the name of the mesh to create
  27917. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27918. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27919. * @param closePath creates a seam between the first and the last points of each path of the path array
  27920. * @param offset is taken in account only if the `pathArray` is containing a single path
  27921. * @param scene defines the hosting scene
  27922. * @param updatable defines if the mesh must be flagged as updatable
  27923. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27924. * @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)
  27925. * @returns a new Mesh
  27926. */
  27927. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27928. /**
  27929. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27930. * @param name defines the name of the mesh to create
  27931. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27932. * @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
  27933. * @param scene defines the hosting scene
  27934. * @param updatable defines if the mesh must be flagged as updatable
  27935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27936. * @returns a new Mesh
  27937. */
  27938. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27939. /**
  27940. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27941. * @param name defines the name of the mesh to create
  27942. * @param size sets the size (float) of each box side (default 1)
  27943. * @param scene defines the hosting scene
  27944. * @param updatable defines if the mesh must be flagged as updatable
  27945. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27946. * @returns a new Mesh
  27947. */
  27948. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27949. /**
  27950. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27951. * @param name defines the name of the mesh to create
  27952. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27953. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27954. * @param scene defines the hosting scene
  27955. * @param updatable defines if the mesh must be flagged as updatable
  27956. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27957. * @returns a new Mesh
  27958. */
  27959. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27960. /**
  27961. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  27962. * @param name defines the name of the mesh to create
  27963. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27964. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27965. * @param scene defines the hosting scene
  27966. * @returns a new Mesh
  27967. */
  27968. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  27969. /**
  27970. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27971. * @param name defines the name of the mesh to create
  27972. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27973. * @param diameterTop set the top cap diameter (floats, default 1)
  27974. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27975. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27976. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27977. * @param scene defines the hosting scene
  27978. * @param updatable defines if the mesh must be flagged as updatable
  27979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27980. * @returns a new Mesh
  27981. */
  27982. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27983. /**
  27984. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27985. * @param name defines the name of the mesh to create
  27986. * @param diameter sets the diameter size (float) of the torus (default 1)
  27987. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27988. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27989. * @param scene defines the hosting scene
  27990. * @param updatable defines if the mesh must be flagged as updatable
  27991. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27992. * @returns a new Mesh
  27993. */
  27994. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27995. /**
  27996. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27997. * @param name defines the name of the mesh to create
  27998. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27999. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28000. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28001. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28002. * @param p the number of windings on X axis (positive integers, default 2)
  28003. * @param q the number of windings on Y axis (positive integers, default 3)
  28004. * @param scene defines the hosting scene
  28005. * @param updatable defines if the mesh must be flagged as updatable
  28006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28007. * @returns a new Mesh
  28008. */
  28009. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28010. /**
  28011. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28012. * @param name defines the name of the mesh to create
  28013. * @param points is an array successive Vector3
  28014. * @param scene defines the hosting scene
  28015. * @param updatable defines if the mesh must be flagged as updatable
  28016. * @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).
  28017. * @returns a new Mesh
  28018. */
  28019. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28020. /**
  28021. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28022. * @param name defines the name of the mesh to create
  28023. * @param points is an array successive Vector3
  28024. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28025. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28026. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28027. * @param scene defines the hosting scene
  28028. * @param updatable defines if the mesh must be flagged as updatable
  28029. * @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)
  28030. * @returns a new Mesh
  28031. */
  28032. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28033. /**
  28034. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28035. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28036. * 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.
  28037. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28038. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28039. * Remember you can only change the shape positions, not their number when updating a polygon.
  28040. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28041. * @param name defines the name of the mesh to create
  28042. * @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
  28043. * @param scene defines the hosting scene
  28044. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28045. * @param updatable defines if the mesh must be flagged as updatable
  28046. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28047. * @param earcutInjection can be used to inject your own earcut reference
  28048. * @returns a new Mesh
  28049. */
  28050. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28051. /**
  28052. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28053. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28054. * @param name defines the name of the mesh to create
  28055. * @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
  28056. * @param depth defines the height of extrusion
  28057. * @param scene defines the hosting scene
  28058. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28059. * @param updatable defines if the mesh must be flagged as updatable
  28060. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28061. * @param earcutInjection can be used to inject your own earcut reference
  28062. * @returns a new Mesh
  28063. */
  28064. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28065. /**
  28066. * Creates an extruded shape mesh.
  28067. * 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
  28068. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28069. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28070. * @param name defines the name of the mesh to create
  28071. * @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
  28072. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28073. * @param scale is the value to scale the shape
  28074. * @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
  28075. * @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
  28076. * @param scene defines the hosting scene
  28077. * @param updatable defines if the mesh must be flagged as updatable
  28078. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28079. * @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)
  28080. * @returns a new Mesh
  28081. */
  28082. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28083. /**
  28084. * Creates an custom extruded shape mesh.
  28085. * The custom extrusion is a parametric shape.
  28086. * It has no predefined shape. Its final shape will depend on the input parameters.
  28087. * Please consider using the same method from the MeshBuilder class instead
  28088. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28089. * @param name defines the name of the mesh to create
  28090. * @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
  28091. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28092. * @param scaleFunction is a custom Javascript function called on each path point
  28093. * @param rotationFunction is a custom Javascript function called on each path point
  28094. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28095. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28096. * @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
  28097. * @param scene defines the hosting scene
  28098. * @param updatable defines if the mesh must be flagged as updatable
  28099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28100. * @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)
  28101. * @returns a new Mesh
  28102. */
  28103. 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;
  28104. /**
  28105. * Creates lathe mesh.
  28106. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28107. * Please consider using the same method from the MeshBuilder class instead
  28108. * @param name defines the name of the mesh to create
  28109. * @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
  28110. * @param radius is the radius value of the lathe
  28111. * @param tessellation is the side number of the lathe.
  28112. * @param scene defines the hosting scene
  28113. * @param updatable defines if the mesh must be flagged as updatable
  28114. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28115. * @returns a new Mesh
  28116. */
  28117. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28118. /**
  28119. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28120. * @param name defines the name of the mesh to create
  28121. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28122. * @param scene defines the hosting scene
  28123. * @param updatable defines if the mesh must be flagged as updatable
  28124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28125. * @returns a new Mesh
  28126. */
  28127. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28128. /**
  28129. * Creates a ground mesh.
  28130. * Please consider using the same method from the MeshBuilder class instead
  28131. * @param name defines the name of the mesh to create
  28132. * @param width set the width of the ground
  28133. * @param height set the height of the ground
  28134. * @param subdivisions sets the number of subdivisions per side
  28135. * @param scene defines the hosting scene
  28136. * @param updatable defines if the mesh must be flagged as updatable
  28137. * @returns a new Mesh
  28138. */
  28139. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28140. /**
  28141. * Creates a tiled ground mesh.
  28142. * Please consider using the same method from the MeshBuilder class instead
  28143. * @param name defines the name of the mesh to create
  28144. * @param xmin set the ground minimum X coordinate
  28145. * @param zmin set the ground minimum Y coordinate
  28146. * @param xmax set the ground maximum X coordinate
  28147. * @param zmax set the ground maximum Z coordinate
  28148. * @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
  28149. * @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
  28150. * @param scene defines the hosting scene
  28151. * @param updatable defines if the mesh must be flagged as updatable
  28152. * @returns a new Mesh
  28153. */
  28154. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28155. w: number;
  28156. h: number;
  28157. }, precision: {
  28158. w: number;
  28159. h: number;
  28160. }, scene: Scene, updatable?: boolean): Mesh;
  28161. /**
  28162. * Creates a ground mesh from a height map.
  28163. * Please consider using the same method from the MeshBuilder class instead
  28164. * @see http://doc.babylonjs.com/babylon101/height_map
  28165. * @param name defines the name of the mesh to create
  28166. * @param url sets the URL of the height map image resource
  28167. * @param width set the ground width size
  28168. * @param height set the ground height size
  28169. * @param subdivisions sets the number of subdivision per side
  28170. * @param minHeight is the minimum altitude on the ground
  28171. * @param maxHeight is the maximum altitude on the ground
  28172. * @param scene defines the hosting scene
  28173. * @param updatable defines if the mesh must be flagged as updatable
  28174. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28175. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28176. * @returns a new Mesh
  28177. */
  28178. 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;
  28179. /**
  28180. * Creates a tube mesh.
  28181. * The tube is a parametric shape.
  28182. * It has no predefined shape. Its final shape will depend on the input parameters.
  28183. * Please consider using the same method from the MeshBuilder class instead
  28184. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28185. * @param name defines the name of the mesh to create
  28186. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28187. * @param radius sets the tube radius size
  28188. * @param tessellation is the number of sides on the tubular surface
  28189. * @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
  28190. * @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
  28191. * @param scene defines the hosting scene
  28192. * @param updatable defines if the mesh must be flagged as updatable
  28193. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28194. * @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)
  28195. * @returns a new Mesh
  28196. */
  28197. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28198. (i: number, distance: number): number;
  28199. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28200. /**
  28201. * Creates a polyhedron mesh.
  28202. * Please consider using the same method from the MeshBuilder class instead.
  28203. * * 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
  28204. * * The parameter `size` (positive float, default 1) sets the polygon size
  28205. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28206. * * 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`
  28207. * * 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
  28208. * * 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)`)
  28209. * * 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
  28210. * * 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
  28211. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28212. * * 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
  28213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28214. * @param name defines the name of the mesh to create
  28215. * @param options defines the options used to create the mesh
  28216. * @param scene defines the hosting scene
  28217. * @returns a new Mesh
  28218. */
  28219. static CreatePolyhedron(name: string, options: {
  28220. type?: number;
  28221. size?: number;
  28222. sizeX?: number;
  28223. sizeY?: number;
  28224. sizeZ?: number;
  28225. custom?: any;
  28226. faceUV?: Vector4[];
  28227. faceColors?: Color4[];
  28228. updatable?: boolean;
  28229. sideOrientation?: number;
  28230. }, scene: Scene): Mesh;
  28231. /**
  28232. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28233. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28234. * * 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`)
  28235. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28236. * * 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
  28237. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28238. * * 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
  28239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28240. * @param name defines the name of the mesh
  28241. * @param options defines the options used to create the mesh
  28242. * @param scene defines the hosting scene
  28243. * @returns a new Mesh
  28244. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28245. */
  28246. static CreateIcoSphere(name: string, options: {
  28247. radius?: number;
  28248. flat?: boolean;
  28249. subdivisions?: number;
  28250. sideOrientation?: number;
  28251. updatable?: boolean;
  28252. }, scene: Scene): Mesh;
  28253. /**
  28254. * Creates a decal mesh.
  28255. * Please consider using the same method from the MeshBuilder class instead.
  28256. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28257. * @param name defines the name of the mesh
  28258. * @param sourceMesh defines the mesh receiving the decal
  28259. * @param position sets the position of the decal in world coordinates
  28260. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28261. * @param size sets the decal scaling
  28262. * @param angle sets the angle to rotate the decal
  28263. * @returns a new Mesh
  28264. */
  28265. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28266. /**
  28267. * Prepare internal position array for software CPU skinning
  28268. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28269. */
  28270. setPositionsForCPUSkinning(): Float32Array;
  28271. /**
  28272. * Prepare internal normal array for software CPU skinning
  28273. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28274. */
  28275. setNormalsForCPUSkinning(): Float32Array;
  28276. /**
  28277. * Updates the vertex buffer by applying transformation from the bones
  28278. * @param skeleton defines the skeleton to apply to current mesh
  28279. * @returns the current mesh
  28280. */
  28281. applySkeleton(skeleton: Skeleton): Mesh;
  28282. /**
  28283. * 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
  28284. * @param meshes defines the list of meshes to scan
  28285. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28286. */
  28287. static MinMax(meshes: AbstractMesh[]): {
  28288. min: Vector3;
  28289. max: Vector3;
  28290. };
  28291. /**
  28292. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28293. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28294. * @returns a vector3
  28295. */
  28296. static Center(meshesOrMinMaxVector: {
  28297. min: Vector3;
  28298. max: Vector3;
  28299. } | AbstractMesh[]): Vector3;
  28300. /**
  28301. * Merge the array of meshes into a single mesh for performance reasons.
  28302. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28303. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28304. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28305. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28306. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28307. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28308. * @returns a new mesh
  28309. */
  28310. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28311. /** @hidden */
  28312. addInstance(instance: InstancedMesh): void;
  28313. /** @hidden */
  28314. removeInstance(instance: InstancedMesh): void;
  28315. }
  28316. }
  28317. declare module BABYLON {
  28318. /**
  28319. * This is the base class of all the camera used in the application.
  28320. * @see http://doc.babylonjs.com/features/cameras
  28321. */
  28322. export class Camera extends Node {
  28323. /** @hidden */
  28324. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28325. /**
  28326. * This is the default projection mode used by the cameras.
  28327. * It helps recreating a feeling of perspective and better appreciate depth.
  28328. * This is the best way to simulate real life cameras.
  28329. */
  28330. static readonly PERSPECTIVE_CAMERA: number;
  28331. /**
  28332. * This helps creating camera with an orthographic mode.
  28333. * 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.
  28334. */
  28335. static readonly ORTHOGRAPHIC_CAMERA: number;
  28336. /**
  28337. * This is the default FOV mode for perspective cameras.
  28338. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28339. */
  28340. static readonly FOVMODE_VERTICAL_FIXED: number;
  28341. /**
  28342. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28343. */
  28344. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28345. /**
  28346. * This specifies ther is no need for a camera rig.
  28347. * Basically only one eye is rendered corresponding to the camera.
  28348. */
  28349. static readonly RIG_MODE_NONE: number;
  28350. /**
  28351. * Simulates a camera Rig with one blue eye and one red eye.
  28352. * This can be use with 3d blue and red glasses.
  28353. */
  28354. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28355. /**
  28356. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28357. */
  28358. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28359. /**
  28360. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28361. */
  28362. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28363. /**
  28364. * Defines that both eyes of the camera will be rendered over under each other.
  28365. */
  28366. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28367. /**
  28368. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28369. */
  28370. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28371. /**
  28372. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28373. */
  28374. static readonly RIG_MODE_VR: number;
  28375. /**
  28376. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28377. */
  28378. static readonly RIG_MODE_WEBVR: number;
  28379. /**
  28380. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28381. */
  28382. static readonly RIG_MODE_CUSTOM: number;
  28383. /**
  28384. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28385. */
  28386. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28387. /**
  28388. * Define the input manager associated with the camera.
  28389. */
  28390. inputs: CameraInputsManager<Camera>;
  28391. /** @hidden */
  28392. _position: Vector3;
  28393. /**
  28394. * Define the current local position of the camera in the scene
  28395. */
  28396. get position(): Vector3;
  28397. set position(newPosition: Vector3);
  28398. /**
  28399. * The vector the camera should consider as up.
  28400. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28401. */
  28402. upVector: Vector3;
  28403. /**
  28404. * Define the current limit on the left side for an orthographic camera
  28405. * In scene unit
  28406. */
  28407. orthoLeft: Nullable<number>;
  28408. /**
  28409. * Define the current limit on the right side for an orthographic camera
  28410. * In scene unit
  28411. */
  28412. orthoRight: Nullable<number>;
  28413. /**
  28414. * Define the current limit on the bottom side for an orthographic camera
  28415. * In scene unit
  28416. */
  28417. orthoBottom: Nullable<number>;
  28418. /**
  28419. * Define the current limit on the top side for an orthographic camera
  28420. * In scene unit
  28421. */
  28422. orthoTop: Nullable<number>;
  28423. /**
  28424. * Field Of View is set in Radians. (default is 0.8)
  28425. */
  28426. fov: number;
  28427. /**
  28428. * Define the minimum distance the camera can see from.
  28429. * This is important to note that the depth buffer are not infinite and the closer it starts
  28430. * the more your scene might encounter depth fighting issue.
  28431. */
  28432. minZ: number;
  28433. /**
  28434. * Define the maximum distance the camera can see to.
  28435. * This is important to note that the depth buffer are not infinite and the further it end
  28436. * the more your scene might encounter depth fighting issue.
  28437. */
  28438. maxZ: number;
  28439. /**
  28440. * Define the default inertia of the camera.
  28441. * This helps giving a smooth feeling to the camera movement.
  28442. */
  28443. inertia: number;
  28444. /**
  28445. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28446. */
  28447. mode: number;
  28448. /**
  28449. * Define whether the camera is intermediate.
  28450. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28451. */
  28452. isIntermediate: boolean;
  28453. /**
  28454. * Define the viewport of the camera.
  28455. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28456. */
  28457. viewport: Viewport;
  28458. /**
  28459. * Restricts the camera to viewing objects with the same layerMask.
  28460. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28461. */
  28462. layerMask: number;
  28463. /**
  28464. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28465. */
  28466. fovMode: number;
  28467. /**
  28468. * Rig mode of the camera.
  28469. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28470. * This is normally controlled byt the camera themselves as internal use.
  28471. */
  28472. cameraRigMode: number;
  28473. /**
  28474. * Defines the distance between both "eyes" in case of a RIG
  28475. */
  28476. interaxialDistance: number;
  28477. /**
  28478. * Defines if stereoscopic rendering is done side by side or over under.
  28479. */
  28480. isStereoscopicSideBySide: boolean;
  28481. /**
  28482. * 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
  28483. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28484. * else in the scene. (Eg. security camera)
  28485. *
  28486. * 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)
  28487. */
  28488. customRenderTargets: RenderTargetTexture[];
  28489. /**
  28490. * When set, the camera will render to this render target instead of the default canvas
  28491. *
  28492. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28493. */
  28494. outputRenderTarget: Nullable<RenderTargetTexture>;
  28495. /**
  28496. * Observable triggered when the camera view matrix has changed.
  28497. */
  28498. onViewMatrixChangedObservable: Observable<Camera>;
  28499. /**
  28500. * Observable triggered when the camera Projection matrix has changed.
  28501. */
  28502. onProjectionMatrixChangedObservable: Observable<Camera>;
  28503. /**
  28504. * Observable triggered when the inputs have been processed.
  28505. */
  28506. onAfterCheckInputsObservable: Observable<Camera>;
  28507. /**
  28508. * Observable triggered when reset has been called and applied to the camera.
  28509. */
  28510. onRestoreStateObservable: Observable<Camera>;
  28511. /**
  28512. * Is this camera a part of a rig system?
  28513. */
  28514. isRigCamera: boolean;
  28515. /**
  28516. * If isRigCamera set to true this will be set with the parent camera.
  28517. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28518. */
  28519. rigParent?: Camera;
  28520. /** @hidden */
  28521. _cameraRigParams: any;
  28522. /** @hidden */
  28523. _rigCameras: Camera[];
  28524. /** @hidden */
  28525. _rigPostProcess: Nullable<PostProcess>;
  28526. protected _webvrViewMatrix: Matrix;
  28527. /** @hidden */
  28528. _skipRendering: boolean;
  28529. /** @hidden */
  28530. _projectionMatrix: Matrix;
  28531. /** @hidden */
  28532. _postProcesses: Nullable<PostProcess>[];
  28533. /** @hidden */
  28534. _activeMeshes: SmartArray<AbstractMesh>;
  28535. protected _globalPosition: Vector3;
  28536. /** @hidden */
  28537. _computedViewMatrix: Matrix;
  28538. private _doNotComputeProjectionMatrix;
  28539. private _transformMatrix;
  28540. private _frustumPlanes;
  28541. private _refreshFrustumPlanes;
  28542. private _storedFov;
  28543. private _stateStored;
  28544. /**
  28545. * Instantiates a new camera object.
  28546. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28547. * @see http://doc.babylonjs.com/features/cameras
  28548. * @param name Defines the name of the camera in the scene
  28549. * @param position Defines the position of the camera
  28550. * @param scene Defines the scene the camera belongs too
  28551. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28552. */
  28553. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28554. /**
  28555. * Store current camera state (fov, position, etc..)
  28556. * @returns the camera
  28557. */
  28558. storeState(): Camera;
  28559. /**
  28560. * Restores the camera state values if it has been stored. You must call storeState() first
  28561. */
  28562. protected _restoreStateValues(): boolean;
  28563. /**
  28564. * Restored camera state. You must call storeState() first.
  28565. * @returns true if restored and false otherwise
  28566. */
  28567. restoreState(): boolean;
  28568. /**
  28569. * Gets the class name of the camera.
  28570. * @returns the class name
  28571. */
  28572. getClassName(): string;
  28573. /** @hidden */
  28574. readonly _isCamera: boolean;
  28575. /**
  28576. * Gets a string representation of the camera useful for debug purpose.
  28577. * @param fullDetails Defines that a more verboe level of logging is required
  28578. * @returns the string representation
  28579. */
  28580. toString(fullDetails?: boolean): string;
  28581. /**
  28582. * Gets the current world space position of the camera.
  28583. */
  28584. get globalPosition(): Vector3;
  28585. /**
  28586. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28587. * @returns the active meshe list
  28588. */
  28589. getActiveMeshes(): SmartArray<AbstractMesh>;
  28590. /**
  28591. * Check whether a mesh is part of the current active mesh list of the camera
  28592. * @param mesh Defines the mesh to check
  28593. * @returns true if active, false otherwise
  28594. */
  28595. isActiveMesh(mesh: Mesh): boolean;
  28596. /**
  28597. * Is this camera ready to be used/rendered
  28598. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28599. * @return true if the camera is ready
  28600. */
  28601. isReady(completeCheck?: boolean): boolean;
  28602. /** @hidden */
  28603. _initCache(): void;
  28604. /** @hidden */
  28605. _updateCache(ignoreParentClass?: boolean): void;
  28606. /** @hidden */
  28607. _isSynchronized(): boolean;
  28608. /** @hidden */
  28609. _isSynchronizedViewMatrix(): boolean;
  28610. /** @hidden */
  28611. _isSynchronizedProjectionMatrix(): boolean;
  28612. /**
  28613. * Attach the input controls to a specific dom element to get the input from.
  28614. * @param element Defines the element the controls should be listened from
  28615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28616. */
  28617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28618. /**
  28619. * Detach the current controls from the specified dom element.
  28620. * @param element Defines the element to stop listening the inputs from
  28621. */
  28622. detachControl(element: HTMLElement): void;
  28623. /**
  28624. * Update the camera state according to the different inputs gathered during the frame.
  28625. */
  28626. update(): void;
  28627. /** @hidden */
  28628. _checkInputs(): void;
  28629. /** @hidden */
  28630. get rigCameras(): Camera[];
  28631. /**
  28632. * Gets the post process used by the rig cameras
  28633. */
  28634. get rigPostProcess(): Nullable<PostProcess>;
  28635. /**
  28636. * Internal, gets the first post proces.
  28637. * @returns the first post process to be run on this camera.
  28638. */
  28639. _getFirstPostProcess(): Nullable<PostProcess>;
  28640. private _cascadePostProcessesToRigCams;
  28641. /**
  28642. * Attach a post process to the camera.
  28643. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28644. * @param postProcess The post process to attach to the camera
  28645. * @param insertAt The position of the post process in case several of them are in use in the scene
  28646. * @returns the position the post process has been inserted at
  28647. */
  28648. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28649. /**
  28650. * Detach a post process to the camera.
  28651. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28652. * @param postProcess The post process to detach from the camera
  28653. */
  28654. detachPostProcess(postProcess: PostProcess): void;
  28655. /**
  28656. * Gets the current world matrix of the camera
  28657. */
  28658. getWorldMatrix(): Matrix;
  28659. /** @hidden */
  28660. _getViewMatrix(): Matrix;
  28661. /**
  28662. * Gets the current view matrix of the camera.
  28663. * @param force forces the camera to recompute the matrix without looking at the cached state
  28664. * @returns the view matrix
  28665. */
  28666. getViewMatrix(force?: boolean): Matrix;
  28667. /**
  28668. * Freeze the projection matrix.
  28669. * It will prevent the cache check of the camera projection compute and can speed up perf
  28670. * if no parameter of the camera are meant to change
  28671. * @param projection Defines manually a projection if necessary
  28672. */
  28673. freezeProjectionMatrix(projection?: Matrix): void;
  28674. /**
  28675. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28676. */
  28677. unfreezeProjectionMatrix(): void;
  28678. /**
  28679. * Gets the current projection matrix of the camera.
  28680. * @param force forces the camera to recompute the matrix without looking at the cached state
  28681. * @returns the projection matrix
  28682. */
  28683. getProjectionMatrix(force?: boolean): Matrix;
  28684. /**
  28685. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28686. * @returns a Matrix
  28687. */
  28688. getTransformationMatrix(): Matrix;
  28689. private _updateFrustumPlanes;
  28690. /**
  28691. * Checks if a cullable object (mesh...) is in the camera frustum
  28692. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28693. * @param target The object to check
  28694. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28695. * @returns true if the object is in frustum otherwise false
  28696. */
  28697. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28698. /**
  28699. * Checks if a cullable object (mesh...) is in the camera frustum
  28700. * Unlike isInFrustum this cheks the full bounding box
  28701. * @param target The object to check
  28702. * @returns true if the object is in frustum otherwise false
  28703. */
  28704. isCompletelyInFrustum(target: ICullable): boolean;
  28705. /**
  28706. * Gets a ray in the forward direction from the camera.
  28707. * @param length Defines the length of the ray to create
  28708. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28709. * @param origin Defines the start point of the ray which defaults to the camera position
  28710. * @returns the forward ray
  28711. */
  28712. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28713. /**
  28714. * Releases resources associated with this node.
  28715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28717. */
  28718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28719. /** @hidden */
  28720. _isLeftCamera: boolean;
  28721. /**
  28722. * Gets the left camera of a rig setup in case of Rigged Camera
  28723. */
  28724. get isLeftCamera(): boolean;
  28725. /** @hidden */
  28726. _isRightCamera: boolean;
  28727. /**
  28728. * Gets the right camera of a rig setup in case of Rigged Camera
  28729. */
  28730. get isRightCamera(): boolean;
  28731. /**
  28732. * Gets the left camera of a rig setup in case of Rigged Camera
  28733. */
  28734. get leftCamera(): Nullable<FreeCamera>;
  28735. /**
  28736. * Gets the right camera of a rig setup in case of Rigged Camera
  28737. */
  28738. get rightCamera(): Nullable<FreeCamera>;
  28739. /**
  28740. * Gets the left camera target of a rig setup in case of Rigged Camera
  28741. * @returns the target position
  28742. */
  28743. getLeftTarget(): Nullable<Vector3>;
  28744. /**
  28745. * Gets the right camera target of a rig setup in case of Rigged Camera
  28746. * @returns the target position
  28747. */
  28748. getRightTarget(): Nullable<Vector3>;
  28749. /**
  28750. * @hidden
  28751. */
  28752. setCameraRigMode(mode: number, rigParams: any): void;
  28753. /** @hidden */
  28754. static _setStereoscopicRigMode(camera: Camera): void;
  28755. /** @hidden */
  28756. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28757. /** @hidden */
  28758. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28759. /** @hidden */
  28760. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28761. /** @hidden */
  28762. _getVRProjectionMatrix(): Matrix;
  28763. protected _updateCameraRotationMatrix(): void;
  28764. protected _updateWebVRCameraRotationMatrix(): void;
  28765. /**
  28766. * This function MUST be overwritten by the different WebVR cameras available.
  28767. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28768. * @hidden
  28769. */
  28770. _getWebVRProjectionMatrix(): Matrix;
  28771. /**
  28772. * This function MUST be overwritten by the different WebVR cameras available.
  28773. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28774. * @hidden
  28775. */
  28776. _getWebVRViewMatrix(): Matrix;
  28777. /** @hidden */
  28778. setCameraRigParameter(name: string, value: any): void;
  28779. /**
  28780. * needs to be overridden by children so sub has required properties to be copied
  28781. * @hidden
  28782. */
  28783. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28784. /**
  28785. * May need to be overridden by children
  28786. * @hidden
  28787. */
  28788. _updateRigCameras(): void;
  28789. /** @hidden */
  28790. _setupInputs(): void;
  28791. /**
  28792. * Serialiaze the camera setup to a json represention
  28793. * @returns the JSON representation
  28794. */
  28795. serialize(): any;
  28796. /**
  28797. * Clones the current camera.
  28798. * @param name The cloned camera name
  28799. * @returns the cloned camera
  28800. */
  28801. clone(name: string): Camera;
  28802. /**
  28803. * Gets the direction of the camera relative to a given local axis.
  28804. * @param localAxis Defines the reference axis to provide a relative direction.
  28805. * @return the direction
  28806. */
  28807. getDirection(localAxis: Vector3): Vector3;
  28808. /**
  28809. * Returns the current camera absolute rotation
  28810. */
  28811. get absoluteRotation(): Quaternion;
  28812. /**
  28813. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28814. * @param localAxis Defines the reference axis to provide a relative direction.
  28815. * @param result Defines the vector to store the result in
  28816. */
  28817. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28818. /**
  28819. * Gets a camera constructor for a given camera type
  28820. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28821. * @param name The name of the camera the result will be able to instantiate
  28822. * @param scene The scene the result will construct the camera in
  28823. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28824. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28825. * @returns a factory method to construc the camera
  28826. */
  28827. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28828. /**
  28829. * Compute the world matrix of the camera.
  28830. * @returns the camera world matrix
  28831. */
  28832. computeWorldMatrix(): Matrix;
  28833. /**
  28834. * Parse a JSON and creates the camera from the parsed information
  28835. * @param parsedCamera The JSON to parse
  28836. * @param scene The scene to instantiate the camera in
  28837. * @returns the newly constructed camera
  28838. */
  28839. static Parse(parsedCamera: any, scene: Scene): Camera;
  28840. }
  28841. }
  28842. declare module BABYLON {
  28843. /**
  28844. * Class containing static functions to help procedurally build meshes
  28845. */
  28846. export class DiscBuilder {
  28847. /**
  28848. * Creates a plane polygonal mesh. By default, this is a disc
  28849. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28850. * * 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
  28851. * * 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
  28852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28853. * * 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
  28854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28855. * @param name defines the name of the mesh
  28856. * @param options defines the options used to create the mesh
  28857. * @param scene defines the hosting scene
  28858. * @returns the plane polygonal mesh
  28859. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28860. */
  28861. static CreateDisc(name: string, options: {
  28862. radius?: number;
  28863. tessellation?: number;
  28864. arc?: number;
  28865. updatable?: boolean;
  28866. sideOrientation?: number;
  28867. frontUVs?: Vector4;
  28868. backUVs?: Vector4;
  28869. }, scene?: Nullable<Scene>): Mesh;
  28870. }
  28871. }
  28872. declare module BABYLON {
  28873. /**
  28874. * Options to be used when creating a FresnelParameters.
  28875. */
  28876. export type IFresnelParametersCreationOptions = {
  28877. /**
  28878. * Define the color used on edges (grazing angle)
  28879. */
  28880. leftColor?: Color3;
  28881. /**
  28882. * Define the color used on center
  28883. */
  28884. rightColor?: Color3;
  28885. /**
  28886. * Define bias applied to computed fresnel term
  28887. */
  28888. bias?: number;
  28889. /**
  28890. * Defined the power exponent applied to fresnel term
  28891. */
  28892. power?: number;
  28893. /**
  28894. * Define if the fresnel effect is enable or not.
  28895. */
  28896. isEnabled?: boolean;
  28897. };
  28898. /**
  28899. * Serialized format for FresnelParameters.
  28900. */
  28901. export type IFresnelParametersSerialized = {
  28902. /**
  28903. * Define the color used on edges (grazing angle) [as an array]
  28904. */
  28905. leftColor: number[];
  28906. /**
  28907. * Define the color used on center [as an array]
  28908. */
  28909. rightColor: number[];
  28910. /**
  28911. * Define bias applied to computed fresnel term
  28912. */
  28913. bias: number;
  28914. /**
  28915. * Defined the power exponent applied to fresnel term
  28916. */
  28917. power?: number;
  28918. /**
  28919. * Define if the fresnel effect is enable or not.
  28920. */
  28921. isEnabled: boolean;
  28922. };
  28923. /**
  28924. * This represents all the required information to add a fresnel effect on a material:
  28925. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28926. */
  28927. export class FresnelParameters {
  28928. private _isEnabled;
  28929. /**
  28930. * Define if the fresnel effect is enable or not.
  28931. */
  28932. get isEnabled(): boolean;
  28933. set isEnabled(value: boolean);
  28934. /**
  28935. * Define the color used on edges (grazing angle)
  28936. */
  28937. leftColor: Color3;
  28938. /**
  28939. * Define the color used on center
  28940. */
  28941. rightColor: Color3;
  28942. /**
  28943. * Define bias applied to computed fresnel term
  28944. */
  28945. bias: number;
  28946. /**
  28947. * Defined the power exponent applied to fresnel term
  28948. */
  28949. power: number;
  28950. /**
  28951. * Creates a new FresnelParameters object.
  28952. *
  28953. * @param options provide your own settings to optionally to override defaults
  28954. */
  28955. constructor(options?: IFresnelParametersCreationOptions);
  28956. /**
  28957. * Clones the current fresnel and its valuues
  28958. * @returns a clone fresnel configuration
  28959. */
  28960. clone(): FresnelParameters;
  28961. /**
  28962. * Determines equality between FresnelParameters objects
  28963. * @param otherFresnelParameters defines the second operand
  28964. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  28965. */
  28966. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  28967. /**
  28968. * Serializes the current fresnel parameters to a JSON representation.
  28969. * @return the JSON serialization
  28970. */
  28971. serialize(): IFresnelParametersSerialized;
  28972. /**
  28973. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28974. * @param parsedFresnelParameters Define the JSON representation
  28975. * @returns the parsed parameters
  28976. */
  28977. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  28978. }
  28979. }
  28980. declare module BABYLON {
  28981. /**
  28982. * This groups all the flags used to control the materials channel.
  28983. */
  28984. export class MaterialFlags {
  28985. private static _DiffuseTextureEnabled;
  28986. /**
  28987. * Are diffuse textures enabled in the application.
  28988. */
  28989. static get DiffuseTextureEnabled(): boolean;
  28990. static set DiffuseTextureEnabled(value: boolean);
  28991. private static _AmbientTextureEnabled;
  28992. /**
  28993. * Are ambient textures enabled in the application.
  28994. */
  28995. static get AmbientTextureEnabled(): boolean;
  28996. static set AmbientTextureEnabled(value: boolean);
  28997. private static _OpacityTextureEnabled;
  28998. /**
  28999. * Are opacity textures enabled in the application.
  29000. */
  29001. static get OpacityTextureEnabled(): boolean;
  29002. static set OpacityTextureEnabled(value: boolean);
  29003. private static _ReflectionTextureEnabled;
  29004. /**
  29005. * Are reflection textures enabled in the application.
  29006. */
  29007. static get ReflectionTextureEnabled(): boolean;
  29008. static set ReflectionTextureEnabled(value: boolean);
  29009. private static _EmissiveTextureEnabled;
  29010. /**
  29011. * Are emissive textures enabled in the application.
  29012. */
  29013. static get EmissiveTextureEnabled(): boolean;
  29014. static set EmissiveTextureEnabled(value: boolean);
  29015. private static _SpecularTextureEnabled;
  29016. /**
  29017. * Are specular textures enabled in the application.
  29018. */
  29019. static get SpecularTextureEnabled(): boolean;
  29020. static set SpecularTextureEnabled(value: boolean);
  29021. private static _BumpTextureEnabled;
  29022. /**
  29023. * Are bump textures enabled in the application.
  29024. */
  29025. static get BumpTextureEnabled(): boolean;
  29026. static set BumpTextureEnabled(value: boolean);
  29027. private static _LightmapTextureEnabled;
  29028. /**
  29029. * Are lightmap textures enabled in the application.
  29030. */
  29031. static get LightmapTextureEnabled(): boolean;
  29032. static set LightmapTextureEnabled(value: boolean);
  29033. private static _RefractionTextureEnabled;
  29034. /**
  29035. * Are refraction textures enabled in the application.
  29036. */
  29037. static get RefractionTextureEnabled(): boolean;
  29038. static set RefractionTextureEnabled(value: boolean);
  29039. private static _ColorGradingTextureEnabled;
  29040. /**
  29041. * Are color grading textures enabled in the application.
  29042. */
  29043. static get ColorGradingTextureEnabled(): boolean;
  29044. static set ColorGradingTextureEnabled(value: boolean);
  29045. private static _FresnelEnabled;
  29046. /**
  29047. * Are fresnels enabled in the application.
  29048. */
  29049. static get FresnelEnabled(): boolean;
  29050. static set FresnelEnabled(value: boolean);
  29051. private static _ClearCoatTextureEnabled;
  29052. /**
  29053. * Are clear coat textures enabled in the application.
  29054. */
  29055. static get ClearCoatTextureEnabled(): boolean;
  29056. static set ClearCoatTextureEnabled(value: boolean);
  29057. private static _ClearCoatBumpTextureEnabled;
  29058. /**
  29059. * Are clear coat bump textures enabled in the application.
  29060. */
  29061. static get ClearCoatBumpTextureEnabled(): boolean;
  29062. static set ClearCoatBumpTextureEnabled(value: boolean);
  29063. private static _ClearCoatTintTextureEnabled;
  29064. /**
  29065. * Are clear coat tint textures enabled in the application.
  29066. */
  29067. static get ClearCoatTintTextureEnabled(): boolean;
  29068. static set ClearCoatTintTextureEnabled(value: boolean);
  29069. private static _SheenTextureEnabled;
  29070. /**
  29071. * Are sheen textures enabled in the application.
  29072. */
  29073. static get SheenTextureEnabled(): boolean;
  29074. static set SheenTextureEnabled(value: boolean);
  29075. private static _AnisotropicTextureEnabled;
  29076. /**
  29077. * Are anisotropic textures enabled in the application.
  29078. */
  29079. static get AnisotropicTextureEnabled(): boolean;
  29080. static set AnisotropicTextureEnabled(value: boolean);
  29081. private static _ThicknessTextureEnabled;
  29082. /**
  29083. * Are thickness textures enabled in the application.
  29084. */
  29085. static get ThicknessTextureEnabled(): boolean;
  29086. static set ThicknessTextureEnabled(value: boolean);
  29087. }
  29088. }
  29089. declare module BABYLON {
  29090. /** @hidden */
  29091. export var defaultFragmentDeclaration: {
  29092. name: string;
  29093. shader: string;
  29094. };
  29095. }
  29096. declare module BABYLON {
  29097. /** @hidden */
  29098. export var defaultUboDeclaration: {
  29099. name: string;
  29100. shader: string;
  29101. };
  29102. }
  29103. declare module BABYLON {
  29104. /** @hidden */
  29105. export var lightFragmentDeclaration: {
  29106. name: string;
  29107. shader: string;
  29108. };
  29109. }
  29110. declare module BABYLON {
  29111. /** @hidden */
  29112. export var lightUboDeclaration: {
  29113. name: string;
  29114. shader: string;
  29115. };
  29116. }
  29117. declare module BABYLON {
  29118. /** @hidden */
  29119. export var lightsFragmentFunctions: {
  29120. name: string;
  29121. shader: string;
  29122. };
  29123. }
  29124. declare module BABYLON {
  29125. /** @hidden */
  29126. export var shadowsFragmentFunctions: {
  29127. name: string;
  29128. shader: string;
  29129. };
  29130. }
  29131. declare module BABYLON {
  29132. /** @hidden */
  29133. export var fresnelFunction: {
  29134. name: string;
  29135. shader: string;
  29136. };
  29137. }
  29138. declare module BABYLON {
  29139. /** @hidden */
  29140. export var bumpFragmentMainFunctions: {
  29141. name: string;
  29142. shader: string;
  29143. };
  29144. }
  29145. declare module BABYLON {
  29146. /** @hidden */
  29147. export var bumpFragmentFunctions: {
  29148. name: string;
  29149. shader: string;
  29150. };
  29151. }
  29152. declare module BABYLON {
  29153. /** @hidden */
  29154. export var logDepthDeclaration: {
  29155. name: string;
  29156. shader: string;
  29157. };
  29158. }
  29159. declare module BABYLON {
  29160. /** @hidden */
  29161. export var bumpFragment: {
  29162. name: string;
  29163. shader: string;
  29164. };
  29165. }
  29166. declare module BABYLON {
  29167. /** @hidden */
  29168. export var depthPrePass: {
  29169. name: string;
  29170. shader: string;
  29171. };
  29172. }
  29173. declare module BABYLON {
  29174. /** @hidden */
  29175. export var lightFragment: {
  29176. name: string;
  29177. shader: string;
  29178. };
  29179. }
  29180. declare module BABYLON {
  29181. /** @hidden */
  29182. export var logDepthFragment: {
  29183. name: string;
  29184. shader: string;
  29185. };
  29186. }
  29187. declare module BABYLON {
  29188. /** @hidden */
  29189. export var defaultPixelShader: {
  29190. name: string;
  29191. shader: string;
  29192. };
  29193. }
  29194. declare module BABYLON {
  29195. /** @hidden */
  29196. export var defaultVertexDeclaration: {
  29197. name: string;
  29198. shader: string;
  29199. };
  29200. }
  29201. declare module BABYLON {
  29202. /** @hidden */
  29203. export var bumpVertexDeclaration: {
  29204. name: string;
  29205. shader: string;
  29206. };
  29207. }
  29208. declare module BABYLON {
  29209. /** @hidden */
  29210. export var bumpVertex: {
  29211. name: string;
  29212. shader: string;
  29213. };
  29214. }
  29215. declare module BABYLON {
  29216. /** @hidden */
  29217. export var fogVertex: {
  29218. name: string;
  29219. shader: string;
  29220. };
  29221. }
  29222. declare module BABYLON {
  29223. /** @hidden */
  29224. export var shadowsVertex: {
  29225. name: string;
  29226. shader: string;
  29227. };
  29228. }
  29229. declare module BABYLON {
  29230. /** @hidden */
  29231. export var pointCloudVertex: {
  29232. name: string;
  29233. shader: string;
  29234. };
  29235. }
  29236. declare module BABYLON {
  29237. /** @hidden */
  29238. export var logDepthVertex: {
  29239. name: string;
  29240. shader: string;
  29241. };
  29242. }
  29243. declare module BABYLON {
  29244. /** @hidden */
  29245. export var defaultVertexShader: {
  29246. name: string;
  29247. shader: string;
  29248. };
  29249. }
  29250. declare module BABYLON {
  29251. /** @hidden */
  29252. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29253. MAINUV1: boolean;
  29254. MAINUV2: boolean;
  29255. DIFFUSE: boolean;
  29256. DIFFUSEDIRECTUV: number;
  29257. AMBIENT: boolean;
  29258. AMBIENTDIRECTUV: number;
  29259. OPACITY: boolean;
  29260. OPACITYDIRECTUV: number;
  29261. OPACITYRGB: boolean;
  29262. REFLECTION: boolean;
  29263. EMISSIVE: boolean;
  29264. EMISSIVEDIRECTUV: number;
  29265. SPECULAR: boolean;
  29266. SPECULARDIRECTUV: number;
  29267. BUMP: boolean;
  29268. BUMPDIRECTUV: number;
  29269. PARALLAX: boolean;
  29270. PARALLAXOCCLUSION: boolean;
  29271. SPECULAROVERALPHA: boolean;
  29272. CLIPPLANE: boolean;
  29273. CLIPPLANE2: boolean;
  29274. CLIPPLANE3: boolean;
  29275. CLIPPLANE4: boolean;
  29276. CLIPPLANE5: boolean;
  29277. CLIPPLANE6: boolean;
  29278. ALPHATEST: boolean;
  29279. DEPTHPREPASS: boolean;
  29280. ALPHAFROMDIFFUSE: boolean;
  29281. POINTSIZE: boolean;
  29282. FOG: boolean;
  29283. SPECULARTERM: boolean;
  29284. DIFFUSEFRESNEL: boolean;
  29285. OPACITYFRESNEL: boolean;
  29286. REFLECTIONFRESNEL: boolean;
  29287. REFRACTIONFRESNEL: boolean;
  29288. EMISSIVEFRESNEL: boolean;
  29289. FRESNEL: boolean;
  29290. NORMAL: boolean;
  29291. UV1: boolean;
  29292. UV2: boolean;
  29293. VERTEXCOLOR: boolean;
  29294. VERTEXALPHA: boolean;
  29295. NUM_BONE_INFLUENCERS: number;
  29296. BonesPerMesh: number;
  29297. BONETEXTURE: boolean;
  29298. INSTANCES: boolean;
  29299. GLOSSINESS: boolean;
  29300. ROUGHNESS: boolean;
  29301. EMISSIVEASILLUMINATION: boolean;
  29302. LINKEMISSIVEWITHDIFFUSE: boolean;
  29303. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29304. LIGHTMAP: boolean;
  29305. LIGHTMAPDIRECTUV: number;
  29306. OBJECTSPACE_NORMALMAP: boolean;
  29307. USELIGHTMAPASSHADOWMAP: boolean;
  29308. REFLECTIONMAP_3D: boolean;
  29309. REFLECTIONMAP_SPHERICAL: boolean;
  29310. REFLECTIONMAP_PLANAR: boolean;
  29311. REFLECTIONMAP_CUBIC: boolean;
  29312. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29313. REFLECTIONMAP_PROJECTION: boolean;
  29314. REFLECTIONMAP_SKYBOX: boolean;
  29315. REFLECTIONMAP_EXPLICIT: boolean;
  29316. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29317. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29318. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29319. INVERTCUBICMAP: boolean;
  29320. LOGARITHMICDEPTH: boolean;
  29321. REFRACTION: boolean;
  29322. REFRACTIONMAP_3D: boolean;
  29323. REFLECTIONOVERALPHA: boolean;
  29324. TWOSIDEDLIGHTING: boolean;
  29325. SHADOWFLOAT: boolean;
  29326. MORPHTARGETS: boolean;
  29327. MORPHTARGETS_NORMAL: boolean;
  29328. MORPHTARGETS_TANGENT: boolean;
  29329. MORPHTARGETS_UV: boolean;
  29330. NUM_MORPH_INFLUENCERS: number;
  29331. NONUNIFORMSCALING: boolean;
  29332. PREMULTIPLYALPHA: boolean;
  29333. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29334. ALPHABLEND: boolean;
  29335. RGBDLIGHTMAP: boolean;
  29336. RGBDREFLECTION: boolean;
  29337. RGBDREFRACTION: boolean;
  29338. IMAGEPROCESSING: boolean;
  29339. VIGNETTE: boolean;
  29340. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29341. VIGNETTEBLENDMODEOPAQUE: boolean;
  29342. TONEMAPPING: boolean;
  29343. TONEMAPPING_ACES: boolean;
  29344. CONTRAST: boolean;
  29345. COLORCURVES: boolean;
  29346. COLORGRADING: boolean;
  29347. COLORGRADING3D: boolean;
  29348. SAMPLER3DGREENDEPTH: boolean;
  29349. SAMPLER3DBGRMAP: boolean;
  29350. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29351. MULTIVIEW: boolean;
  29352. /**
  29353. * If the reflection texture on this material is in linear color space
  29354. * @hidden
  29355. */
  29356. IS_REFLECTION_LINEAR: boolean;
  29357. /**
  29358. * If the refraction texture on this material is in linear color space
  29359. * @hidden
  29360. */
  29361. IS_REFRACTION_LINEAR: boolean;
  29362. EXPOSURE: boolean;
  29363. constructor();
  29364. setReflectionMode(modeToEnable: string): void;
  29365. }
  29366. /**
  29367. * This is the default material used in Babylon. It is the best trade off between quality
  29368. * and performances.
  29369. * @see http://doc.babylonjs.com/babylon101/materials
  29370. */
  29371. export class StandardMaterial extends PushMaterial {
  29372. private _diffuseTexture;
  29373. /**
  29374. * The basic texture of the material as viewed under a light.
  29375. */
  29376. diffuseTexture: Nullable<BaseTexture>;
  29377. private _ambientTexture;
  29378. /**
  29379. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29380. */
  29381. ambientTexture: Nullable<BaseTexture>;
  29382. private _opacityTexture;
  29383. /**
  29384. * Define the transparency of the material from a texture.
  29385. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29386. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29387. */
  29388. opacityTexture: Nullable<BaseTexture>;
  29389. private _reflectionTexture;
  29390. /**
  29391. * Define the texture used to display the reflection.
  29392. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29393. */
  29394. reflectionTexture: Nullable<BaseTexture>;
  29395. private _emissiveTexture;
  29396. /**
  29397. * Define texture of the material as if self lit.
  29398. * This will be mixed in the final result even in the absence of light.
  29399. */
  29400. emissiveTexture: Nullable<BaseTexture>;
  29401. private _specularTexture;
  29402. /**
  29403. * Define how the color and intensity of the highlight given by the light in the material.
  29404. */
  29405. specularTexture: Nullable<BaseTexture>;
  29406. private _bumpTexture;
  29407. /**
  29408. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29409. * 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.
  29410. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29411. */
  29412. bumpTexture: Nullable<BaseTexture>;
  29413. private _lightmapTexture;
  29414. /**
  29415. * Complex lighting can be computationally expensive to compute at runtime.
  29416. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29417. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29418. */
  29419. lightmapTexture: Nullable<BaseTexture>;
  29420. private _refractionTexture;
  29421. /**
  29422. * Define the texture used to display the refraction.
  29423. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29424. */
  29425. refractionTexture: Nullable<BaseTexture>;
  29426. /**
  29427. * The color of the material lit by the environmental background lighting.
  29428. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29429. */
  29430. ambientColor: Color3;
  29431. /**
  29432. * The basic color of the material as viewed under a light.
  29433. */
  29434. diffuseColor: Color3;
  29435. /**
  29436. * Define how the color and intensity of the highlight given by the light in the material.
  29437. */
  29438. specularColor: Color3;
  29439. /**
  29440. * Define the color of the material as if self lit.
  29441. * This will be mixed in the final result even in the absence of light.
  29442. */
  29443. emissiveColor: Color3;
  29444. /**
  29445. * Defines how sharp are the highlights in the material.
  29446. * The bigger the value the sharper giving a more glossy feeling to the result.
  29447. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29448. */
  29449. specularPower: number;
  29450. private _useAlphaFromDiffuseTexture;
  29451. /**
  29452. * Does the transparency come from the diffuse texture alpha channel.
  29453. */
  29454. useAlphaFromDiffuseTexture: boolean;
  29455. private _useEmissiveAsIllumination;
  29456. /**
  29457. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29458. */
  29459. useEmissiveAsIllumination: boolean;
  29460. private _linkEmissiveWithDiffuse;
  29461. /**
  29462. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29463. * the emissive level when the final color is close to one.
  29464. */
  29465. linkEmissiveWithDiffuse: boolean;
  29466. private _useSpecularOverAlpha;
  29467. /**
  29468. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29469. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29470. */
  29471. useSpecularOverAlpha: boolean;
  29472. private _useReflectionOverAlpha;
  29473. /**
  29474. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29475. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29476. */
  29477. useReflectionOverAlpha: boolean;
  29478. private _disableLighting;
  29479. /**
  29480. * Does lights from the scene impacts this material.
  29481. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29482. */
  29483. disableLighting: boolean;
  29484. private _useObjectSpaceNormalMap;
  29485. /**
  29486. * Allows using an object space normal map (instead of tangent space).
  29487. */
  29488. useObjectSpaceNormalMap: boolean;
  29489. private _useParallax;
  29490. /**
  29491. * Is parallax enabled or not.
  29492. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29493. */
  29494. useParallax: boolean;
  29495. private _useParallaxOcclusion;
  29496. /**
  29497. * Is parallax occlusion enabled or not.
  29498. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29499. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29500. */
  29501. useParallaxOcclusion: boolean;
  29502. /**
  29503. * 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.
  29504. */
  29505. parallaxScaleBias: number;
  29506. private _roughness;
  29507. /**
  29508. * Helps to define how blurry the reflections should appears in the material.
  29509. */
  29510. roughness: number;
  29511. /**
  29512. * In case of refraction, define the value of the index of refraction.
  29513. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29514. */
  29515. indexOfRefraction: number;
  29516. /**
  29517. * Invert the refraction texture alongside the y axis.
  29518. * It can be useful with procedural textures or probe for instance.
  29519. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29520. */
  29521. invertRefractionY: boolean;
  29522. /**
  29523. * Defines the alpha limits in alpha test mode.
  29524. */
  29525. alphaCutOff: number;
  29526. private _useLightmapAsShadowmap;
  29527. /**
  29528. * In case of light mapping, define whether the map contains light or shadow informations.
  29529. */
  29530. useLightmapAsShadowmap: boolean;
  29531. private _diffuseFresnelParameters;
  29532. /**
  29533. * Define the diffuse fresnel parameters of the material.
  29534. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29535. */
  29536. diffuseFresnelParameters: FresnelParameters;
  29537. private _opacityFresnelParameters;
  29538. /**
  29539. * Define the opacity fresnel parameters of the material.
  29540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29541. */
  29542. opacityFresnelParameters: FresnelParameters;
  29543. private _reflectionFresnelParameters;
  29544. /**
  29545. * Define the reflection fresnel parameters of the material.
  29546. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29547. */
  29548. reflectionFresnelParameters: FresnelParameters;
  29549. private _refractionFresnelParameters;
  29550. /**
  29551. * Define the refraction fresnel parameters of the material.
  29552. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29553. */
  29554. refractionFresnelParameters: FresnelParameters;
  29555. private _emissiveFresnelParameters;
  29556. /**
  29557. * Define the emissive fresnel parameters of the material.
  29558. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29559. */
  29560. emissiveFresnelParameters: FresnelParameters;
  29561. private _useReflectionFresnelFromSpecular;
  29562. /**
  29563. * If true automatically deducts the fresnels values from the material specularity.
  29564. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29565. */
  29566. useReflectionFresnelFromSpecular: boolean;
  29567. private _useGlossinessFromSpecularMapAlpha;
  29568. /**
  29569. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29570. */
  29571. useGlossinessFromSpecularMapAlpha: boolean;
  29572. private _maxSimultaneousLights;
  29573. /**
  29574. * Defines the maximum number of lights that can be used in the material
  29575. */
  29576. maxSimultaneousLights: number;
  29577. private _invertNormalMapX;
  29578. /**
  29579. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29580. */
  29581. invertNormalMapX: boolean;
  29582. private _invertNormalMapY;
  29583. /**
  29584. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29585. */
  29586. invertNormalMapY: boolean;
  29587. private _twoSidedLighting;
  29588. /**
  29589. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29590. */
  29591. twoSidedLighting: boolean;
  29592. /**
  29593. * Default configuration related to image processing available in the standard Material.
  29594. */
  29595. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29596. /**
  29597. * Gets the image processing configuration used either in this material.
  29598. */
  29599. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29600. /**
  29601. * Sets the Default image processing configuration used either in the this material.
  29602. *
  29603. * If sets to null, the scene one is in use.
  29604. */
  29605. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29606. /**
  29607. * Keep track of the image processing observer to allow dispose and replace.
  29608. */
  29609. private _imageProcessingObserver;
  29610. /**
  29611. * Attaches a new image processing configuration to the Standard Material.
  29612. * @param configuration
  29613. */
  29614. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29615. /**
  29616. * Gets wether the color curves effect is enabled.
  29617. */
  29618. get cameraColorCurvesEnabled(): boolean;
  29619. /**
  29620. * Sets wether the color curves effect is enabled.
  29621. */
  29622. set cameraColorCurvesEnabled(value: boolean);
  29623. /**
  29624. * Gets wether the color grading effect is enabled.
  29625. */
  29626. get cameraColorGradingEnabled(): boolean;
  29627. /**
  29628. * Gets wether the color grading effect is enabled.
  29629. */
  29630. set cameraColorGradingEnabled(value: boolean);
  29631. /**
  29632. * Gets wether tonemapping is enabled or not.
  29633. */
  29634. get cameraToneMappingEnabled(): boolean;
  29635. /**
  29636. * Sets wether tonemapping is enabled or not
  29637. */
  29638. set cameraToneMappingEnabled(value: boolean);
  29639. /**
  29640. * The camera exposure used on this material.
  29641. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29642. * This corresponds to a photographic exposure.
  29643. */
  29644. get cameraExposure(): number;
  29645. /**
  29646. * The camera exposure used on this material.
  29647. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29648. * This corresponds to a photographic exposure.
  29649. */
  29650. set cameraExposure(value: number);
  29651. /**
  29652. * Gets The camera contrast used on this material.
  29653. */
  29654. get cameraContrast(): number;
  29655. /**
  29656. * Sets The camera contrast used on this material.
  29657. */
  29658. set cameraContrast(value: number);
  29659. /**
  29660. * Gets the Color Grading 2D Lookup Texture.
  29661. */
  29662. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29663. /**
  29664. * Sets the Color Grading 2D Lookup Texture.
  29665. */
  29666. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29667. /**
  29668. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29669. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29670. * 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;
  29671. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29672. */
  29673. get cameraColorCurves(): Nullable<ColorCurves>;
  29674. /**
  29675. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29676. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29677. * 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;
  29678. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29679. */
  29680. set cameraColorCurves(value: Nullable<ColorCurves>);
  29681. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29682. protected _worldViewProjectionMatrix: Matrix;
  29683. protected _globalAmbientColor: Color3;
  29684. protected _useLogarithmicDepth: boolean;
  29685. protected _rebuildInParallel: boolean;
  29686. /**
  29687. * Instantiates a new standard material.
  29688. * This is the default material used in Babylon. It is the best trade off between quality
  29689. * and performances.
  29690. * @see http://doc.babylonjs.com/babylon101/materials
  29691. * @param name Define the name of the material in the scene
  29692. * @param scene Define the scene the material belong to
  29693. */
  29694. constructor(name: string, scene: Scene);
  29695. /**
  29696. * Gets a boolean indicating that current material needs to register RTT
  29697. */
  29698. get hasRenderTargetTextures(): boolean;
  29699. /**
  29700. * Gets the current class name of the material e.g. "StandardMaterial"
  29701. * Mainly use in serialization.
  29702. * @returns the class name
  29703. */
  29704. getClassName(): string;
  29705. /**
  29706. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29707. * You can try switching to logarithmic depth.
  29708. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29709. */
  29710. get useLogarithmicDepth(): boolean;
  29711. set useLogarithmicDepth(value: boolean);
  29712. /**
  29713. * Specifies if the material will require alpha blending
  29714. * @returns a boolean specifying if alpha blending is needed
  29715. */
  29716. needAlphaBlending(): boolean;
  29717. /**
  29718. * Specifies if this material should be rendered in alpha test mode
  29719. * @returns a boolean specifying if an alpha test is needed.
  29720. */
  29721. needAlphaTesting(): boolean;
  29722. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29723. /**
  29724. * Get the texture used for alpha test purpose.
  29725. * @returns the diffuse texture in case of the standard material.
  29726. */
  29727. getAlphaTestTexture(): Nullable<BaseTexture>;
  29728. /**
  29729. * Get if the submesh is ready to be used and all its information available.
  29730. * Child classes can use it to update shaders
  29731. * @param mesh defines the mesh to check
  29732. * @param subMesh defines which submesh to check
  29733. * @param useInstances specifies that instances should be used
  29734. * @returns a boolean indicating that the submesh is ready or not
  29735. */
  29736. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29737. /**
  29738. * Builds the material UBO layouts.
  29739. * Used internally during the effect preparation.
  29740. */
  29741. buildUniformLayout(): void;
  29742. /**
  29743. * Unbinds the material from the mesh
  29744. */
  29745. unbind(): void;
  29746. /**
  29747. * Binds the submesh to this material by preparing the effect and shader to draw
  29748. * @param world defines the world transformation matrix
  29749. * @param mesh defines the mesh containing the submesh
  29750. * @param subMesh defines the submesh to bind the material to
  29751. */
  29752. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29753. /**
  29754. * Get the list of animatables in the material.
  29755. * @returns the list of animatables object used in the material
  29756. */
  29757. getAnimatables(): IAnimatable[];
  29758. /**
  29759. * Gets the active textures from the material
  29760. * @returns an array of textures
  29761. */
  29762. getActiveTextures(): BaseTexture[];
  29763. /**
  29764. * Specifies if the material uses a texture
  29765. * @param texture defines the texture to check against the material
  29766. * @returns a boolean specifying if the material uses the texture
  29767. */
  29768. hasTexture(texture: BaseTexture): boolean;
  29769. /**
  29770. * Disposes the material
  29771. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29772. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29773. */
  29774. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29775. /**
  29776. * Makes a duplicate of the material, and gives it a new name
  29777. * @param name defines the new name for the duplicated material
  29778. * @returns the cloned material
  29779. */
  29780. clone(name: string): StandardMaterial;
  29781. /**
  29782. * Serializes this material in a JSON representation
  29783. * @returns the serialized material object
  29784. */
  29785. serialize(): any;
  29786. /**
  29787. * Creates a standard material from parsed material data
  29788. * @param source defines the JSON representation of the material
  29789. * @param scene defines the hosting scene
  29790. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29791. * @returns a new standard material
  29792. */
  29793. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29794. /**
  29795. * Are diffuse textures enabled in the application.
  29796. */
  29797. static get DiffuseTextureEnabled(): boolean;
  29798. static set DiffuseTextureEnabled(value: boolean);
  29799. /**
  29800. * Are ambient textures enabled in the application.
  29801. */
  29802. static get AmbientTextureEnabled(): boolean;
  29803. static set AmbientTextureEnabled(value: boolean);
  29804. /**
  29805. * Are opacity textures enabled in the application.
  29806. */
  29807. static get OpacityTextureEnabled(): boolean;
  29808. static set OpacityTextureEnabled(value: boolean);
  29809. /**
  29810. * Are reflection textures enabled in the application.
  29811. */
  29812. static get ReflectionTextureEnabled(): boolean;
  29813. static set ReflectionTextureEnabled(value: boolean);
  29814. /**
  29815. * Are emissive textures enabled in the application.
  29816. */
  29817. static get EmissiveTextureEnabled(): boolean;
  29818. static set EmissiveTextureEnabled(value: boolean);
  29819. /**
  29820. * Are specular textures enabled in the application.
  29821. */
  29822. static get SpecularTextureEnabled(): boolean;
  29823. static set SpecularTextureEnabled(value: boolean);
  29824. /**
  29825. * Are bump textures enabled in the application.
  29826. */
  29827. static get BumpTextureEnabled(): boolean;
  29828. static set BumpTextureEnabled(value: boolean);
  29829. /**
  29830. * Are lightmap textures enabled in the application.
  29831. */
  29832. static get LightmapTextureEnabled(): boolean;
  29833. static set LightmapTextureEnabled(value: boolean);
  29834. /**
  29835. * Are refraction textures enabled in the application.
  29836. */
  29837. static get RefractionTextureEnabled(): boolean;
  29838. static set RefractionTextureEnabled(value: boolean);
  29839. /**
  29840. * Are color grading textures enabled in the application.
  29841. */
  29842. static get ColorGradingTextureEnabled(): boolean;
  29843. static set ColorGradingTextureEnabled(value: boolean);
  29844. /**
  29845. * Are fresnels enabled in the application.
  29846. */
  29847. static get FresnelEnabled(): boolean;
  29848. static set FresnelEnabled(value: boolean);
  29849. }
  29850. }
  29851. declare module BABYLON {
  29852. /**
  29853. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29854. *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.
  29855. * The SPS is also a particle system. It provides some methods to manage the particles.
  29856. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29857. *
  29858. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29859. */
  29860. export class SolidParticleSystem implements IDisposable {
  29861. /**
  29862. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29863. * Example : var p = SPS.particles[i];
  29864. */
  29865. particles: SolidParticle[];
  29866. /**
  29867. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29868. */
  29869. nbParticles: number;
  29870. /**
  29871. * If the particles must ever face the camera (default false). Useful for planar particles.
  29872. */
  29873. billboard: boolean;
  29874. /**
  29875. * Recompute normals when adding a shape
  29876. */
  29877. recomputeNormals: boolean;
  29878. /**
  29879. * This a counter ofr your own usage. It's not set by any SPS functions.
  29880. */
  29881. counter: number;
  29882. /**
  29883. * The SPS name. This name is also given to the underlying mesh.
  29884. */
  29885. name: string;
  29886. /**
  29887. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29888. */
  29889. mesh: Mesh;
  29890. /**
  29891. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29892. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29893. */
  29894. vars: any;
  29895. /**
  29896. * This array is populated when the SPS is set as 'pickable'.
  29897. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29898. * Each element of this array is an object `{idx: int, faceId: int}`.
  29899. * `idx` is the picked particle index in the `SPS.particles` array
  29900. * `faceId` is the picked face index counted within this particle.
  29901. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29902. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29903. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29904. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29905. */
  29906. pickedParticles: {
  29907. idx: number;
  29908. faceId: number;
  29909. }[];
  29910. /**
  29911. * This array is populated when the SPS is set as 'pickable'
  29912. * Each key of this array is a submesh index.
  29913. * Each element of this array is a second array defined like this :
  29914. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29915. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29916. * `idx` is the picked particle index in the `SPS.particles` array
  29917. * `faceId` is the picked face index counted within this particle.
  29918. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29919. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29920. */
  29921. pickedBySubMesh: {
  29922. idx: number;
  29923. faceId: number;
  29924. }[][];
  29925. /**
  29926. * This array is populated when `enableDepthSort` is set to true.
  29927. * Each element of this array is an instance of the class DepthSortedParticle.
  29928. */
  29929. depthSortedParticles: DepthSortedParticle[];
  29930. /**
  29931. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29932. * @hidden
  29933. */
  29934. _bSphereOnly: boolean;
  29935. /**
  29936. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29937. * @hidden
  29938. */
  29939. _bSphereRadiusFactor: number;
  29940. private _scene;
  29941. private _positions;
  29942. private _indices;
  29943. private _normals;
  29944. private _colors;
  29945. private _uvs;
  29946. private _indices32;
  29947. private _positions32;
  29948. private _normals32;
  29949. private _fixedNormal32;
  29950. private _colors32;
  29951. private _uvs32;
  29952. private _index;
  29953. private _updatable;
  29954. private _pickable;
  29955. private _isVisibilityBoxLocked;
  29956. private _alwaysVisible;
  29957. private _depthSort;
  29958. private _expandable;
  29959. private _shapeCounter;
  29960. private _copy;
  29961. private _color;
  29962. private _computeParticleColor;
  29963. private _computeParticleTexture;
  29964. private _computeParticleRotation;
  29965. private _computeParticleVertex;
  29966. private _computeBoundingBox;
  29967. private _depthSortParticles;
  29968. private _camera;
  29969. private _mustUnrotateFixedNormals;
  29970. private _particlesIntersect;
  29971. private _needs32Bits;
  29972. private _isNotBuilt;
  29973. private _lastParticleId;
  29974. private _idxOfId;
  29975. private _multimaterialEnabled;
  29976. private _useModelMaterial;
  29977. private _indicesByMaterial;
  29978. private _materialIndexes;
  29979. private _depthSortFunction;
  29980. private _materialSortFunction;
  29981. private _materials;
  29982. private _multimaterial;
  29983. private _materialIndexesById;
  29984. private _defaultMaterial;
  29985. private _autoUpdateSubMeshes;
  29986. private _tmpVertex;
  29987. /**
  29988. * Creates a SPS (Solid Particle System) object.
  29989. * @param name (String) is the SPS name, this will be the underlying mesh name.
  29990. * @param scene (Scene) is the scene in which the SPS is added.
  29991. * @param options defines the options of the sps e.g.
  29992. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  29993. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  29994. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  29995. * * 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.
  29996. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  29997. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  29998. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  29999. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30000. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30001. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30002. */
  30003. constructor(name: string, scene: Scene, options?: {
  30004. updatable?: boolean;
  30005. isPickable?: boolean;
  30006. enableDepthSort?: boolean;
  30007. particleIntersection?: boolean;
  30008. boundingSphereOnly?: boolean;
  30009. bSphereRadiusFactor?: number;
  30010. expandable?: boolean;
  30011. useModelMaterial?: boolean;
  30012. enableMultiMaterial?: boolean;
  30013. });
  30014. /**
  30015. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30016. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30017. * @returns the created mesh
  30018. */
  30019. buildMesh(): Mesh;
  30020. /**
  30021. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30022. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30023. * Thus the particles generated from `digest()` have their property `position` set yet.
  30024. * @param mesh ( Mesh ) is the mesh to be digested
  30025. * @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
  30026. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30027. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30028. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30029. * @returns the current SPS
  30030. */
  30031. digest(mesh: Mesh, options?: {
  30032. facetNb?: number;
  30033. number?: number;
  30034. delta?: number;
  30035. storage?: [];
  30036. }): SolidParticleSystem;
  30037. /**
  30038. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30039. * @hidden
  30040. */
  30041. private _unrotateFixedNormals;
  30042. /**
  30043. * Resets the temporary working copy particle
  30044. * @hidden
  30045. */
  30046. private _resetCopy;
  30047. /**
  30048. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30049. * @param p the current index in the positions array to be updated
  30050. * @param ind the current index in the indices array
  30051. * @param shape a Vector3 array, the shape geometry
  30052. * @param positions the positions array to be updated
  30053. * @param meshInd the shape indices array
  30054. * @param indices the indices array to be updated
  30055. * @param meshUV the shape uv array
  30056. * @param uvs the uv array to be updated
  30057. * @param meshCol the shape color array
  30058. * @param colors the color array to be updated
  30059. * @param meshNor the shape normals array
  30060. * @param normals the normals array to be updated
  30061. * @param idx the particle index
  30062. * @param idxInShape the particle index in its shape
  30063. * @param options the addShape() method passed options
  30064. * @model the particle model
  30065. * @hidden
  30066. */
  30067. private _meshBuilder;
  30068. /**
  30069. * Returns a shape Vector3 array from positions float array
  30070. * @param positions float array
  30071. * @returns a vector3 array
  30072. * @hidden
  30073. */
  30074. private _posToShape;
  30075. /**
  30076. * Returns a shapeUV array from a float uvs (array deep copy)
  30077. * @param uvs as a float array
  30078. * @returns a shapeUV array
  30079. * @hidden
  30080. */
  30081. private _uvsToShapeUV;
  30082. /**
  30083. * Adds a new particle object in the particles array
  30084. * @param idx particle index in particles array
  30085. * @param id particle id
  30086. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30087. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30088. * @param model particle ModelShape object
  30089. * @param shapeId model shape identifier
  30090. * @param idxInShape index of the particle in the current model
  30091. * @param bInfo model bounding info object
  30092. * @param storage target storage array, if any
  30093. * @hidden
  30094. */
  30095. private _addParticle;
  30096. /**
  30097. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30098. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30099. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30100. * @param nb (positive integer) the number of particles to be created from this model
  30101. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30102. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30103. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30104. * @returns the number of shapes in the system
  30105. */
  30106. addShape(mesh: Mesh, nb: number, options?: {
  30107. positionFunction?: any;
  30108. vertexFunction?: any;
  30109. storage?: [];
  30110. }): number;
  30111. /**
  30112. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30113. * @hidden
  30114. */
  30115. private _rebuildParticle;
  30116. /**
  30117. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30118. * @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.
  30119. * @returns the SPS.
  30120. */
  30121. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30122. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30123. * Returns an array with the removed particles.
  30124. * 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.
  30125. * The SPS can't be empty so at least one particle needs to remain in place.
  30126. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30127. * @param start index of the first particle to remove
  30128. * @param end index of the last particle to remove (included)
  30129. * @returns an array populated with the removed particles
  30130. */
  30131. removeParticles(start: number, end: number): SolidParticle[];
  30132. /**
  30133. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30134. * @param solidParticleArray an array populated with Solid Particles objects
  30135. * @returns the SPS
  30136. */
  30137. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30138. /**
  30139. * Creates a new particle and modifies the SPS mesh geometry :
  30140. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30141. * - calls _addParticle() to populate the particle array
  30142. * factorized code from addShape() and insertParticlesFromArray()
  30143. * @param idx particle index in the particles array
  30144. * @param i particle index in its shape
  30145. * @param modelShape particle ModelShape object
  30146. * @param shape shape vertex array
  30147. * @param meshInd shape indices array
  30148. * @param meshUV shape uv array
  30149. * @param meshCol shape color array
  30150. * @param meshNor shape normals array
  30151. * @param bbInfo shape bounding info
  30152. * @param storage target particle storage
  30153. * @options addShape() passed options
  30154. * @hidden
  30155. */
  30156. private _insertNewParticle;
  30157. /**
  30158. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30159. * This method calls `updateParticle()` for each particle of the SPS.
  30160. * For an animated SPS, it is usually called within the render loop.
  30161. * 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.
  30162. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30163. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30164. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30165. * @returns the SPS.
  30166. */
  30167. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30168. /**
  30169. * Disposes the SPS.
  30170. */
  30171. dispose(): void;
  30172. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30173. * idx is the particle index in the SPS
  30174. * faceId is the picked face index counted within this particle.
  30175. * Returns null if the pickInfo can't identify a picked particle.
  30176. * @param pickingInfo (PickingInfo object)
  30177. * @returns {idx: number, faceId: number} or null
  30178. */
  30179. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30180. idx: number;
  30181. faceId: number;
  30182. }>;
  30183. /**
  30184. * Returns a SolidParticle object from its identifier : particle.id
  30185. * @param id (integer) the particle Id
  30186. * @returns the searched particle or null if not found in the SPS.
  30187. */
  30188. getParticleById(id: number): Nullable<SolidParticle>;
  30189. /**
  30190. * Returns a new array populated with the particles having the passed shapeId.
  30191. * @param shapeId (integer) the shape identifier
  30192. * @returns a new solid particle array
  30193. */
  30194. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30195. /**
  30196. * Populates the passed array "ref" with the particles having the passed shapeId.
  30197. * @param shapeId the shape identifier
  30198. * @returns the SPS
  30199. * @param ref
  30200. */
  30201. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30202. /**
  30203. * Computes the required SubMeshes according the materials assigned to the particles.
  30204. * @returns the solid particle system.
  30205. * Does nothing if called before the SPS mesh is built.
  30206. */
  30207. computeSubMeshes(): SolidParticleSystem;
  30208. /**
  30209. * Sorts the solid particles by material when MultiMaterial is enabled.
  30210. * Updates the indices32 array.
  30211. * Updates the indicesByMaterial array.
  30212. * Updates the mesh indices array.
  30213. * @returns the SPS
  30214. * @hidden
  30215. */
  30216. private _sortParticlesByMaterial;
  30217. /**
  30218. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30219. * @hidden
  30220. */
  30221. private _setMaterialIndexesById;
  30222. /**
  30223. * Returns an array with unique values of Materials from the passed array
  30224. * @param array the material array to be checked and filtered
  30225. * @hidden
  30226. */
  30227. private _filterUniqueMaterialId;
  30228. /**
  30229. * Sets a new Standard Material as _defaultMaterial if not already set.
  30230. * @hidden
  30231. */
  30232. private _setDefaultMaterial;
  30233. /**
  30234. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30235. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30236. * @returns the SPS.
  30237. */
  30238. refreshVisibleSize(): SolidParticleSystem;
  30239. /**
  30240. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30241. * @param size the size (float) of the visibility box
  30242. * note : this doesn't lock the SPS mesh bounding box.
  30243. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30244. */
  30245. setVisibilityBox(size: number): void;
  30246. /**
  30247. * Gets whether the SPS as always visible or not
  30248. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30249. */
  30250. get isAlwaysVisible(): boolean;
  30251. /**
  30252. * Sets the SPS as always visible or not
  30253. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30254. */
  30255. set isAlwaysVisible(val: boolean);
  30256. /**
  30257. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30258. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30259. */
  30260. set isVisibilityBoxLocked(val: boolean);
  30261. /**
  30262. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30263. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30264. */
  30265. get isVisibilityBoxLocked(): boolean;
  30266. /**
  30267. * Tells to `setParticles()` to compute the particle rotations or not.
  30268. * Default value : true. The SPS is faster when it's set to false.
  30269. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30270. */
  30271. set computeParticleRotation(val: boolean);
  30272. /**
  30273. * Tells to `setParticles()` to compute the particle colors or not.
  30274. * Default value : true. The SPS is faster when it's set to false.
  30275. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30276. */
  30277. set computeParticleColor(val: boolean);
  30278. set computeParticleTexture(val: boolean);
  30279. /**
  30280. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30281. * Default value : false. The SPS is faster when it's set to false.
  30282. * Note : the particle custom vertex positions aren't stored values.
  30283. */
  30284. set computeParticleVertex(val: boolean);
  30285. /**
  30286. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30287. */
  30288. set computeBoundingBox(val: boolean);
  30289. /**
  30290. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30291. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30292. * Default : `true`
  30293. */
  30294. set depthSortParticles(val: boolean);
  30295. /**
  30296. * Gets if `setParticles()` computes the particle rotations or not.
  30297. * Default value : true. The SPS is faster when it's set to false.
  30298. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30299. */
  30300. get computeParticleRotation(): boolean;
  30301. /**
  30302. * Gets if `setParticles()` computes the particle colors or not.
  30303. * Default value : true. The SPS is faster when it's set to false.
  30304. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30305. */
  30306. get computeParticleColor(): boolean;
  30307. /**
  30308. * Gets if `setParticles()` computes the particle textures or not.
  30309. * Default value : true. The SPS is faster when it's set to false.
  30310. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30311. */
  30312. get computeParticleTexture(): boolean;
  30313. /**
  30314. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30315. * Default value : false. The SPS is faster when it's set to false.
  30316. * Note : the particle custom vertex positions aren't stored values.
  30317. */
  30318. get computeParticleVertex(): boolean;
  30319. /**
  30320. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30321. */
  30322. get computeBoundingBox(): boolean;
  30323. /**
  30324. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30325. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30326. * Default : `true`
  30327. */
  30328. get depthSortParticles(): boolean;
  30329. /**
  30330. * Gets if the SPS is created as expandable at construction time.
  30331. * Default : `false`
  30332. */
  30333. get expandable(): boolean;
  30334. /**
  30335. * Gets if the SPS supports the Multi Materials
  30336. */
  30337. get multimaterialEnabled(): boolean;
  30338. /**
  30339. * Gets if the SPS uses the model materials for its own multimaterial.
  30340. */
  30341. get useModelMaterial(): boolean;
  30342. /**
  30343. * The SPS used material array.
  30344. */
  30345. get materials(): Material[];
  30346. /**
  30347. * Sets the SPS MultiMaterial from the passed materials.
  30348. * Note : the passed array is internally copied and not used then by reference.
  30349. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30350. */
  30351. setMultiMaterial(materials: Material[]): void;
  30352. /**
  30353. * The SPS computed multimaterial object
  30354. */
  30355. get multimaterial(): MultiMaterial;
  30356. set multimaterial(mm: MultiMaterial);
  30357. /**
  30358. * If the subMeshes must be updated on the next call to setParticles()
  30359. */
  30360. get autoUpdateSubMeshes(): boolean;
  30361. set autoUpdateSubMeshes(val: boolean);
  30362. /**
  30363. * This function does nothing. It may be overwritten to set all the particle first values.
  30364. * The SPS doesn't call this function, you may have to call it by your own.
  30365. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30366. */
  30367. initParticles(): void;
  30368. /**
  30369. * This function does nothing. It may be overwritten to recycle a particle.
  30370. * The SPS doesn't call this function, you may have to call it by your own.
  30371. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30372. * @param particle The particle to recycle
  30373. * @returns the recycled particle
  30374. */
  30375. recycleParticle(particle: SolidParticle): SolidParticle;
  30376. /**
  30377. * Updates a particle : this function should be overwritten by the user.
  30378. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30379. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30380. * @example : just set a particle position or velocity and recycle conditions
  30381. * @param particle The particle to update
  30382. * @returns the updated particle
  30383. */
  30384. updateParticle(particle: SolidParticle): SolidParticle;
  30385. /**
  30386. * Updates a vertex of a particle : it can be overwritten by the user.
  30387. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30388. * @param particle the current particle
  30389. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30390. * @param pt the index of the current vertex in the particle shape
  30391. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30392. * @example : just set a vertex particle position or color
  30393. * @returns the sps
  30394. */
  30395. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30396. /**
  30397. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30398. * This does nothing and may be overwritten by the user.
  30399. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30400. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30401. * @param update the boolean update value actually passed to setParticles()
  30402. */
  30403. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30404. /**
  30405. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30406. * This will be passed three parameters.
  30407. * This does nothing and may be overwritten by the user.
  30408. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30409. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30410. * @param update the boolean update value actually passed to setParticles()
  30411. */
  30412. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30413. }
  30414. }
  30415. declare module BABYLON {
  30416. /**
  30417. * Represents one particle of a solid particle system.
  30418. */
  30419. export class SolidParticle {
  30420. /**
  30421. * particle global index
  30422. */
  30423. idx: number;
  30424. /**
  30425. * particle identifier
  30426. */
  30427. id: number;
  30428. /**
  30429. * The color of the particle
  30430. */
  30431. color: Nullable<Color4>;
  30432. /**
  30433. * The world space position of the particle.
  30434. */
  30435. position: Vector3;
  30436. /**
  30437. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30438. */
  30439. rotation: Vector3;
  30440. /**
  30441. * The world space rotation quaternion of the particle.
  30442. */
  30443. rotationQuaternion: Nullable<Quaternion>;
  30444. /**
  30445. * The scaling of the particle.
  30446. */
  30447. scaling: Vector3;
  30448. /**
  30449. * The uvs of the particle.
  30450. */
  30451. uvs: Vector4;
  30452. /**
  30453. * The current speed of the particle.
  30454. */
  30455. velocity: Vector3;
  30456. /**
  30457. * The pivot point in the particle local space.
  30458. */
  30459. pivot: Vector3;
  30460. /**
  30461. * Must the particle be translated from its pivot point in its local space ?
  30462. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30463. * Default : false
  30464. */
  30465. translateFromPivot: boolean;
  30466. /**
  30467. * Is the particle active or not ?
  30468. */
  30469. alive: boolean;
  30470. /**
  30471. * Is the particle visible or not ?
  30472. */
  30473. isVisible: boolean;
  30474. /**
  30475. * Index of this particle in the global "positions" array (Internal use)
  30476. * @hidden
  30477. */
  30478. _pos: number;
  30479. /**
  30480. * @hidden Index of this particle in the global "indices" array (Internal use)
  30481. */
  30482. _ind: number;
  30483. /**
  30484. * @hidden ModelShape of this particle (Internal use)
  30485. */
  30486. _model: ModelShape;
  30487. /**
  30488. * ModelShape id of this particle
  30489. */
  30490. shapeId: number;
  30491. /**
  30492. * Index of the particle in its shape id
  30493. */
  30494. idxInShape: number;
  30495. /**
  30496. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30497. */
  30498. _modelBoundingInfo: BoundingInfo;
  30499. /**
  30500. * @hidden Particle BoundingInfo object (Internal use)
  30501. */
  30502. _boundingInfo: BoundingInfo;
  30503. /**
  30504. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30505. */
  30506. _sps: SolidParticleSystem;
  30507. /**
  30508. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30509. */
  30510. _stillInvisible: boolean;
  30511. /**
  30512. * @hidden Last computed particle rotation matrix
  30513. */
  30514. _rotationMatrix: number[];
  30515. /**
  30516. * Parent particle Id, if any.
  30517. * Default null.
  30518. */
  30519. parentId: Nullable<number>;
  30520. /**
  30521. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30522. */
  30523. materialIndex: Nullable<number>;
  30524. /**
  30525. * Custom object or properties.
  30526. */
  30527. props: Nullable<any>;
  30528. /**
  30529. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30530. * The possible values are :
  30531. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30532. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30533. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30534. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30535. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30536. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30537. * */
  30538. cullingStrategy: number;
  30539. /**
  30540. * @hidden Internal global position in the SPS.
  30541. */
  30542. _globalPosition: Vector3;
  30543. /**
  30544. * Creates a Solid Particle object.
  30545. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30546. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30547. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30548. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30549. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30550. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30551. * @param shapeId (integer) is the model shape identifier in the SPS.
  30552. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30553. * @param sps defines the sps it is associated to
  30554. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30555. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30556. */
  30557. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30558. /**
  30559. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30560. * @param target the particle target
  30561. * @returns the current particle
  30562. */
  30563. copyToRef(target: SolidParticle): SolidParticle;
  30564. /**
  30565. * Legacy support, changed scale to scaling
  30566. */
  30567. get scale(): Vector3;
  30568. /**
  30569. * Legacy support, changed scale to scaling
  30570. */
  30571. set scale(scale: Vector3);
  30572. /**
  30573. * Legacy support, changed quaternion to rotationQuaternion
  30574. */
  30575. get quaternion(): Nullable<Quaternion>;
  30576. /**
  30577. * Legacy support, changed quaternion to rotationQuaternion
  30578. */
  30579. set quaternion(q: Nullable<Quaternion>);
  30580. /**
  30581. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30582. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30583. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30584. * @returns true if it intersects
  30585. */
  30586. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30587. /**
  30588. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30589. * A particle is in the frustum if its bounding box intersects the frustum
  30590. * @param frustumPlanes defines the frustum to test
  30591. * @returns true if the particle is in the frustum planes
  30592. */
  30593. isInFrustum(frustumPlanes: Plane[]): boolean;
  30594. /**
  30595. * get the rotation matrix of the particle
  30596. * @hidden
  30597. */
  30598. getRotationMatrix(m: Matrix): void;
  30599. }
  30600. /**
  30601. * Represents the shape of the model used by one particle of a solid particle system.
  30602. * SPS internal tool, don't use it manually.
  30603. */
  30604. export class ModelShape {
  30605. /**
  30606. * The shape id
  30607. * @hidden
  30608. */
  30609. shapeID: number;
  30610. /**
  30611. * flat array of model positions (internal use)
  30612. * @hidden
  30613. */
  30614. _shape: Vector3[];
  30615. /**
  30616. * flat array of model UVs (internal use)
  30617. * @hidden
  30618. */
  30619. _shapeUV: number[];
  30620. /**
  30621. * color array of the model
  30622. * @hidden
  30623. */
  30624. _shapeColors: number[];
  30625. /**
  30626. * indices array of the model
  30627. * @hidden
  30628. */
  30629. _indices: number[];
  30630. /**
  30631. * normals array of the model
  30632. * @hidden
  30633. */
  30634. _normals: number[];
  30635. /**
  30636. * length of the shape in the model indices array (internal use)
  30637. * @hidden
  30638. */
  30639. _indicesLength: number;
  30640. /**
  30641. * Custom position function (internal use)
  30642. * @hidden
  30643. */
  30644. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30645. /**
  30646. * Custom vertex function (internal use)
  30647. * @hidden
  30648. */
  30649. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30650. /**
  30651. * Model material (internal use)
  30652. * @hidden
  30653. */
  30654. _material: Nullable<Material>;
  30655. /**
  30656. * 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.
  30657. * SPS internal tool, don't use it manually.
  30658. * @hidden
  30659. */
  30660. 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>);
  30661. }
  30662. /**
  30663. * Represents a Depth Sorted Particle in the solid particle system.
  30664. * @hidden
  30665. */
  30666. export class DepthSortedParticle {
  30667. /**
  30668. * Particle index
  30669. */
  30670. idx: number;
  30671. /**
  30672. * Index of the particle in the "indices" array
  30673. */
  30674. ind: number;
  30675. /**
  30676. * Length of the particle shape in the "indices" array
  30677. */
  30678. indicesLength: number;
  30679. /**
  30680. * Squared distance from the particle to the camera
  30681. */
  30682. sqDistance: number;
  30683. /**
  30684. * Material index when used with MultiMaterials
  30685. */
  30686. materialIndex: number;
  30687. /**
  30688. * Creates a new sorted particle
  30689. * @param materialIndex
  30690. */
  30691. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30692. }
  30693. /**
  30694. * Represents a solid particle vertex
  30695. */
  30696. export class SolidParticleVertex {
  30697. /**
  30698. * Vertex position
  30699. */
  30700. position: Vector3;
  30701. /**
  30702. * Vertex color
  30703. */
  30704. color: Color4;
  30705. /**
  30706. * Vertex UV
  30707. */
  30708. uv: Vector2;
  30709. /**
  30710. * Creates a new solid particle vertex
  30711. */
  30712. constructor();
  30713. /** Vertex x coordinate */
  30714. get x(): number;
  30715. set x(val: number);
  30716. /** Vertex y coordinate */
  30717. get y(): number;
  30718. set y(val: number);
  30719. /** Vertex z coordinate */
  30720. get z(): number;
  30721. set z(val: number);
  30722. }
  30723. }
  30724. declare module BABYLON {
  30725. /**
  30726. * @hidden
  30727. */
  30728. export class _MeshCollisionData {
  30729. _checkCollisions: boolean;
  30730. _collisionMask: number;
  30731. _collisionGroup: number;
  30732. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30733. _collider: Nullable<Collider>;
  30734. _oldPositionForCollisions: Vector3;
  30735. _diffPositionForCollisions: Vector3;
  30736. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30737. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30738. }
  30739. }
  30740. declare module BABYLON {
  30741. /** @hidden */
  30742. class _FacetDataStorage {
  30743. facetPositions: Vector3[];
  30744. facetNormals: Vector3[];
  30745. facetPartitioning: number[][];
  30746. facetNb: number;
  30747. partitioningSubdivisions: number;
  30748. partitioningBBoxRatio: number;
  30749. facetDataEnabled: boolean;
  30750. facetParameters: any;
  30751. bbSize: Vector3;
  30752. subDiv: {
  30753. max: number;
  30754. X: number;
  30755. Y: number;
  30756. Z: number;
  30757. };
  30758. facetDepthSort: boolean;
  30759. facetDepthSortEnabled: boolean;
  30760. depthSortedIndices: IndicesArray;
  30761. depthSortedFacets: {
  30762. ind: number;
  30763. sqDistance: number;
  30764. }[];
  30765. facetDepthSortFunction: (f1: {
  30766. ind: number;
  30767. sqDistance: number;
  30768. }, f2: {
  30769. ind: number;
  30770. sqDistance: number;
  30771. }) => number;
  30772. facetDepthSortFrom: Vector3;
  30773. facetDepthSortOrigin: Vector3;
  30774. invertedMatrix: Matrix;
  30775. }
  30776. /**
  30777. * @hidden
  30778. **/
  30779. class _InternalAbstractMeshDataInfo {
  30780. _hasVertexAlpha: boolean;
  30781. _useVertexColors: boolean;
  30782. _numBoneInfluencers: number;
  30783. _applyFog: boolean;
  30784. _receiveShadows: boolean;
  30785. _facetData: _FacetDataStorage;
  30786. _visibility: number;
  30787. _skeleton: Nullable<Skeleton>;
  30788. _layerMask: number;
  30789. _computeBonesUsingShaders: boolean;
  30790. _isActive: boolean;
  30791. _onlyForInstances: boolean;
  30792. _isActiveIntermediate: boolean;
  30793. _onlyForInstancesIntermediate: boolean;
  30794. _actAsRegularMesh: boolean;
  30795. }
  30796. /**
  30797. * Class used to store all common mesh properties
  30798. */
  30799. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30800. /** No occlusion */
  30801. static OCCLUSION_TYPE_NONE: number;
  30802. /** Occlusion set to optimisitic */
  30803. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30804. /** Occlusion set to strict */
  30805. static OCCLUSION_TYPE_STRICT: number;
  30806. /** Use an accurante occlusion algorithm */
  30807. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30808. /** Use a conservative occlusion algorithm */
  30809. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30810. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30811. * Test order :
  30812. * Is the bounding sphere outside the frustum ?
  30813. * If not, are the bounding box vertices outside the frustum ?
  30814. * It not, then the cullable object is in the frustum.
  30815. */
  30816. static readonly CULLINGSTRATEGY_STANDARD: number;
  30817. /** Culling strategy : Bounding Sphere Only.
  30818. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30819. * It's also less accurate than the standard because some not visible objects can still be selected.
  30820. * Test : is the bounding sphere outside the frustum ?
  30821. * If not, then the cullable object is in the frustum.
  30822. */
  30823. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30824. /** Culling strategy : Optimistic Inclusion.
  30825. * This in an inclusion test first, then the standard exclusion test.
  30826. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30827. * 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.
  30828. * Anyway, it's as accurate as the standard strategy.
  30829. * Test :
  30830. * Is the cullable object bounding sphere center in the frustum ?
  30831. * If not, apply the default culling strategy.
  30832. */
  30833. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30834. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30835. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30836. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30837. * 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.
  30838. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30839. * Test :
  30840. * Is the cullable object bounding sphere center in the frustum ?
  30841. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30842. */
  30843. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30844. /**
  30845. * No billboard
  30846. */
  30847. static get BILLBOARDMODE_NONE(): number;
  30848. /** Billboard on X axis */
  30849. static get BILLBOARDMODE_X(): number;
  30850. /** Billboard on Y axis */
  30851. static get BILLBOARDMODE_Y(): number;
  30852. /** Billboard on Z axis */
  30853. static get BILLBOARDMODE_Z(): number;
  30854. /** Billboard on all axes */
  30855. static get BILLBOARDMODE_ALL(): number;
  30856. /** Billboard on using position instead of orientation */
  30857. static get BILLBOARDMODE_USE_POSITION(): number;
  30858. /** @hidden */
  30859. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30860. /**
  30861. * The culling strategy to use to check whether the mesh must be rendered or not.
  30862. * This value can be changed at any time and will be used on the next render mesh selection.
  30863. * The possible values are :
  30864. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30865. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30866. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30867. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30868. * Please read each static variable documentation to get details about the culling process.
  30869. * */
  30870. cullingStrategy: number;
  30871. /**
  30872. * Gets the number of facets in the mesh
  30873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30874. */
  30875. get facetNb(): number;
  30876. /**
  30877. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30879. */
  30880. get partitioningSubdivisions(): number;
  30881. set partitioningSubdivisions(nb: number);
  30882. /**
  30883. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30884. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30886. */
  30887. get partitioningBBoxRatio(): number;
  30888. set partitioningBBoxRatio(ratio: number);
  30889. /**
  30890. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30891. * Works only for updatable meshes.
  30892. * Doesn't work with multi-materials
  30893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30894. */
  30895. get mustDepthSortFacets(): boolean;
  30896. set mustDepthSortFacets(sort: boolean);
  30897. /**
  30898. * The location (Vector3) where the facet depth sort must be computed from.
  30899. * By default, the active camera position.
  30900. * Used only when facet depth sort is enabled
  30901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30902. */
  30903. get facetDepthSortFrom(): Vector3;
  30904. set facetDepthSortFrom(location: Vector3);
  30905. /**
  30906. * gets a boolean indicating if facetData is enabled
  30907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30908. */
  30909. get isFacetDataEnabled(): boolean;
  30910. /** @hidden */
  30911. _updateNonUniformScalingState(value: boolean): boolean;
  30912. /**
  30913. * An event triggered when this mesh collides with another one
  30914. */
  30915. onCollideObservable: Observable<AbstractMesh>;
  30916. /** Set a function to call when this mesh collides with another one */
  30917. set onCollide(callback: () => void);
  30918. /**
  30919. * An event triggered when the collision's position changes
  30920. */
  30921. onCollisionPositionChangeObservable: Observable<Vector3>;
  30922. /** Set a function to call when the collision's position changes */
  30923. set onCollisionPositionChange(callback: () => void);
  30924. /**
  30925. * An event triggered when material is changed
  30926. */
  30927. onMaterialChangedObservable: Observable<AbstractMesh>;
  30928. /**
  30929. * Gets or sets the orientation for POV movement & rotation
  30930. */
  30931. definedFacingForward: boolean;
  30932. /** @hidden */
  30933. _occlusionQuery: Nullable<WebGLQuery>;
  30934. /** @hidden */
  30935. _renderingGroup: Nullable<RenderingGroup>;
  30936. /**
  30937. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30938. */
  30939. get visibility(): number;
  30940. /**
  30941. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30942. */
  30943. set visibility(value: number);
  30944. /** Gets or sets the alpha index used to sort transparent meshes
  30945. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  30946. */
  30947. alphaIndex: number;
  30948. /**
  30949. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  30950. */
  30951. isVisible: boolean;
  30952. /**
  30953. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  30954. */
  30955. isPickable: boolean;
  30956. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  30957. showSubMeshesBoundingBox: boolean;
  30958. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  30959. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  30960. */
  30961. isBlocker: boolean;
  30962. /**
  30963. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  30964. */
  30965. enablePointerMoveEvents: boolean;
  30966. /**
  30967. * Specifies the rendering group id for this mesh (0 by default)
  30968. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  30969. */
  30970. renderingGroupId: number;
  30971. private _material;
  30972. /** Gets or sets current material */
  30973. get material(): Nullable<Material>;
  30974. set material(value: Nullable<Material>);
  30975. /**
  30976. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  30977. * @see http://doc.babylonjs.com/babylon101/shadows
  30978. */
  30979. get receiveShadows(): boolean;
  30980. set receiveShadows(value: boolean);
  30981. /** Defines color to use when rendering outline */
  30982. outlineColor: Color3;
  30983. /** Define width to use when rendering outline */
  30984. outlineWidth: number;
  30985. /** Defines color to use when rendering overlay */
  30986. overlayColor: Color3;
  30987. /** Defines alpha to use when rendering overlay */
  30988. overlayAlpha: number;
  30989. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  30990. get hasVertexAlpha(): boolean;
  30991. set hasVertexAlpha(value: boolean);
  30992. /** 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) */
  30993. get useVertexColors(): boolean;
  30994. set useVertexColors(value: boolean);
  30995. /**
  30996. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  30997. */
  30998. get computeBonesUsingShaders(): boolean;
  30999. set computeBonesUsingShaders(value: boolean);
  31000. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31001. get numBoneInfluencers(): number;
  31002. set numBoneInfluencers(value: number);
  31003. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31004. get applyFog(): boolean;
  31005. set applyFog(value: boolean);
  31006. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31007. useOctreeForRenderingSelection: boolean;
  31008. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31009. useOctreeForPicking: boolean;
  31010. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31011. useOctreeForCollisions: boolean;
  31012. /**
  31013. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31014. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31015. */
  31016. get layerMask(): number;
  31017. set layerMask(value: number);
  31018. /**
  31019. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31020. */
  31021. alwaysSelectAsActiveMesh: boolean;
  31022. /**
  31023. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31024. */
  31025. doNotSyncBoundingInfo: boolean;
  31026. /**
  31027. * Gets or sets the current action manager
  31028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31029. */
  31030. actionManager: Nullable<AbstractActionManager>;
  31031. private _meshCollisionData;
  31032. /**
  31033. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31034. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31035. */
  31036. ellipsoid: Vector3;
  31037. /**
  31038. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31039. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31040. */
  31041. ellipsoidOffset: Vector3;
  31042. /**
  31043. * Gets or sets a collision mask used to mask collisions (default is -1).
  31044. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31045. */
  31046. get collisionMask(): number;
  31047. set collisionMask(mask: number);
  31048. /**
  31049. * Gets or sets the current collision group mask (-1 by default).
  31050. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31051. */
  31052. get collisionGroup(): number;
  31053. set collisionGroup(mask: number);
  31054. /**
  31055. * Gets or sets current surrounding meshes (null by default).
  31056. *
  31057. * By default collision detection is tested against every mesh in the scene.
  31058. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31059. * meshes will be tested for the collision.
  31060. *
  31061. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31062. */
  31063. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31064. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31065. /**
  31066. * Defines edge width used when edgesRenderer is enabled
  31067. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31068. */
  31069. edgesWidth: number;
  31070. /**
  31071. * Defines edge color used when edgesRenderer is enabled
  31072. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31073. */
  31074. edgesColor: Color4;
  31075. /** @hidden */
  31076. _edgesRenderer: Nullable<IEdgesRenderer>;
  31077. /** @hidden */
  31078. _masterMesh: Nullable<AbstractMesh>;
  31079. /** @hidden */
  31080. _boundingInfo: Nullable<BoundingInfo>;
  31081. /** @hidden */
  31082. _renderId: number;
  31083. /**
  31084. * Gets or sets the list of subMeshes
  31085. * @see http://doc.babylonjs.com/how_to/multi_materials
  31086. */
  31087. subMeshes: SubMesh[];
  31088. /** @hidden */
  31089. _intersectionsInProgress: AbstractMesh[];
  31090. /** @hidden */
  31091. _unIndexed: boolean;
  31092. /** @hidden */
  31093. _lightSources: Light[];
  31094. /** Gets the list of lights affecting that mesh */
  31095. get lightSources(): Light[];
  31096. /** @hidden */
  31097. get _positions(): Nullable<Vector3[]>;
  31098. /** @hidden */
  31099. _waitingData: {
  31100. lods: Nullable<any>;
  31101. actions: Nullable<any>;
  31102. freezeWorldMatrix: Nullable<boolean>;
  31103. };
  31104. /** @hidden */
  31105. _bonesTransformMatrices: Nullable<Float32Array>;
  31106. /** @hidden */
  31107. _transformMatrixTexture: Nullable<RawTexture>;
  31108. /**
  31109. * Gets or sets a skeleton to apply skining transformations
  31110. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31111. */
  31112. set skeleton(value: Nullable<Skeleton>);
  31113. get skeleton(): Nullable<Skeleton>;
  31114. /**
  31115. * An event triggered when the mesh is rebuilt.
  31116. */
  31117. onRebuildObservable: Observable<AbstractMesh>;
  31118. /**
  31119. * Creates a new AbstractMesh
  31120. * @param name defines the name of the mesh
  31121. * @param scene defines the hosting scene
  31122. */
  31123. constructor(name: string, scene?: Nullable<Scene>);
  31124. /**
  31125. * Returns the string "AbstractMesh"
  31126. * @returns "AbstractMesh"
  31127. */
  31128. getClassName(): string;
  31129. /**
  31130. * Gets a string representation of the current mesh
  31131. * @param fullDetails defines a boolean indicating if full details must be included
  31132. * @returns a string representation of the current mesh
  31133. */
  31134. toString(fullDetails?: boolean): string;
  31135. /**
  31136. * @hidden
  31137. */
  31138. protected _getEffectiveParent(): Nullable<Node>;
  31139. /** @hidden */
  31140. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31141. /** @hidden */
  31142. _rebuild(): void;
  31143. /** @hidden */
  31144. _resyncLightSources(): void;
  31145. /** @hidden */
  31146. _resyncLightSource(light: Light): void;
  31147. /** @hidden */
  31148. _unBindEffect(): void;
  31149. /** @hidden */
  31150. _removeLightSource(light: Light, dispose: boolean): void;
  31151. private _markSubMeshesAsDirty;
  31152. /** @hidden */
  31153. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31154. /** @hidden */
  31155. _markSubMeshesAsAttributesDirty(): void;
  31156. /** @hidden */
  31157. _markSubMeshesAsMiscDirty(): void;
  31158. /**
  31159. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31160. */
  31161. get scaling(): Vector3;
  31162. set scaling(newScaling: Vector3);
  31163. /**
  31164. * Returns true if the mesh is blocked. Implemented by child classes
  31165. */
  31166. get isBlocked(): boolean;
  31167. /**
  31168. * Returns the mesh itself by default. Implemented by child classes
  31169. * @param camera defines the camera to use to pick the right LOD level
  31170. * @returns the currentAbstractMesh
  31171. */
  31172. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31173. /**
  31174. * Returns 0 by default. Implemented by child classes
  31175. * @returns an integer
  31176. */
  31177. getTotalVertices(): number;
  31178. /**
  31179. * Returns a positive integer : the total number of indices in this mesh geometry.
  31180. * @returns the numner of indices or zero if the mesh has no geometry.
  31181. */
  31182. getTotalIndices(): number;
  31183. /**
  31184. * Returns null by default. Implemented by child classes
  31185. * @returns null
  31186. */
  31187. getIndices(): Nullable<IndicesArray>;
  31188. /**
  31189. * Returns the array of the requested vertex data kind. Implemented by child classes
  31190. * @param kind defines the vertex data kind to use
  31191. * @returns null
  31192. */
  31193. getVerticesData(kind: string): Nullable<FloatArray>;
  31194. /**
  31195. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31196. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31197. * Note that a new underlying VertexBuffer object is created each call.
  31198. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31199. * @param kind defines vertex data kind:
  31200. * * VertexBuffer.PositionKind
  31201. * * VertexBuffer.UVKind
  31202. * * VertexBuffer.UV2Kind
  31203. * * VertexBuffer.UV3Kind
  31204. * * VertexBuffer.UV4Kind
  31205. * * VertexBuffer.UV5Kind
  31206. * * VertexBuffer.UV6Kind
  31207. * * VertexBuffer.ColorKind
  31208. * * VertexBuffer.MatricesIndicesKind
  31209. * * VertexBuffer.MatricesIndicesExtraKind
  31210. * * VertexBuffer.MatricesWeightsKind
  31211. * * VertexBuffer.MatricesWeightsExtraKind
  31212. * @param data defines the data source
  31213. * @param updatable defines if the data must be flagged as updatable (or static)
  31214. * @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
  31215. * @returns the current mesh
  31216. */
  31217. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31218. /**
  31219. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31220. * If the mesh has no geometry, it is simply returned as it is.
  31221. * @param kind defines vertex data kind:
  31222. * * VertexBuffer.PositionKind
  31223. * * VertexBuffer.UVKind
  31224. * * VertexBuffer.UV2Kind
  31225. * * VertexBuffer.UV3Kind
  31226. * * VertexBuffer.UV4Kind
  31227. * * VertexBuffer.UV5Kind
  31228. * * VertexBuffer.UV6Kind
  31229. * * VertexBuffer.ColorKind
  31230. * * VertexBuffer.MatricesIndicesKind
  31231. * * VertexBuffer.MatricesIndicesExtraKind
  31232. * * VertexBuffer.MatricesWeightsKind
  31233. * * VertexBuffer.MatricesWeightsExtraKind
  31234. * @param data defines the data source
  31235. * @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
  31236. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31237. * @returns the current mesh
  31238. */
  31239. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31240. /**
  31241. * Sets the mesh indices,
  31242. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31243. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31244. * @param totalVertices Defines the total number of vertices
  31245. * @returns the current mesh
  31246. */
  31247. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31248. /**
  31249. * Gets a boolean indicating if specific vertex data is present
  31250. * @param kind defines the vertex data kind to use
  31251. * @returns true is data kind is present
  31252. */
  31253. isVerticesDataPresent(kind: string): boolean;
  31254. /**
  31255. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31256. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31257. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31258. * @returns a BoundingInfo
  31259. */
  31260. getBoundingInfo(): BoundingInfo;
  31261. /**
  31262. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31263. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31264. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31265. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31266. * @returns the current mesh
  31267. */
  31268. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31269. /**
  31270. * Overwrite the current bounding info
  31271. * @param boundingInfo defines the new bounding info
  31272. * @returns the current mesh
  31273. */
  31274. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31275. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31276. get useBones(): boolean;
  31277. /** @hidden */
  31278. _preActivate(): void;
  31279. /** @hidden */
  31280. _preActivateForIntermediateRendering(renderId: number): void;
  31281. /** @hidden */
  31282. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31283. /** @hidden */
  31284. _postActivate(): void;
  31285. /** @hidden */
  31286. _freeze(): void;
  31287. /** @hidden */
  31288. _unFreeze(): void;
  31289. /**
  31290. * Gets the current world matrix
  31291. * @returns a Matrix
  31292. */
  31293. getWorldMatrix(): Matrix;
  31294. /** @hidden */
  31295. _getWorldMatrixDeterminant(): number;
  31296. /**
  31297. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31298. */
  31299. get isAnInstance(): boolean;
  31300. /**
  31301. * Gets a boolean indicating if this mesh has instances
  31302. */
  31303. get hasInstances(): boolean;
  31304. /**
  31305. * Perform relative position change from the point of view of behind the front of the mesh.
  31306. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31307. * Supports definition of mesh facing forward or backward
  31308. * @param amountRight defines the distance on the right axis
  31309. * @param amountUp defines the distance on the up axis
  31310. * @param amountForward defines the distance on the forward axis
  31311. * @returns the current mesh
  31312. */
  31313. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31314. /**
  31315. * Calculate relative position change from the point of view of behind the front of the mesh.
  31316. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31317. * Supports definition of mesh facing forward or backward
  31318. * @param amountRight defines the distance on the right axis
  31319. * @param amountUp defines the distance on the up axis
  31320. * @param amountForward defines the distance on the forward axis
  31321. * @returns the new displacement vector
  31322. */
  31323. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31324. /**
  31325. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31326. * Supports definition of mesh facing forward or backward
  31327. * @param flipBack defines the flip
  31328. * @param twirlClockwise defines the twirl
  31329. * @param tiltRight defines the tilt
  31330. * @returns the current mesh
  31331. */
  31332. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31333. /**
  31334. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31335. * Supports definition of mesh facing forward or backward.
  31336. * @param flipBack defines the flip
  31337. * @param twirlClockwise defines the twirl
  31338. * @param tiltRight defines the tilt
  31339. * @returns the new rotation vector
  31340. */
  31341. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31342. /**
  31343. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31344. * This means the mesh underlying bounding box and sphere are recomputed.
  31345. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31346. * @returns the current mesh
  31347. */
  31348. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31349. /** @hidden */
  31350. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31351. /** @hidden */
  31352. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31353. /** @hidden */
  31354. _updateBoundingInfo(): AbstractMesh;
  31355. /** @hidden */
  31356. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31357. /** @hidden */
  31358. protected _afterComputeWorldMatrix(): void;
  31359. /** @hidden */
  31360. get _effectiveMesh(): AbstractMesh;
  31361. /**
  31362. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31363. * A mesh is in the frustum if its bounding box intersects the frustum
  31364. * @param frustumPlanes defines the frustum to test
  31365. * @returns true if the mesh is in the frustum planes
  31366. */
  31367. isInFrustum(frustumPlanes: Plane[]): boolean;
  31368. /**
  31369. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31370. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31371. * @param frustumPlanes defines the frustum to test
  31372. * @returns true if the mesh is completely in the frustum planes
  31373. */
  31374. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31375. /**
  31376. * True if the mesh intersects another mesh or a SolidParticle object
  31377. * @param mesh defines a target mesh or SolidParticle to test
  31378. * @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)
  31379. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31380. * @returns true if there is an intersection
  31381. */
  31382. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31383. /**
  31384. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31385. * @param point defines the point to test
  31386. * @returns true if there is an intersection
  31387. */
  31388. intersectsPoint(point: Vector3): boolean;
  31389. /**
  31390. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31392. */
  31393. get checkCollisions(): boolean;
  31394. set checkCollisions(collisionEnabled: boolean);
  31395. /**
  31396. * Gets Collider object used to compute collisions (not physics)
  31397. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31398. */
  31399. get collider(): Nullable<Collider>;
  31400. /**
  31401. * Move the mesh using collision engine
  31402. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31403. * @param displacement defines the requested displacement vector
  31404. * @returns the current mesh
  31405. */
  31406. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31407. private _onCollisionPositionChange;
  31408. /** @hidden */
  31409. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31410. /** @hidden */
  31411. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31412. /** @hidden */
  31413. _checkCollision(collider: Collider): AbstractMesh;
  31414. /** @hidden */
  31415. _generatePointsArray(): boolean;
  31416. /**
  31417. * Checks if the passed Ray intersects with the mesh
  31418. * @param ray defines the ray to use
  31419. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31420. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31421. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31422. * @returns the picking info
  31423. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31424. */
  31425. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31426. /**
  31427. * Clones the current mesh
  31428. * @param name defines the mesh name
  31429. * @param newParent defines the new mesh parent
  31430. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31431. * @returns the new mesh
  31432. */
  31433. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31434. /**
  31435. * Disposes all the submeshes of the current meshnp
  31436. * @returns the current mesh
  31437. */
  31438. releaseSubMeshes(): AbstractMesh;
  31439. /**
  31440. * Releases resources associated with this abstract mesh.
  31441. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31442. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31443. */
  31444. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31445. /**
  31446. * Adds the passed mesh as a child to the current mesh
  31447. * @param mesh defines the child mesh
  31448. * @returns the current mesh
  31449. */
  31450. addChild(mesh: AbstractMesh): AbstractMesh;
  31451. /**
  31452. * Removes the passed mesh from the current mesh children list
  31453. * @param mesh defines the child mesh
  31454. * @returns the current mesh
  31455. */
  31456. removeChild(mesh: AbstractMesh): AbstractMesh;
  31457. /** @hidden */
  31458. private _initFacetData;
  31459. /**
  31460. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31461. * This method can be called within the render loop.
  31462. * 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
  31463. * @returns the current mesh
  31464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31465. */
  31466. updateFacetData(): AbstractMesh;
  31467. /**
  31468. * Returns the facetLocalNormals array.
  31469. * The normals are expressed in the mesh local spac
  31470. * @returns an array of Vector3
  31471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31472. */
  31473. getFacetLocalNormals(): Vector3[];
  31474. /**
  31475. * Returns the facetLocalPositions array.
  31476. * The facet positions are expressed in the mesh local space
  31477. * @returns an array of Vector3
  31478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31479. */
  31480. getFacetLocalPositions(): Vector3[];
  31481. /**
  31482. * Returns the facetLocalPartioning array
  31483. * @returns an array of array of numbers
  31484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31485. */
  31486. getFacetLocalPartitioning(): number[][];
  31487. /**
  31488. * Returns the i-th facet position in the world system.
  31489. * This method allocates a new Vector3 per call
  31490. * @param i defines the facet index
  31491. * @returns a new Vector3
  31492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31493. */
  31494. getFacetPosition(i: number): Vector3;
  31495. /**
  31496. * Sets the reference Vector3 with the i-th facet position in the world system
  31497. * @param i defines the facet index
  31498. * @param ref defines the target vector
  31499. * @returns the current mesh
  31500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31501. */
  31502. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31503. /**
  31504. * Returns the i-th facet normal in the world system.
  31505. * This method allocates a new Vector3 per call
  31506. * @param i defines the facet index
  31507. * @returns a new Vector3
  31508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31509. */
  31510. getFacetNormal(i: number): Vector3;
  31511. /**
  31512. * Sets the reference Vector3 with the i-th facet normal in the world system
  31513. * @param i defines the facet index
  31514. * @param ref defines the target vector
  31515. * @returns the current mesh
  31516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31517. */
  31518. getFacetNormalToRef(i: number, ref: Vector3): this;
  31519. /**
  31520. * 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)
  31521. * @param x defines x coordinate
  31522. * @param y defines y coordinate
  31523. * @param z defines z coordinate
  31524. * @returns the array of facet indexes
  31525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31526. */
  31527. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31528. /**
  31529. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31530. * @param projected sets as the (x,y,z) world projection on the facet
  31531. * @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
  31532. * @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
  31533. * @param x defines x coordinate
  31534. * @param y defines y coordinate
  31535. * @param z defines z coordinate
  31536. * @returns the face index if found (or null instead)
  31537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31538. */
  31539. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31540. /**
  31541. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31542. * @param projected sets as the (x,y,z) local projection on the facet
  31543. * @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
  31544. * @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
  31545. * @param x defines x coordinate
  31546. * @param y defines y coordinate
  31547. * @param z defines z coordinate
  31548. * @returns the face index if found (or null instead)
  31549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31550. */
  31551. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31552. /**
  31553. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31554. * @returns the parameters
  31555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31556. */
  31557. getFacetDataParameters(): any;
  31558. /**
  31559. * Disables the feature FacetData and frees the related memory
  31560. * @returns the current mesh
  31561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31562. */
  31563. disableFacetData(): AbstractMesh;
  31564. /**
  31565. * Updates the AbstractMesh indices array
  31566. * @param indices defines the data source
  31567. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31568. * @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)
  31569. * @returns the current mesh
  31570. */
  31571. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31572. /**
  31573. * Creates new normals data for the mesh
  31574. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31575. * @returns the current mesh
  31576. */
  31577. createNormals(updatable: boolean): AbstractMesh;
  31578. /**
  31579. * Align the mesh with a normal
  31580. * @param normal defines the normal to use
  31581. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31582. * @returns the current mesh
  31583. */
  31584. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31585. /** @hidden */
  31586. _checkOcclusionQuery(): boolean;
  31587. /**
  31588. * Disables the mesh edge rendering mode
  31589. * @returns the currentAbstractMesh
  31590. */
  31591. disableEdgesRendering(): AbstractMesh;
  31592. /**
  31593. * Enables the edge rendering mode on the mesh.
  31594. * This mode makes the mesh edges visible
  31595. * @param epsilon defines the maximal distance between two angles to detect a face
  31596. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31597. * @returns the currentAbstractMesh
  31598. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31599. */
  31600. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31601. }
  31602. }
  31603. declare module BABYLON {
  31604. /**
  31605. * Interface used to define ActionEvent
  31606. */
  31607. export interface IActionEvent {
  31608. /** The mesh or sprite that triggered the action */
  31609. source: any;
  31610. /** The X mouse cursor position at the time of the event */
  31611. pointerX: number;
  31612. /** The Y mouse cursor position at the time of the event */
  31613. pointerY: number;
  31614. /** The mesh that is currently pointed at (can be null) */
  31615. meshUnderPointer: Nullable<AbstractMesh>;
  31616. /** the original (browser) event that triggered the ActionEvent */
  31617. sourceEvent?: any;
  31618. /** additional data for the event */
  31619. additionalData?: any;
  31620. }
  31621. /**
  31622. * ActionEvent is the event being sent when an action is triggered.
  31623. */
  31624. export class ActionEvent implements IActionEvent {
  31625. /** The mesh or sprite that triggered the action */
  31626. source: any;
  31627. /** The X mouse cursor position at the time of the event */
  31628. pointerX: number;
  31629. /** The Y mouse cursor position at the time of the event */
  31630. pointerY: number;
  31631. /** The mesh that is currently pointed at (can be null) */
  31632. meshUnderPointer: Nullable<AbstractMesh>;
  31633. /** the original (browser) event that triggered the ActionEvent */
  31634. sourceEvent?: any;
  31635. /** additional data for the event */
  31636. additionalData?: any;
  31637. /**
  31638. * Creates a new ActionEvent
  31639. * @param source The mesh or sprite that triggered the action
  31640. * @param pointerX The X mouse cursor position at the time of the event
  31641. * @param pointerY The Y mouse cursor position at the time of the event
  31642. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31643. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31644. * @param additionalData additional data for the event
  31645. */
  31646. constructor(
  31647. /** The mesh or sprite that triggered the action */
  31648. source: any,
  31649. /** The X mouse cursor position at the time of the event */
  31650. pointerX: number,
  31651. /** The Y mouse cursor position at the time of the event */
  31652. pointerY: number,
  31653. /** The mesh that is currently pointed at (can be null) */
  31654. meshUnderPointer: Nullable<AbstractMesh>,
  31655. /** the original (browser) event that triggered the ActionEvent */
  31656. sourceEvent?: any,
  31657. /** additional data for the event */
  31658. additionalData?: any);
  31659. /**
  31660. * Helper function to auto-create an ActionEvent from a source mesh.
  31661. * @param source The source mesh that triggered the event
  31662. * @param evt The original (browser) event
  31663. * @param additionalData additional data for the event
  31664. * @returns the new ActionEvent
  31665. */
  31666. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31667. /**
  31668. * Helper function to auto-create an ActionEvent from a source sprite
  31669. * @param source The source sprite that triggered the event
  31670. * @param scene Scene associated with the sprite
  31671. * @param evt The original (browser) event
  31672. * @param additionalData additional data for the event
  31673. * @returns the new ActionEvent
  31674. */
  31675. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31676. /**
  31677. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31678. * @param scene the scene where the event occurred
  31679. * @param evt The original (browser) event
  31680. * @returns the new ActionEvent
  31681. */
  31682. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31683. /**
  31684. * Helper function to auto-create an ActionEvent from a primitive
  31685. * @param prim defines the target primitive
  31686. * @param pointerPos defines the pointer position
  31687. * @param evt The original (browser) event
  31688. * @param additionalData additional data for the event
  31689. * @returns the new ActionEvent
  31690. */
  31691. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31692. }
  31693. }
  31694. declare module BABYLON {
  31695. /**
  31696. * Abstract class used to decouple action Manager from scene and meshes.
  31697. * Do not instantiate.
  31698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31699. */
  31700. export abstract class AbstractActionManager implements IDisposable {
  31701. /** Gets the list of active triggers */
  31702. static Triggers: {
  31703. [key: string]: number;
  31704. };
  31705. /** Gets the cursor to use when hovering items */
  31706. hoverCursor: string;
  31707. /** Gets the list of actions */
  31708. actions: IAction[];
  31709. /**
  31710. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31711. */
  31712. isRecursive: boolean;
  31713. /**
  31714. * Releases all associated resources
  31715. */
  31716. abstract dispose(): void;
  31717. /**
  31718. * Does this action manager has pointer triggers
  31719. */
  31720. abstract get hasPointerTriggers(): boolean;
  31721. /**
  31722. * Does this action manager has pick triggers
  31723. */
  31724. abstract get hasPickTriggers(): boolean;
  31725. /**
  31726. * Process a specific trigger
  31727. * @param trigger defines the trigger to process
  31728. * @param evt defines the event details to be processed
  31729. */
  31730. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31731. /**
  31732. * Does this action manager handles actions of any of the given triggers
  31733. * @param triggers defines the triggers to be tested
  31734. * @return a boolean indicating whether one (or more) of the triggers is handled
  31735. */
  31736. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31737. /**
  31738. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31739. * speed.
  31740. * @param triggerA defines the trigger to be tested
  31741. * @param triggerB defines the trigger to be tested
  31742. * @return a boolean indicating whether one (or more) of the triggers is handled
  31743. */
  31744. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31745. /**
  31746. * Does this action manager handles actions of a given trigger
  31747. * @param trigger defines the trigger to be tested
  31748. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31749. * @return whether the trigger is handled
  31750. */
  31751. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31752. /**
  31753. * Serialize this manager to a JSON object
  31754. * @param name defines the property name to store this manager
  31755. * @returns a JSON representation of this manager
  31756. */
  31757. abstract serialize(name: string): any;
  31758. /**
  31759. * Registers an action to this action manager
  31760. * @param action defines the action to be registered
  31761. * @return the action amended (prepared) after registration
  31762. */
  31763. abstract registerAction(action: IAction): Nullable<IAction>;
  31764. /**
  31765. * Unregisters an action to this action manager
  31766. * @param action defines the action to be unregistered
  31767. * @return a boolean indicating whether the action has been unregistered
  31768. */
  31769. abstract unregisterAction(action: IAction): Boolean;
  31770. /**
  31771. * Does exist one action manager with at least one trigger
  31772. **/
  31773. static get HasTriggers(): boolean;
  31774. /**
  31775. * Does exist one action manager with at least one pick trigger
  31776. **/
  31777. static get HasPickTriggers(): boolean;
  31778. /**
  31779. * Does exist one action manager that handles actions of a given trigger
  31780. * @param trigger defines the trigger to be tested
  31781. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31782. **/
  31783. static HasSpecificTrigger(trigger: number): boolean;
  31784. }
  31785. }
  31786. declare module BABYLON {
  31787. /**
  31788. * Defines how a node can be built from a string name.
  31789. */
  31790. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31791. /**
  31792. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31793. */
  31794. export class Node implements IBehaviorAware<Node> {
  31795. /** @hidden */
  31796. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31797. private static _NodeConstructors;
  31798. /**
  31799. * Add a new node constructor
  31800. * @param type defines the type name of the node to construct
  31801. * @param constructorFunc defines the constructor function
  31802. */
  31803. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31804. /**
  31805. * Returns a node constructor based on type name
  31806. * @param type defines the type name
  31807. * @param name defines the new node name
  31808. * @param scene defines the hosting scene
  31809. * @param options defines optional options to transmit to constructors
  31810. * @returns the new constructor or null
  31811. */
  31812. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31813. /**
  31814. * Gets or sets the name of the node
  31815. */
  31816. name: string;
  31817. /**
  31818. * Gets or sets the id of the node
  31819. */
  31820. id: string;
  31821. /**
  31822. * Gets or sets the unique id of the node
  31823. */
  31824. uniqueId: number;
  31825. /**
  31826. * Gets or sets a string used to store user defined state for the node
  31827. */
  31828. state: string;
  31829. /**
  31830. * Gets or sets an object used to store user defined information for the node
  31831. */
  31832. metadata: any;
  31833. /**
  31834. * For internal use only. Please do not use.
  31835. */
  31836. reservedDataStore: any;
  31837. /**
  31838. * List of inspectable custom properties (used by the Inspector)
  31839. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31840. */
  31841. inspectableCustomProperties: IInspectable[];
  31842. private _doNotSerialize;
  31843. /**
  31844. * Gets or sets a boolean used to define if the node must be serialized
  31845. */
  31846. get doNotSerialize(): boolean;
  31847. set doNotSerialize(value: boolean);
  31848. /** @hidden */
  31849. _isDisposed: boolean;
  31850. /**
  31851. * Gets a list of Animations associated with the node
  31852. */
  31853. animations: Animation[];
  31854. protected _ranges: {
  31855. [name: string]: Nullable<AnimationRange>;
  31856. };
  31857. /**
  31858. * Callback raised when the node is ready to be used
  31859. */
  31860. onReady: Nullable<(node: Node) => void>;
  31861. private _isEnabled;
  31862. private _isParentEnabled;
  31863. private _isReady;
  31864. /** @hidden */
  31865. _currentRenderId: number;
  31866. private _parentUpdateId;
  31867. /** @hidden */
  31868. _childUpdateId: number;
  31869. /** @hidden */
  31870. _waitingParentId: Nullable<string>;
  31871. /** @hidden */
  31872. _scene: Scene;
  31873. /** @hidden */
  31874. _cache: any;
  31875. private _parentNode;
  31876. private _children;
  31877. /** @hidden */
  31878. _worldMatrix: Matrix;
  31879. /** @hidden */
  31880. _worldMatrixDeterminant: number;
  31881. /** @hidden */
  31882. _worldMatrixDeterminantIsDirty: boolean;
  31883. /** @hidden */
  31884. private _sceneRootNodesIndex;
  31885. /**
  31886. * Gets a boolean indicating if the node has been disposed
  31887. * @returns true if the node was disposed
  31888. */
  31889. isDisposed(): boolean;
  31890. /**
  31891. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31892. * @see https://doc.babylonjs.com/how_to/parenting
  31893. */
  31894. set parent(parent: Nullable<Node>);
  31895. get parent(): Nullable<Node>;
  31896. /** @hidden */
  31897. _addToSceneRootNodes(): void;
  31898. /** @hidden */
  31899. _removeFromSceneRootNodes(): void;
  31900. private _animationPropertiesOverride;
  31901. /**
  31902. * Gets or sets the animation properties override
  31903. */
  31904. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31905. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31906. /**
  31907. * Gets a string idenfifying the name of the class
  31908. * @returns "Node" string
  31909. */
  31910. getClassName(): string;
  31911. /** @hidden */
  31912. readonly _isNode: boolean;
  31913. /**
  31914. * An event triggered when the mesh is disposed
  31915. */
  31916. onDisposeObservable: Observable<Node>;
  31917. private _onDisposeObserver;
  31918. /**
  31919. * Sets a callback that will be raised when the node will be disposed
  31920. */
  31921. set onDispose(callback: () => void);
  31922. /**
  31923. * Creates a new Node
  31924. * @param name the name and id to be given to this node
  31925. * @param scene the scene this node will be added to
  31926. */
  31927. constructor(name: string, scene?: Nullable<Scene>);
  31928. /**
  31929. * Gets the scene of the node
  31930. * @returns a scene
  31931. */
  31932. getScene(): Scene;
  31933. /**
  31934. * Gets the engine of the node
  31935. * @returns a Engine
  31936. */
  31937. getEngine(): Engine;
  31938. private _behaviors;
  31939. /**
  31940. * Attach a behavior to the node
  31941. * @see http://doc.babylonjs.com/features/behaviour
  31942. * @param behavior defines the behavior to attach
  31943. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  31944. * @returns the current Node
  31945. */
  31946. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  31947. /**
  31948. * Remove an attached behavior
  31949. * @see http://doc.babylonjs.com/features/behaviour
  31950. * @param behavior defines the behavior to attach
  31951. * @returns the current Node
  31952. */
  31953. removeBehavior(behavior: Behavior<Node>): Node;
  31954. /**
  31955. * Gets the list of attached behaviors
  31956. * @see http://doc.babylonjs.com/features/behaviour
  31957. */
  31958. get behaviors(): Behavior<Node>[];
  31959. /**
  31960. * Gets an attached behavior by name
  31961. * @param name defines the name of the behavior to look for
  31962. * @see http://doc.babylonjs.com/features/behaviour
  31963. * @returns null if behavior was not found else the requested behavior
  31964. */
  31965. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  31966. /**
  31967. * Returns the latest update of the World matrix
  31968. * @returns a Matrix
  31969. */
  31970. getWorldMatrix(): Matrix;
  31971. /** @hidden */
  31972. _getWorldMatrixDeterminant(): number;
  31973. /**
  31974. * Returns directly the latest state of the mesh World matrix.
  31975. * A Matrix is returned.
  31976. */
  31977. get worldMatrixFromCache(): Matrix;
  31978. /** @hidden */
  31979. _initCache(): void;
  31980. /** @hidden */
  31981. updateCache(force?: boolean): void;
  31982. /** @hidden */
  31983. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31984. /** @hidden */
  31985. _updateCache(ignoreParentClass?: boolean): void;
  31986. /** @hidden */
  31987. _isSynchronized(): boolean;
  31988. /** @hidden */
  31989. _markSyncedWithParent(): void;
  31990. /** @hidden */
  31991. isSynchronizedWithParent(): boolean;
  31992. /** @hidden */
  31993. isSynchronized(): boolean;
  31994. /**
  31995. * Is this node ready to be used/rendered
  31996. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  31997. * @return true if the node is ready
  31998. */
  31999. isReady(completeCheck?: boolean): boolean;
  32000. /**
  32001. * Is this node enabled?
  32002. * 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
  32003. * @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
  32004. * @return whether this node (and its parent) is enabled
  32005. */
  32006. isEnabled(checkAncestors?: boolean): boolean;
  32007. /** @hidden */
  32008. protected _syncParentEnabledState(): void;
  32009. /**
  32010. * Set the enabled state of this node
  32011. * @param value defines the new enabled state
  32012. */
  32013. setEnabled(value: boolean): void;
  32014. /**
  32015. * Is this node a descendant of the given node?
  32016. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32017. * @param ancestor defines the parent node to inspect
  32018. * @returns a boolean indicating if this node is a descendant of the given node
  32019. */
  32020. isDescendantOf(ancestor: Node): boolean;
  32021. /** @hidden */
  32022. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32023. /**
  32024. * Will return all nodes that have this node as ascendant
  32025. * @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
  32026. * @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
  32027. * @return all children nodes of all types
  32028. */
  32029. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32030. /**
  32031. * Get all child-meshes of this node
  32032. * @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)
  32033. * @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
  32034. * @returns an array of AbstractMesh
  32035. */
  32036. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32037. /**
  32038. * Get all direct children of this node
  32039. * @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
  32040. * @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)
  32041. * @returns an array of Node
  32042. */
  32043. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32044. /** @hidden */
  32045. _setReady(state: boolean): void;
  32046. /**
  32047. * Get an animation by name
  32048. * @param name defines the name of the animation to look for
  32049. * @returns null if not found else the requested animation
  32050. */
  32051. getAnimationByName(name: string): Nullable<Animation>;
  32052. /**
  32053. * Creates an animation range for this node
  32054. * @param name defines the name of the range
  32055. * @param from defines the starting key
  32056. * @param to defines the end key
  32057. */
  32058. createAnimationRange(name: string, from: number, to: number): void;
  32059. /**
  32060. * Delete a specific animation range
  32061. * @param name defines the name of the range to delete
  32062. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32063. */
  32064. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32065. /**
  32066. * Get an animation range by name
  32067. * @param name defines the name of the animation range to look for
  32068. * @returns null if not found else the requested animation range
  32069. */
  32070. getAnimationRange(name: string): Nullable<AnimationRange>;
  32071. /**
  32072. * Gets the list of all animation ranges defined on this node
  32073. * @returns an array
  32074. */
  32075. getAnimationRanges(): Nullable<AnimationRange>[];
  32076. /**
  32077. * Will start the animation sequence
  32078. * @param name defines the range frames for animation sequence
  32079. * @param loop defines if the animation should loop (false by default)
  32080. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32081. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32082. * @returns the object created for this animation. If range does not exist, it will return null
  32083. */
  32084. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32085. /**
  32086. * Serialize animation ranges into a JSON compatible object
  32087. * @returns serialization object
  32088. */
  32089. serializeAnimationRanges(): any;
  32090. /**
  32091. * Computes the world matrix of the node
  32092. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32093. * @returns the world matrix
  32094. */
  32095. computeWorldMatrix(force?: boolean): Matrix;
  32096. /**
  32097. * Releases resources associated with this node.
  32098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32100. */
  32101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32102. /**
  32103. * Parse animation range data from a serialization object and store them into a given node
  32104. * @param node defines where to store the animation ranges
  32105. * @param parsedNode defines the serialization object to read data from
  32106. * @param scene defines the hosting scene
  32107. */
  32108. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32109. /**
  32110. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32111. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32112. * @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
  32113. * @returns the new bounding vectors
  32114. */
  32115. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32116. min: Vector3;
  32117. max: Vector3;
  32118. };
  32119. }
  32120. }
  32121. declare module BABYLON {
  32122. /**
  32123. * @hidden
  32124. */
  32125. export class _IAnimationState {
  32126. key: number;
  32127. repeatCount: number;
  32128. workValue?: any;
  32129. loopMode?: number;
  32130. offsetValue?: any;
  32131. highLimitValue?: any;
  32132. }
  32133. /**
  32134. * Class used to store any kind of animation
  32135. */
  32136. export class Animation {
  32137. /**Name of the animation */
  32138. name: string;
  32139. /**Property to animate */
  32140. targetProperty: string;
  32141. /**The frames per second of the animation */
  32142. framePerSecond: number;
  32143. /**The data type of the animation */
  32144. dataType: number;
  32145. /**The loop mode of the animation */
  32146. loopMode?: number | undefined;
  32147. /**Specifies if blending should be enabled */
  32148. enableBlending?: boolean | undefined;
  32149. /**
  32150. * Use matrix interpolation instead of using direct key value when animating matrices
  32151. */
  32152. static AllowMatricesInterpolation: boolean;
  32153. /**
  32154. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32155. */
  32156. static AllowMatrixDecomposeForInterpolation: boolean;
  32157. /**
  32158. * Stores the key frames of the animation
  32159. */
  32160. private _keys;
  32161. /**
  32162. * Stores the easing function of the animation
  32163. */
  32164. private _easingFunction;
  32165. /**
  32166. * @hidden Internal use only
  32167. */
  32168. _runtimeAnimations: RuntimeAnimation[];
  32169. /**
  32170. * The set of event that will be linked to this animation
  32171. */
  32172. private _events;
  32173. /**
  32174. * Stores an array of target property paths
  32175. */
  32176. targetPropertyPath: string[];
  32177. /**
  32178. * Stores the blending speed of the animation
  32179. */
  32180. blendingSpeed: number;
  32181. /**
  32182. * Stores the animation ranges for the animation
  32183. */
  32184. private _ranges;
  32185. /**
  32186. * @hidden Internal use
  32187. */
  32188. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32189. /**
  32190. * Sets up an animation
  32191. * @param property The property to animate
  32192. * @param animationType The animation type to apply
  32193. * @param framePerSecond The frames per second of the animation
  32194. * @param easingFunction The easing function used in the animation
  32195. * @returns The created animation
  32196. */
  32197. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32198. /**
  32199. * Create and start an animation on a node
  32200. * @param name defines the name of the global animation that will be run on all nodes
  32201. * @param node defines the root node where the animation will take place
  32202. * @param targetProperty defines property to animate
  32203. * @param framePerSecond defines the number of frame per second yo use
  32204. * @param totalFrame defines the number of frames in total
  32205. * @param from defines the initial value
  32206. * @param to defines the final value
  32207. * @param loopMode defines which loop mode you want to use (off by default)
  32208. * @param easingFunction defines the easing function to use (linear by default)
  32209. * @param onAnimationEnd defines the callback to call when animation end
  32210. * @returns the animatable created for this animation
  32211. */
  32212. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32213. /**
  32214. * Create and start an animation on a node and its descendants
  32215. * @param name defines the name of the global animation that will be run on all nodes
  32216. * @param node defines the root node where the animation will take place
  32217. * @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
  32218. * @param targetProperty defines property to animate
  32219. * @param framePerSecond defines the number of frame per second to use
  32220. * @param totalFrame defines the number of frames in total
  32221. * @param from defines the initial value
  32222. * @param to defines the final value
  32223. * @param loopMode defines which loop mode you want to use (off by default)
  32224. * @param easingFunction defines the easing function to use (linear by default)
  32225. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32226. * @returns the list of animatables created for all nodes
  32227. * @example https://www.babylonjs-playground.com/#MH0VLI
  32228. */
  32229. 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[]>;
  32230. /**
  32231. * Creates a new animation, merges it with the existing animations and starts it
  32232. * @param name Name of the animation
  32233. * @param node Node which contains the scene that begins the animations
  32234. * @param targetProperty Specifies which property to animate
  32235. * @param framePerSecond The frames per second of the animation
  32236. * @param totalFrame The total number of frames
  32237. * @param from The frame at the beginning of the animation
  32238. * @param to The frame at the end of the animation
  32239. * @param loopMode Specifies the loop mode of the animation
  32240. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32241. * @param onAnimationEnd Callback to run once the animation is complete
  32242. * @returns Nullable animation
  32243. */
  32244. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32245. /**
  32246. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32247. * @param sourceAnimation defines the Animation containing keyframes to convert
  32248. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32249. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32250. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32251. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32252. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32253. */
  32254. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32255. /**
  32256. * Transition property of an host to the target Value
  32257. * @param property The property to transition
  32258. * @param targetValue The target Value of the property
  32259. * @param host The object where the property to animate belongs
  32260. * @param scene Scene used to run the animation
  32261. * @param frameRate Framerate (in frame/s) to use
  32262. * @param transition The transition type we want to use
  32263. * @param duration The duration of the animation, in milliseconds
  32264. * @param onAnimationEnd Callback trigger at the end of the animation
  32265. * @returns Nullable animation
  32266. */
  32267. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32268. /**
  32269. * Return the array of runtime animations currently using this animation
  32270. */
  32271. get runtimeAnimations(): RuntimeAnimation[];
  32272. /**
  32273. * Specifies if any of the runtime animations are currently running
  32274. */
  32275. get hasRunningRuntimeAnimations(): boolean;
  32276. /**
  32277. * Initializes the animation
  32278. * @param name Name of the animation
  32279. * @param targetProperty Property to animate
  32280. * @param framePerSecond The frames per second of the animation
  32281. * @param dataType The data type of the animation
  32282. * @param loopMode The loop mode of the animation
  32283. * @param enableBlending Specifies if blending should be enabled
  32284. */
  32285. constructor(
  32286. /**Name of the animation */
  32287. name: string,
  32288. /**Property to animate */
  32289. targetProperty: string,
  32290. /**The frames per second of the animation */
  32291. framePerSecond: number,
  32292. /**The data type of the animation */
  32293. dataType: number,
  32294. /**The loop mode of the animation */
  32295. loopMode?: number | undefined,
  32296. /**Specifies if blending should be enabled */
  32297. enableBlending?: boolean | undefined);
  32298. /**
  32299. * Converts the animation to a string
  32300. * @param fullDetails support for multiple levels of logging within scene loading
  32301. * @returns String form of the animation
  32302. */
  32303. toString(fullDetails?: boolean): string;
  32304. /**
  32305. * Add an event to this animation
  32306. * @param event Event to add
  32307. */
  32308. addEvent(event: AnimationEvent): void;
  32309. /**
  32310. * Remove all events found at the given frame
  32311. * @param frame The frame to remove events from
  32312. */
  32313. removeEvents(frame: number): void;
  32314. /**
  32315. * Retrieves all the events from the animation
  32316. * @returns Events from the animation
  32317. */
  32318. getEvents(): AnimationEvent[];
  32319. /**
  32320. * Creates an animation range
  32321. * @param name Name of the animation range
  32322. * @param from Starting frame of the animation range
  32323. * @param to Ending frame of the animation
  32324. */
  32325. createRange(name: string, from: number, to: number): void;
  32326. /**
  32327. * Deletes an animation range by name
  32328. * @param name Name of the animation range to delete
  32329. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32330. */
  32331. deleteRange(name: string, deleteFrames?: boolean): void;
  32332. /**
  32333. * Gets the animation range by name, or null if not defined
  32334. * @param name Name of the animation range
  32335. * @returns Nullable animation range
  32336. */
  32337. getRange(name: string): Nullable<AnimationRange>;
  32338. /**
  32339. * Gets the key frames from the animation
  32340. * @returns The key frames of the animation
  32341. */
  32342. getKeys(): Array<IAnimationKey>;
  32343. /**
  32344. * Gets the highest frame rate of the animation
  32345. * @returns Highest frame rate of the animation
  32346. */
  32347. getHighestFrame(): number;
  32348. /**
  32349. * Gets the easing function of the animation
  32350. * @returns Easing function of the animation
  32351. */
  32352. getEasingFunction(): IEasingFunction;
  32353. /**
  32354. * Sets the easing function of the animation
  32355. * @param easingFunction A custom mathematical formula for animation
  32356. */
  32357. setEasingFunction(easingFunction: EasingFunction): void;
  32358. /**
  32359. * Interpolates a scalar linearly
  32360. * @param startValue Start value of the animation curve
  32361. * @param endValue End value of the animation curve
  32362. * @param gradient Scalar amount to interpolate
  32363. * @returns Interpolated scalar value
  32364. */
  32365. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32366. /**
  32367. * Interpolates a scalar cubically
  32368. * @param startValue Start value of the animation curve
  32369. * @param outTangent End tangent of the animation
  32370. * @param endValue End value of the animation curve
  32371. * @param inTangent Start tangent of the animation curve
  32372. * @param gradient Scalar amount to interpolate
  32373. * @returns Interpolated scalar value
  32374. */
  32375. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32376. /**
  32377. * Interpolates a quaternion using a spherical linear interpolation
  32378. * @param startValue Start value of the animation curve
  32379. * @param endValue End value of the animation curve
  32380. * @param gradient Scalar amount to interpolate
  32381. * @returns Interpolated quaternion value
  32382. */
  32383. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32384. /**
  32385. * Interpolates a quaternion cubically
  32386. * @param startValue Start value of the animation curve
  32387. * @param outTangent End tangent of the animation curve
  32388. * @param endValue End value of the animation curve
  32389. * @param inTangent Start tangent of the animation curve
  32390. * @param gradient Scalar amount to interpolate
  32391. * @returns Interpolated quaternion value
  32392. */
  32393. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32394. /**
  32395. * Interpolates a Vector3 linearl
  32396. * @param startValue Start value of the animation curve
  32397. * @param endValue End value of the animation curve
  32398. * @param gradient Scalar amount to interpolate
  32399. * @returns Interpolated scalar value
  32400. */
  32401. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32402. /**
  32403. * Interpolates a Vector3 cubically
  32404. * @param startValue Start value of the animation curve
  32405. * @param outTangent End tangent of the animation
  32406. * @param endValue End value of the animation curve
  32407. * @param inTangent Start tangent of the animation curve
  32408. * @param gradient Scalar amount to interpolate
  32409. * @returns InterpolatedVector3 value
  32410. */
  32411. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32412. /**
  32413. * Interpolates a Vector2 linearly
  32414. * @param startValue Start value of the animation curve
  32415. * @param endValue End value of the animation curve
  32416. * @param gradient Scalar amount to interpolate
  32417. * @returns Interpolated Vector2 value
  32418. */
  32419. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32420. /**
  32421. * Interpolates a Vector2 cubically
  32422. * @param startValue Start value of the animation curve
  32423. * @param outTangent End tangent of the animation
  32424. * @param endValue End value of the animation curve
  32425. * @param inTangent Start tangent of the animation curve
  32426. * @param gradient Scalar amount to interpolate
  32427. * @returns Interpolated Vector2 value
  32428. */
  32429. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32430. /**
  32431. * Interpolates a size linearly
  32432. * @param startValue Start value of the animation curve
  32433. * @param endValue End value of the animation curve
  32434. * @param gradient Scalar amount to interpolate
  32435. * @returns Interpolated Size value
  32436. */
  32437. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32438. /**
  32439. * Interpolates a Color3 linearly
  32440. * @param startValue Start value of the animation curve
  32441. * @param endValue End value of the animation curve
  32442. * @param gradient Scalar amount to interpolate
  32443. * @returns Interpolated Color3 value
  32444. */
  32445. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32446. /**
  32447. * Interpolates a Color4 linearly
  32448. * @param startValue Start value of the animation curve
  32449. * @param endValue End value of the animation curve
  32450. * @param gradient Scalar amount to interpolate
  32451. * @returns Interpolated Color3 value
  32452. */
  32453. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32454. /**
  32455. * @hidden Internal use only
  32456. */
  32457. _getKeyValue(value: any): any;
  32458. /**
  32459. * @hidden Internal use only
  32460. */
  32461. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32462. /**
  32463. * Defines the function to use to interpolate matrices
  32464. * @param startValue defines the start matrix
  32465. * @param endValue defines the end matrix
  32466. * @param gradient defines the gradient between both matrices
  32467. * @param result defines an optional target matrix where to store the interpolation
  32468. * @returns the interpolated matrix
  32469. */
  32470. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32471. /**
  32472. * Makes a copy of the animation
  32473. * @returns Cloned animation
  32474. */
  32475. clone(): Animation;
  32476. /**
  32477. * Sets the key frames of the animation
  32478. * @param values The animation key frames to set
  32479. */
  32480. setKeys(values: Array<IAnimationKey>): void;
  32481. /**
  32482. * Serializes the animation to an object
  32483. * @returns Serialized object
  32484. */
  32485. serialize(): any;
  32486. /**
  32487. * Float animation type
  32488. */
  32489. static readonly ANIMATIONTYPE_FLOAT: number;
  32490. /**
  32491. * Vector3 animation type
  32492. */
  32493. static readonly ANIMATIONTYPE_VECTOR3: number;
  32494. /**
  32495. * Quaternion animation type
  32496. */
  32497. static readonly ANIMATIONTYPE_QUATERNION: number;
  32498. /**
  32499. * Matrix animation type
  32500. */
  32501. static readonly ANIMATIONTYPE_MATRIX: number;
  32502. /**
  32503. * Color3 animation type
  32504. */
  32505. static readonly ANIMATIONTYPE_COLOR3: number;
  32506. /**
  32507. * Color3 animation type
  32508. */
  32509. static readonly ANIMATIONTYPE_COLOR4: number;
  32510. /**
  32511. * Vector2 animation type
  32512. */
  32513. static readonly ANIMATIONTYPE_VECTOR2: number;
  32514. /**
  32515. * Size animation type
  32516. */
  32517. static readonly ANIMATIONTYPE_SIZE: number;
  32518. /**
  32519. * Relative Loop Mode
  32520. */
  32521. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32522. /**
  32523. * Cycle Loop Mode
  32524. */
  32525. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32526. /**
  32527. * Constant Loop Mode
  32528. */
  32529. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32530. /** @hidden */
  32531. static _UniversalLerp(left: any, right: any, amount: number): any;
  32532. /**
  32533. * Parses an animation object and creates an animation
  32534. * @param parsedAnimation Parsed animation object
  32535. * @returns Animation object
  32536. */
  32537. static Parse(parsedAnimation: any): Animation;
  32538. /**
  32539. * Appends the serialized animations from the source animations
  32540. * @param source Source containing the animations
  32541. * @param destination Target to store the animations
  32542. */
  32543. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32544. }
  32545. }
  32546. declare module BABYLON {
  32547. /**
  32548. * Interface containing an array of animations
  32549. */
  32550. export interface IAnimatable {
  32551. /**
  32552. * Array of animations
  32553. */
  32554. animations: Nullable<Array<Animation>>;
  32555. }
  32556. }
  32557. declare module BABYLON {
  32558. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32559. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32560. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32561. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32562. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32563. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32564. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32565. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32566. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32567. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32568. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32569. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32570. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32571. /**
  32572. * Decorator used to define property that can be serialized as reference to a camera
  32573. * @param sourceName defines the name of the property to decorate
  32574. */
  32575. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32576. /**
  32577. * Class used to help serialization objects
  32578. */
  32579. export class SerializationHelper {
  32580. /** @hidden */
  32581. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32582. /** @hidden */
  32583. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32584. /** @hidden */
  32585. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32586. /** @hidden */
  32587. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32588. /**
  32589. * Appends the serialized animations from the source animations
  32590. * @param source Source containing the animations
  32591. * @param destination Target to store the animations
  32592. */
  32593. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32594. /**
  32595. * Static function used to serialized a specific entity
  32596. * @param entity defines the entity to serialize
  32597. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32598. * @returns a JSON compatible object representing the serialization of the entity
  32599. */
  32600. static Serialize<T>(entity: T, serializationObject?: any): any;
  32601. /**
  32602. * Creates a new entity from a serialization data object
  32603. * @param creationFunction defines a function used to instanciated the new entity
  32604. * @param source defines the source serialization data
  32605. * @param scene defines the hosting scene
  32606. * @param rootUrl defines the root url for resources
  32607. * @returns a new entity
  32608. */
  32609. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32610. /**
  32611. * Clones an object
  32612. * @param creationFunction defines the function used to instanciate the new object
  32613. * @param source defines the source object
  32614. * @returns the cloned object
  32615. */
  32616. static Clone<T>(creationFunction: () => T, source: T): T;
  32617. /**
  32618. * Instanciates a new object based on a source one (some data will be shared between both object)
  32619. * @param creationFunction defines the function used to instanciate the new object
  32620. * @param source defines the source object
  32621. * @returns the new object
  32622. */
  32623. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32624. }
  32625. }
  32626. declare module BABYLON {
  32627. /**
  32628. * Base class of all the textures in babylon.
  32629. * It groups all the common properties the materials, post process, lights... might need
  32630. * in order to make a correct use of the texture.
  32631. */
  32632. export class BaseTexture implements IAnimatable {
  32633. /**
  32634. * Default anisotropic filtering level for the application.
  32635. * It is set to 4 as a good tradeoff between perf and quality.
  32636. */
  32637. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32638. /**
  32639. * Gets or sets the unique id of the texture
  32640. */
  32641. uniqueId: number;
  32642. /**
  32643. * Define the name of the texture.
  32644. */
  32645. name: string;
  32646. /**
  32647. * Gets or sets an object used to store user defined information.
  32648. */
  32649. metadata: any;
  32650. /**
  32651. * For internal use only. Please do not use.
  32652. */
  32653. reservedDataStore: any;
  32654. private _hasAlpha;
  32655. /**
  32656. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32657. */
  32658. set hasAlpha(value: boolean);
  32659. get hasAlpha(): boolean;
  32660. /**
  32661. * Defines if the alpha value should be determined via the rgb values.
  32662. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32663. */
  32664. getAlphaFromRGB: boolean;
  32665. /**
  32666. * Intensity or strength of the texture.
  32667. * It is commonly used by materials to fine tune the intensity of the texture
  32668. */
  32669. level: number;
  32670. /**
  32671. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32672. * This is part of the texture as textures usually maps to one uv set.
  32673. */
  32674. coordinatesIndex: number;
  32675. private _coordinatesMode;
  32676. /**
  32677. * How a texture is mapped.
  32678. *
  32679. * | Value | Type | Description |
  32680. * | ----- | ----------------------------------- | ----------- |
  32681. * | 0 | EXPLICIT_MODE | |
  32682. * | 1 | SPHERICAL_MODE | |
  32683. * | 2 | PLANAR_MODE | |
  32684. * | 3 | CUBIC_MODE | |
  32685. * | 4 | PROJECTION_MODE | |
  32686. * | 5 | SKYBOX_MODE | |
  32687. * | 6 | INVCUBIC_MODE | |
  32688. * | 7 | EQUIRECTANGULAR_MODE | |
  32689. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32690. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32691. */
  32692. set coordinatesMode(value: number);
  32693. get coordinatesMode(): number;
  32694. /**
  32695. * | Value | Type | Description |
  32696. * | ----- | ------------------ | ----------- |
  32697. * | 0 | CLAMP_ADDRESSMODE | |
  32698. * | 1 | WRAP_ADDRESSMODE | |
  32699. * | 2 | MIRROR_ADDRESSMODE | |
  32700. */
  32701. wrapU: number;
  32702. /**
  32703. * | Value | Type | Description |
  32704. * | ----- | ------------------ | ----------- |
  32705. * | 0 | CLAMP_ADDRESSMODE | |
  32706. * | 1 | WRAP_ADDRESSMODE | |
  32707. * | 2 | MIRROR_ADDRESSMODE | |
  32708. */
  32709. wrapV: number;
  32710. /**
  32711. * | Value | Type | Description |
  32712. * | ----- | ------------------ | ----------- |
  32713. * | 0 | CLAMP_ADDRESSMODE | |
  32714. * | 1 | WRAP_ADDRESSMODE | |
  32715. * | 2 | MIRROR_ADDRESSMODE | |
  32716. */
  32717. wrapR: number;
  32718. /**
  32719. * With compliant hardware and browser (supporting anisotropic filtering)
  32720. * this defines the level of anisotropic filtering in the texture.
  32721. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32722. */
  32723. anisotropicFilteringLevel: number;
  32724. /**
  32725. * Define if the texture is a cube texture or if false a 2d texture.
  32726. */
  32727. get isCube(): boolean;
  32728. set isCube(value: boolean);
  32729. /**
  32730. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32731. */
  32732. get is3D(): boolean;
  32733. set is3D(value: boolean);
  32734. /**
  32735. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32736. */
  32737. get is2DArray(): boolean;
  32738. set is2DArray(value: boolean);
  32739. /**
  32740. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32741. * HDR texture are usually stored in linear space.
  32742. * This only impacts the PBR and Background materials
  32743. */
  32744. gammaSpace: boolean;
  32745. /**
  32746. * Gets or sets whether or not the texture contains RGBD data.
  32747. */
  32748. get isRGBD(): boolean;
  32749. set isRGBD(value: boolean);
  32750. /**
  32751. * Is Z inverted in the texture (useful in a cube texture).
  32752. */
  32753. invertZ: boolean;
  32754. /**
  32755. * Are mip maps generated for this texture or not.
  32756. */
  32757. get noMipmap(): boolean;
  32758. /**
  32759. * @hidden
  32760. */
  32761. lodLevelInAlpha: boolean;
  32762. /**
  32763. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32764. */
  32765. get lodGenerationOffset(): number;
  32766. set lodGenerationOffset(value: number);
  32767. /**
  32768. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32769. */
  32770. get lodGenerationScale(): number;
  32771. set lodGenerationScale(value: number);
  32772. /**
  32773. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32774. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32775. * average roughness values.
  32776. */
  32777. get linearSpecularLOD(): boolean;
  32778. set linearSpecularLOD(value: boolean);
  32779. /**
  32780. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32781. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32782. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32783. */
  32784. get irradianceTexture(): Nullable<BaseTexture>;
  32785. set irradianceTexture(value: Nullable<BaseTexture>);
  32786. /**
  32787. * Define if the texture is a render target.
  32788. */
  32789. isRenderTarget: boolean;
  32790. /**
  32791. * Define the unique id of the texture in the scene.
  32792. */
  32793. get uid(): string;
  32794. /**
  32795. * Return a string representation of the texture.
  32796. * @returns the texture as a string
  32797. */
  32798. toString(): string;
  32799. /**
  32800. * Get the class name of the texture.
  32801. * @returns "BaseTexture"
  32802. */
  32803. getClassName(): string;
  32804. /**
  32805. * Define the list of animation attached to the texture.
  32806. */
  32807. animations: Animation[];
  32808. /**
  32809. * An event triggered when the texture is disposed.
  32810. */
  32811. onDisposeObservable: Observable<BaseTexture>;
  32812. private _onDisposeObserver;
  32813. /**
  32814. * Callback triggered when the texture has been disposed.
  32815. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32816. */
  32817. set onDispose(callback: () => void);
  32818. /**
  32819. * Define the current state of the loading sequence when in delayed load mode.
  32820. */
  32821. delayLoadState: number;
  32822. private _scene;
  32823. private _engine;
  32824. /** @hidden */
  32825. _texture: Nullable<InternalTexture>;
  32826. private _uid;
  32827. /**
  32828. * Define if the texture is preventinga material to render or not.
  32829. * If not and the texture is not ready, the engine will use a default black texture instead.
  32830. */
  32831. get isBlocking(): boolean;
  32832. /**
  32833. * Instantiates a new BaseTexture.
  32834. * Base class of all the textures in babylon.
  32835. * It groups all the common properties the materials, post process, lights... might need
  32836. * in order to make a correct use of the texture.
  32837. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32838. */
  32839. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32840. /**
  32841. * Get the scene the texture belongs to.
  32842. * @returns the scene or null if undefined
  32843. */
  32844. getScene(): Nullable<Scene>;
  32845. /** @hidden */
  32846. protected _getEngine(): Nullable<ThinEngine>;
  32847. /**
  32848. * Get the texture transform matrix used to offset tile the texture for istance.
  32849. * @returns the transformation matrix
  32850. */
  32851. getTextureMatrix(): Matrix;
  32852. /**
  32853. * Get the texture reflection matrix used to rotate/transform the reflection.
  32854. * @returns the reflection matrix
  32855. */
  32856. getReflectionTextureMatrix(): Matrix;
  32857. /**
  32858. * Get the underlying lower level texture from Babylon.
  32859. * @returns the insternal texture
  32860. */
  32861. getInternalTexture(): Nullable<InternalTexture>;
  32862. /**
  32863. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32864. * @returns true if ready or not blocking
  32865. */
  32866. isReadyOrNotBlocking(): boolean;
  32867. /**
  32868. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32869. * @returns true if fully ready
  32870. */
  32871. isReady(): boolean;
  32872. private _cachedSize;
  32873. /**
  32874. * Get the size of the texture.
  32875. * @returns the texture size.
  32876. */
  32877. getSize(): ISize;
  32878. /**
  32879. * Get the base size of the texture.
  32880. * It can be different from the size if the texture has been resized for POT for instance
  32881. * @returns the base size
  32882. */
  32883. getBaseSize(): ISize;
  32884. /**
  32885. * Update the sampling mode of the texture.
  32886. * Default is Trilinear mode.
  32887. *
  32888. * | Value | Type | Description |
  32889. * | ----- | ------------------ | ----------- |
  32890. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32891. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32892. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32893. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32894. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32895. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32896. * | 7 | NEAREST_LINEAR | |
  32897. * | 8 | NEAREST_NEAREST | |
  32898. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32899. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32900. * | 11 | LINEAR_LINEAR | |
  32901. * | 12 | LINEAR_NEAREST | |
  32902. *
  32903. * > _mag_: magnification filter (close to the viewer)
  32904. * > _min_: minification filter (far from the viewer)
  32905. * > _mip_: filter used between mip map levels
  32906. *@param samplingMode Define the new sampling mode of the texture
  32907. */
  32908. updateSamplingMode(samplingMode: number): void;
  32909. /**
  32910. * Scales the texture if is `canRescale()`
  32911. * @param ratio the resize factor we want to use to rescale
  32912. */
  32913. scale(ratio: number): void;
  32914. /**
  32915. * Get if the texture can rescale.
  32916. */
  32917. get canRescale(): boolean;
  32918. /** @hidden */
  32919. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32920. /** @hidden */
  32921. _rebuild(): void;
  32922. /**
  32923. * Triggers the load sequence in delayed load mode.
  32924. */
  32925. delayLoad(): void;
  32926. /**
  32927. * Clones the texture.
  32928. * @returns the cloned texture
  32929. */
  32930. clone(): Nullable<BaseTexture>;
  32931. /**
  32932. * Get the texture underlying type (INT, FLOAT...)
  32933. */
  32934. get textureType(): number;
  32935. /**
  32936. * Get the texture underlying format (RGB, RGBA...)
  32937. */
  32938. get textureFormat(): number;
  32939. /**
  32940. * Indicates that textures need to be re-calculated for all materials
  32941. */
  32942. protected _markAllSubMeshesAsTexturesDirty(): void;
  32943. /**
  32944. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  32945. * This will returns an RGBA array buffer containing either in values (0-255) or
  32946. * float values (0-1) depending of the underlying buffer type.
  32947. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  32948. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  32949. * @param buffer defines a user defined buffer to fill with data (can be null)
  32950. * @returns The Array buffer containing the pixels data.
  32951. */
  32952. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  32953. /**
  32954. * Release and destroy the underlying lower level texture aka internalTexture.
  32955. */
  32956. releaseInternalTexture(): void;
  32957. /** @hidden */
  32958. get _lodTextureHigh(): Nullable<BaseTexture>;
  32959. /** @hidden */
  32960. get _lodTextureMid(): Nullable<BaseTexture>;
  32961. /** @hidden */
  32962. get _lodTextureLow(): Nullable<BaseTexture>;
  32963. /**
  32964. * Dispose the texture and release its associated resources.
  32965. */
  32966. dispose(): void;
  32967. /**
  32968. * Serialize the texture into a JSON representation that can be parsed later on.
  32969. * @returns the JSON representation of the texture
  32970. */
  32971. serialize(): any;
  32972. /**
  32973. * Helper function to be called back once a list of texture contains only ready textures.
  32974. * @param textures Define the list of textures to wait for
  32975. * @param callback Define the callback triggered once the entire list will be ready
  32976. */
  32977. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32978. private static _isScene;
  32979. }
  32980. }
  32981. declare module BABYLON {
  32982. /**
  32983. * Options to be used when creating an effect.
  32984. */
  32985. export interface IEffectCreationOptions {
  32986. /**
  32987. * Atrributes that will be used in the shader.
  32988. */
  32989. attributes: string[];
  32990. /**
  32991. * Uniform varible names that will be set in the shader.
  32992. */
  32993. uniformsNames: string[];
  32994. /**
  32995. * Uniform buffer variable names that will be set in the shader.
  32996. */
  32997. uniformBuffersNames: string[];
  32998. /**
  32999. * Sampler texture variable names that will be set in the shader.
  33000. */
  33001. samplers: string[];
  33002. /**
  33003. * Define statements that will be set in the shader.
  33004. */
  33005. defines: any;
  33006. /**
  33007. * Possible fallbacks for this effect to improve performance when needed.
  33008. */
  33009. fallbacks: Nullable<IEffectFallbacks>;
  33010. /**
  33011. * Callback that will be called when the shader is compiled.
  33012. */
  33013. onCompiled: Nullable<(effect: Effect) => void>;
  33014. /**
  33015. * Callback that will be called if an error occurs during shader compilation.
  33016. */
  33017. onError: Nullable<(effect: Effect, errors: string) => void>;
  33018. /**
  33019. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33020. */
  33021. indexParameters?: any;
  33022. /**
  33023. * Max number of lights that can be used in the shader.
  33024. */
  33025. maxSimultaneousLights?: number;
  33026. /**
  33027. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33028. */
  33029. transformFeedbackVaryings?: Nullable<string[]>;
  33030. }
  33031. /**
  33032. * Effect containing vertex and fragment shader that can be executed on an object.
  33033. */
  33034. export class Effect implements IDisposable {
  33035. /**
  33036. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33037. */
  33038. static ShadersRepository: string;
  33039. /**
  33040. * Enable logging of the shader code when a compilation error occurs
  33041. */
  33042. static LogShaderCodeOnCompilationError: boolean;
  33043. /**
  33044. * Name of the effect.
  33045. */
  33046. name: any;
  33047. /**
  33048. * String container all the define statements that should be set on the shader.
  33049. */
  33050. defines: string;
  33051. /**
  33052. * Callback that will be called when the shader is compiled.
  33053. */
  33054. onCompiled: Nullable<(effect: Effect) => void>;
  33055. /**
  33056. * Callback that will be called if an error occurs during shader compilation.
  33057. */
  33058. onError: Nullable<(effect: Effect, errors: string) => void>;
  33059. /**
  33060. * Callback that will be called when effect is bound.
  33061. */
  33062. onBind: Nullable<(effect: Effect) => void>;
  33063. /**
  33064. * Unique ID of the effect.
  33065. */
  33066. uniqueId: number;
  33067. /**
  33068. * Observable that will be called when the shader is compiled.
  33069. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33070. */
  33071. onCompileObservable: Observable<Effect>;
  33072. /**
  33073. * Observable that will be called if an error occurs during shader compilation.
  33074. */
  33075. onErrorObservable: Observable<Effect>;
  33076. /** @hidden */
  33077. _onBindObservable: Nullable<Observable<Effect>>;
  33078. /**
  33079. * @hidden
  33080. * Specifies if the effect was previously ready
  33081. */
  33082. _wasPreviouslyReady: boolean;
  33083. /**
  33084. * Observable that will be called when effect is bound.
  33085. */
  33086. get onBindObservable(): Observable<Effect>;
  33087. /** @hidden */
  33088. _bonesComputationForcedToCPU: boolean;
  33089. private static _uniqueIdSeed;
  33090. private _engine;
  33091. private _uniformBuffersNames;
  33092. private _uniformBuffersNamesList;
  33093. private _uniformsNames;
  33094. private _samplerList;
  33095. private _samplers;
  33096. private _isReady;
  33097. private _compilationError;
  33098. private _allFallbacksProcessed;
  33099. private _attributesNames;
  33100. private _attributes;
  33101. private _attributeLocationByName;
  33102. private _uniforms;
  33103. /**
  33104. * Key for the effect.
  33105. * @hidden
  33106. */
  33107. _key: string;
  33108. private _indexParameters;
  33109. private _fallbacks;
  33110. private _vertexSourceCode;
  33111. private _fragmentSourceCode;
  33112. private _vertexSourceCodeOverride;
  33113. private _fragmentSourceCodeOverride;
  33114. private _transformFeedbackVaryings;
  33115. /**
  33116. * Compiled shader to webGL program.
  33117. * @hidden
  33118. */
  33119. _pipelineContext: Nullable<IPipelineContext>;
  33120. private _valueCache;
  33121. private static _baseCache;
  33122. /**
  33123. * Instantiates an effect.
  33124. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33125. * @param baseName Name of the effect.
  33126. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33127. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33128. * @param samplers List of sampler variables that will be passed to the shader.
  33129. * @param engine Engine to be used to render the effect
  33130. * @param defines Define statements to be added to the shader.
  33131. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33132. * @param onCompiled Callback that will be called when the shader is compiled.
  33133. * @param onError Callback that will be called if an error occurs during shader compilation.
  33134. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33135. */
  33136. 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);
  33137. private _useFinalCode;
  33138. /**
  33139. * Unique key for this effect
  33140. */
  33141. get key(): string;
  33142. /**
  33143. * If the effect has been compiled and prepared.
  33144. * @returns if the effect is compiled and prepared.
  33145. */
  33146. isReady(): boolean;
  33147. private _isReadyInternal;
  33148. /**
  33149. * The engine the effect was initialized with.
  33150. * @returns the engine.
  33151. */
  33152. getEngine(): Engine;
  33153. /**
  33154. * The pipeline context for this effect
  33155. * @returns the associated pipeline context
  33156. */
  33157. getPipelineContext(): Nullable<IPipelineContext>;
  33158. /**
  33159. * The set of names of attribute variables for the shader.
  33160. * @returns An array of attribute names.
  33161. */
  33162. getAttributesNames(): string[];
  33163. /**
  33164. * Returns the attribute at the given index.
  33165. * @param index The index of the attribute.
  33166. * @returns The location of the attribute.
  33167. */
  33168. getAttributeLocation(index: number): number;
  33169. /**
  33170. * Returns the attribute based on the name of the variable.
  33171. * @param name of the attribute to look up.
  33172. * @returns the attribute location.
  33173. */
  33174. getAttributeLocationByName(name: string): number;
  33175. /**
  33176. * The number of attributes.
  33177. * @returns the numnber of attributes.
  33178. */
  33179. getAttributesCount(): number;
  33180. /**
  33181. * Gets the index of a uniform variable.
  33182. * @param uniformName of the uniform to look up.
  33183. * @returns the index.
  33184. */
  33185. getUniformIndex(uniformName: string): number;
  33186. /**
  33187. * Returns the attribute based on the name of the variable.
  33188. * @param uniformName of the uniform to look up.
  33189. * @returns the location of the uniform.
  33190. */
  33191. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33192. /**
  33193. * Returns an array of sampler variable names
  33194. * @returns The array of sampler variable names.
  33195. */
  33196. getSamplers(): string[];
  33197. /**
  33198. * Returns an array of uniform variable names
  33199. * @returns The array of uniform variable names.
  33200. */
  33201. getUniformNames(): string[];
  33202. /**
  33203. * Returns an array of uniform buffer variable names
  33204. * @returns The array of uniform buffer variable names.
  33205. */
  33206. getUniformBuffersNames(): string[];
  33207. /**
  33208. * Returns the index parameters used to create the effect
  33209. * @returns The index parameters object
  33210. */
  33211. getIndexParameters(): any;
  33212. /**
  33213. * The error from the last compilation.
  33214. * @returns the error string.
  33215. */
  33216. getCompilationError(): string;
  33217. /**
  33218. * Gets a boolean indicating that all fallbacks were used during compilation
  33219. * @returns true if all fallbacks were used
  33220. */
  33221. allFallbacksProcessed(): boolean;
  33222. /**
  33223. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33224. * @param func The callback to be used.
  33225. */
  33226. executeWhenCompiled(func: (effect: Effect) => void): void;
  33227. private _checkIsReady;
  33228. private _loadShader;
  33229. /**
  33230. * Gets the vertex shader source code of this effect
  33231. */
  33232. get vertexSourceCode(): string;
  33233. /**
  33234. * Gets the fragment shader source code of this effect
  33235. */
  33236. get fragmentSourceCode(): string;
  33237. /**
  33238. * Recompiles the webGL program
  33239. * @param vertexSourceCode The source code for the vertex shader.
  33240. * @param fragmentSourceCode The source code for the fragment shader.
  33241. * @param onCompiled Callback called when completed.
  33242. * @param onError Callback called on error.
  33243. * @hidden
  33244. */
  33245. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33246. /**
  33247. * Prepares the effect
  33248. * @hidden
  33249. */
  33250. _prepareEffect(): void;
  33251. private _getShaderCodeAndErrorLine;
  33252. private _processCompilationErrors;
  33253. /**
  33254. * Checks if the effect is supported. (Must be called after compilation)
  33255. */
  33256. get isSupported(): boolean;
  33257. /**
  33258. * Binds a texture to the engine to be used as output of the shader.
  33259. * @param channel Name of the output variable.
  33260. * @param texture Texture to bind.
  33261. * @hidden
  33262. */
  33263. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33264. /**
  33265. * Sets a texture on the engine to be used in the shader.
  33266. * @param channel Name of the sampler variable.
  33267. * @param texture Texture to set.
  33268. */
  33269. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33270. /**
  33271. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33272. * @param channel Name of the sampler variable.
  33273. * @param texture Texture to set.
  33274. */
  33275. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33276. /**
  33277. * Sets an array of textures on the engine to be used in the shader.
  33278. * @param channel Name of the variable.
  33279. * @param textures Textures to set.
  33280. */
  33281. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33282. /**
  33283. * 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)
  33284. * @param channel Name of the sampler variable.
  33285. * @param postProcess Post process to get the input texture from.
  33286. */
  33287. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33288. /**
  33289. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33290. * 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)
  33291. * @param channel Name of the sampler variable.
  33292. * @param postProcess Post process to get the output texture from.
  33293. */
  33294. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33295. /** @hidden */
  33296. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33297. /** @hidden */
  33298. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33299. /** @hidden */
  33300. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33301. /** @hidden */
  33302. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33303. /**
  33304. * Binds a buffer to a uniform.
  33305. * @param buffer Buffer to bind.
  33306. * @param name Name of the uniform variable to bind to.
  33307. */
  33308. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33309. /**
  33310. * Binds block to a uniform.
  33311. * @param blockName Name of the block to bind.
  33312. * @param index Index to bind.
  33313. */
  33314. bindUniformBlock(blockName: string, index: number): void;
  33315. /**
  33316. * Sets an interger value on a uniform variable.
  33317. * @param uniformName Name of the variable.
  33318. * @param value Value to be set.
  33319. * @returns this effect.
  33320. */
  33321. setInt(uniformName: string, value: number): Effect;
  33322. /**
  33323. * Sets an int array on a uniform variable.
  33324. * @param uniformName Name of the variable.
  33325. * @param array array to be set.
  33326. * @returns this effect.
  33327. */
  33328. setIntArray(uniformName: string, array: Int32Array): Effect;
  33329. /**
  33330. * 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)
  33331. * @param uniformName Name of the variable.
  33332. * @param array array to be set.
  33333. * @returns this effect.
  33334. */
  33335. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33336. /**
  33337. * 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)
  33338. * @param uniformName Name of the variable.
  33339. * @param array array to be set.
  33340. * @returns this effect.
  33341. */
  33342. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33343. /**
  33344. * 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)
  33345. * @param uniformName Name of the variable.
  33346. * @param array array to be set.
  33347. * @returns this effect.
  33348. */
  33349. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33350. /**
  33351. * Sets an float array on a uniform variable.
  33352. * @param uniformName Name of the variable.
  33353. * @param array array to be set.
  33354. * @returns this effect.
  33355. */
  33356. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33357. /**
  33358. * 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)
  33359. * @param uniformName Name of the variable.
  33360. * @param array array to be set.
  33361. * @returns this effect.
  33362. */
  33363. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33364. /**
  33365. * 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)
  33366. * @param uniformName Name of the variable.
  33367. * @param array array to be set.
  33368. * @returns this effect.
  33369. */
  33370. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33371. /**
  33372. * 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)
  33373. * @param uniformName Name of the variable.
  33374. * @param array array to be set.
  33375. * @returns this effect.
  33376. */
  33377. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33378. /**
  33379. * Sets an array on a uniform variable.
  33380. * @param uniformName Name of the variable.
  33381. * @param array array to be set.
  33382. * @returns this effect.
  33383. */
  33384. setArray(uniformName: string, array: number[]): Effect;
  33385. /**
  33386. * 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)
  33387. * @param uniformName Name of the variable.
  33388. * @param array array to be set.
  33389. * @returns this effect.
  33390. */
  33391. setArray2(uniformName: string, array: number[]): Effect;
  33392. /**
  33393. * 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)
  33394. * @param uniformName Name of the variable.
  33395. * @param array array to be set.
  33396. * @returns this effect.
  33397. */
  33398. setArray3(uniformName: string, array: number[]): Effect;
  33399. /**
  33400. * 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)
  33401. * @param uniformName Name of the variable.
  33402. * @param array array to be set.
  33403. * @returns this effect.
  33404. */
  33405. setArray4(uniformName: string, array: number[]): Effect;
  33406. /**
  33407. * Sets matrices on a uniform variable.
  33408. * @param uniformName Name of the variable.
  33409. * @param matrices matrices to be set.
  33410. * @returns this effect.
  33411. */
  33412. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33413. /**
  33414. * Sets matrix on a uniform variable.
  33415. * @param uniformName Name of the variable.
  33416. * @param matrix matrix to be set.
  33417. * @returns this effect.
  33418. */
  33419. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33420. /**
  33421. * 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)
  33422. * @param uniformName Name of the variable.
  33423. * @param matrix matrix to be set.
  33424. * @returns this effect.
  33425. */
  33426. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33427. /**
  33428. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33429. * @param uniformName Name of the variable.
  33430. * @param matrix matrix to be set.
  33431. * @returns this effect.
  33432. */
  33433. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33434. /**
  33435. * Sets a float on a uniform variable.
  33436. * @param uniformName Name of the variable.
  33437. * @param value value to be set.
  33438. * @returns this effect.
  33439. */
  33440. setFloat(uniformName: string, value: number): Effect;
  33441. /**
  33442. * Sets a boolean on a uniform variable.
  33443. * @param uniformName Name of the variable.
  33444. * @param bool value to be set.
  33445. * @returns this effect.
  33446. */
  33447. setBool(uniformName: string, bool: boolean): Effect;
  33448. /**
  33449. * Sets a Vector2 on a uniform variable.
  33450. * @param uniformName Name of the variable.
  33451. * @param vector2 vector2 to be set.
  33452. * @returns this effect.
  33453. */
  33454. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33455. /**
  33456. * Sets a float2 on a uniform variable.
  33457. * @param uniformName Name of the variable.
  33458. * @param x First float in float2.
  33459. * @param y Second float in float2.
  33460. * @returns this effect.
  33461. */
  33462. setFloat2(uniformName: string, x: number, y: number): Effect;
  33463. /**
  33464. * Sets a Vector3 on a uniform variable.
  33465. * @param uniformName Name of the variable.
  33466. * @param vector3 Value to be set.
  33467. * @returns this effect.
  33468. */
  33469. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33470. /**
  33471. * Sets a float3 on a uniform variable.
  33472. * @param uniformName Name of the variable.
  33473. * @param x First float in float3.
  33474. * @param y Second float in float3.
  33475. * @param z Third float in float3.
  33476. * @returns this effect.
  33477. */
  33478. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33479. /**
  33480. * Sets a Vector4 on a uniform variable.
  33481. * @param uniformName Name of the variable.
  33482. * @param vector4 Value to be set.
  33483. * @returns this effect.
  33484. */
  33485. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33486. /**
  33487. * Sets a float4 on a uniform variable.
  33488. * @param uniformName Name of the variable.
  33489. * @param x First float in float4.
  33490. * @param y Second float in float4.
  33491. * @param z Third float in float4.
  33492. * @param w Fourth float in float4.
  33493. * @returns this effect.
  33494. */
  33495. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33496. /**
  33497. * Sets a Color3 on a uniform variable.
  33498. * @param uniformName Name of the variable.
  33499. * @param color3 Value to be set.
  33500. * @returns this effect.
  33501. */
  33502. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33503. /**
  33504. * Sets a Color4 on a uniform variable.
  33505. * @param uniformName Name of the variable.
  33506. * @param color3 Value to be set.
  33507. * @param alpha Alpha value to be set.
  33508. * @returns this effect.
  33509. */
  33510. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33511. /**
  33512. * Sets a Color4 on a uniform variable
  33513. * @param uniformName defines the name of the variable
  33514. * @param color4 defines the value to be set
  33515. * @returns this effect.
  33516. */
  33517. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33518. /** Release all associated resources */
  33519. dispose(): void;
  33520. /**
  33521. * This function will add a new shader to the shader store
  33522. * @param name the name of the shader
  33523. * @param pixelShader optional pixel shader content
  33524. * @param vertexShader optional vertex shader content
  33525. */
  33526. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33527. /**
  33528. * Store of each shader (The can be looked up using effect.key)
  33529. */
  33530. static ShadersStore: {
  33531. [key: string]: string;
  33532. };
  33533. /**
  33534. * Store of each included file for a shader (The can be looked up using effect.key)
  33535. */
  33536. static IncludesShadersStore: {
  33537. [key: string]: string;
  33538. };
  33539. /**
  33540. * Resets the cache of effects.
  33541. */
  33542. static ResetCache(): void;
  33543. }
  33544. }
  33545. declare module BABYLON {
  33546. /**
  33547. * Interface used to describe the capabilities of the engine relatively to the current browser
  33548. */
  33549. export interface EngineCapabilities {
  33550. /** Maximum textures units per fragment shader */
  33551. maxTexturesImageUnits: number;
  33552. /** Maximum texture units per vertex shader */
  33553. maxVertexTextureImageUnits: number;
  33554. /** Maximum textures units in the entire pipeline */
  33555. maxCombinedTexturesImageUnits: number;
  33556. /** Maximum texture size */
  33557. maxTextureSize: number;
  33558. /** Maximum texture samples */
  33559. maxSamples?: number;
  33560. /** Maximum cube texture size */
  33561. maxCubemapTextureSize: number;
  33562. /** Maximum render texture size */
  33563. maxRenderTextureSize: number;
  33564. /** Maximum number of vertex attributes */
  33565. maxVertexAttribs: number;
  33566. /** Maximum number of varyings */
  33567. maxVaryingVectors: number;
  33568. /** Maximum number of uniforms per vertex shader */
  33569. maxVertexUniformVectors: number;
  33570. /** Maximum number of uniforms per fragment shader */
  33571. maxFragmentUniformVectors: number;
  33572. /** Defines if standard derivates (dx/dy) are supported */
  33573. standardDerivatives: boolean;
  33574. /** Defines if s3tc texture compression is supported */
  33575. s3tc?: WEBGL_compressed_texture_s3tc;
  33576. /** Defines if pvrtc texture compression is supported */
  33577. pvrtc: any;
  33578. /** Defines if etc1 texture compression is supported */
  33579. etc1: any;
  33580. /** Defines if etc2 texture compression is supported */
  33581. etc2: any;
  33582. /** Defines if astc texture compression is supported */
  33583. astc: any;
  33584. /** Defines if float textures are supported */
  33585. textureFloat: boolean;
  33586. /** Defines if vertex array objects are supported */
  33587. vertexArrayObject: boolean;
  33588. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33589. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33590. /** Gets the maximum level of anisotropy supported */
  33591. maxAnisotropy: number;
  33592. /** Defines if instancing is supported */
  33593. instancedArrays: boolean;
  33594. /** Defines if 32 bits indices are supported */
  33595. uintIndices: boolean;
  33596. /** Defines if high precision shaders are supported */
  33597. highPrecisionShaderSupported: boolean;
  33598. /** Defines if depth reading in the fragment shader is supported */
  33599. fragmentDepthSupported: boolean;
  33600. /** Defines if float texture linear filtering is supported*/
  33601. textureFloatLinearFiltering: boolean;
  33602. /** Defines if rendering to float textures is supported */
  33603. textureFloatRender: boolean;
  33604. /** Defines if half float textures are supported*/
  33605. textureHalfFloat: boolean;
  33606. /** Defines if half float texture linear filtering is supported*/
  33607. textureHalfFloatLinearFiltering: boolean;
  33608. /** Defines if rendering to half float textures is supported */
  33609. textureHalfFloatRender: boolean;
  33610. /** Defines if textureLOD shader command is supported */
  33611. textureLOD: boolean;
  33612. /** Defines if draw buffers extension is supported */
  33613. drawBuffersExtension: boolean;
  33614. /** Defines if depth textures are supported */
  33615. depthTextureExtension: boolean;
  33616. /** Defines if float color buffer are supported */
  33617. colorBufferFloat: boolean;
  33618. /** Gets disjoint timer query extension (null if not supported) */
  33619. timerQuery?: EXT_disjoint_timer_query;
  33620. /** Defines if timestamp can be used with timer query */
  33621. canUseTimestampForTimerQuery: boolean;
  33622. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33623. multiview?: any;
  33624. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33625. oculusMultiview?: any;
  33626. /** Function used to let the system compiles shaders in background */
  33627. parallelShaderCompile?: {
  33628. COMPLETION_STATUS_KHR: number;
  33629. };
  33630. /** Max number of texture samples for MSAA */
  33631. maxMSAASamples: number;
  33632. /** Defines if the blend min max extension is supported */
  33633. blendMinMax: boolean;
  33634. }
  33635. }
  33636. declare module BABYLON {
  33637. /**
  33638. * @hidden
  33639. **/
  33640. export class DepthCullingState {
  33641. private _isDepthTestDirty;
  33642. private _isDepthMaskDirty;
  33643. private _isDepthFuncDirty;
  33644. private _isCullFaceDirty;
  33645. private _isCullDirty;
  33646. private _isZOffsetDirty;
  33647. private _isFrontFaceDirty;
  33648. private _depthTest;
  33649. private _depthMask;
  33650. private _depthFunc;
  33651. private _cull;
  33652. private _cullFace;
  33653. private _zOffset;
  33654. private _frontFace;
  33655. /**
  33656. * Initializes the state.
  33657. */
  33658. constructor();
  33659. get isDirty(): boolean;
  33660. get zOffset(): number;
  33661. set zOffset(value: number);
  33662. get cullFace(): Nullable<number>;
  33663. set cullFace(value: Nullable<number>);
  33664. get cull(): Nullable<boolean>;
  33665. set cull(value: Nullable<boolean>);
  33666. get depthFunc(): Nullable<number>;
  33667. set depthFunc(value: Nullable<number>);
  33668. get depthMask(): boolean;
  33669. set depthMask(value: boolean);
  33670. get depthTest(): boolean;
  33671. set depthTest(value: boolean);
  33672. get frontFace(): Nullable<number>;
  33673. set frontFace(value: Nullable<number>);
  33674. reset(): void;
  33675. apply(gl: WebGLRenderingContext): void;
  33676. }
  33677. }
  33678. declare module BABYLON {
  33679. /**
  33680. * @hidden
  33681. **/
  33682. export class StencilState {
  33683. /** 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 */
  33684. static readonly ALWAYS: number;
  33685. /** Passed to stencilOperation to specify that stencil value must be kept */
  33686. static readonly KEEP: number;
  33687. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33688. static readonly REPLACE: number;
  33689. private _isStencilTestDirty;
  33690. private _isStencilMaskDirty;
  33691. private _isStencilFuncDirty;
  33692. private _isStencilOpDirty;
  33693. private _stencilTest;
  33694. private _stencilMask;
  33695. private _stencilFunc;
  33696. private _stencilFuncRef;
  33697. private _stencilFuncMask;
  33698. private _stencilOpStencilFail;
  33699. private _stencilOpDepthFail;
  33700. private _stencilOpStencilDepthPass;
  33701. get isDirty(): boolean;
  33702. get stencilFunc(): number;
  33703. set stencilFunc(value: number);
  33704. get stencilFuncRef(): number;
  33705. set stencilFuncRef(value: number);
  33706. get stencilFuncMask(): number;
  33707. set stencilFuncMask(value: number);
  33708. get stencilOpStencilFail(): number;
  33709. set stencilOpStencilFail(value: number);
  33710. get stencilOpDepthFail(): number;
  33711. set stencilOpDepthFail(value: number);
  33712. get stencilOpStencilDepthPass(): number;
  33713. set stencilOpStencilDepthPass(value: number);
  33714. get stencilMask(): number;
  33715. set stencilMask(value: number);
  33716. get stencilTest(): boolean;
  33717. set stencilTest(value: boolean);
  33718. constructor();
  33719. reset(): void;
  33720. apply(gl: WebGLRenderingContext): void;
  33721. }
  33722. }
  33723. declare module BABYLON {
  33724. /**
  33725. * @hidden
  33726. **/
  33727. export class AlphaState {
  33728. private _isAlphaBlendDirty;
  33729. private _isBlendFunctionParametersDirty;
  33730. private _isBlendEquationParametersDirty;
  33731. private _isBlendConstantsDirty;
  33732. private _alphaBlend;
  33733. private _blendFunctionParameters;
  33734. private _blendEquationParameters;
  33735. private _blendConstants;
  33736. /**
  33737. * Initializes the state.
  33738. */
  33739. constructor();
  33740. get isDirty(): boolean;
  33741. get alphaBlend(): boolean;
  33742. set alphaBlend(value: boolean);
  33743. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33744. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33745. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33746. reset(): void;
  33747. apply(gl: WebGLRenderingContext): void;
  33748. }
  33749. }
  33750. declare module BABYLON {
  33751. /** @hidden */
  33752. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33753. attributeProcessor(attribute: string): string;
  33754. varyingProcessor(varying: string, isFragment: boolean): string;
  33755. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33756. }
  33757. }
  33758. declare module BABYLON {
  33759. /**
  33760. * Interface for attribute information associated with buffer instanciation
  33761. */
  33762. export interface InstancingAttributeInfo {
  33763. /**
  33764. * Name of the GLSL attribute
  33765. * if attribute index is not specified, this is used to retrieve the index from the effect
  33766. */
  33767. attributeName: string;
  33768. /**
  33769. * Index/offset of the attribute in the vertex shader
  33770. * if not specified, this will be computes from the name.
  33771. */
  33772. index?: number;
  33773. /**
  33774. * size of the attribute, 1, 2, 3 or 4
  33775. */
  33776. attributeSize: number;
  33777. /**
  33778. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33779. */
  33780. offset: number;
  33781. /**
  33782. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33783. * default to 1
  33784. */
  33785. divisor?: number;
  33786. /**
  33787. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33788. * default is FLOAT
  33789. */
  33790. attributeType?: number;
  33791. /**
  33792. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33793. */
  33794. normalized?: boolean;
  33795. }
  33796. }
  33797. declare module BABYLON {
  33798. interface ThinEngine {
  33799. /**
  33800. * Update a video texture
  33801. * @param texture defines the texture to update
  33802. * @param video defines the video element to use
  33803. * @param invertY defines if data must be stored with Y axis inverted
  33804. */
  33805. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33806. }
  33807. }
  33808. declare module BABYLON {
  33809. /**
  33810. * Settings for finer control over video usage
  33811. */
  33812. export interface VideoTextureSettings {
  33813. /**
  33814. * Applies `autoplay` to video, if specified
  33815. */
  33816. autoPlay?: boolean;
  33817. /**
  33818. * Applies `loop` to video, if specified
  33819. */
  33820. loop?: boolean;
  33821. /**
  33822. * Automatically updates internal texture from video at every frame in the render loop
  33823. */
  33824. autoUpdateTexture: boolean;
  33825. /**
  33826. * Image src displayed during the video loading or until the user interacts with the video.
  33827. */
  33828. poster?: string;
  33829. }
  33830. /**
  33831. * If you want to display a video in your scene, this is the special texture for that.
  33832. * This special texture works similar to other textures, with the exception of a few parameters.
  33833. * @see https://doc.babylonjs.com/how_to/video_texture
  33834. */
  33835. export class VideoTexture extends Texture {
  33836. /**
  33837. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33838. */
  33839. readonly autoUpdateTexture: boolean;
  33840. /**
  33841. * The video instance used by the texture internally
  33842. */
  33843. readonly video: HTMLVideoElement;
  33844. private _onUserActionRequestedObservable;
  33845. /**
  33846. * Event triggerd when a dom action is required by the user to play the video.
  33847. * This happens due to recent changes in browser policies preventing video to auto start.
  33848. */
  33849. get onUserActionRequestedObservable(): Observable<Texture>;
  33850. private _generateMipMaps;
  33851. private _stillImageCaptured;
  33852. private _displayingPosterTexture;
  33853. private _settings;
  33854. private _createInternalTextureOnEvent;
  33855. private _frameId;
  33856. private _currentSrc;
  33857. /**
  33858. * Creates a video texture.
  33859. * If you want to display a video in your scene, this is the special texture for that.
  33860. * This special texture works similar to other textures, with the exception of a few parameters.
  33861. * @see https://doc.babylonjs.com/how_to/video_texture
  33862. * @param name optional name, will detect from video source, if not defined
  33863. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33864. * @param scene is obviously the current scene.
  33865. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33866. * @param invertY is false by default but can be used to invert video on Y axis
  33867. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33868. * @param settings allows finer control over video usage
  33869. */
  33870. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33871. private _getName;
  33872. private _getVideo;
  33873. private _createInternalTexture;
  33874. private reset;
  33875. /**
  33876. * @hidden Internal method to initiate `update`.
  33877. */
  33878. _rebuild(): void;
  33879. /**
  33880. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33881. */
  33882. update(): void;
  33883. /**
  33884. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33885. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33886. */
  33887. updateTexture(isVisible: boolean): void;
  33888. protected _updateInternalTexture: () => void;
  33889. /**
  33890. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33891. * @param url New url.
  33892. */
  33893. updateURL(url: string): void;
  33894. /**
  33895. * Clones the texture.
  33896. * @returns the cloned texture
  33897. */
  33898. clone(): VideoTexture;
  33899. /**
  33900. * Dispose the texture and release its associated resources.
  33901. */
  33902. dispose(): void;
  33903. /**
  33904. * Creates a video texture straight from a stream.
  33905. * @param scene Define the scene the texture should be created in
  33906. * @param stream Define the stream the texture should be created from
  33907. * @returns The created video texture as a promise
  33908. */
  33909. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33910. /**
  33911. * Creates a video texture straight from your WebCam video feed.
  33912. * @param scene Define the scene the texture should be created in
  33913. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33914. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33915. * @returns The created video texture as a promise
  33916. */
  33917. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33918. minWidth: number;
  33919. maxWidth: number;
  33920. minHeight: number;
  33921. maxHeight: number;
  33922. deviceId: string;
  33923. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33924. /**
  33925. * Creates a video texture straight from your WebCam video feed.
  33926. * @param scene Define the scene the texture should be created in
  33927. * @param onReady Define a callback to triggered once the texture will be ready
  33928. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33929. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33930. */
  33931. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33932. minWidth: number;
  33933. maxWidth: number;
  33934. minHeight: number;
  33935. maxHeight: number;
  33936. deviceId: string;
  33937. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  33938. }
  33939. }
  33940. declare module BABYLON {
  33941. /**
  33942. * Defines the interface used by objects working like Scene
  33943. * @hidden
  33944. */
  33945. export interface ISceneLike {
  33946. _addPendingData(data: any): void;
  33947. _removePendingData(data: any): void;
  33948. offlineProvider: IOfflineProvider;
  33949. }
  33950. /** Interface defining initialization parameters for Engine class */
  33951. export interface EngineOptions extends WebGLContextAttributes {
  33952. /**
  33953. * Defines if the engine should no exceed a specified device ratio
  33954. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  33955. */
  33956. limitDeviceRatio?: number;
  33957. /**
  33958. * Defines if webvr should be enabled automatically
  33959. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33960. */
  33961. autoEnableWebVR?: boolean;
  33962. /**
  33963. * Defines if webgl2 should be turned off even if supported
  33964. * @see http://doc.babylonjs.com/features/webgl2
  33965. */
  33966. disableWebGL2Support?: boolean;
  33967. /**
  33968. * Defines if webaudio should be initialized as well
  33969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33970. */
  33971. audioEngine?: boolean;
  33972. /**
  33973. * Defines if animations should run using a deterministic lock step
  33974. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33975. */
  33976. deterministicLockstep?: boolean;
  33977. /** Defines the maximum steps to use with deterministic lock step mode */
  33978. lockstepMaxSteps?: number;
  33979. /** Defines the seconds between each deterministic lock step */
  33980. timeStep?: number;
  33981. /**
  33982. * Defines that engine should ignore context lost events
  33983. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  33984. */
  33985. doNotHandleContextLost?: boolean;
  33986. /**
  33987. * Defines that engine should ignore modifying touch action attribute and style
  33988. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  33989. */
  33990. doNotHandleTouchAction?: boolean;
  33991. /**
  33992. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  33993. */
  33994. useHighPrecisionFloats?: boolean;
  33995. }
  33996. /**
  33997. * The base engine class (root of all engines)
  33998. */
  33999. export class ThinEngine {
  34000. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34001. static ExceptionList: ({
  34002. key: string;
  34003. capture: string;
  34004. captureConstraint: number;
  34005. targets: string[];
  34006. } | {
  34007. key: string;
  34008. capture: null;
  34009. captureConstraint: null;
  34010. targets: string[];
  34011. })[];
  34012. /** @hidden */
  34013. static _TextureLoaders: IInternalTextureLoader[];
  34014. /**
  34015. * Returns the current npm package of the sdk
  34016. */
  34017. static get NpmPackage(): string;
  34018. /**
  34019. * Returns the current version of the framework
  34020. */
  34021. static get Version(): string;
  34022. /**
  34023. * Returns a string describing the current engine
  34024. */
  34025. get description(): string;
  34026. /**
  34027. * Gets or sets the epsilon value used by collision engine
  34028. */
  34029. static CollisionsEpsilon: number;
  34030. /**
  34031. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34032. */
  34033. static get ShadersRepository(): string;
  34034. static set ShadersRepository(value: string);
  34035. /** @hidden */
  34036. _shaderProcessor: IShaderProcessor;
  34037. /**
  34038. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34039. */
  34040. forcePOTTextures: boolean;
  34041. /**
  34042. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34043. */
  34044. isFullscreen: boolean;
  34045. /**
  34046. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34047. */
  34048. cullBackFaces: boolean;
  34049. /**
  34050. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34051. */
  34052. renderEvenInBackground: boolean;
  34053. /**
  34054. * Gets or sets a boolean indicating that cache can be kept between frames
  34055. */
  34056. preventCacheWipeBetweenFrames: boolean;
  34057. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34058. validateShaderPrograms: boolean;
  34059. /**
  34060. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34061. * This can provide greater z depth for distant objects.
  34062. */
  34063. useReverseDepthBuffer: boolean;
  34064. /**
  34065. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34066. */
  34067. disableUniformBuffers: boolean;
  34068. /** @hidden */
  34069. _uniformBuffers: UniformBuffer[];
  34070. /**
  34071. * Gets a boolean indicating that the engine supports uniform buffers
  34072. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34073. */
  34074. get supportsUniformBuffers(): boolean;
  34075. /** @hidden */
  34076. _gl: WebGLRenderingContext;
  34077. /** @hidden */
  34078. _webGLVersion: number;
  34079. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34080. protected _windowIsBackground: boolean;
  34081. protected _creationOptions: EngineOptions;
  34082. protected _highPrecisionShadersAllowed: boolean;
  34083. /** @hidden */
  34084. get _shouldUseHighPrecisionShader(): boolean;
  34085. /**
  34086. * Gets a boolean indicating that only power of 2 textures are supported
  34087. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34088. */
  34089. get needPOTTextures(): boolean;
  34090. /** @hidden */
  34091. _badOS: boolean;
  34092. /** @hidden */
  34093. _badDesktopOS: boolean;
  34094. private _hardwareScalingLevel;
  34095. /** @hidden */
  34096. _caps: EngineCapabilities;
  34097. private _isStencilEnable;
  34098. private _glVersion;
  34099. private _glRenderer;
  34100. private _glVendor;
  34101. /** @hidden */
  34102. _videoTextureSupported: boolean;
  34103. protected _renderingQueueLaunched: boolean;
  34104. protected _activeRenderLoops: (() => void)[];
  34105. /**
  34106. * Observable signaled when a context lost event is raised
  34107. */
  34108. onContextLostObservable: Observable<ThinEngine>;
  34109. /**
  34110. * Observable signaled when a context restored event is raised
  34111. */
  34112. onContextRestoredObservable: Observable<ThinEngine>;
  34113. private _onContextLost;
  34114. private _onContextRestored;
  34115. protected _contextWasLost: boolean;
  34116. /** @hidden */
  34117. _doNotHandleContextLost: boolean;
  34118. /**
  34119. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34120. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34121. */
  34122. get doNotHandleContextLost(): boolean;
  34123. set doNotHandleContextLost(value: boolean);
  34124. /**
  34125. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34126. */
  34127. disableVertexArrayObjects: boolean;
  34128. /** @hidden */
  34129. protected _colorWrite: boolean;
  34130. /** @hidden */
  34131. protected _colorWriteChanged: boolean;
  34132. /** @hidden */
  34133. protected _depthCullingState: DepthCullingState;
  34134. /** @hidden */
  34135. protected _stencilState: StencilState;
  34136. /** @hidden */
  34137. _alphaState: AlphaState;
  34138. /** @hidden */
  34139. _alphaMode: number;
  34140. /** @hidden */
  34141. _alphaEquation: number;
  34142. /** @hidden */
  34143. _internalTexturesCache: InternalTexture[];
  34144. /** @hidden */
  34145. protected _activeChannel: number;
  34146. private _currentTextureChannel;
  34147. /** @hidden */
  34148. protected _boundTexturesCache: {
  34149. [key: string]: Nullable<InternalTexture>;
  34150. };
  34151. /** @hidden */
  34152. protected _currentEffect: Nullable<Effect>;
  34153. /** @hidden */
  34154. protected _currentProgram: Nullable<WebGLProgram>;
  34155. private _compiledEffects;
  34156. private _vertexAttribArraysEnabled;
  34157. /** @hidden */
  34158. protected _cachedViewport: Nullable<IViewportLike>;
  34159. private _cachedVertexArrayObject;
  34160. /** @hidden */
  34161. protected _cachedVertexBuffers: any;
  34162. /** @hidden */
  34163. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34164. /** @hidden */
  34165. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34166. /** @hidden */
  34167. _currentRenderTarget: Nullable<InternalTexture>;
  34168. private _uintIndicesCurrentlySet;
  34169. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34170. /** @hidden */
  34171. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34172. /** @hidden */
  34173. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34174. private _currentBufferPointers;
  34175. private _currentInstanceLocations;
  34176. private _currentInstanceBuffers;
  34177. private _textureUnits;
  34178. /** @hidden */
  34179. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34180. /** @hidden */
  34181. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34182. /** @hidden */
  34183. _boundRenderFunction: any;
  34184. private _vaoRecordInProgress;
  34185. private _mustWipeVertexAttributes;
  34186. private _emptyTexture;
  34187. private _emptyCubeTexture;
  34188. private _emptyTexture3D;
  34189. private _emptyTexture2DArray;
  34190. /** @hidden */
  34191. _frameHandler: number;
  34192. private _nextFreeTextureSlots;
  34193. private _maxSimultaneousTextures;
  34194. private _activeRequests;
  34195. /** @hidden */
  34196. _transformTextureUrl: Nullable<(url: string) => string>;
  34197. protected get _supportsHardwareTextureRescaling(): boolean;
  34198. private _framebufferDimensionsObject;
  34199. /**
  34200. * sets the object from which width and height will be taken from when getting render width and height
  34201. * Will fallback to the gl object
  34202. * @param dimensions the framebuffer width and height that will be used.
  34203. */
  34204. set framebufferDimensionsObject(dimensions: Nullable<{
  34205. framebufferWidth: number;
  34206. framebufferHeight: number;
  34207. }>);
  34208. /**
  34209. * Gets the current viewport
  34210. */
  34211. get currentViewport(): Nullable<IViewportLike>;
  34212. /**
  34213. * Gets the default empty texture
  34214. */
  34215. get emptyTexture(): InternalTexture;
  34216. /**
  34217. * Gets the default empty 3D texture
  34218. */
  34219. get emptyTexture3D(): InternalTexture;
  34220. /**
  34221. * Gets the default empty 2D array texture
  34222. */
  34223. get emptyTexture2DArray(): InternalTexture;
  34224. /**
  34225. * Gets the default empty cube texture
  34226. */
  34227. get emptyCubeTexture(): InternalTexture;
  34228. /**
  34229. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34230. */
  34231. readonly premultipliedAlpha: boolean;
  34232. /**
  34233. * Observable event triggered before each texture is initialized
  34234. */
  34235. onBeforeTextureInitObservable: Observable<Texture>;
  34236. /**
  34237. * Creates a new engine
  34238. * @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
  34239. * @param antialias defines enable antialiasing (default: false)
  34240. * @param options defines further options to be sent to the getContext() function
  34241. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34242. */
  34243. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34244. private _rebuildInternalTextures;
  34245. private _rebuildEffects;
  34246. /**
  34247. * Gets a boolean indicating if all created effects are ready
  34248. * @returns true if all effects are ready
  34249. */
  34250. areAllEffectsReady(): boolean;
  34251. protected _rebuildBuffers(): void;
  34252. protected _initGLContext(): void;
  34253. /**
  34254. * Gets version of the current webGL context
  34255. */
  34256. get webGLVersion(): number;
  34257. /**
  34258. * Gets a string idenfifying the name of the class
  34259. * @returns "Engine" string
  34260. */
  34261. getClassName(): string;
  34262. /**
  34263. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34264. */
  34265. get isStencilEnable(): boolean;
  34266. /** @hidden */
  34267. _prepareWorkingCanvas(): void;
  34268. /**
  34269. * Reset the texture cache to empty state
  34270. */
  34271. resetTextureCache(): void;
  34272. /**
  34273. * Gets an object containing information about the current webGL context
  34274. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34275. */
  34276. getGlInfo(): {
  34277. vendor: string;
  34278. renderer: string;
  34279. version: string;
  34280. };
  34281. /**
  34282. * Defines the hardware scaling level.
  34283. * By default the hardware scaling level is computed from the window device ratio.
  34284. * 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.
  34285. * @param level defines the level to use
  34286. */
  34287. setHardwareScalingLevel(level: number): void;
  34288. /**
  34289. * Gets the current hardware scaling level.
  34290. * By default the hardware scaling level is computed from the window device ratio.
  34291. * 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.
  34292. * @returns a number indicating the current hardware scaling level
  34293. */
  34294. getHardwareScalingLevel(): number;
  34295. /**
  34296. * Gets the list of loaded textures
  34297. * @returns an array containing all loaded textures
  34298. */
  34299. getLoadedTexturesCache(): InternalTexture[];
  34300. /**
  34301. * Gets the object containing all engine capabilities
  34302. * @returns the EngineCapabilities object
  34303. */
  34304. getCaps(): EngineCapabilities;
  34305. /**
  34306. * stop executing a render loop function and remove it from the execution array
  34307. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34308. */
  34309. stopRenderLoop(renderFunction?: () => void): void;
  34310. /** @hidden */
  34311. _renderLoop(): void;
  34312. /**
  34313. * Gets the HTML canvas attached with the current webGL context
  34314. * @returns a HTML canvas
  34315. */
  34316. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34317. /**
  34318. * Gets host window
  34319. * @returns the host window object
  34320. */
  34321. getHostWindow(): Nullable<Window>;
  34322. /**
  34323. * Gets the current render width
  34324. * @param useScreen defines if screen size must be used (or the current render target if any)
  34325. * @returns a number defining the current render width
  34326. */
  34327. getRenderWidth(useScreen?: boolean): number;
  34328. /**
  34329. * Gets the current render height
  34330. * @param useScreen defines if screen size must be used (or the current render target if any)
  34331. * @returns a number defining the current render height
  34332. */
  34333. getRenderHeight(useScreen?: boolean): number;
  34334. /**
  34335. * Can be used to override the current requestAnimationFrame requester.
  34336. * @hidden
  34337. */
  34338. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34339. /**
  34340. * Register and execute a render loop. The engine can have more than one render function
  34341. * @param renderFunction defines the function to continuously execute
  34342. */
  34343. runRenderLoop(renderFunction: () => void): void;
  34344. /**
  34345. * Clear the current render buffer or the current render target (if any is set up)
  34346. * @param color defines the color to use
  34347. * @param backBuffer defines if the back buffer must be cleared
  34348. * @param depth defines if the depth buffer must be cleared
  34349. * @param stencil defines if the stencil buffer must be cleared
  34350. */
  34351. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34352. private _viewportCached;
  34353. /** @hidden */
  34354. _viewport(x: number, y: number, width: number, height: number): void;
  34355. /**
  34356. * Set the WebGL's viewport
  34357. * @param viewport defines the viewport element to be used
  34358. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34359. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34360. */
  34361. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34362. /**
  34363. * Begin a new frame
  34364. */
  34365. beginFrame(): void;
  34366. /**
  34367. * Enf the current frame
  34368. */
  34369. endFrame(): void;
  34370. /**
  34371. * Resize the view according to the canvas' size
  34372. */
  34373. resize(): void;
  34374. /**
  34375. * Force a specific size of the canvas
  34376. * @param width defines the new canvas' width
  34377. * @param height defines the new canvas' height
  34378. */
  34379. setSize(width: number, height: number): void;
  34380. /**
  34381. * Binds the frame buffer to the specified texture.
  34382. * @param texture The texture to render to or null for the default canvas
  34383. * @param faceIndex The face of the texture to render to in case of cube texture
  34384. * @param requiredWidth The width of the target to render to
  34385. * @param requiredHeight The height of the target to render to
  34386. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34387. * @param lodLevel defines the lod level to bind to the frame buffer
  34388. * @param layer defines the 2d array index to bind to frame buffer to
  34389. */
  34390. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34391. /** @hidden */
  34392. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34393. /**
  34394. * Unbind the current render target texture from the webGL context
  34395. * @param texture defines the render target texture to unbind
  34396. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34397. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34398. */
  34399. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34400. /**
  34401. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34402. */
  34403. flushFramebuffer(): void;
  34404. /**
  34405. * Unbind the current render target and bind the default framebuffer
  34406. */
  34407. restoreDefaultFramebuffer(): void;
  34408. /** @hidden */
  34409. protected _resetVertexBufferBinding(): void;
  34410. /**
  34411. * Creates a vertex buffer
  34412. * @param data the data for the vertex buffer
  34413. * @returns the new WebGL static buffer
  34414. */
  34415. createVertexBuffer(data: DataArray): DataBuffer;
  34416. private _createVertexBuffer;
  34417. /**
  34418. * Creates a dynamic vertex buffer
  34419. * @param data the data for the dynamic vertex buffer
  34420. * @returns the new WebGL dynamic buffer
  34421. */
  34422. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34423. protected _resetIndexBufferBinding(): void;
  34424. /**
  34425. * Creates a new index buffer
  34426. * @param indices defines the content of the index buffer
  34427. * @param updatable defines if the index buffer must be updatable
  34428. * @returns a new webGL buffer
  34429. */
  34430. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34431. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34432. /**
  34433. * Bind a webGL buffer to the webGL context
  34434. * @param buffer defines the buffer to bind
  34435. */
  34436. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34437. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34438. private bindBuffer;
  34439. /**
  34440. * update the bound buffer with the given data
  34441. * @param data defines the data to update
  34442. */
  34443. updateArrayBuffer(data: Float32Array): void;
  34444. private _vertexAttribPointer;
  34445. /** @hidden */
  34446. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34447. private _bindVertexBuffersAttributes;
  34448. /**
  34449. * Records a vertex array object
  34450. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34451. * @param vertexBuffers defines the list of vertex buffers to store
  34452. * @param indexBuffer defines the index buffer to store
  34453. * @param effect defines the effect to store
  34454. * @returns the new vertex array object
  34455. */
  34456. recordVertexArrayObject(vertexBuffers: {
  34457. [key: string]: VertexBuffer;
  34458. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34459. /**
  34460. * Bind a specific vertex array object
  34461. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34462. * @param vertexArrayObject defines the vertex array object to bind
  34463. * @param indexBuffer defines the index buffer to bind
  34464. */
  34465. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34466. /**
  34467. * Bind webGl buffers directly to the webGL context
  34468. * @param vertexBuffer defines the vertex buffer to bind
  34469. * @param indexBuffer defines the index buffer to bind
  34470. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34471. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34472. * @param effect defines the effect associated with the vertex buffer
  34473. */
  34474. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34475. private _unbindVertexArrayObject;
  34476. /**
  34477. * Bind a list of vertex buffers to the webGL context
  34478. * @param vertexBuffers defines the list of vertex buffers to bind
  34479. * @param indexBuffer defines the index buffer to bind
  34480. * @param effect defines the effect associated with the vertex buffers
  34481. */
  34482. bindBuffers(vertexBuffers: {
  34483. [key: string]: Nullable<VertexBuffer>;
  34484. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34485. /**
  34486. * Unbind all instance attributes
  34487. */
  34488. unbindInstanceAttributes(): void;
  34489. /**
  34490. * Release and free the memory of a vertex array object
  34491. * @param vao defines the vertex array object to delete
  34492. */
  34493. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34494. /** @hidden */
  34495. _releaseBuffer(buffer: DataBuffer): boolean;
  34496. protected _deleteBuffer(buffer: DataBuffer): void;
  34497. /**
  34498. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34499. * @param instancesBuffer defines the webGL buffer to update and bind
  34500. * @param data defines the data to store in the buffer
  34501. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34502. */
  34503. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34504. /**
  34505. * Bind the content of a webGL buffer used with instantiation
  34506. * @param instancesBuffer defines the webGL buffer to bind
  34507. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34508. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34509. */
  34510. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34511. /**
  34512. * Disable the instance attribute corresponding to the name in parameter
  34513. * @param name defines the name of the attribute to disable
  34514. */
  34515. disableInstanceAttributeByName(name: string): void;
  34516. /**
  34517. * Disable the instance attribute corresponding to the location in parameter
  34518. * @param attributeLocation defines the attribute location of the attribute to disable
  34519. */
  34520. disableInstanceAttribute(attributeLocation: number): void;
  34521. /**
  34522. * Disable the attribute corresponding to the location in parameter
  34523. * @param attributeLocation defines the attribute location of the attribute to disable
  34524. */
  34525. disableAttributeByIndex(attributeLocation: number): void;
  34526. /**
  34527. * Send a draw order
  34528. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34529. * @param indexStart defines the starting index
  34530. * @param indexCount defines the number of index to draw
  34531. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34532. */
  34533. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34534. /**
  34535. * Draw a list of points
  34536. * @param verticesStart defines the index of first vertex to draw
  34537. * @param verticesCount defines the count of vertices to draw
  34538. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34539. */
  34540. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34541. /**
  34542. * Draw a list of unindexed primitives
  34543. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34544. * @param verticesStart defines the index of first vertex to draw
  34545. * @param verticesCount defines the count of vertices to draw
  34546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34547. */
  34548. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34549. /**
  34550. * Draw a list of indexed primitives
  34551. * @param fillMode defines the primitive to use
  34552. * @param indexStart defines the starting index
  34553. * @param indexCount defines the number of index to draw
  34554. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34555. */
  34556. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34557. /**
  34558. * Draw a list of unindexed primitives
  34559. * @param fillMode defines the primitive to use
  34560. * @param verticesStart defines the index of first vertex to draw
  34561. * @param verticesCount defines the count of vertices to draw
  34562. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34563. */
  34564. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34565. private _drawMode;
  34566. /** @hidden */
  34567. protected _reportDrawCall(): void;
  34568. /** @hidden */
  34569. _releaseEffect(effect: Effect): void;
  34570. /** @hidden */
  34571. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34572. /**
  34573. * Create a new effect (used to store vertex/fragment shaders)
  34574. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34575. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34576. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34577. * @param samplers defines an array of string used to represent textures
  34578. * @param defines defines the string containing the defines to use to compile the shaders
  34579. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34580. * @param onCompiled defines a function to call when the effect creation is successful
  34581. * @param onError defines a function to call when the effect creation has failed
  34582. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34583. * @returns the new Effect
  34584. */
  34585. 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;
  34586. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34587. private _compileShader;
  34588. private _compileRawShader;
  34589. /** @hidden */
  34590. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34591. /**
  34592. * Directly creates a webGL program
  34593. * @param pipelineContext defines the pipeline context to attach to
  34594. * @param vertexCode defines the vertex shader code to use
  34595. * @param fragmentCode defines the fragment shader code to use
  34596. * @param context defines the webGL context to use (if not set, the current one will be used)
  34597. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34598. * @returns the new webGL program
  34599. */
  34600. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34601. /**
  34602. * Creates a webGL program
  34603. * @param pipelineContext defines the pipeline context to attach to
  34604. * @param vertexCode defines the vertex shader code to use
  34605. * @param fragmentCode defines the fragment shader code to use
  34606. * @param defines defines the string containing the defines to use to compile the shaders
  34607. * @param context defines the webGL context to use (if not set, the current one will be used)
  34608. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34609. * @returns the new webGL program
  34610. */
  34611. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34612. /**
  34613. * Creates a new pipeline context
  34614. * @returns the new pipeline
  34615. */
  34616. createPipelineContext(): IPipelineContext;
  34617. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34618. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34619. /** @hidden */
  34620. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34621. /** @hidden */
  34622. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34623. /** @hidden */
  34624. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34625. /**
  34626. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34627. * @param pipelineContext defines the pipeline context to use
  34628. * @param uniformsNames defines the list of uniform names
  34629. * @returns an array of webGL uniform locations
  34630. */
  34631. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34632. /**
  34633. * Gets the lsit of active attributes for a given webGL program
  34634. * @param pipelineContext defines the pipeline context to use
  34635. * @param attributesNames defines the list of attribute names to get
  34636. * @returns an array of indices indicating the offset of each attribute
  34637. */
  34638. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34639. /**
  34640. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34641. * @param effect defines the effect to activate
  34642. */
  34643. enableEffect(effect: Nullable<Effect>): void;
  34644. /**
  34645. * Set the value of an uniform to a number (int)
  34646. * @param uniform defines the webGL uniform location where to store the value
  34647. * @param value defines the int number to store
  34648. */
  34649. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34650. /**
  34651. * Set the value of an uniform to an array of int32
  34652. * @param uniform defines the webGL uniform location where to store the value
  34653. * @param array defines the array of int32 to store
  34654. */
  34655. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34656. /**
  34657. * Set the value of an uniform to an array of int32 (stored as vec2)
  34658. * @param uniform defines the webGL uniform location where to store the value
  34659. * @param array defines the array of int32 to store
  34660. */
  34661. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34662. /**
  34663. * Set the value of an uniform to an array of int32 (stored as vec3)
  34664. * @param uniform defines the webGL uniform location where to store the value
  34665. * @param array defines the array of int32 to store
  34666. */
  34667. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34668. /**
  34669. * Set the value of an uniform to an array of int32 (stored as vec4)
  34670. * @param uniform defines the webGL uniform location where to store the value
  34671. * @param array defines the array of int32 to store
  34672. */
  34673. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34674. /**
  34675. * Set the value of an uniform to an array of number
  34676. * @param uniform defines the webGL uniform location where to store the value
  34677. * @param array defines the array of number to store
  34678. */
  34679. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34680. /**
  34681. * Set the value of an uniform to an array of number (stored as vec2)
  34682. * @param uniform defines the webGL uniform location where to store the value
  34683. * @param array defines the array of number to store
  34684. */
  34685. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34686. /**
  34687. * Set the value of an uniform to an array of number (stored as vec3)
  34688. * @param uniform defines the webGL uniform location where to store the value
  34689. * @param array defines the array of number to store
  34690. */
  34691. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34692. /**
  34693. * Set the value of an uniform to an array of number (stored as vec4)
  34694. * @param uniform defines the webGL uniform location where to store the value
  34695. * @param array defines the array of number to store
  34696. */
  34697. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34698. /**
  34699. * Set the value of an uniform to an array of float32 (stored as matrices)
  34700. * @param uniform defines the webGL uniform location where to store the value
  34701. * @param matrices defines the array of float32 to store
  34702. */
  34703. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34704. /**
  34705. * Set the value of an uniform to a matrix (3x3)
  34706. * @param uniform defines the webGL uniform location where to store the value
  34707. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34708. */
  34709. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34710. /**
  34711. * Set the value of an uniform to a matrix (2x2)
  34712. * @param uniform defines the webGL uniform location where to store the value
  34713. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34714. */
  34715. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34716. /**
  34717. * Set the value of an uniform to a number (float)
  34718. * @param uniform defines the webGL uniform location where to store the value
  34719. * @param value defines the float number to store
  34720. */
  34721. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34722. /**
  34723. * Set the value of an uniform to a vec2
  34724. * @param uniform defines the webGL uniform location where to store the value
  34725. * @param x defines the 1st component of the value
  34726. * @param y defines the 2nd component of the value
  34727. */
  34728. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34729. /**
  34730. * Set the value of an uniform to a vec3
  34731. * @param uniform defines the webGL uniform location where to store the value
  34732. * @param x defines the 1st component of the value
  34733. * @param y defines the 2nd component of the value
  34734. * @param z defines the 3rd component of the value
  34735. */
  34736. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34737. /**
  34738. * Set the value of an uniform to a vec4
  34739. * @param uniform defines the webGL uniform location where to store the value
  34740. * @param x defines the 1st component of the value
  34741. * @param y defines the 2nd component of the value
  34742. * @param z defines the 3rd component of the value
  34743. * @param w defines the 4th component of the value
  34744. */
  34745. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34746. /**
  34747. * Apply all cached states (depth, culling, stencil and alpha)
  34748. */
  34749. applyStates(): void;
  34750. /**
  34751. * Enable or disable color writing
  34752. * @param enable defines the state to set
  34753. */
  34754. setColorWrite(enable: boolean): void;
  34755. /**
  34756. * Gets a boolean indicating if color writing is enabled
  34757. * @returns the current color writing state
  34758. */
  34759. getColorWrite(): boolean;
  34760. /**
  34761. * Gets the depth culling state manager
  34762. */
  34763. get depthCullingState(): DepthCullingState;
  34764. /**
  34765. * Gets the alpha state manager
  34766. */
  34767. get alphaState(): AlphaState;
  34768. /**
  34769. * Gets the stencil state manager
  34770. */
  34771. get stencilState(): StencilState;
  34772. /**
  34773. * Clears the list of texture accessible through engine.
  34774. * This can help preventing texture load conflict due to name collision.
  34775. */
  34776. clearInternalTexturesCache(): void;
  34777. /**
  34778. * Force the entire cache to be cleared
  34779. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34780. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34781. */
  34782. wipeCaches(bruteForce?: boolean): void;
  34783. /** @hidden */
  34784. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34785. min: number;
  34786. mag: number;
  34787. };
  34788. /** @hidden */
  34789. _createTexture(): WebGLTexture;
  34790. /**
  34791. * Usually called from Texture.ts.
  34792. * Passed information to create a WebGLTexture
  34793. * @param url defines a value which contains one of the following:
  34794. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34795. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34796. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34797. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34798. * @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)
  34799. * @param scene needed for loading to the correct scene
  34800. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34801. * @param onLoad optional callback to be called upon successful completion
  34802. * @param onError optional callback to be called upon failure
  34803. * @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
  34804. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34805. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34806. * @param forcedExtension defines the extension to use to pick the right loader
  34807. * @param mimeType defines an optional mime type
  34808. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34809. */
  34810. 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;
  34811. /**
  34812. * Loads an image as an HTMLImageElement.
  34813. * @param input url string, ArrayBuffer, or Blob to load
  34814. * @param onLoad callback called when the image successfully loads
  34815. * @param onError callback called when the image fails to load
  34816. * @param offlineProvider offline provider for caching
  34817. * @param mimeType optional mime type
  34818. * @returns the HTMLImageElement of the loaded image
  34819. * @hidden
  34820. */
  34821. 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>;
  34822. /**
  34823. * @hidden
  34824. */
  34825. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34826. private _unpackFlipYCached;
  34827. /**
  34828. * In case you are sharing the context with other applications, it might
  34829. * be interested to not cache the unpack flip y state to ensure a consistent
  34830. * value would be set.
  34831. */
  34832. enableUnpackFlipYCached: boolean;
  34833. /** @hidden */
  34834. _unpackFlipY(value: boolean): void;
  34835. /** @hidden */
  34836. _getUnpackAlignement(): number;
  34837. private _getTextureTarget;
  34838. /**
  34839. * Update the sampling mode of a given texture
  34840. * @param samplingMode defines the required sampling mode
  34841. * @param texture defines the texture to update
  34842. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34843. */
  34844. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34845. /**
  34846. * Update the sampling mode of a given texture
  34847. * @param texture defines the texture to update
  34848. * @param wrapU defines the texture wrap mode of the u coordinates
  34849. * @param wrapV defines the texture wrap mode of the v coordinates
  34850. * @param wrapR defines the texture wrap mode of the r coordinates
  34851. */
  34852. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34853. /** @hidden */
  34854. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34855. width: number;
  34856. height: number;
  34857. layers?: number;
  34858. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34859. /** @hidden */
  34860. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34861. /** @hidden */
  34862. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34863. /**
  34864. * Update a portion of an internal texture
  34865. * @param texture defines the texture to update
  34866. * @param imageData defines the data to store into the texture
  34867. * @param xOffset defines the x coordinates of the update rectangle
  34868. * @param yOffset defines the y coordinates of the update rectangle
  34869. * @param width defines the width of the update rectangle
  34870. * @param height defines the height of the update rectangle
  34871. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34872. * @param lod defines the lod level to update (0 by default)
  34873. */
  34874. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34875. /** @hidden */
  34876. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34877. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34878. private _prepareWebGLTexture;
  34879. /** @hidden */
  34880. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34881. private _getDepthStencilBuffer;
  34882. /** @hidden */
  34883. _releaseFramebufferObjects(texture: InternalTexture): void;
  34884. /** @hidden */
  34885. _releaseTexture(texture: InternalTexture): void;
  34886. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34887. protected _setProgram(program: WebGLProgram): void;
  34888. protected _boundUniforms: {
  34889. [key: number]: WebGLUniformLocation;
  34890. };
  34891. /**
  34892. * Binds an effect to the webGL context
  34893. * @param effect defines the effect to bind
  34894. */
  34895. bindSamplers(effect: Effect): void;
  34896. private _activateCurrentTexture;
  34897. /** @hidden */
  34898. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34899. /** @hidden */
  34900. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34901. /**
  34902. * Unbind all textures from the webGL context
  34903. */
  34904. unbindAllTextures(): void;
  34905. /**
  34906. * Sets a texture to the according uniform.
  34907. * @param channel The texture channel
  34908. * @param uniform The uniform to set
  34909. * @param texture The texture to apply
  34910. */
  34911. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34912. private _bindSamplerUniformToChannel;
  34913. private _getTextureWrapMode;
  34914. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34915. /**
  34916. * Sets an array of texture to the webGL context
  34917. * @param channel defines the channel where the texture array must be set
  34918. * @param uniform defines the associated uniform location
  34919. * @param textures defines the array of textures to bind
  34920. */
  34921. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34922. /** @hidden */
  34923. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34924. private _setTextureParameterFloat;
  34925. private _setTextureParameterInteger;
  34926. /**
  34927. * Unbind all vertex attributes from the webGL context
  34928. */
  34929. unbindAllAttributes(): void;
  34930. /**
  34931. * 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
  34932. */
  34933. releaseEffects(): void;
  34934. /**
  34935. * Dispose and release all associated resources
  34936. */
  34937. dispose(): void;
  34938. /**
  34939. * Attach a new callback raised when context lost event is fired
  34940. * @param callback defines the callback to call
  34941. */
  34942. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34943. /**
  34944. * Attach a new callback raised when context restored event is fired
  34945. * @param callback defines the callback to call
  34946. */
  34947. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34948. /**
  34949. * Get the current error code of the webGL context
  34950. * @returns the error code
  34951. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34952. */
  34953. getError(): number;
  34954. private _canRenderToFloatFramebuffer;
  34955. private _canRenderToHalfFloatFramebuffer;
  34956. private _canRenderToFramebuffer;
  34957. /** @hidden */
  34958. _getWebGLTextureType(type: number): number;
  34959. /** @hidden */
  34960. _getInternalFormat(format: number): number;
  34961. /** @hidden */
  34962. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  34963. /** @hidden */
  34964. _getRGBAMultiSampleBufferFormat(type: number): number;
  34965. /** @hidden */
  34966. _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;
  34967. /**
  34968. * Loads a file from a url
  34969. * @param url url to load
  34970. * @param onSuccess callback called when the file successfully loads
  34971. * @param onProgress callback called while file is loading (if the server supports this mode)
  34972. * @param offlineProvider defines the offline provider for caching
  34973. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34974. * @param onError callback called when the file fails to load
  34975. * @returns a file request object
  34976. * @hidden
  34977. */
  34978. 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;
  34979. /**
  34980. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34981. * @param x defines the x coordinate of the rectangle where pixels must be read
  34982. * @param y defines the y coordinate of the rectangle where pixels must be read
  34983. * @param width defines the width of the rectangle where pixels must be read
  34984. * @param height defines the height of the rectangle where pixels must be read
  34985. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  34986. * @returns a Uint8Array containing RGBA colors
  34987. */
  34988. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  34989. private static _isSupported;
  34990. /**
  34991. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34992. * @returns true if the engine can be created
  34993. * @ignorenaming
  34994. */
  34995. static isSupported(): boolean;
  34996. /**
  34997. * Find the next highest power of two.
  34998. * @param x Number to start search from.
  34999. * @return Next highest power of two.
  35000. */
  35001. static CeilingPOT(x: number): number;
  35002. /**
  35003. * Find the next lowest power of two.
  35004. * @param x Number to start search from.
  35005. * @return Next lowest power of two.
  35006. */
  35007. static FloorPOT(x: number): number;
  35008. /**
  35009. * Find the nearest power of two.
  35010. * @param x Number to start search from.
  35011. * @return Next nearest power of two.
  35012. */
  35013. static NearestPOT(x: number): number;
  35014. /**
  35015. * Get the closest exponent of two
  35016. * @param value defines the value to approximate
  35017. * @param max defines the maximum value to return
  35018. * @param mode defines how to define the closest value
  35019. * @returns closest exponent of two of the given value
  35020. */
  35021. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35022. /**
  35023. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35024. * @param func - the function to be called
  35025. * @param requester - the object that will request the next frame. Falls back to window.
  35026. * @returns frame number
  35027. */
  35028. static QueueNewFrame(func: () => void, requester?: any): number;
  35029. /**
  35030. * Gets host document
  35031. * @returns the host document object
  35032. */
  35033. getHostDocument(): Nullable<Document>;
  35034. }
  35035. }
  35036. declare module BABYLON {
  35037. /**
  35038. * Class representing spherical harmonics coefficients to the 3rd degree
  35039. */
  35040. export class SphericalHarmonics {
  35041. /**
  35042. * Defines whether or not the harmonics have been prescaled for rendering.
  35043. */
  35044. preScaled: boolean;
  35045. /**
  35046. * The l0,0 coefficients of the spherical harmonics
  35047. */
  35048. l00: Vector3;
  35049. /**
  35050. * The l1,-1 coefficients of the spherical harmonics
  35051. */
  35052. l1_1: Vector3;
  35053. /**
  35054. * The l1,0 coefficients of the spherical harmonics
  35055. */
  35056. l10: Vector3;
  35057. /**
  35058. * The l1,1 coefficients of the spherical harmonics
  35059. */
  35060. l11: Vector3;
  35061. /**
  35062. * The l2,-2 coefficients of the spherical harmonics
  35063. */
  35064. l2_2: Vector3;
  35065. /**
  35066. * The l2,-1 coefficients of the spherical harmonics
  35067. */
  35068. l2_1: Vector3;
  35069. /**
  35070. * The l2,0 coefficients of the spherical harmonics
  35071. */
  35072. l20: Vector3;
  35073. /**
  35074. * The l2,1 coefficients of the spherical harmonics
  35075. */
  35076. l21: Vector3;
  35077. /**
  35078. * The l2,2 coefficients of the spherical harmonics
  35079. */
  35080. l22: Vector3;
  35081. /**
  35082. * Adds a light to the spherical harmonics
  35083. * @param direction the direction of the light
  35084. * @param color the color of the light
  35085. * @param deltaSolidAngle the delta solid angle of the light
  35086. */
  35087. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35088. /**
  35089. * Scales the spherical harmonics by the given amount
  35090. * @param scale the amount to scale
  35091. */
  35092. scaleInPlace(scale: number): void;
  35093. /**
  35094. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35095. *
  35096. * ```
  35097. * E_lm = A_l * L_lm
  35098. * ```
  35099. *
  35100. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35101. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35102. * the scaling factors are given in equation 9.
  35103. */
  35104. convertIncidentRadianceToIrradiance(): void;
  35105. /**
  35106. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35107. *
  35108. * ```
  35109. * L = (1/pi) * E * rho
  35110. * ```
  35111. *
  35112. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35113. */
  35114. convertIrradianceToLambertianRadiance(): void;
  35115. /**
  35116. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35117. * required operations at run time.
  35118. *
  35119. * This is simply done by scaling back the SH with Ylm constants parameter.
  35120. * The trigonometric part being applied by the shader at run time.
  35121. */
  35122. preScaleForRendering(): void;
  35123. /**
  35124. * Constructs a spherical harmonics from an array.
  35125. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35126. * @returns the spherical harmonics
  35127. */
  35128. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35129. /**
  35130. * Gets the spherical harmonics from polynomial
  35131. * @param polynomial the spherical polynomial
  35132. * @returns the spherical harmonics
  35133. */
  35134. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35135. }
  35136. /**
  35137. * Class representing spherical polynomial coefficients to the 3rd degree
  35138. */
  35139. export class SphericalPolynomial {
  35140. private _harmonics;
  35141. /**
  35142. * The spherical harmonics used to create the polynomials.
  35143. */
  35144. get preScaledHarmonics(): SphericalHarmonics;
  35145. /**
  35146. * The x coefficients of the spherical polynomial
  35147. */
  35148. x: Vector3;
  35149. /**
  35150. * The y coefficients of the spherical polynomial
  35151. */
  35152. y: Vector3;
  35153. /**
  35154. * The z coefficients of the spherical polynomial
  35155. */
  35156. z: Vector3;
  35157. /**
  35158. * The xx coefficients of the spherical polynomial
  35159. */
  35160. xx: Vector3;
  35161. /**
  35162. * The yy coefficients of the spherical polynomial
  35163. */
  35164. yy: Vector3;
  35165. /**
  35166. * The zz coefficients of the spherical polynomial
  35167. */
  35168. zz: Vector3;
  35169. /**
  35170. * The xy coefficients of the spherical polynomial
  35171. */
  35172. xy: Vector3;
  35173. /**
  35174. * The yz coefficients of the spherical polynomial
  35175. */
  35176. yz: Vector3;
  35177. /**
  35178. * The zx coefficients of the spherical polynomial
  35179. */
  35180. zx: Vector3;
  35181. /**
  35182. * Adds an ambient color to the spherical polynomial
  35183. * @param color the color to add
  35184. */
  35185. addAmbient(color: Color3): void;
  35186. /**
  35187. * Scales the spherical polynomial by the given amount
  35188. * @param scale the amount to scale
  35189. */
  35190. scaleInPlace(scale: number): void;
  35191. /**
  35192. * Gets the spherical polynomial from harmonics
  35193. * @param harmonics the spherical harmonics
  35194. * @returns the spherical polynomial
  35195. */
  35196. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35197. /**
  35198. * Constructs a spherical polynomial from an array.
  35199. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35200. * @returns the spherical polynomial
  35201. */
  35202. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35203. }
  35204. }
  35205. declare module BABYLON {
  35206. /**
  35207. * Defines the source of the internal texture
  35208. */
  35209. export enum InternalTextureSource {
  35210. /**
  35211. * The source of the texture data is unknown
  35212. */
  35213. Unknown = 0,
  35214. /**
  35215. * Texture data comes from an URL
  35216. */
  35217. Url = 1,
  35218. /**
  35219. * Texture data is only used for temporary storage
  35220. */
  35221. Temp = 2,
  35222. /**
  35223. * Texture data comes from raw data (ArrayBuffer)
  35224. */
  35225. Raw = 3,
  35226. /**
  35227. * Texture content is dynamic (video or dynamic texture)
  35228. */
  35229. Dynamic = 4,
  35230. /**
  35231. * Texture content is generated by rendering to it
  35232. */
  35233. RenderTarget = 5,
  35234. /**
  35235. * Texture content is part of a multi render target process
  35236. */
  35237. MultiRenderTarget = 6,
  35238. /**
  35239. * Texture data comes from a cube data file
  35240. */
  35241. Cube = 7,
  35242. /**
  35243. * Texture data comes from a raw cube data
  35244. */
  35245. CubeRaw = 8,
  35246. /**
  35247. * Texture data come from a prefiltered cube data file
  35248. */
  35249. CubePrefiltered = 9,
  35250. /**
  35251. * Texture content is raw 3D data
  35252. */
  35253. Raw3D = 10,
  35254. /**
  35255. * Texture content is raw 2D array data
  35256. */
  35257. Raw2DArray = 11,
  35258. /**
  35259. * Texture content is a depth texture
  35260. */
  35261. Depth = 12,
  35262. /**
  35263. * Texture data comes from a raw cube data encoded with RGBD
  35264. */
  35265. CubeRawRGBD = 13
  35266. }
  35267. /**
  35268. * Class used to store data associated with WebGL texture data for the engine
  35269. * This class should not be used directly
  35270. */
  35271. export class InternalTexture {
  35272. /** @hidden */
  35273. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35274. /**
  35275. * Defines if the texture is ready
  35276. */
  35277. isReady: boolean;
  35278. /**
  35279. * Defines if the texture is a cube texture
  35280. */
  35281. isCube: boolean;
  35282. /**
  35283. * Defines if the texture contains 3D data
  35284. */
  35285. is3D: boolean;
  35286. /**
  35287. * Defines if the texture contains 2D array data
  35288. */
  35289. is2DArray: boolean;
  35290. /**
  35291. * Defines if the texture contains multiview data
  35292. */
  35293. isMultiview: boolean;
  35294. /**
  35295. * Gets the URL used to load this texture
  35296. */
  35297. url: string;
  35298. /**
  35299. * Gets the sampling mode of the texture
  35300. */
  35301. samplingMode: number;
  35302. /**
  35303. * Gets a boolean indicating if the texture needs mipmaps generation
  35304. */
  35305. generateMipMaps: boolean;
  35306. /**
  35307. * Gets the number of samples used by the texture (WebGL2+ only)
  35308. */
  35309. samples: number;
  35310. /**
  35311. * Gets the type of the texture (int, float...)
  35312. */
  35313. type: number;
  35314. /**
  35315. * Gets the format of the texture (RGB, RGBA...)
  35316. */
  35317. format: number;
  35318. /**
  35319. * Observable called when the texture is loaded
  35320. */
  35321. onLoadedObservable: Observable<InternalTexture>;
  35322. /**
  35323. * Gets the width of the texture
  35324. */
  35325. width: number;
  35326. /**
  35327. * Gets the height of the texture
  35328. */
  35329. height: number;
  35330. /**
  35331. * Gets the depth of the texture
  35332. */
  35333. depth: number;
  35334. /**
  35335. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35336. */
  35337. baseWidth: number;
  35338. /**
  35339. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35340. */
  35341. baseHeight: number;
  35342. /**
  35343. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35344. */
  35345. baseDepth: number;
  35346. /**
  35347. * Gets a boolean indicating if the texture is inverted on Y axis
  35348. */
  35349. invertY: boolean;
  35350. /** @hidden */
  35351. _invertVScale: boolean;
  35352. /** @hidden */
  35353. _associatedChannel: number;
  35354. /** @hidden */
  35355. _source: InternalTextureSource;
  35356. /** @hidden */
  35357. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35358. /** @hidden */
  35359. _bufferView: Nullable<ArrayBufferView>;
  35360. /** @hidden */
  35361. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35362. /** @hidden */
  35363. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35364. /** @hidden */
  35365. _size: number;
  35366. /** @hidden */
  35367. _extension: string;
  35368. /** @hidden */
  35369. _files: Nullable<string[]>;
  35370. /** @hidden */
  35371. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35372. /** @hidden */
  35373. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35374. /** @hidden */
  35375. _framebuffer: Nullable<WebGLFramebuffer>;
  35376. /** @hidden */
  35377. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35378. /** @hidden */
  35379. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35380. /** @hidden */
  35381. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35382. /** @hidden */
  35383. _attachments: Nullable<number[]>;
  35384. /** @hidden */
  35385. _cachedCoordinatesMode: Nullable<number>;
  35386. /** @hidden */
  35387. _cachedWrapU: Nullable<number>;
  35388. /** @hidden */
  35389. _cachedWrapV: Nullable<number>;
  35390. /** @hidden */
  35391. _cachedWrapR: Nullable<number>;
  35392. /** @hidden */
  35393. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35394. /** @hidden */
  35395. _isDisabled: boolean;
  35396. /** @hidden */
  35397. _compression: Nullable<string>;
  35398. /** @hidden */
  35399. _generateStencilBuffer: boolean;
  35400. /** @hidden */
  35401. _generateDepthBuffer: boolean;
  35402. /** @hidden */
  35403. _comparisonFunction: number;
  35404. /** @hidden */
  35405. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35406. /** @hidden */
  35407. _lodGenerationScale: number;
  35408. /** @hidden */
  35409. _lodGenerationOffset: number;
  35410. /** @hidden */
  35411. _depthStencilTexture: Nullable<InternalTexture>;
  35412. /** @hidden */
  35413. _colorTextureArray: Nullable<WebGLTexture>;
  35414. /** @hidden */
  35415. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35416. /** @hidden */
  35417. _lodTextureHigh: Nullable<BaseTexture>;
  35418. /** @hidden */
  35419. _lodTextureMid: Nullable<BaseTexture>;
  35420. /** @hidden */
  35421. _lodTextureLow: Nullable<BaseTexture>;
  35422. /** @hidden */
  35423. _isRGBD: boolean;
  35424. /** @hidden */
  35425. _linearSpecularLOD: boolean;
  35426. /** @hidden */
  35427. _irradianceTexture: Nullable<BaseTexture>;
  35428. /** @hidden */
  35429. _webGLTexture: Nullable<WebGLTexture>;
  35430. /** @hidden */
  35431. _references: number;
  35432. private _engine;
  35433. /**
  35434. * Gets the Engine the texture belongs to.
  35435. * @returns The babylon engine
  35436. */
  35437. getEngine(): ThinEngine;
  35438. /**
  35439. * Gets the data source type of the texture
  35440. */
  35441. get source(): InternalTextureSource;
  35442. /**
  35443. * Creates a new InternalTexture
  35444. * @param engine defines the engine to use
  35445. * @param source defines the type of data that will be used
  35446. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35447. */
  35448. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35449. /**
  35450. * Increments the number of references (ie. the number of Texture that point to it)
  35451. */
  35452. incrementReferences(): void;
  35453. /**
  35454. * Change the size of the texture (not the size of the content)
  35455. * @param width defines the new width
  35456. * @param height defines the new height
  35457. * @param depth defines the new depth (1 by default)
  35458. */
  35459. updateSize(width: int, height: int, depth?: int): void;
  35460. /** @hidden */
  35461. _rebuild(): void;
  35462. /** @hidden */
  35463. _swapAndDie(target: InternalTexture): void;
  35464. /**
  35465. * Dispose the current allocated resources
  35466. */
  35467. dispose(): void;
  35468. }
  35469. }
  35470. declare module BABYLON {
  35471. /**
  35472. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35474. */
  35475. export class Analyser {
  35476. /**
  35477. * Gets or sets the smoothing
  35478. * @ignorenaming
  35479. */
  35480. SMOOTHING: number;
  35481. /**
  35482. * Gets or sets the FFT table size
  35483. * @ignorenaming
  35484. */
  35485. FFT_SIZE: number;
  35486. /**
  35487. * Gets or sets the bar graph amplitude
  35488. * @ignorenaming
  35489. */
  35490. BARGRAPHAMPLITUDE: number;
  35491. /**
  35492. * Gets or sets the position of the debug canvas
  35493. * @ignorenaming
  35494. */
  35495. DEBUGCANVASPOS: {
  35496. x: number;
  35497. y: number;
  35498. };
  35499. /**
  35500. * Gets or sets the debug canvas size
  35501. * @ignorenaming
  35502. */
  35503. DEBUGCANVASSIZE: {
  35504. width: number;
  35505. height: number;
  35506. };
  35507. private _byteFreqs;
  35508. private _byteTime;
  35509. private _floatFreqs;
  35510. private _webAudioAnalyser;
  35511. private _debugCanvas;
  35512. private _debugCanvasContext;
  35513. private _scene;
  35514. private _registerFunc;
  35515. private _audioEngine;
  35516. /**
  35517. * Creates a new analyser
  35518. * @param scene defines hosting scene
  35519. */
  35520. constructor(scene: Scene);
  35521. /**
  35522. * Get the number of data values you will have to play with for the visualization
  35523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35524. * @returns a number
  35525. */
  35526. getFrequencyBinCount(): number;
  35527. /**
  35528. * Gets the current frequency data as a byte array
  35529. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35530. * @returns a Uint8Array
  35531. */
  35532. getByteFrequencyData(): Uint8Array;
  35533. /**
  35534. * Gets the current waveform as a byte array
  35535. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35536. * @returns a Uint8Array
  35537. */
  35538. getByteTimeDomainData(): Uint8Array;
  35539. /**
  35540. * Gets the current frequency data as a float array
  35541. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35542. * @returns a Float32Array
  35543. */
  35544. getFloatFrequencyData(): Float32Array;
  35545. /**
  35546. * Renders the debug canvas
  35547. */
  35548. drawDebugCanvas(): void;
  35549. /**
  35550. * Stops rendering the debug canvas and removes it
  35551. */
  35552. stopDebugCanvas(): void;
  35553. /**
  35554. * Connects two audio nodes
  35555. * @param inputAudioNode defines first node to connect
  35556. * @param outputAudioNode defines second node to connect
  35557. */
  35558. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35559. /**
  35560. * Releases all associated resources
  35561. */
  35562. dispose(): void;
  35563. }
  35564. }
  35565. declare module BABYLON {
  35566. /**
  35567. * This represents an audio engine and it is responsible
  35568. * to play, synchronize and analyse sounds throughout the application.
  35569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35570. */
  35571. export interface IAudioEngine extends IDisposable {
  35572. /**
  35573. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35574. */
  35575. readonly canUseWebAudio: boolean;
  35576. /**
  35577. * Gets the current AudioContext if available.
  35578. */
  35579. readonly audioContext: Nullable<AudioContext>;
  35580. /**
  35581. * The master gain node defines the global audio volume of your audio engine.
  35582. */
  35583. readonly masterGain: GainNode;
  35584. /**
  35585. * Gets whether or not mp3 are supported by your browser.
  35586. */
  35587. readonly isMP3supported: boolean;
  35588. /**
  35589. * Gets whether or not ogg are supported by your browser.
  35590. */
  35591. readonly isOGGsupported: boolean;
  35592. /**
  35593. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35594. * @ignoreNaming
  35595. */
  35596. WarnedWebAudioUnsupported: boolean;
  35597. /**
  35598. * Defines if the audio engine relies on a custom unlocked button.
  35599. * In this case, the embedded button will not be displayed.
  35600. */
  35601. useCustomUnlockedButton: boolean;
  35602. /**
  35603. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35604. */
  35605. readonly unlocked: boolean;
  35606. /**
  35607. * Event raised when audio has been unlocked on the browser.
  35608. */
  35609. onAudioUnlockedObservable: Observable<AudioEngine>;
  35610. /**
  35611. * Event raised when audio has been locked on the browser.
  35612. */
  35613. onAudioLockedObservable: Observable<AudioEngine>;
  35614. /**
  35615. * Flags the audio engine in Locked state.
  35616. * This happens due to new browser policies preventing audio to autoplay.
  35617. */
  35618. lock(): void;
  35619. /**
  35620. * Unlocks the audio engine once a user action has been done on the dom.
  35621. * This is helpful to resume play once browser policies have been satisfied.
  35622. */
  35623. unlock(): void;
  35624. /**
  35625. * Gets the global volume sets on the master gain.
  35626. * @returns the global volume if set or -1 otherwise
  35627. */
  35628. getGlobalVolume(): number;
  35629. /**
  35630. * Sets the global volume of your experience (sets on the master gain).
  35631. * @param newVolume Defines the new global volume of the application
  35632. */
  35633. setGlobalVolume(newVolume: number): void;
  35634. /**
  35635. * Connect the audio engine to an audio analyser allowing some amazing
  35636. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35637. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35638. * @param analyser The analyser to connect to the engine
  35639. */
  35640. connectToAnalyser(analyser: Analyser): void;
  35641. }
  35642. /**
  35643. * This represents the default audio engine used in babylon.
  35644. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35646. */
  35647. export class AudioEngine implements IAudioEngine {
  35648. private _audioContext;
  35649. private _audioContextInitialized;
  35650. private _muteButton;
  35651. private _hostElement;
  35652. /**
  35653. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35654. */
  35655. canUseWebAudio: boolean;
  35656. /**
  35657. * The master gain node defines the global audio volume of your audio engine.
  35658. */
  35659. masterGain: GainNode;
  35660. /**
  35661. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35662. * @ignoreNaming
  35663. */
  35664. WarnedWebAudioUnsupported: boolean;
  35665. /**
  35666. * Gets whether or not mp3 are supported by your browser.
  35667. */
  35668. isMP3supported: boolean;
  35669. /**
  35670. * Gets whether or not ogg are supported by your browser.
  35671. */
  35672. isOGGsupported: boolean;
  35673. /**
  35674. * Gets whether audio has been unlocked on the device.
  35675. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35676. * a user interaction has happened.
  35677. */
  35678. unlocked: boolean;
  35679. /**
  35680. * Defines if the audio engine relies on a custom unlocked button.
  35681. * In this case, the embedded button will not be displayed.
  35682. */
  35683. useCustomUnlockedButton: boolean;
  35684. /**
  35685. * Event raised when audio has been unlocked on the browser.
  35686. */
  35687. onAudioUnlockedObservable: Observable<AudioEngine>;
  35688. /**
  35689. * Event raised when audio has been locked on the browser.
  35690. */
  35691. onAudioLockedObservable: Observable<AudioEngine>;
  35692. /**
  35693. * Gets the current AudioContext if available.
  35694. */
  35695. get audioContext(): Nullable<AudioContext>;
  35696. private _connectedAnalyser;
  35697. /**
  35698. * Instantiates a new audio engine.
  35699. *
  35700. * There should be only one per page as some browsers restrict the number
  35701. * of audio contexts you can create.
  35702. * @param hostElement defines the host element where to display the mute icon if necessary
  35703. */
  35704. constructor(hostElement?: Nullable<HTMLElement>);
  35705. /**
  35706. * Flags the audio engine in Locked state.
  35707. * This happens due to new browser policies preventing audio to autoplay.
  35708. */
  35709. lock(): void;
  35710. /**
  35711. * Unlocks the audio engine once a user action has been done on the dom.
  35712. * This is helpful to resume play once browser policies have been satisfied.
  35713. */
  35714. unlock(): void;
  35715. private _resumeAudioContext;
  35716. private _initializeAudioContext;
  35717. private _tryToRun;
  35718. private _triggerRunningState;
  35719. private _triggerSuspendedState;
  35720. private _displayMuteButton;
  35721. private _moveButtonToTopLeft;
  35722. private _onResize;
  35723. private _hideMuteButton;
  35724. /**
  35725. * Destroy and release the resources associated with the audio ccontext.
  35726. */
  35727. dispose(): void;
  35728. /**
  35729. * Gets the global volume sets on the master gain.
  35730. * @returns the global volume if set or -1 otherwise
  35731. */
  35732. getGlobalVolume(): number;
  35733. /**
  35734. * Sets the global volume of your experience (sets on the master gain).
  35735. * @param newVolume Defines the new global volume of the application
  35736. */
  35737. setGlobalVolume(newVolume: number): void;
  35738. /**
  35739. * Connect the audio engine to an audio analyser allowing some amazing
  35740. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35742. * @param analyser The analyser to connect to the engine
  35743. */
  35744. connectToAnalyser(analyser: Analyser): void;
  35745. }
  35746. }
  35747. declare module BABYLON {
  35748. /**
  35749. * Interface used to present a loading screen while loading a scene
  35750. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35751. */
  35752. export interface ILoadingScreen {
  35753. /**
  35754. * Function called to display the loading screen
  35755. */
  35756. displayLoadingUI: () => void;
  35757. /**
  35758. * Function called to hide the loading screen
  35759. */
  35760. hideLoadingUI: () => void;
  35761. /**
  35762. * Gets or sets the color to use for the background
  35763. */
  35764. loadingUIBackgroundColor: string;
  35765. /**
  35766. * Gets or sets the text to display while loading
  35767. */
  35768. loadingUIText: string;
  35769. }
  35770. /**
  35771. * Class used for the default loading screen
  35772. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35773. */
  35774. export class DefaultLoadingScreen implements ILoadingScreen {
  35775. private _renderingCanvas;
  35776. private _loadingText;
  35777. private _loadingDivBackgroundColor;
  35778. private _loadingDiv;
  35779. private _loadingTextDiv;
  35780. /** Gets or sets the logo url to use for the default loading screen */
  35781. static DefaultLogoUrl: string;
  35782. /** Gets or sets the spinner url to use for the default loading screen */
  35783. static DefaultSpinnerUrl: string;
  35784. /**
  35785. * Creates a new default loading screen
  35786. * @param _renderingCanvas defines the canvas used to render the scene
  35787. * @param _loadingText defines the default text to display
  35788. * @param _loadingDivBackgroundColor defines the default background color
  35789. */
  35790. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35791. /**
  35792. * Function called to display the loading screen
  35793. */
  35794. displayLoadingUI(): void;
  35795. /**
  35796. * Function called to hide the loading screen
  35797. */
  35798. hideLoadingUI(): void;
  35799. /**
  35800. * Gets or sets the text to display while loading
  35801. */
  35802. set loadingUIText(text: string);
  35803. get loadingUIText(): string;
  35804. /**
  35805. * Gets or sets the color to use for the background
  35806. */
  35807. get loadingUIBackgroundColor(): string;
  35808. set loadingUIBackgroundColor(color: string);
  35809. private _resizeLoadingUI;
  35810. }
  35811. }
  35812. declare module BABYLON {
  35813. /**
  35814. * Interface for any object that can request an animation frame
  35815. */
  35816. export interface ICustomAnimationFrameRequester {
  35817. /**
  35818. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35819. */
  35820. renderFunction?: Function;
  35821. /**
  35822. * Called to request the next frame to render to
  35823. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35824. */
  35825. requestAnimationFrame: Function;
  35826. /**
  35827. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35828. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35829. */
  35830. requestID?: number;
  35831. }
  35832. }
  35833. declare module BABYLON {
  35834. /**
  35835. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35836. */
  35837. export class PerformanceMonitor {
  35838. private _enabled;
  35839. private _rollingFrameTime;
  35840. private _lastFrameTimeMs;
  35841. /**
  35842. * constructor
  35843. * @param frameSampleSize The number of samples required to saturate the sliding window
  35844. */
  35845. constructor(frameSampleSize?: number);
  35846. /**
  35847. * Samples current frame
  35848. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35849. */
  35850. sampleFrame(timeMs?: number): void;
  35851. /**
  35852. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35853. */
  35854. get averageFrameTime(): number;
  35855. /**
  35856. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35857. */
  35858. get averageFrameTimeVariance(): number;
  35859. /**
  35860. * Returns the frame time of the most recent frame
  35861. */
  35862. get instantaneousFrameTime(): number;
  35863. /**
  35864. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35865. */
  35866. get averageFPS(): number;
  35867. /**
  35868. * Returns the average framerate in frames per second using the most recent frame time
  35869. */
  35870. get instantaneousFPS(): number;
  35871. /**
  35872. * Returns true if enough samples have been taken to completely fill the sliding window
  35873. */
  35874. get isSaturated(): boolean;
  35875. /**
  35876. * Enables contributions to the sliding window sample set
  35877. */
  35878. enable(): void;
  35879. /**
  35880. * Disables contributions to the sliding window sample set
  35881. * Samples will not be interpolated over the disabled period
  35882. */
  35883. disable(): void;
  35884. /**
  35885. * Returns true if sampling is enabled
  35886. */
  35887. get isEnabled(): boolean;
  35888. /**
  35889. * Resets performance monitor
  35890. */
  35891. reset(): void;
  35892. }
  35893. /**
  35894. * RollingAverage
  35895. *
  35896. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35897. */
  35898. export class RollingAverage {
  35899. /**
  35900. * Current average
  35901. */
  35902. average: number;
  35903. /**
  35904. * Current variance
  35905. */
  35906. variance: number;
  35907. protected _samples: Array<number>;
  35908. protected _sampleCount: number;
  35909. protected _pos: number;
  35910. protected _m2: number;
  35911. /**
  35912. * constructor
  35913. * @param length The number of samples required to saturate the sliding window
  35914. */
  35915. constructor(length: number);
  35916. /**
  35917. * Adds a sample to the sample set
  35918. * @param v The sample value
  35919. */
  35920. add(v: number): void;
  35921. /**
  35922. * Returns previously added values or null if outside of history or outside the sliding window domain
  35923. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35924. * @return Value previously recorded with add() or null if outside of range
  35925. */
  35926. history(i: number): number;
  35927. /**
  35928. * Returns true if enough samples have been taken to completely fill the sliding window
  35929. * @return true if sample-set saturated
  35930. */
  35931. isSaturated(): boolean;
  35932. /**
  35933. * Resets the rolling average (equivalent to 0 samples taken so far)
  35934. */
  35935. reset(): void;
  35936. /**
  35937. * Wraps a value around the sample range boundaries
  35938. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  35939. * @return Wrapped position in sample range
  35940. */
  35941. protected _wrapPosition(i: number): number;
  35942. }
  35943. }
  35944. declare module BABYLON {
  35945. /**
  35946. * This class is used to track a performance counter which is number based.
  35947. * The user has access to many properties which give statistics of different nature.
  35948. *
  35949. * The implementer can track two kinds of Performance Counter: time and count.
  35950. * 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.
  35951. * 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.
  35952. */
  35953. export class PerfCounter {
  35954. /**
  35955. * Gets or sets a global boolean to turn on and off all the counters
  35956. */
  35957. static Enabled: boolean;
  35958. /**
  35959. * Returns the smallest value ever
  35960. */
  35961. get min(): number;
  35962. /**
  35963. * Returns the biggest value ever
  35964. */
  35965. get max(): number;
  35966. /**
  35967. * Returns the average value since the performance counter is running
  35968. */
  35969. get average(): number;
  35970. /**
  35971. * Returns the average value of the last second the counter was monitored
  35972. */
  35973. get lastSecAverage(): number;
  35974. /**
  35975. * Returns the current value
  35976. */
  35977. get current(): number;
  35978. /**
  35979. * Gets the accumulated total
  35980. */
  35981. get total(): number;
  35982. /**
  35983. * Gets the total value count
  35984. */
  35985. get count(): number;
  35986. /**
  35987. * Creates a new counter
  35988. */
  35989. constructor();
  35990. /**
  35991. * Call this method to start monitoring a new frame.
  35992. * 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.
  35993. */
  35994. fetchNewFrame(): void;
  35995. /**
  35996. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  35997. * @param newCount the count value to add to the monitored count
  35998. * @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.
  35999. */
  36000. addCount(newCount: number, fetchResult: boolean): void;
  36001. /**
  36002. * Start monitoring this performance counter
  36003. */
  36004. beginMonitoring(): void;
  36005. /**
  36006. * Compute the time lapsed since the previous beginMonitoring() call.
  36007. * @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
  36008. */
  36009. endMonitoring(newFrame?: boolean): void;
  36010. private _fetchResult;
  36011. private _startMonitoringTime;
  36012. private _min;
  36013. private _max;
  36014. private _average;
  36015. private _current;
  36016. private _totalValueCount;
  36017. private _totalAccumulated;
  36018. private _lastSecAverage;
  36019. private _lastSecAccumulated;
  36020. private _lastSecTime;
  36021. private _lastSecValueCount;
  36022. }
  36023. }
  36024. declare module BABYLON {
  36025. interface ThinEngine {
  36026. /**
  36027. * Sets alpha constants used by some alpha blending modes
  36028. * @param r defines the red component
  36029. * @param g defines the green component
  36030. * @param b defines the blue component
  36031. * @param a defines the alpha component
  36032. */
  36033. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36034. /**
  36035. * Sets the current alpha mode
  36036. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36037. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36038. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36039. */
  36040. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36041. /**
  36042. * Gets the current alpha mode
  36043. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36044. * @returns the current alpha mode
  36045. */
  36046. getAlphaMode(): number;
  36047. /**
  36048. * Sets the current alpha equation
  36049. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36050. */
  36051. setAlphaEquation(equation: number): void;
  36052. /**
  36053. * Gets the current alpha equation.
  36054. * @returns the current alpha equation
  36055. */
  36056. getAlphaEquation(): number;
  36057. }
  36058. }
  36059. declare module BABYLON {
  36060. interface ThinEngine {
  36061. /** @hidden */
  36062. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36063. }
  36064. }
  36065. declare module BABYLON {
  36066. /**
  36067. * Defines the interface used by display changed events
  36068. */
  36069. export interface IDisplayChangedEventArgs {
  36070. /** Gets the vrDisplay object (if any) */
  36071. vrDisplay: Nullable<any>;
  36072. /** Gets a boolean indicating if webVR is supported */
  36073. vrSupported: boolean;
  36074. }
  36075. /**
  36076. * Defines the interface used by objects containing a viewport (like a camera)
  36077. */
  36078. interface IViewportOwnerLike {
  36079. /**
  36080. * Gets or sets the viewport
  36081. */
  36082. viewport: IViewportLike;
  36083. }
  36084. /**
  36085. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36086. */
  36087. export class Engine extends ThinEngine {
  36088. /** Defines that alpha blending is disabled */
  36089. static readonly ALPHA_DISABLE: number;
  36090. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36091. static readonly ALPHA_ADD: number;
  36092. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36093. static readonly ALPHA_COMBINE: number;
  36094. /** Defines that alpha blending to DEST - SRC * DEST */
  36095. static readonly ALPHA_SUBTRACT: number;
  36096. /** Defines that alpha blending to SRC * DEST */
  36097. static readonly ALPHA_MULTIPLY: number;
  36098. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36099. static readonly ALPHA_MAXIMIZED: number;
  36100. /** Defines that alpha blending to SRC + DEST */
  36101. static readonly ALPHA_ONEONE: number;
  36102. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36103. static readonly ALPHA_PREMULTIPLIED: number;
  36104. /**
  36105. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36106. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36107. */
  36108. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36109. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36110. static readonly ALPHA_INTERPOLATE: number;
  36111. /**
  36112. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36113. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36114. */
  36115. static readonly ALPHA_SCREENMODE: number;
  36116. /** Defines that the ressource is not delayed*/
  36117. static readonly DELAYLOADSTATE_NONE: number;
  36118. /** Defines that the ressource was successfully delay loaded */
  36119. static readonly DELAYLOADSTATE_LOADED: number;
  36120. /** Defines that the ressource is currently delay loading */
  36121. static readonly DELAYLOADSTATE_LOADING: number;
  36122. /** Defines that the ressource is delayed and has not started loading */
  36123. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36124. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36125. static readonly NEVER: number;
  36126. /** 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 */
  36127. static readonly ALWAYS: number;
  36128. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36129. static readonly LESS: number;
  36130. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36131. static readonly EQUAL: number;
  36132. /** 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 */
  36133. static readonly LEQUAL: number;
  36134. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36135. static readonly GREATER: number;
  36136. /** 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 */
  36137. static readonly GEQUAL: number;
  36138. /** 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 */
  36139. static readonly NOTEQUAL: number;
  36140. /** Passed to stencilOperation to specify that stencil value must be kept */
  36141. static readonly KEEP: number;
  36142. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36143. static readonly REPLACE: number;
  36144. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36145. static readonly INCR: number;
  36146. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36147. static readonly DECR: number;
  36148. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36149. static readonly INVERT: number;
  36150. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36151. static readonly INCR_WRAP: number;
  36152. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36153. static readonly DECR_WRAP: number;
  36154. /** Texture is not repeating outside of 0..1 UVs */
  36155. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36156. /** Texture is repeating outside of 0..1 UVs */
  36157. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36158. /** Texture is repeating and mirrored */
  36159. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36160. /** ALPHA */
  36161. static readonly TEXTUREFORMAT_ALPHA: number;
  36162. /** LUMINANCE */
  36163. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36164. /** LUMINANCE_ALPHA */
  36165. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36166. /** RGB */
  36167. static readonly TEXTUREFORMAT_RGB: number;
  36168. /** RGBA */
  36169. static readonly TEXTUREFORMAT_RGBA: number;
  36170. /** RED */
  36171. static readonly TEXTUREFORMAT_RED: number;
  36172. /** RED (2nd reference) */
  36173. static readonly TEXTUREFORMAT_R: number;
  36174. /** RG */
  36175. static readonly TEXTUREFORMAT_RG: number;
  36176. /** RED_INTEGER */
  36177. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36178. /** RED_INTEGER (2nd reference) */
  36179. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36180. /** RG_INTEGER */
  36181. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36182. /** RGB_INTEGER */
  36183. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36184. /** RGBA_INTEGER */
  36185. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36186. /** UNSIGNED_BYTE */
  36187. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36188. /** UNSIGNED_BYTE (2nd reference) */
  36189. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36190. /** FLOAT */
  36191. static readonly TEXTURETYPE_FLOAT: number;
  36192. /** HALF_FLOAT */
  36193. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36194. /** BYTE */
  36195. static readonly TEXTURETYPE_BYTE: number;
  36196. /** SHORT */
  36197. static readonly TEXTURETYPE_SHORT: number;
  36198. /** UNSIGNED_SHORT */
  36199. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36200. /** INT */
  36201. static readonly TEXTURETYPE_INT: number;
  36202. /** UNSIGNED_INT */
  36203. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36204. /** UNSIGNED_SHORT_4_4_4_4 */
  36205. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36206. /** UNSIGNED_SHORT_5_5_5_1 */
  36207. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36208. /** UNSIGNED_SHORT_5_6_5 */
  36209. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36210. /** UNSIGNED_INT_2_10_10_10_REV */
  36211. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36212. /** UNSIGNED_INT_24_8 */
  36213. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36214. /** UNSIGNED_INT_10F_11F_11F_REV */
  36215. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36216. /** UNSIGNED_INT_5_9_9_9_REV */
  36217. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36218. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36219. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36220. /** nearest is mag = nearest and min = nearest and mip = linear */
  36221. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36222. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36223. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36224. /** Trilinear is mag = linear and min = linear and mip = linear */
  36225. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36226. /** nearest is mag = nearest and min = nearest and mip = linear */
  36227. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36228. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36229. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36230. /** Trilinear is mag = linear and min = linear and mip = linear */
  36231. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36232. /** mag = nearest and min = nearest and mip = nearest */
  36233. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36234. /** mag = nearest and min = linear and mip = nearest */
  36235. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36236. /** mag = nearest and min = linear and mip = linear */
  36237. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36238. /** mag = nearest and min = linear and mip = none */
  36239. static readonly TEXTURE_NEAREST_LINEAR: number;
  36240. /** mag = nearest and min = nearest and mip = none */
  36241. static readonly TEXTURE_NEAREST_NEAREST: number;
  36242. /** mag = linear and min = nearest and mip = nearest */
  36243. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36244. /** mag = linear and min = nearest and mip = linear */
  36245. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36246. /** mag = linear and min = linear and mip = none */
  36247. static readonly TEXTURE_LINEAR_LINEAR: number;
  36248. /** mag = linear and min = nearest and mip = none */
  36249. static readonly TEXTURE_LINEAR_NEAREST: number;
  36250. /** Explicit coordinates mode */
  36251. static readonly TEXTURE_EXPLICIT_MODE: number;
  36252. /** Spherical coordinates mode */
  36253. static readonly TEXTURE_SPHERICAL_MODE: number;
  36254. /** Planar coordinates mode */
  36255. static readonly TEXTURE_PLANAR_MODE: number;
  36256. /** Cubic coordinates mode */
  36257. static readonly TEXTURE_CUBIC_MODE: number;
  36258. /** Projection coordinates mode */
  36259. static readonly TEXTURE_PROJECTION_MODE: number;
  36260. /** Skybox coordinates mode */
  36261. static readonly TEXTURE_SKYBOX_MODE: number;
  36262. /** Inverse Cubic coordinates mode */
  36263. static readonly TEXTURE_INVCUBIC_MODE: number;
  36264. /** Equirectangular coordinates mode */
  36265. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36266. /** Equirectangular Fixed coordinates mode */
  36267. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36268. /** Equirectangular Fixed Mirrored coordinates mode */
  36269. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36270. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36271. static readonly SCALEMODE_FLOOR: number;
  36272. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36273. static readonly SCALEMODE_NEAREST: number;
  36274. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36275. static readonly SCALEMODE_CEILING: number;
  36276. /**
  36277. * Returns the current npm package of the sdk
  36278. */
  36279. static get NpmPackage(): string;
  36280. /**
  36281. * Returns the current version of the framework
  36282. */
  36283. static get Version(): string;
  36284. /** Gets the list of created engines */
  36285. static get Instances(): Engine[];
  36286. /**
  36287. * Gets the latest created engine
  36288. */
  36289. static get LastCreatedEngine(): Nullable<Engine>;
  36290. /**
  36291. * Gets the latest created scene
  36292. */
  36293. static get LastCreatedScene(): Nullable<Scene>;
  36294. /**
  36295. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36296. * @param flag defines which part of the materials must be marked as dirty
  36297. * @param predicate defines a predicate used to filter which materials should be affected
  36298. */
  36299. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36300. /**
  36301. * Method called to create the default loading screen.
  36302. * This can be overriden in your own app.
  36303. * @param canvas The rendering canvas element
  36304. * @returns The loading screen
  36305. */
  36306. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36307. /**
  36308. * Method called to create the default rescale post process on each engine.
  36309. */
  36310. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36311. /**
  36312. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36313. **/
  36314. enableOfflineSupport: boolean;
  36315. /**
  36316. * 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)
  36317. **/
  36318. disableManifestCheck: boolean;
  36319. /**
  36320. * Gets the list of created scenes
  36321. */
  36322. scenes: Scene[];
  36323. /**
  36324. * Event raised when a new scene is created
  36325. */
  36326. onNewSceneAddedObservable: Observable<Scene>;
  36327. /**
  36328. * Gets the list of created postprocesses
  36329. */
  36330. postProcesses: PostProcess[];
  36331. /**
  36332. * Gets a boolean indicating if the pointer is currently locked
  36333. */
  36334. isPointerLock: boolean;
  36335. /**
  36336. * Observable event triggered each time the rendering canvas is resized
  36337. */
  36338. onResizeObservable: Observable<Engine>;
  36339. /**
  36340. * Observable event triggered each time the canvas loses focus
  36341. */
  36342. onCanvasBlurObservable: Observable<Engine>;
  36343. /**
  36344. * Observable event triggered each time the canvas gains focus
  36345. */
  36346. onCanvasFocusObservable: Observable<Engine>;
  36347. /**
  36348. * Observable event triggered each time the canvas receives pointerout event
  36349. */
  36350. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36351. /**
  36352. * Observable raised when the engine begins a new frame
  36353. */
  36354. onBeginFrameObservable: Observable<Engine>;
  36355. /**
  36356. * If set, will be used to request the next animation frame for the render loop
  36357. */
  36358. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36359. /**
  36360. * Observable raised when the engine ends the current frame
  36361. */
  36362. onEndFrameObservable: Observable<Engine>;
  36363. /**
  36364. * Observable raised when the engine is about to compile a shader
  36365. */
  36366. onBeforeShaderCompilationObservable: Observable<Engine>;
  36367. /**
  36368. * Observable raised when the engine has jsut compiled a shader
  36369. */
  36370. onAfterShaderCompilationObservable: Observable<Engine>;
  36371. /**
  36372. * Gets the audio engine
  36373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36374. * @ignorenaming
  36375. */
  36376. static audioEngine: IAudioEngine;
  36377. /**
  36378. * Default AudioEngine factory responsible of creating the Audio Engine.
  36379. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36380. */
  36381. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36382. /**
  36383. * Default offline support factory responsible of creating a tool used to store data locally.
  36384. * By default, this will create a Database object if the workload has been embedded.
  36385. */
  36386. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36387. private _loadingScreen;
  36388. private _pointerLockRequested;
  36389. private _rescalePostProcess;
  36390. private _deterministicLockstep;
  36391. private _lockstepMaxSteps;
  36392. private _timeStep;
  36393. protected get _supportsHardwareTextureRescaling(): boolean;
  36394. private _fps;
  36395. private _deltaTime;
  36396. /** @hidden */
  36397. _drawCalls: PerfCounter;
  36398. /** 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 */
  36399. canvasTabIndex: number;
  36400. /**
  36401. * Turn this value on if you want to pause FPS computation when in background
  36402. */
  36403. disablePerformanceMonitorInBackground: boolean;
  36404. private _performanceMonitor;
  36405. /**
  36406. * Gets the performance monitor attached to this engine
  36407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36408. */
  36409. get performanceMonitor(): PerformanceMonitor;
  36410. private _onFocus;
  36411. private _onBlur;
  36412. private _onCanvasPointerOut;
  36413. private _onCanvasBlur;
  36414. private _onCanvasFocus;
  36415. private _onFullscreenChange;
  36416. private _onPointerLockChange;
  36417. /**
  36418. * Gets the HTML element used to attach event listeners
  36419. * @returns a HTML element
  36420. */
  36421. getInputElement(): Nullable<HTMLElement>;
  36422. /**
  36423. * Creates a new engine
  36424. * @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
  36425. * @param antialias defines enable antialiasing (default: false)
  36426. * @param options defines further options to be sent to the getContext() function
  36427. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36428. */
  36429. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36430. /**
  36431. * Gets current aspect ratio
  36432. * @param viewportOwner defines the camera to use to get the aspect ratio
  36433. * @param useScreen defines if screen size must be used (or the current render target if any)
  36434. * @returns a number defining the aspect ratio
  36435. */
  36436. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36437. /**
  36438. * Gets current screen aspect ratio
  36439. * @returns a number defining the aspect ratio
  36440. */
  36441. getScreenAspectRatio(): number;
  36442. /**
  36443. * Gets the client rect of the HTML canvas attached with the current webGL context
  36444. * @returns a client rectanglee
  36445. */
  36446. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36447. /**
  36448. * Gets the client rect of the HTML element used for events
  36449. * @returns a client rectanglee
  36450. */
  36451. getInputElementClientRect(): Nullable<ClientRect>;
  36452. /**
  36453. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36454. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36455. * @returns true if engine is in deterministic lock step mode
  36456. */
  36457. isDeterministicLockStep(): boolean;
  36458. /**
  36459. * Gets the max steps when engine is running in deterministic lock step
  36460. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36461. * @returns the max steps
  36462. */
  36463. getLockstepMaxSteps(): number;
  36464. /**
  36465. * Returns the time in ms between steps when using deterministic lock step.
  36466. * @returns time step in (ms)
  36467. */
  36468. getTimeStep(): number;
  36469. /**
  36470. * Force the mipmap generation for the given render target texture
  36471. * @param texture defines the render target texture to use
  36472. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36473. */
  36474. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36475. /** States */
  36476. /**
  36477. * Set various states to the webGL context
  36478. * @param culling defines backface culling state
  36479. * @param zOffset defines the value to apply to zOffset (0 by default)
  36480. * @param force defines if states must be applied even if cache is up to date
  36481. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36482. */
  36483. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36484. /**
  36485. * Set the z offset to apply to current rendering
  36486. * @param value defines the offset to apply
  36487. */
  36488. setZOffset(value: number): void;
  36489. /**
  36490. * Gets the current value of the zOffset
  36491. * @returns the current zOffset state
  36492. */
  36493. getZOffset(): number;
  36494. /**
  36495. * Enable or disable depth buffering
  36496. * @param enable defines the state to set
  36497. */
  36498. setDepthBuffer(enable: boolean): void;
  36499. /**
  36500. * Gets a boolean indicating if depth writing is enabled
  36501. * @returns the current depth writing state
  36502. */
  36503. getDepthWrite(): boolean;
  36504. /**
  36505. * Enable or disable depth writing
  36506. * @param enable defines the state to set
  36507. */
  36508. setDepthWrite(enable: boolean): void;
  36509. /**
  36510. * Gets a boolean indicating if stencil buffer is enabled
  36511. * @returns the current stencil buffer state
  36512. */
  36513. getStencilBuffer(): boolean;
  36514. /**
  36515. * Enable or disable the stencil buffer
  36516. * @param enable defines if the stencil buffer must be enabled or disabled
  36517. */
  36518. setStencilBuffer(enable: boolean): void;
  36519. /**
  36520. * Gets the current stencil mask
  36521. * @returns a number defining the new stencil mask to use
  36522. */
  36523. getStencilMask(): number;
  36524. /**
  36525. * Sets the current stencil mask
  36526. * @param mask defines the new stencil mask to use
  36527. */
  36528. setStencilMask(mask: number): void;
  36529. /**
  36530. * Gets the current stencil function
  36531. * @returns a number defining the stencil function to use
  36532. */
  36533. getStencilFunction(): number;
  36534. /**
  36535. * Gets the current stencil reference value
  36536. * @returns a number defining the stencil reference value to use
  36537. */
  36538. getStencilFunctionReference(): number;
  36539. /**
  36540. * Gets the current stencil mask
  36541. * @returns a number defining the stencil mask to use
  36542. */
  36543. getStencilFunctionMask(): number;
  36544. /**
  36545. * Sets the current stencil function
  36546. * @param stencilFunc defines the new stencil function to use
  36547. */
  36548. setStencilFunction(stencilFunc: number): void;
  36549. /**
  36550. * Sets the current stencil reference
  36551. * @param reference defines the new stencil reference to use
  36552. */
  36553. setStencilFunctionReference(reference: number): void;
  36554. /**
  36555. * Sets the current stencil mask
  36556. * @param mask defines the new stencil mask to use
  36557. */
  36558. setStencilFunctionMask(mask: number): void;
  36559. /**
  36560. * Gets the current stencil operation when stencil fails
  36561. * @returns a number defining stencil operation to use when stencil fails
  36562. */
  36563. getStencilOperationFail(): number;
  36564. /**
  36565. * Gets the current stencil operation when depth fails
  36566. * @returns a number defining stencil operation to use when depth fails
  36567. */
  36568. getStencilOperationDepthFail(): number;
  36569. /**
  36570. * Gets the current stencil operation when stencil passes
  36571. * @returns a number defining stencil operation to use when stencil passes
  36572. */
  36573. getStencilOperationPass(): number;
  36574. /**
  36575. * Sets the stencil operation to use when stencil fails
  36576. * @param operation defines the stencil operation to use when stencil fails
  36577. */
  36578. setStencilOperationFail(operation: number): void;
  36579. /**
  36580. * Sets the stencil operation to use when depth fails
  36581. * @param operation defines the stencil operation to use when depth fails
  36582. */
  36583. setStencilOperationDepthFail(operation: number): void;
  36584. /**
  36585. * Sets the stencil operation to use when stencil passes
  36586. * @param operation defines the stencil operation to use when stencil passes
  36587. */
  36588. setStencilOperationPass(operation: number): void;
  36589. /**
  36590. * Sets a boolean indicating if the dithering state is enabled or disabled
  36591. * @param value defines the dithering state
  36592. */
  36593. setDitheringState(value: boolean): void;
  36594. /**
  36595. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36596. * @param value defines the rasterizer state
  36597. */
  36598. setRasterizerState(value: boolean): void;
  36599. /**
  36600. * Gets the current depth function
  36601. * @returns a number defining the depth function
  36602. */
  36603. getDepthFunction(): Nullable<number>;
  36604. /**
  36605. * Sets the current depth function
  36606. * @param depthFunc defines the function to use
  36607. */
  36608. setDepthFunction(depthFunc: number): void;
  36609. /**
  36610. * Sets the current depth function to GREATER
  36611. */
  36612. setDepthFunctionToGreater(): void;
  36613. /**
  36614. * Sets the current depth function to GEQUAL
  36615. */
  36616. setDepthFunctionToGreaterOrEqual(): void;
  36617. /**
  36618. * Sets the current depth function to LESS
  36619. */
  36620. setDepthFunctionToLess(): void;
  36621. /**
  36622. * Sets the current depth function to LEQUAL
  36623. */
  36624. setDepthFunctionToLessOrEqual(): void;
  36625. private _cachedStencilBuffer;
  36626. private _cachedStencilFunction;
  36627. private _cachedStencilMask;
  36628. private _cachedStencilOperationPass;
  36629. private _cachedStencilOperationFail;
  36630. private _cachedStencilOperationDepthFail;
  36631. private _cachedStencilReference;
  36632. /**
  36633. * Caches the the state of the stencil buffer
  36634. */
  36635. cacheStencilState(): void;
  36636. /**
  36637. * Restores the state of the stencil buffer
  36638. */
  36639. restoreStencilState(): void;
  36640. /**
  36641. * Directly set the WebGL Viewport
  36642. * @param x defines the x coordinate of the viewport (in screen space)
  36643. * @param y defines the y coordinate of the viewport (in screen space)
  36644. * @param width defines the width of the viewport (in screen space)
  36645. * @param height defines the height of the viewport (in screen space)
  36646. * @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
  36647. */
  36648. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36649. /**
  36650. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36651. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36652. * @param y defines the y-coordinate of the corner of the clear rectangle
  36653. * @param width defines the width of the clear rectangle
  36654. * @param height defines the height of the clear rectangle
  36655. * @param clearColor defines the clear color
  36656. */
  36657. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36658. /**
  36659. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36660. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36661. * @param y defines the y-coordinate of the corner of the clear rectangle
  36662. * @param width defines the width of the clear rectangle
  36663. * @param height defines the height of the clear rectangle
  36664. */
  36665. enableScissor(x: number, y: number, width: number, height: number): void;
  36666. /**
  36667. * Disable previously set scissor test rectangle
  36668. */
  36669. disableScissor(): void;
  36670. protected _reportDrawCall(): void;
  36671. /**
  36672. * Initializes a webVR display and starts listening to display change events
  36673. * The onVRDisplayChangedObservable will be notified upon these changes
  36674. * @returns The onVRDisplayChangedObservable
  36675. */
  36676. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36677. /** @hidden */
  36678. _prepareVRComponent(): void;
  36679. /** @hidden */
  36680. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36681. /** @hidden */
  36682. _submitVRFrame(): void;
  36683. /**
  36684. * Call this function to leave webVR mode
  36685. * Will do nothing if webVR is not supported or if there is no webVR device
  36686. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36687. */
  36688. disableVR(): void;
  36689. /**
  36690. * Gets a boolean indicating that the system is in VR mode and is presenting
  36691. * @returns true if VR mode is engaged
  36692. */
  36693. isVRPresenting(): boolean;
  36694. /** @hidden */
  36695. _requestVRFrame(): void;
  36696. /** @hidden */
  36697. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36698. /**
  36699. * Gets the source code of the vertex shader associated with a specific webGL program
  36700. * @param program defines the program to use
  36701. * @returns a string containing the source code of the vertex shader associated with the program
  36702. */
  36703. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36704. /**
  36705. * Gets the source code of the fragment shader associated with a specific webGL program
  36706. * @param program defines the program to use
  36707. * @returns a string containing the source code of the fragment shader associated with the program
  36708. */
  36709. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36710. /**
  36711. * Sets a depth stencil texture from a render target to the according uniform.
  36712. * @param channel The texture channel
  36713. * @param uniform The uniform to set
  36714. * @param texture The render target texture containing the depth stencil texture to apply
  36715. */
  36716. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36717. /**
  36718. * Sets a texture to the webGL context from a postprocess
  36719. * @param channel defines the channel to use
  36720. * @param postProcess defines the source postprocess
  36721. */
  36722. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36723. /**
  36724. * Binds the output of the passed in post process to the texture channel specified
  36725. * @param channel The channel the texture should be bound to
  36726. * @param postProcess The post process which's output should be bound
  36727. */
  36728. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36729. protected _rebuildBuffers(): void;
  36730. /** @hidden */
  36731. _renderFrame(): void;
  36732. _renderLoop(): void;
  36733. /** @hidden */
  36734. _renderViews(): boolean;
  36735. /**
  36736. * Toggle full screen mode
  36737. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36738. */
  36739. switchFullscreen(requestPointerLock: boolean): void;
  36740. /**
  36741. * Enters full screen mode
  36742. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36743. */
  36744. enterFullscreen(requestPointerLock: boolean): void;
  36745. /**
  36746. * Exits full screen mode
  36747. */
  36748. exitFullscreen(): void;
  36749. /**
  36750. * Enters Pointerlock mode
  36751. */
  36752. enterPointerlock(): void;
  36753. /**
  36754. * Exits Pointerlock mode
  36755. */
  36756. exitPointerlock(): void;
  36757. /**
  36758. * Begin a new frame
  36759. */
  36760. beginFrame(): void;
  36761. /**
  36762. * Enf the current frame
  36763. */
  36764. endFrame(): void;
  36765. resize(): void;
  36766. /**
  36767. * Force a specific size of the canvas
  36768. * @param width defines the new canvas' width
  36769. * @param height defines the new canvas' height
  36770. */
  36771. setSize(width: number, height: number): void;
  36772. /**
  36773. * Updates a dynamic vertex buffer.
  36774. * @param vertexBuffer the vertex buffer to update
  36775. * @param data the data used to update the vertex buffer
  36776. * @param byteOffset the byte offset of the data
  36777. * @param byteLength the byte length of the data
  36778. */
  36779. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36780. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36781. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36782. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36783. _releaseTexture(texture: InternalTexture): void;
  36784. /**
  36785. * @hidden
  36786. * Rescales a texture
  36787. * @param source input texutre
  36788. * @param destination destination texture
  36789. * @param scene scene to use to render the resize
  36790. * @param internalFormat format to use when resizing
  36791. * @param onComplete callback to be called when resize has completed
  36792. */
  36793. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36794. /**
  36795. * Gets the current framerate
  36796. * @returns a number representing the framerate
  36797. */
  36798. getFps(): number;
  36799. /**
  36800. * Gets the time spent between current and previous frame
  36801. * @returns a number representing the delta time in ms
  36802. */
  36803. getDeltaTime(): number;
  36804. private _measureFps;
  36805. /** @hidden */
  36806. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36807. /**
  36808. * Update a dynamic index buffer
  36809. * @param indexBuffer defines the target index buffer
  36810. * @param indices defines the data to update
  36811. * @param offset defines the offset in the target index buffer where update should start
  36812. */
  36813. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36814. /**
  36815. * Updates the sample count of a render target texture
  36816. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36817. * @param texture defines the texture to update
  36818. * @param samples defines the sample count to set
  36819. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36820. */
  36821. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36822. /**
  36823. * Updates a depth texture Comparison Mode and Function.
  36824. * If the comparison Function is equal to 0, the mode will be set to none.
  36825. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36826. * @param texture The texture to set the comparison function for
  36827. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36828. */
  36829. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36830. /**
  36831. * Creates a webGL buffer to use with instanciation
  36832. * @param capacity defines the size of the buffer
  36833. * @returns the webGL buffer
  36834. */
  36835. createInstancesBuffer(capacity: number): DataBuffer;
  36836. /**
  36837. * Delete a webGL buffer used with instanciation
  36838. * @param buffer defines the webGL buffer to delete
  36839. */
  36840. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36841. private _clientWaitAsync;
  36842. /** @hidden */
  36843. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36844. dispose(): void;
  36845. private _disableTouchAction;
  36846. /**
  36847. * Display the loading screen
  36848. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36849. */
  36850. displayLoadingUI(): void;
  36851. /**
  36852. * Hide the loading screen
  36853. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36854. */
  36855. hideLoadingUI(): void;
  36856. /**
  36857. * Gets the current loading screen object
  36858. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36859. */
  36860. get loadingScreen(): ILoadingScreen;
  36861. /**
  36862. * Sets the current loading screen object
  36863. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36864. */
  36865. set loadingScreen(loadingScreen: ILoadingScreen);
  36866. /**
  36867. * Sets the current loading screen text
  36868. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36869. */
  36870. set loadingUIText(text: string);
  36871. /**
  36872. * Sets the current loading screen background color
  36873. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36874. */
  36875. set loadingUIBackgroundColor(color: string);
  36876. /** Pointerlock and fullscreen */
  36877. /**
  36878. * Ask the browser to promote the current element to pointerlock mode
  36879. * @param element defines the DOM element to promote
  36880. */
  36881. static _RequestPointerlock(element: HTMLElement): void;
  36882. /**
  36883. * Asks the browser to exit pointerlock mode
  36884. */
  36885. static _ExitPointerlock(): void;
  36886. /**
  36887. * Ask the browser to promote the current element to fullscreen rendering mode
  36888. * @param element defines the DOM element to promote
  36889. */
  36890. static _RequestFullscreen(element: HTMLElement): void;
  36891. /**
  36892. * Asks the browser to exit fullscreen mode
  36893. */
  36894. static _ExitFullscreen(): void;
  36895. }
  36896. }
  36897. declare module BABYLON {
  36898. /**
  36899. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36900. * during the life time of the application.
  36901. */
  36902. export class EngineStore {
  36903. /** Gets the list of created engines */
  36904. static Instances: Engine[];
  36905. /** @hidden */
  36906. static _LastCreatedScene: Nullable<Scene>;
  36907. /**
  36908. * Gets the latest created engine
  36909. */
  36910. static get LastCreatedEngine(): Nullable<Engine>;
  36911. /**
  36912. * Gets the latest created scene
  36913. */
  36914. static get LastCreatedScene(): Nullable<Scene>;
  36915. /**
  36916. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36917. * @ignorenaming
  36918. */
  36919. static UseFallbackTexture: boolean;
  36920. /**
  36921. * Texture content used if a texture cannot loaded
  36922. * @ignorenaming
  36923. */
  36924. static FallbackTexture: string;
  36925. }
  36926. }
  36927. declare module BABYLON {
  36928. /**
  36929. * Helper class that provides a small promise polyfill
  36930. */
  36931. export class PromisePolyfill {
  36932. /**
  36933. * Static function used to check if the polyfill is required
  36934. * If this is the case then the function will inject the polyfill to window.Promise
  36935. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  36936. */
  36937. static Apply(force?: boolean): void;
  36938. }
  36939. }
  36940. declare module BABYLON {
  36941. /**
  36942. * Interface for screenshot methods with describe argument called `size` as object with options
  36943. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  36944. */
  36945. export interface IScreenshotSize {
  36946. /**
  36947. * number in pixels for canvas height
  36948. */
  36949. height?: number;
  36950. /**
  36951. * multiplier allowing render at a higher or lower resolution
  36952. * If value is defined then height and width will be ignored and taken from camera
  36953. */
  36954. precision?: number;
  36955. /**
  36956. * number in pixels for canvas width
  36957. */
  36958. width?: number;
  36959. }
  36960. }
  36961. declare module BABYLON {
  36962. interface IColor4Like {
  36963. r: float;
  36964. g: float;
  36965. b: float;
  36966. a: float;
  36967. }
  36968. /**
  36969. * Class containing a set of static utilities functions
  36970. */
  36971. export class Tools {
  36972. /**
  36973. * Gets or sets the base URL to use to load assets
  36974. */
  36975. static get BaseUrl(): string;
  36976. static set BaseUrl(value: string);
  36977. /**
  36978. * Enable/Disable Custom HTTP Request Headers globally.
  36979. * default = false
  36980. * @see CustomRequestHeaders
  36981. */
  36982. static UseCustomRequestHeaders: boolean;
  36983. /**
  36984. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  36985. * i.e. when loading files, where the server/service expects an Authorization header
  36986. */
  36987. static CustomRequestHeaders: {
  36988. [key: string]: string;
  36989. };
  36990. /**
  36991. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  36992. */
  36993. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  36994. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  36995. /**
  36996. * Default behaviour for cors in the application.
  36997. * It can be a string if the expected behavior is identical in the entire app.
  36998. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  36999. */
  37000. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37001. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37002. /**
  37003. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37004. * @ignorenaming
  37005. */
  37006. static get UseFallbackTexture(): boolean;
  37007. static set UseFallbackTexture(value: boolean);
  37008. /**
  37009. * Use this object to register external classes like custom textures or material
  37010. * to allow the laoders to instantiate them
  37011. */
  37012. static get RegisteredExternalClasses(): {
  37013. [key: string]: Object;
  37014. };
  37015. static set RegisteredExternalClasses(classes: {
  37016. [key: string]: Object;
  37017. });
  37018. /**
  37019. * Texture content used if a texture cannot loaded
  37020. * @ignorenaming
  37021. */
  37022. static get fallbackTexture(): string;
  37023. static set fallbackTexture(value: string);
  37024. /**
  37025. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37026. * @param u defines the coordinate on X axis
  37027. * @param v defines the coordinate on Y axis
  37028. * @param width defines the width of the source data
  37029. * @param height defines the height of the source data
  37030. * @param pixels defines the source byte array
  37031. * @param color defines the output color
  37032. */
  37033. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37034. /**
  37035. * Interpolates between a and b via alpha
  37036. * @param a The lower value (returned when alpha = 0)
  37037. * @param b The upper value (returned when alpha = 1)
  37038. * @param alpha The interpolation-factor
  37039. * @return The mixed value
  37040. */
  37041. static Mix(a: number, b: number, alpha: number): number;
  37042. /**
  37043. * Tries to instantiate a new object from a given class name
  37044. * @param className defines the class name to instantiate
  37045. * @returns the new object or null if the system was not able to do the instantiation
  37046. */
  37047. static Instantiate(className: string): any;
  37048. /**
  37049. * Provides a slice function that will work even on IE
  37050. * @param data defines the array to slice
  37051. * @param start defines the start of the data (optional)
  37052. * @param end defines the end of the data (optional)
  37053. * @returns the new sliced array
  37054. */
  37055. static Slice<T>(data: T, start?: number, end?: number): T;
  37056. /**
  37057. * Polyfill for setImmediate
  37058. * @param action defines the action to execute after the current execution block
  37059. */
  37060. static SetImmediate(action: () => void): void;
  37061. /**
  37062. * Function indicating if a number is an exponent of 2
  37063. * @param value defines the value to test
  37064. * @returns true if the value is an exponent of 2
  37065. */
  37066. static IsExponentOfTwo(value: number): boolean;
  37067. private static _tmpFloatArray;
  37068. /**
  37069. * Returns the nearest 32-bit single precision float representation of a Number
  37070. * @param value A Number. If the parameter is of a different type, it will get converted
  37071. * to a number or to NaN if it cannot be converted
  37072. * @returns number
  37073. */
  37074. static FloatRound(value: number): number;
  37075. /**
  37076. * Extracts the filename from a path
  37077. * @param path defines the path to use
  37078. * @returns the filename
  37079. */
  37080. static GetFilename(path: string): string;
  37081. /**
  37082. * Extracts the "folder" part of a path (everything before the filename).
  37083. * @param uri The URI to extract the info from
  37084. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37085. * @returns The "folder" part of the path
  37086. */
  37087. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37088. /**
  37089. * Extracts text content from a DOM element hierarchy
  37090. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37091. */
  37092. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37093. /**
  37094. * Convert an angle in radians to degrees
  37095. * @param angle defines the angle to convert
  37096. * @returns the angle in degrees
  37097. */
  37098. static ToDegrees(angle: number): number;
  37099. /**
  37100. * Convert an angle in degrees to radians
  37101. * @param angle defines the angle to convert
  37102. * @returns the angle in radians
  37103. */
  37104. static ToRadians(angle: number): number;
  37105. /**
  37106. * Returns an array if obj is not an array
  37107. * @param obj defines the object to evaluate as an array
  37108. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37109. * @returns either obj directly if obj is an array or a new array containing obj
  37110. */
  37111. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37112. /**
  37113. * Gets the pointer prefix to use
  37114. * @param engine defines the engine we are finding the prefix for
  37115. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37116. */
  37117. static GetPointerPrefix(engine: Engine): string;
  37118. /**
  37119. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37120. * @param url define the url we are trying
  37121. * @param element define the dom element where to configure the cors policy
  37122. */
  37123. static SetCorsBehavior(url: string | string[], element: {
  37124. crossOrigin: string | null;
  37125. }): void;
  37126. /**
  37127. * Removes unwanted characters from an url
  37128. * @param url defines the url to clean
  37129. * @returns the cleaned url
  37130. */
  37131. static CleanUrl(url: string): string;
  37132. /**
  37133. * Gets or sets a function used to pre-process url before using them to load assets
  37134. */
  37135. static get PreprocessUrl(): (url: string) => string;
  37136. static set PreprocessUrl(processor: (url: string) => string);
  37137. /**
  37138. * Loads an image as an HTMLImageElement.
  37139. * @param input url string, ArrayBuffer, or Blob to load
  37140. * @param onLoad callback called when the image successfully loads
  37141. * @param onError callback called when the image fails to load
  37142. * @param offlineProvider offline provider for caching
  37143. * @param mimeType optional mime type
  37144. * @returns the HTMLImageElement of the loaded image
  37145. */
  37146. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37147. /**
  37148. * Loads a file from a url
  37149. * @param url url string, ArrayBuffer, or Blob to load
  37150. * @param onSuccess callback called when the file successfully loads
  37151. * @param onProgress callback called while file is loading (if the server supports this mode)
  37152. * @param offlineProvider defines the offline provider for caching
  37153. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37154. * @param onError callback called when the file fails to load
  37155. * @returns a file request object
  37156. */
  37157. 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;
  37158. /**
  37159. * Loads a file from a url
  37160. * @param url the file url to load
  37161. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37162. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37163. */
  37164. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37165. /**
  37166. * Load a script (identified by an url). When the url returns, the
  37167. * content of this file is added into a new script element, attached to the DOM (body element)
  37168. * @param scriptUrl defines the url of the script to laod
  37169. * @param onSuccess defines the callback called when the script is loaded
  37170. * @param onError defines the callback to call if an error occurs
  37171. * @param scriptId defines the id of the script element
  37172. */
  37173. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37174. /**
  37175. * Load an asynchronous script (identified by an url). When the url returns, the
  37176. * content of this file is added into a new script element, attached to the DOM (body element)
  37177. * @param scriptUrl defines the url of the script to laod
  37178. * @param scriptId defines the id of the script element
  37179. * @returns a promise request object
  37180. */
  37181. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37182. /**
  37183. * Loads a file from a blob
  37184. * @param fileToLoad defines the blob to use
  37185. * @param callback defines the callback to call when data is loaded
  37186. * @param progressCallback defines the callback to call during loading process
  37187. * @returns a file request object
  37188. */
  37189. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37190. /**
  37191. * Reads a file from a File object
  37192. * @param file defines the file to load
  37193. * @param onSuccess defines the callback to call when data is loaded
  37194. * @param onProgress defines the callback to call during loading process
  37195. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37196. * @param onError defines the callback to call when an error occurs
  37197. * @returns a file request object
  37198. */
  37199. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37200. /**
  37201. * Creates a data url from a given string content
  37202. * @param content defines the content to convert
  37203. * @returns the new data url link
  37204. */
  37205. static FileAsURL(content: string): string;
  37206. /**
  37207. * Format the given number to a specific decimal format
  37208. * @param value defines the number to format
  37209. * @param decimals defines the number of decimals to use
  37210. * @returns the formatted string
  37211. */
  37212. static Format(value: number, decimals?: number): string;
  37213. /**
  37214. * Tries to copy an object by duplicating every property
  37215. * @param source defines the source object
  37216. * @param destination defines the target object
  37217. * @param doNotCopyList defines a list of properties to avoid
  37218. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37219. */
  37220. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37221. /**
  37222. * Gets a boolean indicating if the given object has no own property
  37223. * @param obj defines the object to test
  37224. * @returns true if object has no own property
  37225. */
  37226. static IsEmpty(obj: any): boolean;
  37227. /**
  37228. * Function used to register events at window level
  37229. * @param windowElement defines the Window object to use
  37230. * @param events defines the events to register
  37231. */
  37232. static RegisterTopRootEvents(windowElement: Window, events: {
  37233. name: string;
  37234. handler: Nullable<(e: FocusEvent) => any>;
  37235. }[]): void;
  37236. /**
  37237. * Function used to unregister events from window level
  37238. * @param windowElement defines the Window object to use
  37239. * @param events defines the events to unregister
  37240. */
  37241. static UnregisterTopRootEvents(windowElement: Window, events: {
  37242. name: string;
  37243. handler: Nullable<(e: FocusEvent) => any>;
  37244. }[]): void;
  37245. /**
  37246. * @ignore
  37247. */
  37248. static _ScreenshotCanvas: HTMLCanvasElement;
  37249. /**
  37250. * Dumps the current bound framebuffer
  37251. * @param width defines the rendering width
  37252. * @param height defines the rendering height
  37253. * @param engine defines the hosting engine
  37254. * @param successCallback defines the callback triggered once the data are available
  37255. * @param mimeType defines the mime type of the result
  37256. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37257. */
  37258. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37259. /**
  37260. * Converts the canvas data to blob.
  37261. * This acts as a polyfill for browsers not supporting the to blob function.
  37262. * @param canvas Defines the canvas to extract the data from
  37263. * @param successCallback Defines the callback triggered once the data are available
  37264. * @param mimeType Defines the mime type of the result
  37265. */
  37266. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37267. /**
  37268. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37269. * @param successCallback defines the callback triggered once the data are available
  37270. * @param mimeType defines the mime type of the result
  37271. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37272. */
  37273. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37274. /**
  37275. * Downloads a blob in the browser
  37276. * @param blob defines the blob to download
  37277. * @param fileName defines the name of the downloaded file
  37278. */
  37279. static Download(blob: Blob, fileName: string): void;
  37280. /**
  37281. * Captures a screenshot of the current rendering
  37282. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37283. * @param engine defines the rendering engine
  37284. * @param camera defines the source camera
  37285. * @param size This parameter can be set to a single number or to an object with the
  37286. * following (optional) properties: precision, width, height. If a single number is passed,
  37287. * it will be used for both width and height. If an object is passed, the screenshot size
  37288. * will be derived from the parameters. The precision property is a multiplier allowing
  37289. * rendering at a higher or lower resolution
  37290. * @param successCallback defines the callback receives a single parameter which contains the
  37291. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37292. * src parameter of an <img> to display it
  37293. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37294. * Check your browser for supported MIME types
  37295. */
  37296. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37297. /**
  37298. * Captures a screenshot of the current rendering
  37299. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37300. * @param engine defines the rendering engine
  37301. * @param camera defines the source camera
  37302. * @param size This parameter can be set to a single number or to an object with the
  37303. * following (optional) properties: precision, width, height. If a single number is passed,
  37304. * it will be used for both width and height. If an object is passed, the screenshot size
  37305. * will be derived from the parameters. The precision property is a multiplier allowing
  37306. * rendering at a higher or lower resolution
  37307. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37308. * Check your browser for supported MIME types
  37309. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37310. * to the src parameter of an <img> to display it
  37311. */
  37312. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37313. /**
  37314. * Generates an image screenshot from the specified camera.
  37315. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37316. * @param engine The engine to use for rendering
  37317. * @param camera The camera to use for rendering
  37318. * @param size This parameter can be set to a single number or to an object with the
  37319. * following (optional) properties: precision, width, height. If a single number is passed,
  37320. * it will be used for both width and height. If an object is passed, the screenshot size
  37321. * will be derived from the parameters. The precision property is a multiplier allowing
  37322. * rendering at a higher or lower resolution
  37323. * @param successCallback The callback receives a single parameter which contains the
  37324. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37325. * src parameter of an <img> to display it
  37326. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37327. * Check your browser for supported MIME types
  37328. * @param samples Texture samples (default: 1)
  37329. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37330. * @param fileName A name for for the downloaded file.
  37331. */
  37332. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37333. /**
  37334. * Generates an image screenshot from the specified camera.
  37335. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37336. * @param engine The engine to use for rendering
  37337. * @param camera The camera to use for rendering
  37338. * @param size This parameter can be set to a single number or to an object with the
  37339. * following (optional) properties: precision, width, height. If a single number is passed,
  37340. * it will be used for both width and height. If an object is passed, the screenshot size
  37341. * will be derived from the parameters. The precision property is a multiplier allowing
  37342. * rendering at a higher or lower resolution
  37343. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37344. * Check your browser for supported MIME types
  37345. * @param samples Texture samples (default: 1)
  37346. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37347. * @param fileName A name for for the downloaded file.
  37348. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37349. * to the src parameter of an <img> to display it
  37350. */
  37351. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37352. /**
  37353. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37354. * Be aware Math.random() could cause collisions, but:
  37355. * "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"
  37356. * @returns a pseudo random id
  37357. */
  37358. static RandomId(): string;
  37359. /**
  37360. * Test if the given uri is a base64 string
  37361. * @param uri The uri to test
  37362. * @return True if the uri is a base64 string or false otherwise
  37363. */
  37364. static IsBase64(uri: string): boolean;
  37365. /**
  37366. * Decode the given base64 uri.
  37367. * @param uri The uri to decode
  37368. * @return The decoded base64 data.
  37369. */
  37370. static DecodeBase64(uri: string): ArrayBuffer;
  37371. /**
  37372. * Gets the absolute url.
  37373. * @param url the input url
  37374. * @return the absolute url
  37375. */
  37376. static GetAbsoluteUrl(url: string): string;
  37377. /**
  37378. * No log
  37379. */
  37380. static readonly NoneLogLevel: number;
  37381. /**
  37382. * Only message logs
  37383. */
  37384. static readonly MessageLogLevel: number;
  37385. /**
  37386. * Only warning logs
  37387. */
  37388. static readonly WarningLogLevel: number;
  37389. /**
  37390. * Only error logs
  37391. */
  37392. static readonly ErrorLogLevel: number;
  37393. /**
  37394. * All logs
  37395. */
  37396. static readonly AllLogLevel: number;
  37397. /**
  37398. * Gets a value indicating the number of loading errors
  37399. * @ignorenaming
  37400. */
  37401. static get errorsCount(): number;
  37402. /**
  37403. * Callback called when a new log is added
  37404. */
  37405. static OnNewCacheEntry: (entry: string) => void;
  37406. /**
  37407. * Log a message to the console
  37408. * @param message defines the message to log
  37409. */
  37410. static Log(message: string): void;
  37411. /**
  37412. * Write a warning message to the console
  37413. * @param message defines the message to log
  37414. */
  37415. static Warn(message: string): void;
  37416. /**
  37417. * Write an error message to the console
  37418. * @param message defines the message to log
  37419. */
  37420. static Error(message: string): void;
  37421. /**
  37422. * Gets current log cache (list of logs)
  37423. */
  37424. static get LogCache(): string;
  37425. /**
  37426. * Clears the log cache
  37427. */
  37428. static ClearLogCache(): void;
  37429. /**
  37430. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37431. */
  37432. static set LogLevels(level: number);
  37433. /**
  37434. * Checks if the window object exists
  37435. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37436. */
  37437. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37438. /**
  37439. * No performance log
  37440. */
  37441. static readonly PerformanceNoneLogLevel: number;
  37442. /**
  37443. * Use user marks to log performance
  37444. */
  37445. static readonly PerformanceUserMarkLogLevel: number;
  37446. /**
  37447. * Log performance to the console
  37448. */
  37449. static readonly PerformanceConsoleLogLevel: number;
  37450. private static _performance;
  37451. /**
  37452. * Sets the current performance log level
  37453. */
  37454. static set PerformanceLogLevel(level: number);
  37455. private static _StartPerformanceCounterDisabled;
  37456. private static _EndPerformanceCounterDisabled;
  37457. private static _StartUserMark;
  37458. private static _EndUserMark;
  37459. private static _StartPerformanceConsole;
  37460. private static _EndPerformanceConsole;
  37461. /**
  37462. * Starts a performance counter
  37463. */
  37464. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37465. /**
  37466. * Ends a specific performance coutner
  37467. */
  37468. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37469. /**
  37470. * Gets either window.performance.now() if supported or Date.now() else
  37471. */
  37472. static get Now(): number;
  37473. /**
  37474. * This method will return the name of the class used to create the instance of the given object.
  37475. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37476. * @param object the object to get the class name from
  37477. * @param isType defines if the object is actually a type
  37478. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37479. */
  37480. static GetClassName(object: any, isType?: boolean): string;
  37481. /**
  37482. * Gets the first element of an array satisfying a given predicate
  37483. * @param array defines the array to browse
  37484. * @param predicate defines the predicate to use
  37485. * @returns null if not found or the element
  37486. */
  37487. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37488. /**
  37489. * This method will return the name of the full name of the class, including its owning module (if any).
  37490. * 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).
  37491. * @param object the object to get the class name from
  37492. * @param isType defines if the object is actually a type
  37493. * @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.
  37494. * @ignorenaming
  37495. */
  37496. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37497. /**
  37498. * Returns a promise that resolves after the given amount of time.
  37499. * @param delay Number of milliseconds to delay
  37500. * @returns Promise that resolves after the given amount of time
  37501. */
  37502. static DelayAsync(delay: number): Promise<void>;
  37503. /**
  37504. * Utility function to detect if the current user agent is Safari
  37505. * @returns whether or not the current user agent is safari
  37506. */
  37507. static IsSafari(): boolean;
  37508. }
  37509. /**
  37510. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37511. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37512. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37513. * @param name The name of the class, case should be preserved
  37514. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37515. */
  37516. export function className(name: string, module?: string): (target: Object) => void;
  37517. /**
  37518. * An implementation of a loop for asynchronous functions.
  37519. */
  37520. export class AsyncLoop {
  37521. /**
  37522. * Defines the number of iterations for the loop
  37523. */
  37524. iterations: number;
  37525. /**
  37526. * Defines the current index of the loop.
  37527. */
  37528. index: number;
  37529. private _done;
  37530. private _fn;
  37531. private _successCallback;
  37532. /**
  37533. * Constructor.
  37534. * @param iterations the number of iterations.
  37535. * @param func the function to run each iteration
  37536. * @param successCallback the callback that will be called upon succesful execution
  37537. * @param offset starting offset.
  37538. */
  37539. constructor(
  37540. /**
  37541. * Defines the number of iterations for the loop
  37542. */
  37543. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37544. /**
  37545. * Execute the next iteration. Must be called after the last iteration was finished.
  37546. */
  37547. executeNext(): void;
  37548. /**
  37549. * Break the loop and run the success callback.
  37550. */
  37551. breakLoop(): void;
  37552. /**
  37553. * Create and run an async loop.
  37554. * @param iterations the number of iterations.
  37555. * @param fn the function to run each iteration
  37556. * @param successCallback the callback that will be called upon succesful execution
  37557. * @param offset starting offset.
  37558. * @returns the created async loop object
  37559. */
  37560. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37561. /**
  37562. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37563. * @param iterations total number of iterations
  37564. * @param syncedIterations number of synchronous iterations in each async iteration.
  37565. * @param fn the function to call each iteration.
  37566. * @param callback a success call back that will be called when iterating stops.
  37567. * @param breakFunction a break condition (optional)
  37568. * @param timeout timeout settings for the setTimeout function. default - 0.
  37569. * @returns the created async loop object
  37570. */
  37571. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37572. }
  37573. }
  37574. declare module BABYLON {
  37575. /**
  37576. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37577. * The underlying implementation relies on an associative array to ensure the best performances.
  37578. * The value can be anything including 'null' but except 'undefined'
  37579. */
  37580. export class StringDictionary<T> {
  37581. /**
  37582. * This will clear this dictionary and copy the content from the 'source' one.
  37583. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37584. * @param source the dictionary to take the content from and copy to this dictionary
  37585. */
  37586. copyFrom(source: StringDictionary<T>): void;
  37587. /**
  37588. * Get a value based from its key
  37589. * @param key the given key to get the matching value from
  37590. * @return the value if found, otherwise undefined is returned
  37591. */
  37592. get(key: string): T | undefined;
  37593. /**
  37594. * Get a value from its key or add it if it doesn't exist.
  37595. * This method will ensure you that a given key/data will be present in the dictionary.
  37596. * @param key the given key to get the matching value from
  37597. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37598. * The factory will only be invoked if there's no data for the given key.
  37599. * @return the value corresponding to the key.
  37600. */
  37601. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37602. /**
  37603. * Get a value from its key if present in the dictionary otherwise add it
  37604. * @param key the key to get the value from
  37605. * @param val if there's no such key/value pair in the dictionary add it with this value
  37606. * @return the value corresponding to the key
  37607. */
  37608. getOrAdd(key: string, val: T): T;
  37609. /**
  37610. * Check if there's a given key in the dictionary
  37611. * @param key the key to check for
  37612. * @return true if the key is present, false otherwise
  37613. */
  37614. contains(key: string): boolean;
  37615. /**
  37616. * Add a new key and its corresponding value
  37617. * @param key the key to add
  37618. * @param value the value corresponding to the key
  37619. * @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
  37620. */
  37621. add(key: string, value: T): boolean;
  37622. /**
  37623. * Update a specific value associated to a key
  37624. * @param key defines the key to use
  37625. * @param value defines the value to store
  37626. * @returns true if the value was updated (or false if the key was not found)
  37627. */
  37628. set(key: string, value: T): boolean;
  37629. /**
  37630. * Get the element of the given key and remove it from the dictionary
  37631. * @param key defines the key to search
  37632. * @returns the value associated with the key or null if not found
  37633. */
  37634. getAndRemove(key: string): Nullable<T>;
  37635. /**
  37636. * Remove a key/value from the dictionary.
  37637. * @param key the key to remove
  37638. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37639. */
  37640. remove(key: string): boolean;
  37641. /**
  37642. * Clear the whole content of the dictionary
  37643. */
  37644. clear(): void;
  37645. /**
  37646. * Gets the current count
  37647. */
  37648. get count(): number;
  37649. /**
  37650. * Execute a callback on each key/val of the dictionary.
  37651. * Note that you can remove any element in this dictionary in the callback implementation
  37652. * @param callback the callback to execute on a given key/value pair
  37653. */
  37654. forEach(callback: (key: string, val: T) => void): void;
  37655. /**
  37656. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37657. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37658. * Note that you can remove any element in this dictionary in the callback implementation
  37659. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37660. * @returns the first item
  37661. */
  37662. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37663. private _count;
  37664. private _data;
  37665. }
  37666. }
  37667. declare module BABYLON {
  37668. /** @hidden */
  37669. export interface ICollisionCoordinator {
  37670. createCollider(): Collider;
  37671. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37672. init(scene: Scene): void;
  37673. }
  37674. /** @hidden */
  37675. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37676. private _scene;
  37677. private _scaledPosition;
  37678. private _scaledVelocity;
  37679. private _finalPosition;
  37680. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37681. createCollider(): Collider;
  37682. init(scene: Scene): void;
  37683. private _collideWithWorld;
  37684. }
  37685. }
  37686. declare module BABYLON {
  37687. /**
  37688. * Class used to manage all inputs for the scene.
  37689. */
  37690. export class InputManager {
  37691. /** The distance in pixel that you have to move to prevent some events */
  37692. static DragMovementThreshold: number;
  37693. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37694. static LongPressDelay: number;
  37695. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37696. static DoubleClickDelay: number;
  37697. /** If you need to check double click without raising a single click at first click, enable this flag */
  37698. static ExclusiveDoubleClickMode: boolean;
  37699. private _wheelEventName;
  37700. private _onPointerMove;
  37701. private _onPointerDown;
  37702. private _onPointerUp;
  37703. private _initClickEvent;
  37704. private _initActionManager;
  37705. private _delayedSimpleClick;
  37706. private _delayedSimpleClickTimeout;
  37707. private _previousDelayedSimpleClickTimeout;
  37708. private _meshPickProceed;
  37709. private _previousButtonPressed;
  37710. private _currentPickResult;
  37711. private _previousPickResult;
  37712. private _totalPointersPressed;
  37713. private _doubleClickOccured;
  37714. private _pointerOverMesh;
  37715. private _pickedDownMesh;
  37716. private _pickedUpMesh;
  37717. private _pointerX;
  37718. private _pointerY;
  37719. private _unTranslatedPointerX;
  37720. private _unTranslatedPointerY;
  37721. private _startingPointerPosition;
  37722. private _previousStartingPointerPosition;
  37723. private _startingPointerTime;
  37724. private _previousStartingPointerTime;
  37725. private _pointerCaptures;
  37726. private _onKeyDown;
  37727. private _onKeyUp;
  37728. private _onCanvasFocusObserver;
  37729. private _onCanvasBlurObserver;
  37730. private _scene;
  37731. /**
  37732. * Creates a new InputManager
  37733. * @param scene defines the hosting scene
  37734. */
  37735. constructor(scene: Scene);
  37736. /**
  37737. * Gets the mesh that is currently under the pointer
  37738. */
  37739. get meshUnderPointer(): Nullable<AbstractMesh>;
  37740. /**
  37741. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37742. */
  37743. get unTranslatedPointer(): Vector2;
  37744. /**
  37745. * Gets or sets the current on-screen X position of the pointer
  37746. */
  37747. get pointerX(): number;
  37748. set pointerX(value: number);
  37749. /**
  37750. * Gets or sets the current on-screen Y position of the pointer
  37751. */
  37752. get pointerY(): number;
  37753. set pointerY(value: number);
  37754. private _updatePointerPosition;
  37755. private _processPointerMove;
  37756. private _setRayOnPointerInfo;
  37757. private _checkPrePointerObservable;
  37758. /**
  37759. * Use this method to simulate a pointer move on a mesh
  37760. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37761. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37762. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37763. */
  37764. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37765. /**
  37766. * Use this method to simulate a pointer down on a mesh
  37767. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37768. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37769. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37770. */
  37771. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37772. private _processPointerDown;
  37773. /** @hidden */
  37774. _isPointerSwiping(): boolean;
  37775. /**
  37776. * Use this method to simulate a pointer up on a mesh
  37777. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37778. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37779. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37780. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37781. */
  37782. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37783. private _processPointerUp;
  37784. /**
  37785. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37786. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37787. * @returns true if the pointer was captured
  37788. */
  37789. isPointerCaptured(pointerId?: number): boolean;
  37790. /**
  37791. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37792. * @param attachUp defines if you want to attach events to pointerup
  37793. * @param attachDown defines if you want to attach events to pointerdown
  37794. * @param attachMove defines if you want to attach events to pointermove
  37795. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37796. */
  37797. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37798. /**
  37799. * Detaches all event handlers
  37800. */
  37801. detachControl(): void;
  37802. /**
  37803. * Force the value of meshUnderPointer
  37804. * @param mesh defines the mesh to use
  37805. */
  37806. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37807. /**
  37808. * Gets the mesh under the pointer
  37809. * @returns a Mesh or null if no mesh is under the pointer
  37810. */
  37811. getPointerOverMesh(): Nullable<AbstractMesh>;
  37812. }
  37813. }
  37814. declare module BABYLON {
  37815. /**
  37816. * This class defines the direct association between an animation and a target
  37817. */
  37818. export class TargetedAnimation {
  37819. /**
  37820. * Animation to perform
  37821. */
  37822. animation: Animation;
  37823. /**
  37824. * Target to animate
  37825. */
  37826. target: any;
  37827. /**
  37828. * Serialize the object
  37829. * @returns the JSON object representing the current entity
  37830. */
  37831. serialize(): any;
  37832. }
  37833. /**
  37834. * Use this class to create coordinated animations on multiple targets
  37835. */
  37836. export class AnimationGroup implements IDisposable {
  37837. /** The name of the animation group */
  37838. name: string;
  37839. private _scene;
  37840. private _targetedAnimations;
  37841. private _animatables;
  37842. private _from;
  37843. private _to;
  37844. private _isStarted;
  37845. private _isPaused;
  37846. private _speedRatio;
  37847. private _loopAnimation;
  37848. private _isAdditive;
  37849. /**
  37850. * Gets or sets the unique id of the node
  37851. */
  37852. uniqueId: number;
  37853. /**
  37854. * This observable will notify when one animation have ended
  37855. */
  37856. onAnimationEndObservable: Observable<TargetedAnimation>;
  37857. /**
  37858. * Observer raised when one animation loops
  37859. */
  37860. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37861. /**
  37862. * Observer raised when all animations have looped
  37863. */
  37864. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37865. /**
  37866. * This observable will notify when all animations have ended.
  37867. */
  37868. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37869. /**
  37870. * This observable will notify when all animations have paused.
  37871. */
  37872. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37873. /**
  37874. * This observable will notify when all animations are playing.
  37875. */
  37876. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37877. /**
  37878. * Gets the first frame
  37879. */
  37880. get from(): number;
  37881. /**
  37882. * Gets the last frame
  37883. */
  37884. get to(): number;
  37885. /**
  37886. * Define if the animations are started
  37887. */
  37888. get isStarted(): boolean;
  37889. /**
  37890. * Gets a value indicating that the current group is playing
  37891. */
  37892. get isPlaying(): boolean;
  37893. /**
  37894. * Gets or sets the speed ratio to use for all animations
  37895. */
  37896. get speedRatio(): number;
  37897. /**
  37898. * Gets or sets the speed ratio to use for all animations
  37899. */
  37900. set speedRatio(value: number);
  37901. /**
  37902. * Gets or sets if all animations should loop or not
  37903. */
  37904. get loopAnimation(): boolean;
  37905. set loopAnimation(value: boolean);
  37906. /**
  37907. * Gets or sets if all animations should be evaluated additively
  37908. */
  37909. get isAdditive(): boolean;
  37910. set isAdditive(value: boolean);
  37911. /**
  37912. * Gets the targeted animations for this animation group
  37913. */
  37914. get targetedAnimations(): Array<TargetedAnimation>;
  37915. /**
  37916. * returning the list of animatables controlled by this animation group.
  37917. */
  37918. get animatables(): Array<Animatable>;
  37919. /**
  37920. * Instantiates a new Animation Group.
  37921. * This helps managing several animations at once.
  37922. * @see http://doc.babylonjs.com/how_to/group
  37923. * @param name Defines the name of the group
  37924. * @param scene Defines the scene the group belongs to
  37925. */
  37926. constructor(
  37927. /** The name of the animation group */
  37928. name: string, scene?: Nullable<Scene>);
  37929. /**
  37930. * Add an animation (with its target) in the group
  37931. * @param animation defines the animation we want to add
  37932. * @param target defines the target of the animation
  37933. * @returns the TargetedAnimation object
  37934. */
  37935. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  37936. /**
  37937. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  37938. * It can add constant keys at begin or end
  37939. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  37940. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  37941. * @returns the animation group
  37942. */
  37943. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  37944. private _animationLoopCount;
  37945. private _animationLoopFlags;
  37946. private _processLoop;
  37947. /**
  37948. * Start all animations on given targets
  37949. * @param loop defines if animations must loop
  37950. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  37951. * @param from defines the from key (optional)
  37952. * @param to defines the to key (optional)
  37953. * @param isAdditive defines the additive state for the resulting animatables (optional)
  37954. * @returns the current animation group
  37955. */
  37956. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  37957. /**
  37958. * Pause all animations
  37959. * @returns the animation group
  37960. */
  37961. pause(): AnimationGroup;
  37962. /**
  37963. * Play all animations to initial state
  37964. * This function will start() the animations if they were not started or will restart() them if they were paused
  37965. * @param loop defines if animations must loop
  37966. * @returns the animation group
  37967. */
  37968. play(loop?: boolean): AnimationGroup;
  37969. /**
  37970. * Reset all animations to initial state
  37971. * @returns the animation group
  37972. */
  37973. reset(): AnimationGroup;
  37974. /**
  37975. * Restart animations from key 0
  37976. * @returns the animation group
  37977. */
  37978. restart(): AnimationGroup;
  37979. /**
  37980. * Stop all animations
  37981. * @returns the animation group
  37982. */
  37983. stop(): AnimationGroup;
  37984. /**
  37985. * Set animation weight for all animatables
  37986. * @param weight defines the weight to use
  37987. * @return the animationGroup
  37988. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  37989. */
  37990. setWeightForAllAnimatables(weight: number): AnimationGroup;
  37991. /**
  37992. * Synchronize and normalize all animatables with a source animatable
  37993. * @param root defines the root animatable to synchronize with
  37994. * @return the animationGroup
  37995. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  37996. */
  37997. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  37998. /**
  37999. * Goes to a specific frame in this animation group
  38000. * @param frame the frame number to go to
  38001. * @return the animationGroup
  38002. */
  38003. goToFrame(frame: number): AnimationGroup;
  38004. /**
  38005. * Dispose all associated resources
  38006. */
  38007. dispose(): void;
  38008. private _checkAnimationGroupEnded;
  38009. /**
  38010. * Clone the current animation group and returns a copy
  38011. * @param newName defines the name of the new group
  38012. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38013. * @returns the new aniamtion group
  38014. */
  38015. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38016. /**
  38017. * Serializes the animationGroup to an object
  38018. * @returns Serialized object
  38019. */
  38020. serialize(): any;
  38021. /**
  38022. * Returns a new AnimationGroup object parsed from the source provided.
  38023. * @param parsedAnimationGroup defines the source
  38024. * @param scene defines the scene that will receive the animationGroup
  38025. * @returns a new AnimationGroup
  38026. */
  38027. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38028. /**
  38029. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38030. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38031. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38032. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38033. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38034. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38035. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38036. */
  38037. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38038. /**
  38039. * Returns the string "AnimationGroup"
  38040. * @returns "AnimationGroup"
  38041. */
  38042. getClassName(): string;
  38043. /**
  38044. * Creates a detailled string about the object
  38045. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38046. * @returns a string representing the object
  38047. */
  38048. toString(fullDetails?: boolean): string;
  38049. }
  38050. }
  38051. declare module BABYLON {
  38052. /**
  38053. * Define an interface for all classes that will hold resources
  38054. */
  38055. export interface IDisposable {
  38056. /**
  38057. * Releases all held resources
  38058. */
  38059. dispose(): void;
  38060. }
  38061. /** Interface defining initialization parameters for Scene class */
  38062. export interface SceneOptions {
  38063. /**
  38064. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38065. * It will improve performance when the number of geometries becomes important.
  38066. */
  38067. useGeometryUniqueIdsMap?: boolean;
  38068. /**
  38069. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38070. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38071. */
  38072. useMaterialMeshMap?: boolean;
  38073. /**
  38074. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38075. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38076. */
  38077. useClonedMeshMap?: boolean;
  38078. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38079. virtual?: boolean;
  38080. }
  38081. /**
  38082. * Represents a scene to be rendered by the engine.
  38083. * @see http://doc.babylonjs.com/features/scene
  38084. */
  38085. export class Scene extends AbstractScene implements IAnimatable {
  38086. /** The fog is deactivated */
  38087. static readonly FOGMODE_NONE: number;
  38088. /** The fog density is following an exponential function */
  38089. static readonly FOGMODE_EXP: number;
  38090. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38091. static readonly FOGMODE_EXP2: number;
  38092. /** The fog density is following a linear function. */
  38093. static readonly FOGMODE_LINEAR: number;
  38094. /**
  38095. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38096. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38097. */
  38098. static MinDeltaTime: number;
  38099. /**
  38100. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38102. */
  38103. static MaxDeltaTime: number;
  38104. /**
  38105. * Factory used to create the default material.
  38106. * @param name The name of the material to create
  38107. * @param scene The scene to create the material for
  38108. * @returns The default material
  38109. */
  38110. static DefaultMaterialFactory(scene: Scene): Material;
  38111. /**
  38112. * Factory used to create the a collision coordinator.
  38113. * @returns The collision coordinator
  38114. */
  38115. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38116. /** @hidden */
  38117. _inputManager: InputManager;
  38118. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38119. cameraToUseForPointers: Nullable<Camera>;
  38120. /** @hidden */
  38121. readonly _isScene: boolean;
  38122. /** @hidden */
  38123. _blockEntityCollection: boolean;
  38124. /**
  38125. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38126. */
  38127. autoClear: boolean;
  38128. /**
  38129. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38130. */
  38131. autoClearDepthAndStencil: boolean;
  38132. /**
  38133. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38134. */
  38135. clearColor: Color4;
  38136. /**
  38137. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38138. */
  38139. ambientColor: Color3;
  38140. /**
  38141. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38142. * It should only be one of the following (if not the default embedded one):
  38143. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38144. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38145. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38146. * The material properties need to be setup according to the type of texture in use.
  38147. */
  38148. environmentBRDFTexture: BaseTexture;
  38149. /** @hidden */
  38150. protected _environmentTexture: Nullable<BaseTexture>;
  38151. /**
  38152. * Texture used in all pbr material as the reflection texture.
  38153. * As in the majority of the scene they are the same (exception for multi room and so on),
  38154. * this is easier to reference from here than from all the materials.
  38155. */
  38156. get environmentTexture(): Nullable<BaseTexture>;
  38157. /**
  38158. * Texture used in all pbr material as the reflection texture.
  38159. * As in the majority of the scene they are the same (exception for multi room and so on),
  38160. * this is easier to set here than in all the materials.
  38161. */
  38162. set environmentTexture(value: Nullable<BaseTexture>);
  38163. /** @hidden */
  38164. protected _environmentIntensity: number;
  38165. /**
  38166. * Intensity of the environment in all pbr material.
  38167. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38168. * As in the majority of the scene they are the same (exception for multi room and so on),
  38169. * this is easier to reference from here than from all the materials.
  38170. */
  38171. get environmentIntensity(): number;
  38172. /**
  38173. * Intensity of the environment in all pbr material.
  38174. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38175. * As in the majority of the scene they are the same (exception for multi room and so on),
  38176. * this is easier to set here than in all the materials.
  38177. */
  38178. set environmentIntensity(value: number);
  38179. /** @hidden */
  38180. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38181. /**
  38182. * Default image processing configuration used either in the rendering
  38183. * Forward main pass or through the imageProcessingPostProcess if present.
  38184. * As in the majority of the scene they are the same (exception for multi camera),
  38185. * this is easier to reference from here than from all the materials and post process.
  38186. *
  38187. * No setter as we it is a shared configuration, you can set the values instead.
  38188. */
  38189. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38190. private _forceWireframe;
  38191. /**
  38192. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38193. */
  38194. set forceWireframe(value: boolean);
  38195. get forceWireframe(): boolean;
  38196. private _skipFrustumClipping;
  38197. /**
  38198. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38199. */
  38200. set skipFrustumClipping(value: boolean);
  38201. get skipFrustumClipping(): boolean;
  38202. private _forcePointsCloud;
  38203. /**
  38204. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38205. */
  38206. set forcePointsCloud(value: boolean);
  38207. get forcePointsCloud(): boolean;
  38208. /**
  38209. * Gets or sets the active clipplane 1
  38210. */
  38211. clipPlane: Nullable<Plane>;
  38212. /**
  38213. * Gets or sets the active clipplane 2
  38214. */
  38215. clipPlane2: Nullable<Plane>;
  38216. /**
  38217. * Gets or sets the active clipplane 3
  38218. */
  38219. clipPlane3: Nullable<Plane>;
  38220. /**
  38221. * Gets or sets the active clipplane 4
  38222. */
  38223. clipPlane4: Nullable<Plane>;
  38224. /**
  38225. * Gets or sets the active clipplane 5
  38226. */
  38227. clipPlane5: Nullable<Plane>;
  38228. /**
  38229. * Gets or sets the active clipplane 6
  38230. */
  38231. clipPlane6: Nullable<Plane>;
  38232. /**
  38233. * Gets or sets a boolean indicating if animations are enabled
  38234. */
  38235. animationsEnabled: boolean;
  38236. private _animationPropertiesOverride;
  38237. /**
  38238. * Gets or sets the animation properties override
  38239. */
  38240. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38241. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38242. /**
  38243. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38244. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38245. */
  38246. useConstantAnimationDeltaTime: boolean;
  38247. /**
  38248. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38249. * Please note that it requires to run a ray cast through the scene on every frame
  38250. */
  38251. constantlyUpdateMeshUnderPointer: boolean;
  38252. /**
  38253. * Defines the HTML cursor to use when hovering over interactive elements
  38254. */
  38255. hoverCursor: string;
  38256. /**
  38257. * Defines the HTML default cursor to use (empty by default)
  38258. */
  38259. defaultCursor: string;
  38260. /**
  38261. * Defines whether cursors are handled by the scene.
  38262. */
  38263. doNotHandleCursors: boolean;
  38264. /**
  38265. * This is used to call preventDefault() on pointer down
  38266. * in order to block unwanted artifacts like system double clicks
  38267. */
  38268. preventDefaultOnPointerDown: boolean;
  38269. /**
  38270. * This is used to call preventDefault() on pointer up
  38271. * in order to block unwanted artifacts like system double clicks
  38272. */
  38273. preventDefaultOnPointerUp: boolean;
  38274. /**
  38275. * Gets or sets user defined metadata
  38276. */
  38277. metadata: any;
  38278. /**
  38279. * For internal use only. Please do not use.
  38280. */
  38281. reservedDataStore: any;
  38282. /**
  38283. * Gets the name of the plugin used to load this scene (null by default)
  38284. */
  38285. loadingPluginName: string;
  38286. /**
  38287. * Use this array to add regular expressions used to disable offline support for specific urls
  38288. */
  38289. disableOfflineSupportExceptionRules: RegExp[];
  38290. /**
  38291. * An event triggered when the scene is disposed.
  38292. */
  38293. onDisposeObservable: Observable<Scene>;
  38294. private _onDisposeObserver;
  38295. /** Sets a function to be executed when this scene is disposed. */
  38296. set onDispose(callback: () => void);
  38297. /**
  38298. * An event triggered before rendering the scene (right after animations and physics)
  38299. */
  38300. onBeforeRenderObservable: Observable<Scene>;
  38301. private _onBeforeRenderObserver;
  38302. /** Sets a function to be executed before rendering this scene */
  38303. set beforeRender(callback: Nullable<() => void>);
  38304. /**
  38305. * An event triggered after rendering the scene
  38306. */
  38307. onAfterRenderObservable: Observable<Scene>;
  38308. /**
  38309. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38310. */
  38311. onAfterRenderCameraObservable: Observable<Camera>;
  38312. private _onAfterRenderObserver;
  38313. /** Sets a function to be executed after rendering this scene */
  38314. set afterRender(callback: Nullable<() => void>);
  38315. /**
  38316. * An event triggered before animating the scene
  38317. */
  38318. onBeforeAnimationsObservable: Observable<Scene>;
  38319. /**
  38320. * An event triggered after animations processing
  38321. */
  38322. onAfterAnimationsObservable: Observable<Scene>;
  38323. /**
  38324. * An event triggered before draw calls are ready to be sent
  38325. */
  38326. onBeforeDrawPhaseObservable: Observable<Scene>;
  38327. /**
  38328. * An event triggered after draw calls have been sent
  38329. */
  38330. onAfterDrawPhaseObservable: Observable<Scene>;
  38331. /**
  38332. * An event triggered when the scene is ready
  38333. */
  38334. onReadyObservable: Observable<Scene>;
  38335. /**
  38336. * An event triggered before rendering a camera
  38337. */
  38338. onBeforeCameraRenderObservable: Observable<Camera>;
  38339. private _onBeforeCameraRenderObserver;
  38340. /** Sets a function to be executed before rendering a camera*/
  38341. set beforeCameraRender(callback: () => void);
  38342. /**
  38343. * An event triggered after rendering a camera
  38344. */
  38345. onAfterCameraRenderObservable: Observable<Camera>;
  38346. private _onAfterCameraRenderObserver;
  38347. /** Sets a function to be executed after rendering a camera*/
  38348. set afterCameraRender(callback: () => void);
  38349. /**
  38350. * An event triggered when active meshes evaluation is about to start
  38351. */
  38352. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38353. /**
  38354. * An event triggered when active meshes evaluation is done
  38355. */
  38356. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38357. /**
  38358. * An event triggered when particles rendering is about to start
  38359. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38360. */
  38361. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38362. /**
  38363. * An event triggered when particles rendering is done
  38364. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38365. */
  38366. onAfterParticlesRenderingObservable: Observable<Scene>;
  38367. /**
  38368. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38369. */
  38370. onDataLoadedObservable: Observable<Scene>;
  38371. /**
  38372. * An event triggered when a camera is created
  38373. */
  38374. onNewCameraAddedObservable: Observable<Camera>;
  38375. /**
  38376. * An event triggered when a camera is removed
  38377. */
  38378. onCameraRemovedObservable: Observable<Camera>;
  38379. /**
  38380. * An event triggered when a light is created
  38381. */
  38382. onNewLightAddedObservable: Observable<Light>;
  38383. /**
  38384. * An event triggered when a light is removed
  38385. */
  38386. onLightRemovedObservable: Observable<Light>;
  38387. /**
  38388. * An event triggered when a geometry is created
  38389. */
  38390. onNewGeometryAddedObservable: Observable<Geometry>;
  38391. /**
  38392. * An event triggered when a geometry is removed
  38393. */
  38394. onGeometryRemovedObservable: Observable<Geometry>;
  38395. /**
  38396. * An event triggered when a transform node is created
  38397. */
  38398. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38399. /**
  38400. * An event triggered when a transform node is removed
  38401. */
  38402. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38403. /**
  38404. * An event triggered when a mesh is created
  38405. */
  38406. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38407. /**
  38408. * An event triggered when a mesh is removed
  38409. */
  38410. onMeshRemovedObservable: Observable<AbstractMesh>;
  38411. /**
  38412. * An event triggered when a skeleton is created
  38413. */
  38414. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38415. /**
  38416. * An event triggered when a skeleton is removed
  38417. */
  38418. onSkeletonRemovedObservable: Observable<Skeleton>;
  38419. /**
  38420. * An event triggered when a material is created
  38421. */
  38422. onNewMaterialAddedObservable: Observable<Material>;
  38423. /**
  38424. * An event triggered when a material is removed
  38425. */
  38426. onMaterialRemovedObservable: Observable<Material>;
  38427. /**
  38428. * An event triggered when a texture is created
  38429. */
  38430. onNewTextureAddedObservable: Observable<BaseTexture>;
  38431. /**
  38432. * An event triggered when a texture is removed
  38433. */
  38434. onTextureRemovedObservable: Observable<BaseTexture>;
  38435. /**
  38436. * An event triggered when render targets are about to be rendered
  38437. * Can happen multiple times per frame.
  38438. */
  38439. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38440. /**
  38441. * An event triggered when render targets were rendered.
  38442. * Can happen multiple times per frame.
  38443. */
  38444. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38445. /**
  38446. * An event triggered before calculating deterministic simulation step
  38447. */
  38448. onBeforeStepObservable: Observable<Scene>;
  38449. /**
  38450. * An event triggered after calculating deterministic simulation step
  38451. */
  38452. onAfterStepObservable: Observable<Scene>;
  38453. /**
  38454. * An event triggered when the activeCamera property is updated
  38455. */
  38456. onActiveCameraChanged: Observable<Scene>;
  38457. /**
  38458. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38459. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38460. * 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)
  38461. */
  38462. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38463. /**
  38464. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38465. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38466. * 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)
  38467. */
  38468. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38469. /**
  38470. * This Observable will when a mesh has been imported into the scene.
  38471. */
  38472. onMeshImportedObservable: Observable<AbstractMesh>;
  38473. /**
  38474. * This Observable will when an animation file has been imported into the scene.
  38475. */
  38476. onAnimationFileImportedObservable: Observable<Scene>;
  38477. /**
  38478. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38479. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38480. */
  38481. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38482. /** @hidden */
  38483. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38484. /**
  38485. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38486. */
  38487. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38488. /**
  38489. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38490. */
  38491. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38492. /**
  38493. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38494. */
  38495. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38496. /** Callback called when a pointer move is detected */
  38497. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38498. /** Callback called when a pointer down is detected */
  38499. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38500. /** Callback called when a pointer up is detected */
  38501. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38502. /** Callback called when a pointer pick is detected */
  38503. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38504. /**
  38505. * 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).
  38506. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38507. */
  38508. onPrePointerObservable: Observable<PointerInfoPre>;
  38509. /**
  38510. * Observable event triggered each time an input event is received from the rendering canvas
  38511. */
  38512. onPointerObservable: Observable<PointerInfo>;
  38513. /**
  38514. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38515. */
  38516. get unTranslatedPointer(): Vector2;
  38517. /**
  38518. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38519. */
  38520. static get DragMovementThreshold(): number;
  38521. static set DragMovementThreshold(value: number);
  38522. /**
  38523. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38524. */
  38525. static get LongPressDelay(): number;
  38526. static set LongPressDelay(value: number);
  38527. /**
  38528. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38529. */
  38530. static get DoubleClickDelay(): number;
  38531. static set DoubleClickDelay(value: number);
  38532. /** If you need to check double click without raising a single click at first click, enable this flag */
  38533. static get ExclusiveDoubleClickMode(): boolean;
  38534. static set ExclusiveDoubleClickMode(value: boolean);
  38535. /** @hidden */
  38536. _mirroredCameraPosition: Nullable<Vector3>;
  38537. /**
  38538. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38539. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38540. */
  38541. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38542. /**
  38543. * Observable event triggered each time an keyboard event is received from the hosting window
  38544. */
  38545. onKeyboardObservable: Observable<KeyboardInfo>;
  38546. private _useRightHandedSystem;
  38547. /**
  38548. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38549. */
  38550. set useRightHandedSystem(value: boolean);
  38551. get useRightHandedSystem(): boolean;
  38552. private _timeAccumulator;
  38553. private _currentStepId;
  38554. private _currentInternalStep;
  38555. /**
  38556. * Sets the step Id used by deterministic lock step
  38557. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38558. * @param newStepId defines the step Id
  38559. */
  38560. setStepId(newStepId: number): void;
  38561. /**
  38562. * Gets the step Id used by deterministic lock step
  38563. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38564. * @returns the step Id
  38565. */
  38566. getStepId(): number;
  38567. /**
  38568. * Gets the internal step used by deterministic lock step
  38569. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38570. * @returns the internal step
  38571. */
  38572. getInternalStep(): number;
  38573. private _fogEnabled;
  38574. /**
  38575. * Gets or sets a boolean indicating if fog is enabled on this scene
  38576. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38577. * (Default is true)
  38578. */
  38579. set fogEnabled(value: boolean);
  38580. get fogEnabled(): boolean;
  38581. private _fogMode;
  38582. /**
  38583. * Gets or sets the fog mode to use
  38584. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38585. * | mode | value |
  38586. * | --- | --- |
  38587. * | FOGMODE_NONE | 0 |
  38588. * | FOGMODE_EXP | 1 |
  38589. * | FOGMODE_EXP2 | 2 |
  38590. * | FOGMODE_LINEAR | 3 |
  38591. */
  38592. set fogMode(value: number);
  38593. get fogMode(): number;
  38594. /**
  38595. * Gets or sets the fog color to use
  38596. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38597. * (Default is Color3(0.2, 0.2, 0.3))
  38598. */
  38599. fogColor: Color3;
  38600. /**
  38601. * Gets or sets the fog density to use
  38602. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38603. * (Default is 0.1)
  38604. */
  38605. fogDensity: number;
  38606. /**
  38607. * Gets or sets the fog start distance to use
  38608. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38609. * (Default is 0)
  38610. */
  38611. fogStart: number;
  38612. /**
  38613. * Gets or sets the fog end distance to use
  38614. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38615. * (Default is 1000)
  38616. */
  38617. fogEnd: number;
  38618. private _shadowsEnabled;
  38619. /**
  38620. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38621. */
  38622. set shadowsEnabled(value: boolean);
  38623. get shadowsEnabled(): boolean;
  38624. private _lightsEnabled;
  38625. /**
  38626. * Gets or sets a boolean indicating if lights are enabled on this scene
  38627. */
  38628. set lightsEnabled(value: boolean);
  38629. get lightsEnabled(): boolean;
  38630. /** All of the active cameras added to this scene. */
  38631. activeCameras: Camera[];
  38632. /** @hidden */
  38633. _activeCamera: Nullable<Camera>;
  38634. /** Gets or sets the current active camera */
  38635. get activeCamera(): Nullable<Camera>;
  38636. set activeCamera(value: Nullable<Camera>);
  38637. private _defaultMaterial;
  38638. /** The default material used on meshes when no material is affected */
  38639. get defaultMaterial(): Material;
  38640. /** The default material used on meshes when no material is affected */
  38641. set defaultMaterial(value: Material);
  38642. private _texturesEnabled;
  38643. /**
  38644. * Gets or sets a boolean indicating if textures are enabled on this scene
  38645. */
  38646. set texturesEnabled(value: boolean);
  38647. get texturesEnabled(): boolean;
  38648. /**
  38649. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38650. */
  38651. physicsEnabled: boolean;
  38652. /**
  38653. * Gets or sets a boolean indicating if particles are enabled on this scene
  38654. */
  38655. particlesEnabled: boolean;
  38656. /**
  38657. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38658. */
  38659. spritesEnabled: boolean;
  38660. private _skeletonsEnabled;
  38661. /**
  38662. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38663. */
  38664. set skeletonsEnabled(value: boolean);
  38665. get skeletonsEnabled(): boolean;
  38666. /**
  38667. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38668. */
  38669. lensFlaresEnabled: boolean;
  38670. /**
  38671. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38673. */
  38674. collisionsEnabled: boolean;
  38675. private _collisionCoordinator;
  38676. /** @hidden */
  38677. get collisionCoordinator(): ICollisionCoordinator;
  38678. /**
  38679. * Defines the gravity applied to this scene (used only for collisions)
  38680. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38681. */
  38682. gravity: Vector3;
  38683. /**
  38684. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38685. */
  38686. postProcessesEnabled: boolean;
  38687. /**
  38688. * The list of postprocesses added to the scene
  38689. */
  38690. postProcesses: PostProcess[];
  38691. /**
  38692. * Gets the current postprocess manager
  38693. */
  38694. postProcessManager: PostProcessManager;
  38695. /**
  38696. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38697. */
  38698. renderTargetsEnabled: boolean;
  38699. /**
  38700. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38701. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38702. */
  38703. dumpNextRenderTargets: boolean;
  38704. /**
  38705. * The list of user defined render targets added to the scene
  38706. */
  38707. customRenderTargets: RenderTargetTexture[];
  38708. /**
  38709. * Defines if texture loading must be delayed
  38710. * If true, textures will only be loaded when they need to be rendered
  38711. */
  38712. useDelayedTextureLoading: boolean;
  38713. /**
  38714. * Gets the list of meshes imported to the scene through SceneLoader
  38715. */
  38716. importedMeshesFiles: String[];
  38717. /**
  38718. * Gets or sets a boolean indicating if probes are enabled on this scene
  38719. */
  38720. probesEnabled: boolean;
  38721. /**
  38722. * Gets or sets the current offline provider to use to store scene data
  38723. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38724. */
  38725. offlineProvider: IOfflineProvider;
  38726. /**
  38727. * Gets or sets the action manager associated with the scene
  38728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38729. */
  38730. actionManager: AbstractActionManager;
  38731. private _meshesForIntersections;
  38732. /**
  38733. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38734. */
  38735. proceduralTexturesEnabled: boolean;
  38736. private _engine;
  38737. private _totalVertices;
  38738. /** @hidden */
  38739. _activeIndices: PerfCounter;
  38740. /** @hidden */
  38741. _activeParticles: PerfCounter;
  38742. /** @hidden */
  38743. _activeBones: PerfCounter;
  38744. private _animationRatio;
  38745. /** @hidden */
  38746. _animationTimeLast: number;
  38747. /** @hidden */
  38748. _animationTime: number;
  38749. /**
  38750. * Gets or sets a general scale for animation speed
  38751. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38752. */
  38753. animationTimeScale: number;
  38754. /** @hidden */
  38755. _cachedMaterial: Nullable<Material>;
  38756. /** @hidden */
  38757. _cachedEffect: Nullable<Effect>;
  38758. /** @hidden */
  38759. _cachedVisibility: Nullable<number>;
  38760. private _renderId;
  38761. private _frameId;
  38762. private _executeWhenReadyTimeoutId;
  38763. private _intermediateRendering;
  38764. private _viewUpdateFlag;
  38765. private _projectionUpdateFlag;
  38766. /** @hidden */
  38767. _toBeDisposed: Nullable<IDisposable>[];
  38768. private _activeRequests;
  38769. /** @hidden */
  38770. _pendingData: any[];
  38771. private _isDisposed;
  38772. /**
  38773. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38774. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38775. */
  38776. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38777. private _activeMeshes;
  38778. private _processedMaterials;
  38779. private _renderTargets;
  38780. /** @hidden */
  38781. _activeParticleSystems: SmartArray<IParticleSystem>;
  38782. private _activeSkeletons;
  38783. private _softwareSkinnedMeshes;
  38784. private _renderingManager;
  38785. /** @hidden */
  38786. _activeAnimatables: Animatable[];
  38787. private _transformMatrix;
  38788. private _sceneUbo;
  38789. /** @hidden */
  38790. _viewMatrix: Matrix;
  38791. private _projectionMatrix;
  38792. /** @hidden */
  38793. _forcedViewPosition: Nullable<Vector3>;
  38794. /** @hidden */
  38795. _frustumPlanes: Plane[];
  38796. /**
  38797. * Gets the list of frustum planes (built from the active camera)
  38798. */
  38799. get frustumPlanes(): Plane[];
  38800. /**
  38801. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38802. * This is useful if there are more lights that the maximum simulteanous authorized
  38803. */
  38804. requireLightSorting: boolean;
  38805. /** @hidden */
  38806. readonly useMaterialMeshMap: boolean;
  38807. /** @hidden */
  38808. readonly useClonedMeshMap: boolean;
  38809. private _externalData;
  38810. private _uid;
  38811. /**
  38812. * @hidden
  38813. * Backing store of defined scene components.
  38814. */
  38815. _components: ISceneComponent[];
  38816. /**
  38817. * @hidden
  38818. * Backing store of defined scene components.
  38819. */
  38820. _serializableComponents: ISceneSerializableComponent[];
  38821. /**
  38822. * List of components to register on the next registration step.
  38823. */
  38824. private _transientComponents;
  38825. /**
  38826. * Registers the transient components if needed.
  38827. */
  38828. private _registerTransientComponents;
  38829. /**
  38830. * @hidden
  38831. * Add a component to the scene.
  38832. * Note that the ccomponent could be registered on th next frame if this is called after
  38833. * the register component stage.
  38834. * @param component Defines the component to add to the scene
  38835. */
  38836. _addComponent(component: ISceneComponent): void;
  38837. /**
  38838. * @hidden
  38839. * Gets a component from the scene.
  38840. * @param name defines the name of the component to retrieve
  38841. * @returns the component or null if not present
  38842. */
  38843. _getComponent(name: string): Nullable<ISceneComponent>;
  38844. /**
  38845. * @hidden
  38846. * Defines the actions happening before camera updates.
  38847. */
  38848. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38849. /**
  38850. * @hidden
  38851. * Defines the actions happening before clear the canvas.
  38852. */
  38853. _beforeClearStage: Stage<SimpleStageAction>;
  38854. /**
  38855. * @hidden
  38856. * Defines the actions when collecting render targets for the frame.
  38857. */
  38858. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38859. /**
  38860. * @hidden
  38861. * Defines the actions happening for one camera in the frame.
  38862. */
  38863. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38864. /**
  38865. * @hidden
  38866. * Defines the actions happening during the per mesh ready checks.
  38867. */
  38868. _isReadyForMeshStage: Stage<MeshStageAction>;
  38869. /**
  38870. * @hidden
  38871. * Defines the actions happening before evaluate active mesh checks.
  38872. */
  38873. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38874. /**
  38875. * @hidden
  38876. * Defines the actions happening during the evaluate sub mesh checks.
  38877. */
  38878. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38879. /**
  38880. * @hidden
  38881. * Defines the actions happening during the active mesh stage.
  38882. */
  38883. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38884. /**
  38885. * @hidden
  38886. * Defines the actions happening during the per camera render target step.
  38887. */
  38888. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38889. /**
  38890. * @hidden
  38891. * Defines the actions happening just before the active camera is drawing.
  38892. */
  38893. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38894. /**
  38895. * @hidden
  38896. * Defines the actions happening just before a render target is drawing.
  38897. */
  38898. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38899. /**
  38900. * @hidden
  38901. * Defines the actions happening just before a rendering group is drawing.
  38902. */
  38903. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38904. /**
  38905. * @hidden
  38906. * Defines the actions happening just before a mesh is drawing.
  38907. */
  38908. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38909. /**
  38910. * @hidden
  38911. * Defines the actions happening just after a mesh has been drawn.
  38912. */
  38913. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38914. /**
  38915. * @hidden
  38916. * Defines the actions happening just after a rendering group has been drawn.
  38917. */
  38918. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38919. /**
  38920. * @hidden
  38921. * Defines the actions happening just after the active camera has been drawn.
  38922. */
  38923. _afterCameraDrawStage: Stage<CameraStageAction>;
  38924. /**
  38925. * @hidden
  38926. * Defines the actions happening just after a render target has been drawn.
  38927. */
  38928. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38929. /**
  38930. * @hidden
  38931. * Defines the actions happening just after rendering all cameras and computing intersections.
  38932. */
  38933. _afterRenderStage: Stage<SimpleStageAction>;
  38934. /**
  38935. * @hidden
  38936. * Defines the actions happening when a pointer move event happens.
  38937. */
  38938. _pointerMoveStage: Stage<PointerMoveStageAction>;
  38939. /**
  38940. * @hidden
  38941. * Defines the actions happening when a pointer down event happens.
  38942. */
  38943. _pointerDownStage: Stage<PointerUpDownStageAction>;
  38944. /**
  38945. * @hidden
  38946. * Defines the actions happening when a pointer up event happens.
  38947. */
  38948. _pointerUpStage: Stage<PointerUpDownStageAction>;
  38949. /**
  38950. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  38951. */
  38952. private geometriesByUniqueId;
  38953. /**
  38954. * Creates a new Scene
  38955. * @param engine defines the engine to use to render this scene
  38956. * @param options defines the scene options
  38957. */
  38958. constructor(engine: Engine, options?: SceneOptions);
  38959. /**
  38960. * Gets a string idenfifying the name of the class
  38961. * @returns "Scene" string
  38962. */
  38963. getClassName(): string;
  38964. private _defaultMeshCandidates;
  38965. /**
  38966. * @hidden
  38967. */
  38968. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  38969. private _defaultSubMeshCandidates;
  38970. /**
  38971. * @hidden
  38972. */
  38973. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  38974. /**
  38975. * Sets the default candidate providers for the scene.
  38976. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  38977. * and getCollidingSubMeshCandidates to their default function
  38978. */
  38979. setDefaultCandidateProviders(): void;
  38980. /**
  38981. * Gets the mesh that is currently under the pointer
  38982. */
  38983. get meshUnderPointer(): Nullable<AbstractMesh>;
  38984. /**
  38985. * Gets or sets the current on-screen X position of the pointer
  38986. */
  38987. get pointerX(): number;
  38988. set pointerX(value: number);
  38989. /**
  38990. * Gets or sets the current on-screen Y position of the pointer
  38991. */
  38992. get pointerY(): number;
  38993. set pointerY(value: number);
  38994. /**
  38995. * Gets the cached material (ie. the latest rendered one)
  38996. * @returns the cached material
  38997. */
  38998. getCachedMaterial(): Nullable<Material>;
  38999. /**
  39000. * Gets the cached effect (ie. the latest rendered one)
  39001. * @returns the cached effect
  39002. */
  39003. getCachedEffect(): Nullable<Effect>;
  39004. /**
  39005. * Gets the cached visibility state (ie. the latest rendered one)
  39006. * @returns the cached visibility state
  39007. */
  39008. getCachedVisibility(): Nullable<number>;
  39009. /**
  39010. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39011. * @param material defines the current material
  39012. * @param effect defines the current effect
  39013. * @param visibility defines the current visibility state
  39014. * @returns true if one parameter is not cached
  39015. */
  39016. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39017. /**
  39018. * Gets the engine associated with the scene
  39019. * @returns an Engine
  39020. */
  39021. getEngine(): Engine;
  39022. /**
  39023. * Gets the total number of vertices rendered per frame
  39024. * @returns the total number of vertices rendered per frame
  39025. */
  39026. getTotalVertices(): number;
  39027. /**
  39028. * Gets the performance counter for total vertices
  39029. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39030. */
  39031. get totalVerticesPerfCounter(): PerfCounter;
  39032. /**
  39033. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39034. * @returns the total number of active indices rendered per frame
  39035. */
  39036. getActiveIndices(): number;
  39037. /**
  39038. * Gets the performance counter for active indices
  39039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39040. */
  39041. get totalActiveIndicesPerfCounter(): PerfCounter;
  39042. /**
  39043. * Gets the total number of active particles rendered per frame
  39044. * @returns the total number of active particles rendered per frame
  39045. */
  39046. getActiveParticles(): number;
  39047. /**
  39048. * Gets the performance counter for active particles
  39049. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39050. */
  39051. get activeParticlesPerfCounter(): PerfCounter;
  39052. /**
  39053. * Gets the total number of active bones rendered per frame
  39054. * @returns the total number of active bones rendered per frame
  39055. */
  39056. getActiveBones(): number;
  39057. /**
  39058. * Gets the performance counter for active bones
  39059. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39060. */
  39061. get activeBonesPerfCounter(): PerfCounter;
  39062. /**
  39063. * Gets the array of active meshes
  39064. * @returns an array of AbstractMesh
  39065. */
  39066. getActiveMeshes(): SmartArray<AbstractMesh>;
  39067. /**
  39068. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39069. * @returns a number
  39070. */
  39071. getAnimationRatio(): number;
  39072. /**
  39073. * Gets an unique Id for the current render phase
  39074. * @returns a number
  39075. */
  39076. getRenderId(): number;
  39077. /**
  39078. * Gets an unique Id for the current frame
  39079. * @returns a number
  39080. */
  39081. getFrameId(): number;
  39082. /** Call this function if you want to manually increment the render Id*/
  39083. incrementRenderId(): void;
  39084. private _createUbo;
  39085. /**
  39086. * Use this method to simulate a pointer move on a mesh
  39087. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39088. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39089. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39090. * @returns the current scene
  39091. */
  39092. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39093. /**
  39094. * Use this method to simulate a pointer down on a mesh
  39095. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39096. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39097. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39098. * @returns the current scene
  39099. */
  39100. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39101. /**
  39102. * Use this method to simulate a pointer up on a mesh
  39103. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39104. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39105. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39106. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39107. * @returns the current scene
  39108. */
  39109. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39110. /**
  39111. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39112. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39113. * @returns true if the pointer was captured
  39114. */
  39115. isPointerCaptured(pointerId?: number): boolean;
  39116. /**
  39117. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39118. * @param attachUp defines if you want to attach events to pointerup
  39119. * @param attachDown defines if you want to attach events to pointerdown
  39120. * @param attachMove defines if you want to attach events to pointermove
  39121. */
  39122. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39123. /** Detaches all event handlers*/
  39124. detachControl(): void;
  39125. /**
  39126. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39127. * Delay loaded resources are not taking in account
  39128. * @return true if all required resources are ready
  39129. */
  39130. isReady(): boolean;
  39131. /** Resets all cached information relative to material (including effect and visibility) */
  39132. resetCachedMaterial(): void;
  39133. /**
  39134. * Registers a function to be called before every frame render
  39135. * @param func defines the function to register
  39136. */
  39137. registerBeforeRender(func: () => void): void;
  39138. /**
  39139. * Unregisters a function called before every frame render
  39140. * @param func defines the function to unregister
  39141. */
  39142. unregisterBeforeRender(func: () => void): void;
  39143. /**
  39144. * Registers a function to be called after every frame render
  39145. * @param func defines the function to register
  39146. */
  39147. registerAfterRender(func: () => void): void;
  39148. /**
  39149. * Unregisters a function called after every frame render
  39150. * @param func defines the function to unregister
  39151. */
  39152. unregisterAfterRender(func: () => void): void;
  39153. private _executeOnceBeforeRender;
  39154. /**
  39155. * The provided function will run before render once and will be disposed afterwards.
  39156. * A timeout delay can be provided so that the function will be executed in N ms.
  39157. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39158. * @param func The function to be executed.
  39159. * @param timeout optional delay in ms
  39160. */
  39161. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39162. /** @hidden */
  39163. _addPendingData(data: any): void;
  39164. /** @hidden */
  39165. _removePendingData(data: any): void;
  39166. /**
  39167. * Returns the number of items waiting to be loaded
  39168. * @returns the number of items waiting to be loaded
  39169. */
  39170. getWaitingItemsCount(): number;
  39171. /**
  39172. * Returns a boolean indicating if the scene is still loading data
  39173. */
  39174. get isLoading(): boolean;
  39175. /**
  39176. * Registers a function to be executed when the scene is ready
  39177. * @param {Function} func - the function to be executed
  39178. */
  39179. executeWhenReady(func: () => void): void;
  39180. /**
  39181. * Returns a promise that resolves when the scene is ready
  39182. * @returns A promise that resolves when the scene is ready
  39183. */
  39184. whenReadyAsync(): Promise<void>;
  39185. /** @hidden */
  39186. _checkIsReady(): void;
  39187. /**
  39188. * Gets all animatable attached to the scene
  39189. */
  39190. get animatables(): Animatable[];
  39191. /**
  39192. * Resets the last animation time frame.
  39193. * Useful to override when animations start running when loading a scene for the first time.
  39194. */
  39195. resetLastAnimationTimeFrame(): void;
  39196. /**
  39197. * Gets the current view matrix
  39198. * @returns a Matrix
  39199. */
  39200. getViewMatrix(): Matrix;
  39201. /**
  39202. * Gets the current projection matrix
  39203. * @returns a Matrix
  39204. */
  39205. getProjectionMatrix(): Matrix;
  39206. /**
  39207. * Gets the current transform matrix
  39208. * @returns a Matrix made of View * Projection
  39209. */
  39210. getTransformMatrix(): Matrix;
  39211. /**
  39212. * Sets the current transform matrix
  39213. * @param viewL defines the View matrix to use
  39214. * @param projectionL defines the Projection matrix to use
  39215. * @param viewR defines the right View matrix to use (if provided)
  39216. * @param projectionR defines the right Projection matrix to use (if provided)
  39217. */
  39218. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39219. /**
  39220. * Gets the uniform buffer used to store scene data
  39221. * @returns a UniformBuffer
  39222. */
  39223. getSceneUniformBuffer(): UniformBuffer;
  39224. /**
  39225. * Gets an unique (relatively to the current scene) Id
  39226. * @returns an unique number for the scene
  39227. */
  39228. getUniqueId(): number;
  39229. /**
  39230. * Add a mesh to the list of scene's meshes
  39231. * @param newMesh defines the mesh to add
  39232. * @param recursive if all child meshes should also be added to the scene
  39233. */
  39234. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39235. /**
  39236. * Remove a mesh for the list of scene's meshes
  39237. * @param toRemove defines the mesh to remove
  39238. * @param recursive if all child meshes should also be removed from the scene
  39239. * @returns the index where the mesh was in the mesh list
  39240. */
  39241. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39242. /**
  39243. * Add a transform node to the list of scene's transform nodes
  39244. * @param newTransformNode defines the transform node to add
  39245. */
  39246. addTransformNode(newTransformNode: TransformNode): void;
  39247. /**
  39248. * Remove a transform node for the list of scene's transform nodes
  39249. * @param toRemove defines the transform node to remove
  39250. * @returns the index where the transform node was in the transform node list
  39251. */
  39252. removeTransformNode(toRemove: TransformNode): number;
  39253. /**
  39254. * Remove a skeleton for the list of scene's skeletons
  39255. * @param toRemove defines the skeleton to remove
  39256. * @returns the index where the skeleton was in the skeleton list
  39257. */
  39258. removeSkeleton(toRemove: Skeleton): number;
  39259. /**
  39260. * Remove a morph target for the list of scene's morph targets
  39261. * @param toRemove defines the morph target to remove
  39262. * @returns the index where the morph target was in the morph target list
  39263. */
  39264. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39265. /**
  39266. * Remove a light for the list of scene's lights
  39267. * @param toRemove defines the light to remove
  39268. * @returns the index where the light was in the light list
  39269. */
  39270. removeLight(toRemove: Light): number;
  39271. /**
  39272. * Remove a camera for the list of scene's cameras
  39273. * @param toRemove defines the camera to remove
  39274. * @returns the index where the camera was in the camera list
  39275. */
  39276. removeCamera(toRemove: Camera): number;
  39277. /**
  39278. * Remove a particle system for the list of scene's particle systems
  39279. * @param toRemove defines the particle system to remove
  39280. * @returns the index where the particle system was in the particle system list
  39281. */
  39282. removeParticleSystem(toRemove: IParticleSystem): number;
  39283. /**
  39284. * Remove a animation for the list of scene's animations
  39285. * @param toRemove defines the animation to remove
  39286. * @returns the index where the animation was in the animation list
  39287. */
  39288. removeAnimation(toRemove: Animation): number;
  39289. /**
  39290. * Will stop the animation of the given target
  39291. * @param target - the target
  39292. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39293. * @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)
  39294. */
  39295. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39296. /**
  39297. * Removes the given animation group from this scene.
  39298. * @param toRemove The animation group to remove
  39299. * @returns The index of the removed animation group
  39300. */
  39301. removeAnimationGroup(toRemove: AnimationGroup): number;
  39302. /**
  39303. * Removes the given multi-material from this scene.
  39304. * @param toRemove The multi-material to remove
  39305. * @returns The index of the removed multi-material
  39306. */
  39307. removeMultiMaterial(toRemove: MultiMaterial): number;
  39308. /**
  39309. * Removes the given material from this scene.
  39310. * @param toRemove The material to remove
  39311. * @returns The index of the removed material
  39312. */
  39313. removeMaterial(toRemove: Material): number;
  39314. /**
  39315. * Removes the given action manager from this scene.
  39316. * @param toRemove The action manager to remove
  39317. * @returns The index of the removed action manager
  39318. */
  39319. removeActionManager(toRemove: AbstractActionManager): number;
  39320. /**
  39321. * Removes the given texture from this scene.
  39322. * @param toRemove The texture to remove
  39323. * @returns The index of the removed texture
  39324. */
  39325. removeTexture(toRemove: BaseTexture): number;
  39326. /**
  39327. * Adds the given light to this scene
  39328. * @param newLight The light to add
  39329. */
  39330. addLight(newLight: Light): void;
  39331. /**
  39332. * Sorts the list list based on light priorities
  39333. */
  39334. sortLightsByPriority(): void;
  39335. /**
  39336. * Adds the given camera to this scene
  39337. * @param newCamera The camera to add
  39338. */
  39339. addCamera(newCamera: Camera): void;
  39340. /**
  39341. * Adds the given skeleton to this scene
  39342. * @param newSkeleton The skeleton to add
  39343. */
  39344. addSkeleton(newSkeleton: Skeleton): void;
  39345. /**
  39346. * Adds the given particle system to this scene
  39347. * @param newParticleSystem The particle system to add
  39348. */
  39349. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39350. /**
  39351. * Adds the given animation to this scene
  39352. * @param newAnimation The animation to add
  39353. */
  39354. addAnimation(newAnimation: Animation): void;
  39355. /**
  39356. * Adds the given animation group to this scene.
  39357. * @param newAnimationGroup The animation group to add
  39358. */
  39359. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39360. /**
  39361. * Adds the given multi-material to this scene
  39362. * @param newMultiMaterial The multi-material to add
  39363. */
  39364. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39365. /**
  39366. * Adds the given material to this scene
  39367. * @param newMaterial The material to add
  39368. */
  39369. addMaterial(newMaterial: Material): void;
  39370. /**
  39371. * Adds the given morph target to this scene
  39372. * @param newMorphTargetManager The morph target to add
  39373. */
  39374. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39375. /**
  39376. * Adds the given geometry to this scene
  39377. * @param newGeometry The geometry to add
  39378. */
  39379. addGeometry(newGeometry: Geometry): void;
  39380. /**
  39381. * Adds the given action manager to this scene
  39382. * @param newActionManager The action manager to add
  39383. */
  39384. addActionManager(newActionManager: AbstractActionManager): void;
  39385. /**
  39386. * Adds the given texture to this scene.
  39387. * @param newTexture The texture to add
  39388. */
  39389. addTexture(newTexture: BaseTexture): void;
  39390. /**
  39391. * Switch active camera
  39392. * @param newCamera defines the new active camera
  39393. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39394. */
  39395. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39396. /**
  39397. * sets the active camera of the scene using its ID
  39398. * @param id defines the camera's ID
  39399. * @return the new active camera or null if none found.
  39400. */
  39401. setActiveCameraByID(id: string): Nullable<Camera>;
  39402. /**
  39403. * sets the active camera of the scene using its name
  39404. * @param name defines the camera's name
  39405. * @returns the new active camera or null if none found.
  39406. */
  39407. setActiveCameraByName(name: string): Nullable<Camera>;
  39408. /**
  39409. * get an animation group using its name
  39410. * @param name defines the material's name
  39411. * @return the animation group or null if none found.
  39412. */
  39413. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39414. /**
  39415. * Get a material using its unique id
  39416. * @param uniqueId defines the material's unique id
  39417. * @return the material or null if none found.
  39418. */
  39419. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39420. /**
  39421. * get a material using its id
  39422. * @param id defines the material's ID
  39423. * @return the material or null if none found.
  39424. */
  39425. getMaterialByID(id: string): Nullable<Material>;
  39426. /**
  39427. * Gets a the last added material using a given id
  39428. * @param id defines the material's ID
  39429. * @return the last material with the given id or null if none found.
  39430. */
  39431. getLastMaterialByID(id: string): Nullable<Material>;
  39432. /**
  39433. * Gets a material using its name
  39434. * @param name defines the material's name
  39435. * @return the material or null if none found.
  39436. */
  39437. getMaterialByName(name: string): Nullable<Material>;
  39438. /**
  39439. * Get a texture using its unique id
  39440. * @param uniqueId defines the texture's unique id
  39441. * @return the texture or null if none found.
  39442. */
  39443. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39444. /**
  39445. * Gets a camera using its id
  39446. * @param id defines the id to look for
  39447. * @returns the camera or null if not found
  39448. */
  39449. getCameraByID(id: string): Nullable<Camera>;
  39450. /**
  39451. * Gets a camera using its unique id
  39452. * @param uniqueId defines the unique id to look for
  39453. * @returns the camera or null if not found
  39454. */
  39455. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39456. /**
  39457. * Gets a camera using its name
  39458. * @param name defines the camera's name
  39459. * @return the camera or null if none found.
  39460. */
  39461. getCameraByName(name: string): Nullable<Camera>;
  39462. /**
  39463. * Gets a bone using its id
  39464. * @param id defines the bone's id
  39465. * @return the bone or null if not found
  39466. */
  39467. getBoneByID(id: string): Nullable<Bone>;
  39468. /**
  39469. * Gets a bone using its id
  39470. * @param name defines the bone's name
  39471. * @return the bone or null if not found
  39472. */
  39473. getBoneByName(name: string): Nullable<Bone>;
  39474. /**
  39475. * Gets a light node using its name
  39476. * @param name defines the the light's name
  39477. * @return the light or null if none found.
  39478. */
  39479. getLightByName(name: string): Nullable<Light>;
  39480. /**
  39481. * Gets a light node using its id
  39482. * @param id defines the light's id
  39483. * @return the light or null if none found.
  39484. */
  39485. getLightByID(id: string): Nullable<Light>;
  39486. /**
  39487. * Gets a light node using its scene-generated unique ID
  39488. * @param uniqueId defines the light's unique id
  39489. * @return the light or null if none found.
  39490. */
  39491. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39492. /**
  39493. * Gets a particle system by id
  39494. * @param id defines the particle system id
  39495. * @return the corresponding system or null if none found
  39496. */
  39497. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39498. /**
  39499. * Gets a geometry using its ID
  39500. * @param id defines the geometry's id
  39501. * @return the geometry or null if none found.
  39502. */
  39503. getGeometryByID(id: string): Nullable<Geometry>;
  39504. private _getGeometryByUniqueID;
  39505. /**
  39506. * Add a new geometry to this scene
  39507. * @param geometry defines the geometry to be added to the scene.
  39508. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39509. * @return a boolean defining if the geometry was added or not
  39510. */
  39511. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39512. /**
  39513. * Removes an existing geometry
  39514. * @param geometry defines the geometry to be removed from the scene
  39515. * @return a boolean defining if the geometry was removed or not
  39516. */
  39517. removeGeometry(geometry: Geometry): boolean;
  39518. /**
  39519. * Gets the list of geometries attached to the scene
  39520. * @returns an array of Geometry
  39521. */
  39522. getGeometries(): Geometry[];
  39523. /**
  39524. * Gets the first added mesh found of a given ID
  39525. * @param id defines the id to search for
  39526. * @return the mesh found or null if not found at all
  39527. */
  39528. getMeshByID(id: string): Nullable<AbstractMesh>;
  39529. /**
  39530. * Gets a list of meshes using their id
  39531. * @param id defines the id to search for
  39532. * @returns a list of meshes
  39533. */
  39534. getMeshesByID(id: string): Array<AbstractMesh>;
  39535. /**
  39536. * Gets the first added transform node found of a given ID
  39537. * @param id defines the id to search for
  39538. * @return the found transform node or null if not found at all.
  39539. */
  39540. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39541. /**
  39542. * Gets a transform node with its auto-generated unique id
  39543. * @param uniqueId efines the unique id to search for
  39544. * @return the found transform node or null if not found at all.
  39545. */
  39546. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39547. /**
  39548. * Gets a list of transform nodes using their id
  39549. * @param id defines the id to search for
  39550. * @returns a list of transform nodes
  39551. */
  39552. getTransformNodesByID(id: string): Array<TransformNode>;
  39553. /**
  39554. * Gets a mesh with its auto-generated unique id
  39555. * @param uniqueId defines the unique id to search for
  39556. * @return the found mesh or null if not found at all.
  39557. */
  39558. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39559. /**
  39560. * Gets a the last added mesh using a given id
  39561. * @param id defines the id to search for
  39562. * @return the found mesh or null if not found at all.
  39563. */
  39564. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39565. /**
  39566. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39567. * @param id defines the id to search for
  39568. * @return the found node or null if not found at all
  39569. */
  39570. getLastEntryByID(id: string): Nullable<Node>;
  39571. /**
  39572. * Gets a node (Mesh, Camera, Light) using a given id
  39573. * @param id defines the id to search for
  39574. * @return the found node or null if not found at all
  39575. */
  39576. getNodeByID(id: string): Nullable<Node>;
  39577. /**
  39578. * Gets a node (Mesh, Camera, Light) using a given name
  39579. * @param name defines the name to search for
  39580. * @return the found node or null if not found at all.
  39581. */
  39582. getNodeByName(name: string): Nullable<Node>;
  39583. /**
  39584. * Gets a mesh using a given name
  39585. * @param name defines the name to search for
  39586. * @return the found mesh or null if not found at all.
  39587. */
  39588. getMeshByName(name: string): Nullable<AbstractMesh>;
  39589. /**
  39590. * Gets a transform node using a given name
  39591. * @param name defines the name to search for
  39592. * @return the found transform node or null if not found at all.
  39593. */
  39594. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39595. /**
  39596. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39597. * @param id defines the id to search for
  39598. * @return the found skeleton or null if not found at all.
  39599. */
  39600. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39601. /**
  39602. * Gets a skeleton using a given auto generated unique id
  39603. * @param uniqueId defines the unique id to search for
  39604. * @return the found skeleton or null if not found at all.
  39605. */
  39606. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39607. /**
  39608. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39609. * @param id defines the id to search for
  39610. * @return the found skeleton or null if not found at all.
  39611. */
  39612. getSkeletonById(id: string): Nullable<Skeleton>;
  39613. /**
  39614. * Gets a skeleton using a given name
  39615. * @param name defines the name to search for
  39616. * @return the found skeleton or null if not found at all.
  39617. */
  39618. getSkeletonByName(name: string): Nullable<Skeleton>;
  39619. /**
  39620. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39621. * @param id defines the id to search for
  39622. * @return the found morph target manager or null if not found at all.
  39623. */
  39624. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39625. /**
  39626. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39627. * @param id defines the id to search for
  39628. * @return the found morph target or null if not found at all.
  39629. */
  39630. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39631. /**
  39632. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39633. * @param name defines the name to search for
  39634. * @return the found morph target or null if not found at all.
  39635. */
  39636. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39637. /**
  39638. * Gets a boolean indicating if the given mesh is active
  39639. * @param mesh defines the mesh to look for
  39640. * @returns true if the mesh is in the active list
  39641. */
  39642. isActiveMesh(mesh: AbstractMesh): boolean;
  39643. /**
  39644. * Return a unique id as a string which can serve as an identifier for the scene
  39645. */
  39646. get uid(): string;
  39647. /**
  39648. * Add an externaly attached data from its key.
  39649. * This method call will fail and return false, if such key already exists.
  39650. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39651. * @param key the unique key that identifies the data
  39652. * @param data the data object to associate to the key for this Engine instance
  39653. * @return true if no such key were already present and the data was added successfully, false otherwise
  39654. */
  39655. addExternalData<T>(key: string, data: T): boolean;
  39656. /**
  39657. * Get an externaly attached data from its key
  39658. * @param key the unique key that identifies the data
  39659. * @return the associated data, if present (can be null), or undefined if not present
  39660. */
  39661. getExternalData<T>(key: string): Nullable<T>;
  39662. /**
  39663. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39664. * @param key the unique key that identifies the data
  39665. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39666. * @return the associated data, can be null if the factory returned null.
  39667. */
  39668. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39669. /**
  39670. * Remove an externaly attached data from the Engine instance
  39671. * @param key the unique key that identifies the data
  39672. * @return true if the data was successfully removed, false if it doesn't exist
  39673. */
  39674. removeExternalData(key: string): boolean;
  39675. private _evaluateSubMesh;
  39676. /**
  39677. * Clear the processed materials smart array preventing retention point in material dispose.
  39678. */
  39679. freeProcessedMaterials(): void;
  39680. private _preventFreeActiveMeshesAndRenderingGroups;
  39681. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39682. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39683. * when disposing several meshes in a row or a hierarchy of meshes.
  39684. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39685. */
  39686. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39687. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39688. /**
  39689. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39690. */
  39691. freeActiveMeshes(): void;
  39692. /**
  39693. * Clear the info related to rendering groups preventing retention points during dispose.
  39694. */
  39695. freeRenderingGroups(): void;
  39696. /** @hidden */
  39697. _isInIntermediateRendering(): boolean;
  39698. /**
  39699. * Lambda returning the list of potentially active meshes.
  39700. */
  39701. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39702. /**
  39703. * Lambda returning the list of potentially active sub meshes.
  39704. */
  39705. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39706. /**
  39707. * Lambda returning the list of potentially intersecting sub meshes.
  39708. */
  39709. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39710. /**
  39711. * Lambda returning the list of potentially colliding sub meshes.
  39712. */
  39713. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39714. private _activeMeshesFrozen;
  39715. private _skipEvaluateActiveMeshesCompletely;
  39716. /**
  39717. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39718. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39719. * @returns the current scene
  39720. */
  39721. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39722. /**
  39723. * Use this function to restart evaluating active meshes on every frame
  39724. * @returns the current scene
  39725. */
  39726. unfreezeActiveMeshes(): Scene;
  39727. private _evaluateActiveMeshes;
  39728. private _activeMesh;
  39729. /**
  39730. * Update the transform matrix to update from the current active camera
  39731. * @param force defines a boolean used to force the update even if cache is up to date
  39732. */
  39733. updateTransformMatrix(force?: boolean): void;
  39734. private _bindFrameBuffer;
  39735. /** @hidden */
  39736. _allowPostProcessClearColor: boolean;
  39737. /** @hidden */
  39738. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39739. private _processSubCameras;
  39740. private _checkIntersections;
  39741. /** @hidden */
  39742. _advancePhysicsEngineStep(step: number): void;
  39743. /**
  39744. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39745. */
  39746. getDeterministicFrameTime: () => number;
  39747. /** @hidden */
  39748. _animate(): void;
  39749. /** Execute all animations (for a frame) */
  39750. animate(): void;
  39751. /**
  39752. * Render the scene
  39753. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39754. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39755. */
  39756. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39757. /**
  39758. * Freeze all materials
  39759. * A frozen material will not be updatable but should be faster to render
  39760. */
  39761. freezeMaterials(): void;
  39762. /**
  39763. * Unfreeze all materials
  39764. * A frozen material will not be updatable but should be faster to render
  39765. */
  39766. unfreezeMaterials(): void;
  39767. /**
  39768. * Releases all held ressources
  39769. */
  39770. dispose(): void;
  39771. /**
  39772. * Gets if the scene is already disposed
  39773. */
  39774. get isDisposed(): boolean;
  39775. /**
  39776. * Call this function to reduce memory footprint of the scene.
  39777. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39778. */
  39779. clearCachedVertexData(): void;
  39780. /**
  39781. * This function will remove the local cached buffer data from texture.
  39782. * It will save memory but will prevent the texture from being rebuilt
  39783. */
  39784. cleanCachedTextureBuffer(): void;
  39785. /**
  39786. * Get the world extend vectors with an optional filter
  39787. *
  39788. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39789. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39790. */
  39791. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39792. min: Vector3;
  39793. max: Vector3;
  39794. };
  39795. /**
  39796. * Creates a ray that can be used to pick in the scene
  39797. * @param x defines the x coordinate of the origin (on-screen)
  39798. * @param y defines the y coordinate of the origin (on-screen)
  39799. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39800. * @param camera defines the camera to use for the picking
  39801. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39802. * @returns a Ray
  39803. */
  39804. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39805. /**
  39806. * Creates a ray that can be used to pick in the scene
  39807. * @param x defines the x coordinate of the origin (on-screen)
  39808. * @param y defines the y coordinate of the origin (on-screen)
  39809. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39810. * @param result defines the ray where to store the picking ray
  39811. * @param camera defines the camera to use for the picking
  39812. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39813. * @returns the current scene
  39814. */
  39815. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39816. /**
  39817. * Creates a ray that can be used to pick in the scene
  39818. * @param x defines the x coordinate of the origin (on-screen)
  39819. * @param y defines the y coordinate of the origin (on-screen)
  39820. * @param camera defines the camera to use for the picking
  39821. * @returns a Ray
  39822. */
  39823. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39824. /**
  39825. * Creates a ray that can be used to pick in the scene
  39826. * @param x defines the x coordinate of the origin (on-screen)
  39827. * @param y defines the y coordinate of the origin (on-screen)
  39828. * @param result defines the ray where to store the picking ray
  39829. * @param camera defines the camera to use for the picking
  39830. * @returns the current scene
  39831. */
  39832. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39833. /** Launch a ray to try to pick a mesh in the scene
  39834. * @param x position on screen
  39835. * @param y position on screen
  39836. * @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
  39837. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39838. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39839. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39840. * @returns a PickingInfo
  39841. */
  39842. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39843. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39844. * @param x position on screen
  39845. * @param y position on screen
  39846. * @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
  39847. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39848. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39849. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  39850. */
  39851. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39852. /** Use the given ray to pick a mesh in the scene
  39853. * @param ray The ray to use to pick meshes
  39854. * @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
  39855. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39856. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39857. * @returns a PickingInfo
  39858. */
  39859. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39860. /**
  39861. * Launch a ray to try to pick a mesh in the scene
  39862. * @param x X position on screen
  39863. * @param y Y position on screen
  39864. * @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
  39865. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39866. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39867. * @returns an array of PickingInfo
  39868. */
  39869. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39870. /**
  39871. * Launch a ray to try to pick a mesh in the scene
  39872. * @param ray Ray to use
  39873. * @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
  39874. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39875. * @returns an array of PickingInfo
  39876. */
  39877. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39878. /**
  39879. * Force the value of meshUnderPointer
  39880. * @param mesh defines the mesh to use
  39881. */
  39882. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39883. /**
  39884. * Gets the mesh under the pointer
  39885. * @returns a Mesh or null if no mesh is under the pointer
  39886. */
  39887. getPointerOverMesh(): Nullable<AbstractMesh>;
  39888. /** @hidden */
  39889. _rebuildGeometries(): void;
  39890. /** @hidden */
  39891. _rebuildTextures(): void;
  39892. private _getByTags;
  39893. /**
  39894. * Get a list of meshes by tags
  39895. * @param tagsQuery defines the tags query to use
  39896. * @param forEach defines a predicate used to filter results
  39897. * @returns an array of Mesh
  39898. */
  39899. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39900. /**
  39901. * Get a list of cameras by tags
  39902. * @param tagsQuery defines the tags query to use
  39903. * @param forEach defines a predicate used to filter results
  39904. * @returns an array of Camera
  39905. */
  39906. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39907. /**
  39908. * Get a list of lights by tags
  39909. * @param tagsQuery defines the tags query to use
  39910. * @param forEach defines a predicate used to filter results
  39911. * @returns an array of Light
  39912. */
  39913. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39914. /**
  39915. * Get a list of materials by tags
  39916. * @param tagsQuery defines the tags query to use
  39917. * @param forEach defines a predicate used to filter results
  39918. * @returns an array of Material
  39919. */
  39920. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39921. /**
  39922. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39923. * This allowed control for front to back rendering or reversly depending of the special needs.
  39924. *
  39925. * @param renderingGroupId The rendering group id corresponding to its index
  39926. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39927. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39928. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39929. */
  39930. 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;
  39931. /**
  39932. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39933. *
  39934. * @param renderingGroupId The rendering group id corresponding to its index
  39935. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39936. * @param depth Automatically clears depth between groups if true and autoClear is true.
  39937. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  39938. */
  39939. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  39940. /**
  39941. * Gets the current auto clear configuration for one rendering group of the rendering
  39942. * manager.
  39943. * @param index the rendering group index to get the information for
  39944. * @returns The auto clear setup for the requested rendering group
  39945. */
  39946. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  39947. private _blockMaterialDirtyMechanism;
  39948. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  39949. get blockMaterialDirtyMechanism(): boolean;
  39950. set blockMaterialDirtyMechanism(value: boolean);
  39951. /**
  39952. * Will flag all materials as dirty to trigger new shader compilation
  39953. * @param flag defines the flag used to specify which material part must be marked as dirty
  39954. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  39955. */
  39956. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39957. /** @hidden */
  39958. _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;
  39959. /** @hidden */
  39960. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39961. /** @hidden */
  39962. _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;
  39963. /** @hidden */
  39964. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  39965. /** @hidden */
  39966. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39967. /** @hidden */
  39968. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39969. }
  39970. }
  39971. declare module BABYLON {
  39972. /**
  39973. * Set of assets to keep when moving a scene into an asset container.
  39974. */
  39975. export class KeepAssets extends AbstractScene {
  39976. }
  39977. /**
  39978. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  39979. */
  39980. export class InstantiatedEntries {
  39981. /**
  39982. * List of new root nodes (eg. nodes with no parent)
  39983. */
  39984. rootNodes: TransformNode[];
  39985. /**
  39986. * List of new skeletons
  39987. */
  39988. skeletons: Skeleton[];
  39989. /**
  39990. * List of new animation groups
  39991. */
  39992. animationGroups: AnimationGroup[];
  39993. }
  39994. /**
  39995. * Container with a set of assets that can be added or removed from a scene.
  39996. */
  39997. export class AssetContainer extends AbstractScene {
  39998. private _wasAddedToScene;
  39999. /**
  40000. * The scene the AssetContainer belongs to.
  40001. */
  40002. scene: Scene;
  40003. /**
  40004. * Instantiates an AssetContainer.
  40005. * @param scene The scene the AssetContainer belongs to.
  40006. */
  40007. constructor(scene: Scene);
  40008. /**
  40009. * Instantiate or clone all meshes and add the new ones to the scene.
  40010. * Skeletons and animation groups will all be cloned
  40011. * @param nameFunction defines an optional function used to get new names for clones
  40012. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40013. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40014. */
  40015. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40016. /**
  40017. * Adds all the assets from the container to the scene.
  40018. */
  40019. addAllToScene(): void;
  40020. /**
  40021. * Removes all the assets in the container from the scene
  40022. */
  40023. removeAllFromScene(): void;
  40024. /**
  40025. * Disposes all the assets in the container
  40026. */
  40027. dispose(): void;
  40028. private _moveAssets;
  40029. /**
  40030. * Removes all the assets contained in the scene and adds them to the container.
  40031. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40032. */
  40033. moveAllFromScene(keepAssets?: KeepAssets): void;
  40034. /**
  40035. * 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.
  40036. * @returns the root mesh
  40037. */
  40038. createRootMesh(): Mesh;
  40039. /**
  40040. * Merge animations (direct and animation groups) from this asset container into a scene
  40041. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40042. * @param animatables set of animatables to retarget to a node from the scene
  40043. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40044. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40045. */
  40046. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40047. }
  40048. }
  40049. declare module BABYLON {
  40050. /**
  40051. * Defines how the parser contract is defined.
  40052. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40053. */
  40054. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40055. /**
  40056. * Defines how the individual parser contract is defined.
  40057. * These parser can parse an individual asset
  40058. */
  40059. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40060. /**
  40061. * Base class of the scene acting as a container for the different elements composing a scene.
  40062. * This class is dynamically extended by the different components of the scene increasing
  40063. * flexibility and reducing coupling
  40064. */
  40065. export abstract class AbstractScene {
  40066. /**
  40067. * Stores the list of available parsers in the application.
  40068. */
  40069. private static _BabylonFileParsers;
  40070. /**
  40071. * Stores the list of available individual parsers in the application.
  40072. */
  40073. private static _IndividualBabylonFileParsers;
  40074. /**
  40075. * Adds a parser in the list of available ones
  40076. * @param name Defines the name of the parser
  40077. * @param parser Defines the parser to add
  40078. */
  40079. static AddParser(name: string, parser: BabylonFileParser): void;
  40080. /**
  40081. * Gets a general parser from the list of avaialble ones
  40082. * @param name Defines the name of the parser
  40083. * @returns the requested parser or null
  40084. */
  40085. static GetParser(name: string): Nullable<BabylonFileParser>;
  40086. /**
  40087. * Adds n individual parser in the list of available ones
  40088. * @param name Defines the name of the parser
  40089. * @param parser Defines the parser to add
  40090. */
  40091. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40092. /**
  40093. * Gets an individual parser from the list of avaialble ones
  40094. * @param name Defines the name of the parser
  40095. * @returns the requested parser or null
  40096. */
  40097. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40098. /**
  40099. * Parser json data and populate both a scene and its associated container object
  40100. * @param jsonData Defines the data to parse
  40101. * @param scene Defines the scene to parse the data for
  40102. * @param container Defines the container attached to the parsing sequence
  40103. * @param rootUrl Defines the root url of the data
  40104. */
  40105. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40106. /**
  40107. * Gets the list of root nodes (ie. nodes with no parent)
  40108. */
  40109. rootNodes: Node[];
  40110. /** All of the cameras added to this scene
  40111. * @see http://doc.babylonjs.com/babylon101/cameras
  40112. */
  40113. cameras: Camera[];
  40114. /**
  40115. * All of the lights added to this scene
  40116. * @see http://doc.babylonjs.com/babylon101/lights
  40117. */
  40118. lights: Light[];
  40119. /**
  40120. * All of the (abstract) meshes added to this scene
  40121. */
  40122. meshes: AbstractMesh[];
  40123. /**
  40124. * The list of skeletons added to the scene
  40125. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40126. */
  40127. skeletons: Skeleton[];
  40128. /**
  40129. * All of the particle systems added to this scene
  40130. * @see http://doc.babylonjs.com/babylon101/particles
  40131. */
  40132. particleSystems: IParticleSystem[];
  40133. /**
  40134. * Gets a list of Animations associated with the scene
  40135. */
  40136. animations: Animation[];
  40137. /**
  40138. * All of the animation groups added to this scene
  40139. * @see http://doc.babylonjs.com/how_to/group
  40140. */
  40141. animationGroups: AnimationGroup[];
  40142. /**
  40143. * All of the multi-materials added to this scene
  40144. * @see http://doc.babylonjs.com/how_to/multi_materials
  40145. */
  40146. multiMaterials: MultiMaterial[];
  40147. /**
  40148. * All of the materials added to this scene
  40149. * In the context of a Scene, it is not supposed to be modified manually.
  40150. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40151. * Note also that the order of the Material within the array is not significant and might change.
  40152. * @see http://doc.babylonjs.com/babylon101/materials
  40153. */
  40154. materials: Material[];
  40155. /**
  40156. * The list of morph target managers added to the scene
  40157. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40158. */
  40159. morphTargetManagers: MorphTargetManager[];
  40160. /**
  40161. * The list of geometries used in the scene.
  40162. */
  40163. geometries: Geometry[];
  40164. /**
  40165. * All of the tranform nodes added to this scene
  40166. * In the context of a Scene, it is not supposed to be modified manually.
  40167. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40168. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40169. * @see http://doc.babylonjs.com/how_to/transformnode
  40170. */
  40171. transformNodes: TransformNode[];
  40172. /**
  40173. * ActionManagers available on the scene.
  40174. */
  40175. actionManagers: AbstractActionManager[];
  40176. /**
  40177. * Textures to keep.
  40178. */
  40179. textures: BaseTexture[];
  40180. /**
  40181. * Environment texture for the scene
  40182. */
  40183. environmentTexture: Nullable<BaseTexture>;
  40184. /**
  40185. * @returns all meshes, lights, cameras, transformNodes and bones
  40186. */
  40187. getNodes(): Array<Node>;
  40188. }
  40189. }
  40190. declare module BABYLON {
  40191. /**
  40192. * Interface used to define options for Sound class
  40193. */
  40194. export interface ISoundOptions {
  40195. /**
  40196. * Does the sound autoplay once loaded.
  40197. */
  40198. autoplay?: boolean;
  40199. /**
  40200. * Does the sound loop after it finishes playing once.
  40201. */
  40202. loop?: boolean;
  40203. /**
  40204. * Sound's volume
  40205. */
  40206. volume?: number;
  40207. /**
  40208. * Is it a spatial sound?
  40209. */
  40210. spatialSound?: boolean;
  40211. /**
  40212. * Maximum distance to hear that sound
  40213. */
  40214. maxDistance?: number;
  40215. /**
  40216. * Uses user defined attenuation function
  40217. */
  40218. useCustomAttenuation?: boolean;
  40219. /**
  40220. * Define the roll off factor of spatial sounds.
  40221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40222. */
  40223. rolloffFactor?: number;
  40224. /**
  40225. * Define the reference distance the sound should be heard perfectly.
  40226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40227. */
  40228. refDistance?: number;
  40229. /**
  40230. * Define the distance attenuation model the sound will follow.
  40231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40232. */
  40233. distanceModel?: string;
  40234. /**
  40235. * Defines the playback speed (1 by default)
  40236. */
  40237. playbackRate?: number;
  40238. /**
  40239. * Defines if the sound is from a streaming source
  40240. */
  40241. streaming?: boolean;
  40242. /**
  40243. * Defines an optional length (in seconds) inside the sound file
  40244. */
  40245. length?: number;
  40246. /**
  40247. * Defines an optional offset (in seconds) inside the sound file
  40248. */
  40249. offset?: number;
  40250. /**
  40251. * If true, URLs will not be required to state the audio file codec to use.
  40252. */
  40253. skipCodecCheck?: boolean;
  40254. }
  40255. /**
  40256. * Defines a sound that can be played in the application.
  40257. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40259. */
  40260. export class Sound {
  40261. /**
  40262. * The name of the sound in the scene.
  40263. */
  40264. name: string;
  40265. /**
  40266. * Does the sound autoplay once loaded.
  40267. */
  40268. autoplay: boolean;
  40269. /**
  40270. * Does the sound loop after it finishes playing once.
  40271. */
  40272. loop: boolean;
  40273. /**
  40274. * Does the sound use a custom attenuation curve to simulate the falloff
  40275. * happening when the source gets further away from the camera.
  40276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40277. */
  40278. useCustomAttenuation: boolean;
  40279. /**
  40280. * The sound track id this sound belongs to.
  40281. */
  40282. soundTrackId: number;
  40283. /**
  40284. * Is this sound currently played.
  40285. */
  40286. isPlaying: boolean;
  40287. /**
  40288. * Is this sound currently paused.
  40289. */
  40290. isPaused: boolean;
  40291. /**
  40292. * Does this sound enables spatial sound.
  40293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40294. */
  40295. spatialSound: boolean;
  40296. /**
  40297. * Define the reference distance the sound should be heard perfectly.
  40298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40299. */
  40300. refDistance: number;
  40301. /**
  40302. * Define the roll off factor of spatial sounds.
  40303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40304. */
  40305. rolloffFactor: number;
  40306. /**
  40307. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40309. */
  40310. maxDistance: number;
  40311. /**
  40312. * Define the distance attenuation model the sound will follow.
  40313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40314. */
  40315. distanceModel: string;
  40316. /**
  40317. * @hidden
  40318. * Back Compat
  40319. **/
  40320. onended: () => any;
  40321. /**
  40322. * Gets or sets an object used to store user defined information for the sound.
  40323. */
  40324. metadata: any;
  40325. /**
  40326. * Observable event when the current playing sound finishes.
  40327. */
  40328. onEndedObservable: Observable<Sound>;
  40329. private _panningModel;
  40330. private _playbackRate;
  40331. private _streaming;
  40332. private _startTime;
  40333. private _startOffset;
  40334. private _position;
  40335. /** @hidden */
  40336. _positionInEmitterSpace: boolean;
  40337. private _localDirection;
  40338. private _volume;
  40339. private _isReadyToPlay;
  40340. private _isDirectional;
  40341. private _readyToPlayCallback;
  40342. private _audioBuffer;
  40343. private _soundSource;
  40344. private _streamingSource;
  40345. private _soundPanner;
  40346. private _soundGain;
  40347. private _inputAudioNode;
  40348. private _outputAudioNode;
  40349. private _coneInnerAngle;
  40350. private _coneOuterAngle;
  40351. private _coneOuterGain;
  40352. private _scene;
  40353. private _connectedTransformNode;
  40354. private _customAttenuationFunction;
  40355. private _registerFunc;
  40356. private _isOutputConnected;
  40357. private _htmlAudioElement;
  40358. private _urlType;
  40359. private _length?;
  40360. private _offset?;
  40361. /** @hidden */
  40362. static _SceneComponentInitialization: (scene: Scene) => void;
  40363. /**
  40364. * Create a sound and attach it to a scene
  40365. * @param name Name of your sound
  40366. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40367. * @param scene defines the scene the sound belongs to
  40368. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40369. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40370. */
  40371. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40372. /**
  40373. * Release the sound and its associated resources
  40374. */
  40375. dispose(): void;
  40376. /**
  40377. * Gets if the sounds is ready to be played or not.
  40378. * @returns true if ready, otherwise false
  40379. */
  40380. isReady(): boolean;
  40381. private _soundLoaded;
  40382. /**
  40383. * Sets the data of the sound from an audiobuffer
  40384. * @param audioBuffer The audioBuffer containing the data
  40385. */
  40386. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40387. /**
  40388. * Updates the current sounds options such as maxdistance, loop...
  40389. * @param options A JSON object containing values named as the object properties
  40390. */
  40391. updateOptions(options: ISoundOptions): void;
  40392. private _createSpatialParameters;
  40393. private _updateSpatialParameters;
  40394. /**
  40395. * Switch the panning model to HRTF:
  40396. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40398. */
  40399. switchPanningModelToHRTF(): void;
  40400. /**
  40401. * Switch the panning model to Equal Power:
  40402. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40404. */
  40405. switchPanningModelToEqualPower(): void;
  40406. private _switchPanningModel;
  40407. /**
  40408. * Connect this sound to a sound track audio node like gain...
  40409. * @param soundTrackAudioNode the sound track audio node to connect to
  40410. */
  40411. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40412. /**
  40413. * Transform this sound into a directional source
  40414. * @param coneInnerAngle Size of the inner cone in degree
  40415. * @param coneOuterAngle Size of the outer cone in degree
  40416. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40417. */
  40418. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40419. /**
  40420. * Gets or sets the inner angle for the directional cone.
  40421. */
  40422. get directionalConeInnerAngle(): number;
  40423. /**
  40424. * Gets or sets the inner angle for the directional cone.
  40425. */
  40426. set directionalConeInnerAngle(value: number);
  40427. /**
  40428. * Gets or sets the outer angle for the directional cone.
  40429. */
  40430. get directionalConeOuterAngle(): number;
  40431. /**
  40432. * Gets or sets the outer angle for the directional cone.
  40433. */
  40434. set directionalConeOuterAngle(value: number);
  40435. /**
  40436. * Sets the position of the emitter if spatial sound is enabled
  40437. * @param newPosition Defines the new posisiton
  40438. */
  40439. setPosition(newPosition: Vector3): void;
  40440. /**
  40441. * Sets the local direction of the emitter if spatial sound is enabled
  40442. * @param newLocalDirection Defines the new local direction
  40443. */
  40444. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40445. private _updateDirection;
  40446. /** @hidden */
  40447. updateDistanceFromListener(): void;
  40448. /**
  40449. * Sets a new custom attenuation function for the sound.
  40450. * @param callback Defines the function used for the attenuation
  40451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40452. */
  40453. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40454. /**
  40455. * Play the sound
  40456. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40457. * @param offset (optional) Start the sound at a specific time in seconds
  40458. * @param length (optional) Sound duration (in seconds)
  40459. */
  40460. play(time?: number, offset?: number, length?: number): void;
  40461. private _onended;
  40462. /**
  40463. * Stop the sound
  40464. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40465. */
  40466. stop(time?: number): void;
  40467. /**
  40468. * Put the sound in pause
  40469. */
  40470. pause(): void;
  40471. /**
  40472. * Sets a dedicated volume for this sounds
  40473. * @param newVolume Define the new volume of the sound
  40474. * @param time Define time for gradual change to new volume
  40475. */
  40476. setVolume(newVolume: number, time?: number): void;
  40477. /**
  40478. * Set the sound play back rate
  40479. * @param newPlaybackRate Define the playback rate the sound should be played at
  40480. */
  40481. setPlaybackRate(newPlaybackRate: number): void;
  40482. /**
  40483. * Gets the volume of the sound.
  40484. * @returns the volume of the sound
  40485. */
  40486. getVolume(): number;
  40487. /**
  40488. * Attach the sound to a dedicated mesh
  40489. * @param transformNode The transform node to connect the sound with
  40490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40491. */
  40492. attachToMesh(transformNode: TransformNode): void;
  40493. /**
  40494. * Detach the sound from the previously attached mesh
  40495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40496. */
  40497. detachFromMesh(): void;
  40498. private _onRegisterAfterWorldMatrixUpdate;
  40499. /**
  40500. * Clone the current sound in the scene.
  40501. * @returns the new sound clone
  40502. */
  40503. clone(): Nullable<Sound>;
  40504. /**
  40505. * Gets the current underlying audio buffer containing the data
  40506. * @returns the audio buffer
  40507. */
  40508. getAudioBuffer(): Nullable<AudioBuffer>;
  40509. /**
  40510. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40511. * @returns the source node
  40512. */
  40513. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40514. /**
  40515. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40516. * @returns the gain node
  40517. */
  40518. getSoundGain(): Nullable<GainNode>;
  40519. /**
  40520. * Serializes the Sound in a JSON representation
  40521. * @returns the JSON representation of the sound
  40522. */
  40523. serialize(): any;
  40524. /**
  40525. * Parse a JSON representation of a sound to innstantiate in a given scene
  40526. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40527. * @param scene Define the scene the new parsed sound should be created in
  40528. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40529. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40530. * @returns the newly parsed sound
  40531. */
  40532. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40533. }
  40534. }
  40535. declare module BABYLON {
  40536. /**
  40537. * This defines an action helpful to play a defined sound on a triggered action.
  40538. */
  40539. export class PlaySoundAction extends Action {
  40540. private _sound;
  40541. /**
  40542. * Instantiate the action
  40543. * @param triggerOptions defines the trigger options
  40544. * @param sound defines the sound to play
  40545. * @param condition defines the trigger related conditions
  40546. */
  40547. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40548. /** @hidden */
  40549. _prepare(): void;
  40550. /**
  40551. * Execute the action and play the sound.
  40552. */
  40553. execute(): void;
  40554. /**
  40555. * Serializes the actions and its related information.
  40556. * @param parent defines the object to serialize in
  40557. * @returns the serialized object
  40558. */
  40559. serialize(parent: any): any;
  40560. }
  40561. /**
  40562. * This defines an action helpful to stop a defined sound on a triggered action.
  40563. */
  40564. export class StopSoundAction extends Action {
  40565. private _sound;
  40566. /**
  40567. * Instantiate the action
  40568. * @param triggerOptions defines the trigger options
  40569. * @param sound defines the sound to stop
  40570. * @param condition defines the trigger related conditions
  40571. */
  40572. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40573. /** @hidden */
  40574. _prepare(): void;
  40575. /**
  40576. * Execute the action and stop the sound.
  40577. */
  40578. execute(): void;
  40579. /**
  40580. * Serializes the actions and its related information.
  40581. * @param parent defines the object to serialize in
  40582. * @returns the serialized object
  40583. */
  40584. serialize(parent: any): any;
  40585. }
  40586. }
  40587. declare module BABYLON {
  40588. /**
  40589. * This defines an action responsible to change the value of a property
  40590. * by interpolating between its current value and the newly set one once triggered.
  40591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40592. */
  40593. export class InterpolateValueAction extends Action {
  40594. /**
  40595. * Defines the path of the property where the value should be interpolated
  40596. */
  40597. propertyPath: string;
  40598. /**
  40599. * Defines the target value at the end of the interpolation.
  40600. */
  40601. value: any;
  40602. /**
  40603. * Defines the time it will take for the property to interpolate to the value.
  40604. */
  40605. duration: number;
  40606. /**
  40607. * Defines if the other scene animations should be stopped when the action has been triggered
  40608. */
  40609. stopOtherAnimations?: boolean;
  40610. /**
  40611. * Defines a callback raised once the interpolation animation has been done.
  40612. */
  40613. onInterpolationDone?: () => void;
  40614. /**
  40615. * Observable triggered once the interpolation animation has been done.
  40616. */
  40617. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40618. private _target;
  40619. private _effectiveTarget;
  40620. private _property;
  40621. /**
  40622. * Instantiate the action
  40623. * @param triggerOptions defines the trigger options
  40624. * @param target defines the object containing the value to interpolate
  40625. * @param propertyPath defines the path to the property in the target object
  40626. * @param value defines the target value at the end of the interpolation
  40627. * @param duration deines the time it will take for the property to interpolate to the value.
  40628. * @param condition defines the trigger related conditions
  40629. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40630. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40631. */
  40632. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40633. /** @hidden */
  40634. _prepare(): void;
  40635. /**
  40636. * Execute the action starts the value interpolation.
  40637. */
  40638. execute(): void;
  40639. /**
  40640. * Serializes the actions and its related information.
  40641. * @param parent defines the object to serialize in
  40642. * @returns the serialized object
  40643. */
  40644. serialize(parent: any): any;
  40645. }
  40646. }
  40647. declare module BABYLON {
  40648. /**
  40649. * Options allowed during the creation of a sound track.
  40650. */
  40651. export interface ISoundTrackOptions {
  40652. /**
  40653. * The volume the sound track should take during creation
  40654. */
  40655. volume?: number;
  40656. /**
  40657. * Define if the sound track is the main sound track of the scene
  40658. */
  40659. mainTrack?: boolean;
  40660. }
  40661. /**
  40662. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40663. * It will be also used in a future release to apply effects on a specific track.
  40664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40665. */
  40666. export class SoundTrack {
  40667. /**
  40668. * The unique identifier of the sound track in the scene.
  40669. */
  40670. id: number;
  40671. /**
  40672. * The list of sounds included in the sound track.
  40673. */
  40674. soundCollection: Array<Sound>;
  40675. private _outputAudioNode;
  40676. private _scene;
  40677. private _connectedAnalyser;
  40678. private _options;
  40679. private _isInitialized;
  40680. /**
  40681. * Creates a new sound track.
  40682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40683. * @param scene Define the scene the sound track belongs to
  40684. * @param options
  40685. */
  40686. constructor(scene: Scene, options?: ISoundTrackOptions);
  40687. private _initializeSoundTrackAudioGraph;
  40688. /**
  40689. * Release the sound track and its associated resources
  40690. */
  40691. dispose(): void;
  40692. /**
  40693. * Adds a sound to this sound track
  40694. * @param sound define the cound to add
  40695. * @ignoreNaming
  40696. */
  40697. AddSound(sound: Sound): void;
  40698. /**
  40699. * Removes a sound to this sound track
  40700. * @param sound define the cound to remove
  40701. * @ignoreNaming
  40702. */
  40703. RemoveSound(sound: Sound): void;
  40704. /**
  40705. * Set a global volume for the full sound track.
  40706. * @param newVolume Define the new volume of the sound track
  40707. */
  40708. setVolume(newVolume: number): void;
  40709. /**
  40710. * Switch the panning model to HRTF:
  40711. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40713. */
  40714. switchPanningModelToHRTF(): void;
  40715. /**
  40716. * Switch the panning model to Equal Power:
  40717. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40719. */
  40720. switchPanningModelToEqualPower(): void;
  40721. /**
  40722. * Connect the sound track to an audio analyser allowing some amazing
  40723. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40725. * @param analyser The analyser to connect to the engine
  40726. */
  40727. connectToAnalyser(analyser: Analyser): void;
  40728. }
  40729. }
  40730. declare module BABYLON {
  40731. interface AbstractScene {
  40732. /**
  40733. * The list of sounds used in the scene.
  40734. */
  40735. sounds: Nullable<Array<Sound>>;
  40736. }
  40737. interface Scene {
  40738. /**
  40739. * @hidden
  40740. * Backing field
  40741. */
  40742. _mainSoundTrack: SoundTrack;
  40743. /**
  40744. * The main sound track played by the scene.
  40745. * It cotains your primary collection of sounds.
  40746. */
  40747. mainSoundTrack: SoundTrack;
  40748. /**
  40749. * The list of sound tracks added to the scene
  40750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40751. */
  40752. soundTracks: Nullable<Array<SoundTrack>>;
  40753. /**
  40754. * Gets a sound using a given name
  40755. * @param name defines the name to search for
  40756. * @return the found sound or null if not found at all.
  40757. */
  40758. getSoundByName(name: string): Nullable<Sound>;
  40759. /**
  40760. * Gets or sets if audio support is enabled
  40761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40762. */
  40763. audioEnabled: boolean;
  40764. /**
  40765. * Gets or sets if audio will be output to headphones
  40766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40767. */
  40768. headphone: boolean;
  40769. /**
  40770. * Gets or sets custom audio listener position provider
  40771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40772. */
  40773. audioListenerPositionProvider: Nullable<() => Vector3>;
  40774. /**
  40775. * Gets or sets a refresh rate when using 3D audio positioning
  40776. */
  40777. audioPositioningRefreshRate: number;
  40778. }
  40779. /**
  40780. * Defines the sound scene component responsible to manage any sounds
  40781. * in a given scene.
  40782. */
  40783. export class AudioSceneComponent implements ISceneSerializableComponent {
  40784. /**
  40785. * The component name helpfull to identify the component in the list of scene components.
  40786. */
  40787. readonly name: string;
  40788. /**
  40789. * The scene the component belongs to.
  40790. */
  40791. scene: Scene;
  40792. private _audioEnabled;
  40793. /**
  40794. * Gets whether audio is enabled or not.
  40795. * Please use related enable/disable method to switch state.
  40796. */
  40797. get audioEnabled(): boolean;
  40798. private _headphone;
  40799. /**
  40800. * Gets whether audio is outputing to headphone or not.
  40801. * Please use the according Switch methods to change output.
  40802. */
  40803. get headphone(): boolean;
  40804. /**
  40805. * Gets or sets a refresh rate when using 3D audio positioning
  40806. */
  40807. audioPositioningRefreshRate: number;
  40808. private _audioListenerPositionProvider;
  40809. /**
  40810. * Gets the current audio listener position provider
  40811. */
  40812. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40813. /**
  40814. * Sets a custom listener position for all sounds in the scene
  40815. * By default, this is the position of the first active camera
  40816. */
  40817. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40818. /**
  40819. * Creates a new instance of the component for the given scene
  40820. * @param scene Defines the scene to register the component in
  40821. */
  40822. constructor(scene: Scene);
  40823. /**
  40824. * Registers the component in a given scene
  40825. */
  40826. register(): void;
  40827. /**
  40828. * Rebuilds the elements related to this component in case of
  40829. * context lost for instance.
  40830. */
  40831. rebuild(): void;
  40832. /**
  40833. * Serializes the component data to the specified json object
  40834. * @param serializationObject The object to serialize to
  40835. */
  40836. serialize(serializationObject: any): void;
  40837. /**
  40838. * Adds all the elements from the container to the scene
  40839. * @param container the container holding the elements
  40840. */
  40841. addFromContainer(container: AbstractScene): void;
  40842. /**
  40843. * Removes all the elements in the container from the scene
  40844. * @param container contains the elements to remove
  40845. * @param dispose if the removed element should be disposed (default: false)
  40846. */
  40847. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40848. /**
  40849. * Disposes the component and the associated ressources.
  40850. */
  40851. dispose(): void;
  40852. /**
  40853. * Disables audio in the associated scene.
  40854. */
  40855. disableAudio(): void;
  40856. /**
  40857. * Enables audio in the associated scene.
  40858. */
  40859. enableAudio(): void;
  40860. /**
  40861. * Switch audio to headphone output.
  40862. */
  40863. switchAudioModeForHeadphones(): void;
  40864. /**
  40865. * Switch audio to normal speakers.
  40866. */
  40867. switchAudioModeForNormalSpeakers(): void;
  40868. private _cachedCameraDirection;
  40869. private _cachedCameraPosition;
  40870. private _lastCheck;
  40871. private _afterRender;
  40872. }
  40873. }
  40874. declare module BABYLON {
  40875. /**
  40876. * Wraps one or more Sound objects and selects one with random weight for playback.
  40877. */
  40878. export class WeightedSound {
  40879. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40880. loop: boolean;
  40881. private _coneInnerAngle;
  40882. private _coneOuterAngle;
  40883. private _volume;
  40884. /** A Sound is currently playing. */
  40885. isPlaying: boolean;
  40886. /** A Sound is currently paused. */
  40887. isPaused: boolean;
  40888. private _sounds;
  40889. private _weights;
  40890. private _currentIndex?;
  40891. /**
  40892. * Creates a new WeightedSound from the list of sounds given.
  40893. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40894. * @param sounds Array of Sounds that will be selected from.
  40895. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40896. */
  40897. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40898. /**
  40899. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40900. */
  40901. get directionalConeInnerAngle(): number;
  40902. /**
  40903. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40904. */
  40905. set directionalConeInnerAngle(value: number);
  40906. /**
  40907. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40908. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40909. */
  40910. get directionalConeOuterAngle(): number;
  40911. /**
  40912. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40913. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40914. */
  40915. set directionalConeOuterAngle(value: number);
  40916. /**
  40917. * Playback volume.
  40918. */
  40919. get volume(): number;
  40920. /**
  40921. * Playback volume.
  40922. */
  40923. set volume(value: number);
  40924. private _onended;
  40925. /**
  40926. * Suspend playback
  40927. */
  40928. pause(): void;
  40929. /**
  40930. * Stop playback
  40931. */
  40932. stop(): void;
  40933. /**
  40934. * Start playback.
  40935. * @param startOffset Position the clip head at a specific time in seconds.
  40936. */
  40937. play(startOffset?: number): void;
  40938. }
  40939. }
  40940. declare module BABYLON {
  40941. /**
  40942. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40943. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40944. */
  40945. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40946. /**
  40947. * Gets the name of the behavior.
  40948. */
  40949. get name(): string;
  40950. /**
  40951. * The easing function used by animations
  40952. */
  40953. static EasingFunction: BackEase;
  40954. /**
  40955. * The easing mode used by animations
  40956. */
  40957. static EasingMode: number;
  40958. /**
  40959. * The duration of the animation, in milliseconds
  40960. */
  40961. transitionDuration: number;
  40962. /**
  40963. * Length of the distance animated by the transition when lower radius is reached
  40964. */
  40965. lowerRadiusTransitionRange: number;
  40966. /**
  40967. * Length of the distance animated by the transition when upper radius is reached
  40968. */
  40969. upperRadiusTransitionRange: number;
  40970. private _autoTransitionRange;
  40971. /**
  40972. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40973. */
  40974. get autoTransitionRange(): boolean;
  40975. /**
  40976. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40977. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40978. */
  40979. set autoTransitionRange(value: boolean);
  40980. private _attachedCamera;
  40981. private _onAfterCheckInputsObserver;
  40982. private _onMeshTargetChangedObserver;
  40983. /**
  40984. * Initializes the behavior.
  40985. */
  40986. init(): void;
  40987. /**
  40988. * Attaches the behavior to its arc rotate camera.
  40989. * @param camera Defines the camera to attach the behavior to
  40990. */
  40991. attach(camera: ArcRotateCamera): void;
  40992. /**
  40993. * Detaches the behavior from its current arc rotate camera.
  40994. */
  40995. detach(): void;
  40996. private _radiusIsAnimating;
  40997. private _radiusBounceTransition;
  40998. private _animatables;
  40999. private _cachedWheelPrecision;
  41000. /**
  41001. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41002. * @param radiusLimit The limit to check against.
  41003. * @return Bool to indicate if at limit.
  41004. */
  41005. private _isRadiusAtLimit;
  41006. /**
  41007. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41008. * @param radiusDelta The delta by which to animate to. Can be negative.
  41009. */
  41010. private _applyBoundRadiusAnimation;
  41011. /**
  41012. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41013. */
  41014. protected _clearAnimationLocks(): void;
  41015. /**
  41016. * Stops and removes all animations that have been applied to the camera
  41017. */
  41018. stopAllAnimations(): void;
  41019. }
  41020. }
  41021. declare module BABYLON {
  41022. /**
  41023. * 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.
  41024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41025. */
  41026. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41027. /**
  41028. * Gets the name of the behavior.
  41029. */
  41030. get name(): string;
  41031. private _mode;
  41032. private _radiusScale;
  41033. private _positionScale;
  41034. private _defaultElevation;
  41035. private _elevationReturnTime;
  41036. private _elevationReturnWaitTime;
  41037. private _zoomStopsAnimation;
  41038. private _framingTime;
  41039. /**
  41040. * The easing function used by animations
  41041. */
  41042. static EasingFunction: ExponentialEase;
  41043. /**
  41044. * The easing mode used by animations
  41045. */
  41046. static EasingMode: number;
  41047. /**
  41048. * Sets the current mode used by the behavior
  41049. */
  41050. set mode(mode: number);
  41051. /**
  41052. * Gets current mode used by the behavior.
  41053. */
  41054. get mode(): number;
  41055. /**
  41056. * Sets the scale applied to the radius (1 by default)
  41057. */
  41058. set radiusScale(radius: number);
  41059. /**
  41060. * Gets the scale applied to the radius
  41061. */
  41062. get radiusScale(): number;
  41063. /**
  41064. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41065. */
  41066. set positionScale(scale: number);
  41067. /**
  41068. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41069. */
  41070. get positionScale(): number;
  41071. /**
  41072. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41073. * behaviour is triggered, in radians.
  41074. */
  41075. set defaultElevation(elevation: number);
  41076. /**
  41077. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41078. * behaviour is triggered, in radians.
  41079. */
  41080. get defaultElevation(): number;
  41081. /**
  41082. * Sets the time (in milliseconds) taken to return to the default beta position.
  41083. * Negative value indicates camera should not return to default.
  41084. */
  41085. set elevationReturnTime(speed: number);
  41086. /**
  41087. * Gets the time (in milliseconds) taken to return to the default beta position.
  41088. * Negative value indicates camera should not return to default.
  41089. */
  41090. get elevationReturnTime(): number;
  41091. /**
  41092. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41093. */
  41094. set elevationReturnWaitTime(time: number);
  41095. /**
  41096. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41097. */
  41098. get elevationReturnWaitTime(): number;
  41099. /**
  41100. * Sets the flag that indicates if user zooming should stop animation.
  41101. */
  41102. set zoomStopsAnimation(flag: boolean);
  41103. /**
  41104. * Gets the flag that indicates if user zooming should stop animation.
  41105. */
  41106. get zoomStopsAnimation(): boolean;
  41107. /**
  41108. * Sets the transition time when framing the mesh, in milliseconds
  41109. */
  41110. set framingTime(time: number);
  41111. /**
  41112. * Gets the transition time when framing the mesh, in milliseconds
  41113. */
  41114. get framingTime(): number;
  41115. /**
  41116. * Define if the behavior should automatically change the configured
  41117. * camera limits and sensibilities.
  41118. */
  41119. autoCorrectCameraLimitsAndSensibility: boolean;
  41120. private _onPrePointerObservableObserver;
  41121. private _onAfterCheckInputsObserver;
  41122. private _onMeshTargetChangedObserver;
  41123. private _attachedCamera;
  41124. private _isPointerDown;
  41125. private _lastInteractionTime;
  41126. /**
  41127. * Initializes the behavior.
  41128. */
  41129. init(): void;
  41130. /**
  41131. * Attaches the behavior to its arc rotate camera.
  41132. * @param camera Defines the camera to attach the behavior to
  41133. */
  41134. attach(camera: ArcRotateCamera): void;
  41135. /**
  41136. * Detaches the behavior from its current arc rotate camera.
  41137. */
  41138. detach(): void;
  41139. private _animatables;
  41140. private _betaIsAnimating;
  41141. private _betaTransition;
  41142. private _radiusTransition;
  41143. private _vectorTransition;
  41144. /**
  41145. * Targets the given mesh and updates zoom level accordingly.
  41146. * @param mesh The mesh to target.
  41147. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41148. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41149. */
  41150. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41151. /**
  41152. * Targets the given mesh with its children and updates zoom level accordingly.
  41153. * @param mesh The mesh to target.
  41154. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41155. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41156. */
  41157. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41158. /**
  41159. * Targets the given meshes with their children and updates zoom level accordingly.
  41160. * @param meshes The mesh to target.
  41161. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41162. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41163. */
  41164. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41165. /**
  41166. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41167. * @param minimumWorld Determines the smaller position of the bounding box extend
  41168. * @param maximumWorld Determines the bigger position of the bounding box extend
  41169. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41170. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41171. */
  41172. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41173. /**
  41174. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41175. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41176. * frustum width.
  41177. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41178. * to fully enclose the mesh in the viewing frustum.
  41179. */
  41180. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41181. /**
  41182. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41183. * is automatically returned to its default position (expected to be above ground plane).
  41184. */
  41185. private _maintainCameraAboveGround;
  41186. /**
  41187. * Returns the frustum slope based on the canvas ratio and camera FOV
  41188. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41189. */
  41190. private _getFrustumSlope;
  41191. /**
  41192. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41193. */
  41194. private _clearAnimationLocks;
  41195. /**
  41196. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41197. */
  41198. private _applyUserInteraction;
  41199. /**
  41200. * Stops and removes all animations that have been applied to the camera
  41201. */
  41202. stopAllAnimations(): void;
  41203. /**
  41204. * Gets a value indicating if the user is moving the camera
  41205. */
  41206. get isUserIsMoving(): boolean;
  41207. /**
  41208. * The camera can move all the way towards the mesh.
  41209. */
  41210. static IgnoreBoundsSizeMode: number;
  41211. /**
  41212. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41213. */
  41214. static FitFrustumSidesMode: number;
  41215. }
  41216. }
  41217. declare module BABYLON {
  41218. /**
  41219. * Base class for Camera Pointer Inputs.
  41220. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41221. * for example usage.
  41222. */
  41223. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41224. /**
  41225. * Defines the camera the input is attached to.
  41226. */
  41227. abstract camera: Camera;
  41228. /**
  41229. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41230. */
  41231. protected _altKey: boolean;
  41232. protected _ctrlKey: boolean;
  41233. protected _metaKey: boolean;
  41234. protected _shiftKey: boolean;
  41235. /**
  41236. * Which mouse buttons were pressed at time of last mouse event.
  41237. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41238. */
  41239. protected _buttonsPressed: number;
  41240. /**
  41241. * Defines the buttons associated with the input to handle camera move.
  41242. */
  41243. buttons: number[];
  41244. /**
  41245. * Attach the input controls to a specific dom element to get the input from.
  41246. * @param element Defines the element the controls should be listened from
  41247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41248. */
  41249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41250. /**
  41251. * Detach the current controls from the specified dom element.
  41252. * @param element Defines the element to stop listening the inputs from
  41253. */
  41254. detachControl(element: Nullable<HTMLElement>): void;
  41255. /**
  41256. * Gets the class name of the current input.
  41257. * @returns the class name
  41258. */
  41259. getClassName(): string;
  41260. /**
  41261. * Get the friendly name associated with the input class.
  41262. * @returns the input friendly name
  41263. */
  41264. getSimpleName(): string;
  41265. /**
  41266. * Called on pointer POINTERDOUBLETAP event.
  41267. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41268. */
  41269. protected onDoubleTap(type: string): void;
  41270. /**
  41271. * Called on pointer POINTERMOVE event if only a single touch is active.
  41272. * Override this method to provide functionality.
  41273. */
  41274. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41275. /**
  41276. * Called on pointer POINTERMOVE event if multiple touches are active.
  41277. * Override this method to provide functionality.
  41278. */
  41279. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41280. /**
  41281. * Called on JS contextmenu event.
  41282. * Override this method to provide functionality.
  41283. */
  41284. protected onContextMenu(evt: PointerEvent): void;
  41285. /**
  41286. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41287. * press.
  41288. * Override this method to provide functionality.
  41289. */
  41290. protected onButtonDown(evt: PointerEvent): void;
  41291. /**
  41292. * Called each time a new POINTERUP event occurs. Ie, for each button
  41293. * release.
  41294. * Override this method to provide functionality.
  41295. */
  41296. protected onButtonUp(evt: PointerEvent): void;
  41297. /**
  41298. * Called when window becomes inactive.
  41299. * Override this method to provide functionality.
  41300. */
  41301. protected onLostFocus(): void;
  41302. private _pointerInput;
  41303. private _observer;
  41304. private _onLostFocus;
  41305. private pointA;
  41306. private pointB;
  41307. }
  41308. }
  41309. declare module BABYLON {
  41310. /**
  41311. * Manage the pointers inputs to control an arc rotate camera.
  41312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41313. */
  41314. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41315. /**
  41316. * Defines the camera the input is attached to.
  41317. */
  41318. camera: ArcRotateCamera;
  41319. /**
  41320. * Gets the class name of the current input.
  41321. * @returns the class name
  41322. */
  41323. getClassName(): string;
  41324. /**
  41325. * Defines the buttons associated with the input to handle camera move.
  41326. */
  41327. buttons: number[];
  41328. /**
  41329. * Defines the pointer angular sensibility along the X axis or how fast is
  41330. * the camera rotating.
  41331. */
  41332. angularSensibilityX: number;
  41333. /**
  41334. * Defines the pointer angular sensibility along the Y axis or how fast is
  41335. * the camera rotating.
  41336. */
  41337. angularSensibilityY: number;
  41338. /**
  41339. * Defines the pointer pinch precision or how fast is the camera zooming.
  41340. */
  41341. pinchPrecision: number;
  41342. /**
  41343. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41344. * from 0.
  41345. * It defines the percentage of current camera.radius to use as delta when
  41346. * pinch zoom is used.
  41347. */
  41348. pinchDeltaPercentage: number;
  41349. /**
  41350. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41351. * that any object in the plane at the camera's target point will scale
  41352. * perfectly with finger motion.
  41353. * Overrides pinchDeltaPercentage and pinchPrecision.
  41354. */
  41355. useNaturalPinchZoom: boolean;
  41356. /**
  41357. * Defines the pointer panning sensibility or how fast is the camera moving.
  41358. */
  41359. panningSensibility: number;
  41360. /**
  41361. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41362. */
  41363. multiTouchPanning: boolean;
  41364. /**
  41365. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41366. * zoom (pinch) through multitouch.
  41367. */
  41368. multiTouchPanAndZoom: boolean;
  41369. /**
  41370. * Revers pinch action direction.
  41371. */
  41372. pinchInwards: boolean;
  41373. private _isPanClick;
  41374. private _twoFingerActivityCount;
  41375. private _isPinching;
  41376. /**
  41377. * Called on pointer POINTERMOVE event if only a single touch is active.
  41378. */
  41379. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41380. /**
  41381. * Called on pointer POINTERDOUBLETAP event.
  41382. */
  41383. protected onDoubleTap(type: string): void;
  41384. /**
  41385. * Called on pointer POINTERMOVE event if multiple touches are active.
  41386. */
  41387. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41388. /**
  41389. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41390. * press.
  41391. */
  41392. protected onButtonDown(evt: PointerEvent): void;
  41393. /**
  41394. * Called each time a new POINTERUP event occurs. Ie, for each button
  41395. * release.
  41396. */
  41397. protected onButtonUp(evt: PointerEvent): void;
  41398. /**
  41399. * Called when window becomes inactive.
  41400. */
  41401. protected onLostFocus(): void;
  41402. }
  41403. }
  41404. declare module BABYLON {
  41405. /**
  41406. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41408. */
  41409. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41410. /**
  41411. * Defines the camera the input is attached to.
  41412. */
  41413. camera: ArcRotateCamera;
  41414. /**
  41415. * Defines the list of key codes associated with the up action (increase alpha)
  41416. */
  41417. keysUp: number[];
  41418. /**
  41419. * Defines the list of key codes associated with the down action (decrease alpha)
  41420. */
  41421. keysDown: number[];
  41422. /**
  41423. * Defines the list of key codes associated with the left action (increase beta)
  41424. */
  41425. keysLeft: number[];
  41426. /**
  41427. * Defines the list of key codes associated with the right action (decrease beta)
  41428. */
  41429. keysRight: number[];
  41430. /**
  41431. * Defines the list of key codes associated with the reset action.
  41432. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41433. */
  41434. keysReset: number[];
  41435. /**
  41436. * Defines the panning sensibility of the inputs.
  41437. * (How fast is the camera panning)
  41438. */
  41439. panningSensibility: number;
  41440. /**
  41441. * Defines the zooming sensibility of the inputs.
  41442. * (How fast is the camera zooming)
  41443. */
  41444. zoomingSensibility: number;
  41445. /**
  41446. * Defines whether maintaining the alt key down switch the movement mode from
  41447. * orientation to zoom.
  41448. */
  41449. useAltToZoom: boolean;
  41450. /**
  41451. * Rotation speed of the camera
  41452. */
  41453. angularSpeed: number;
  41454. private _keys;
  41455. private _ctrlPressed;
  41456. private _altPressed;
  41457. private _onCanvasBlurObserver;
  41458. private _onKeyboardObserver;
  41459. private _engine;
  41460. private _scene;
  41461. /**
  41462. * Attach the input controls to a specific dom element to get the input from.
  41463. * @param element Defines the element the controls should be listened from
  41464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41465. */
  41466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41467. /**
  41468. * Detach the current controls from the specified dom element.
  41469. * @param element Defines the element to stop listening the inputs from
  41470. */
  41471. detachControl(element: Nullable<HTMLElement>): void;
  41472. /**
  41473. * Update the current camera state depending on the inputs that have been used this frame.
  41474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41475. */
  41476. checkInputs(): void;
  41477. /**
  41478. * Gets the class name of the current intput.
  41479. * @returns the class name
  41480. */
  41481. getClassName(): string;
  41482. /**
  41483. * Get the friendly name associated with the input class.
  41484. * @returns the input friendly name
  41485. */
  41486. getSimpleName(): string;
  41487. }
  41488. }
  41489. declare module BABYLON {
  41490. /**
  41491. * Manage the mouse wheel inputs to control an arc rotate camera.
  41492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41493. */
  41494. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41495. /**
  41496. * Defines the camera the input is attached to.
  41497. */
  41498. camera: ArcRotateCamera;
  41499. /**
  41500. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41501. */
  41502. wheelPrecision: number;
  41503. /**
  41504. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41505. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41506. */
  41507. wheelDeltaPercentage: number;
  41508. private _wheel;
  41509. private _observer;
  41510. private computeDeltaFromMouseWheelLegacyEvent;
  41511. /**
  41512. * Attach the input controls to a specific dom element to get the input from.
  41513. * @param element Defines the element the controls should be listened from
  41514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41515. */
  41516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41517. /**
  41518. * Detach the current controls from the specified dom element.
  41519. * @param element Defines the element to stop listening the inputs from
  41520. */
  41521. detachControl(element: Nullable<HTMLElement>): void;
  41522. /**
  41523. * Gets the class name of the current intput.
  41524. * @returns the class name
  41525. */
  41526. getClassName(): string;
  41527. /**
  41528. * Get the friendly name associated with the input class.
  41529. * @returns the input friendly name
  41530. */
  41531. getSimpleName(): string;
  41532. }
  41533. }
  41534. declare module BABYLON {
  41535. /**
  41536. * Default Inputs manager for the ArcRotateCamera.
  41537. * It groups all the default supported inputs for ease of use.
  41538. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41539. */
  41540. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41541. /**
  41542. * Instantiates a new ArcRotateCameraInputsManager.
  41543. * @param camera Defines the camera the inputs belong to
  41544. */
  41545. constructor(camera: ArcRotateCamera);
  41546. /**
  41547. * Add mouse wheel input support to the input manager.
  41548. * @returns the current input manager
  41549. */
  41550. addMouseWheel(): ArcRotateCameraInputsManager;
  41551. /**
  41552. * Add pointers input support to the input manager.
  41553. * @returns the current input manager
  41554. */
  41555. addPointers(): ArcRotateCameraInputsManager;
  41556. /**
  41557. * Add keyboard input support to the input manager.
  41558. * @returns the current input manager
  41559. */
  41560. addKeyboard(): ArcRotateCameraInputsManager;
  41561. }
  41562. }
  41563. declare module BABYLON {
  41564. /**
  41565. * This represents an orbital type of camera.
  41566. *
  41567. * 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.
  41568. * 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.
  41569. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41570. */
  41571. export class ArcRotateCamera extends TargetCamera {
  41572. /**
  41573. * Defines the rotation angle of the camera along the longitudinal axis.
  41574. */
  41575. alpha: number;
  41576. /**
  41577. * Defines the rotation angle of the camera along the latitudinal axis.
  41578. */
  41579. beta: number;
  41580. /**
  41581. * Defines the radius of the camera from it s target point.
  41582. */
  41583. radius: number;
  41584. protected _target: Vector3;
  41585. protected _targetHost: Nullable<AbstractMesh>;
  41586. /**
  41587. * Defines the target point of the camera.
  41588. * The camera looks towards it form the radius distance.
  41589. */
  41590. get target(): Vector3;
  41591. set target(value: Vector3);
  41592. /**
  41593. * Define the current local position of the camera in the scene
  41594. */
  41595. get position(): Vector3;
  41596. set position(newPosition: Vector3);
  41597. protected _upVector: Vector3;
  41598. protected _upToYMatrix: Matrix;
  41599. protected _YToUpMatrix: Matrix;
  41600. /**
  41601. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41602. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41603. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41604. */
  41605. set upVector(vec: Vector3);
  41606. get upVector(): Vector3;
  41607. /**
  41608. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41609. */
  41610. setMatUp(): void;
  41611. /**
  41612. * Current inertia value on the longitudinal axis.
  41613. * The bigger this number the longer it will take for the camera to stop.
  41614. */
  41615. inertialAlphaOffset: number;
  41616. /**
  41617. * Current inertia value on the latitudinal axis.
  41618. * The bigger this number the longer it will take for the camera to stop.
  41619. */
  41620. inertialBetaOffset: number;
  41621. /**
  41622. * Current inertia value on the radius axis.
  41623. * The bigger this number the longer it will take for the camera to stop.
  41624. */
  41625. inertialRadiusOffset: number;
  41626. /**
  41627. * Minimum allowed angle on the longitudinal axis.
  41628. * This can help limiting how the Camera is able to move in the scene.
  41629. */
  41630. lowerAlphaLimit: Nullable<number>;
  41631. /**
  41632. * Maximum allowed angle on the longitudinal axis.
  41633. * This can help limiting how the Camera is able to move in the scene.
  41634. */
  41635. upperAlphaLimit: Nullable<number>;
  41636. /**
  41637. * Minimum allowed angle on the latitudinal axis.
  41638. * This can help limiting how the Camera is able to move in the scene.
  41639. */
  41640. lowerBetaLimit: number;
  41641. /**
  41642. * Maximum allowed angle on the latitudinal axis.
  41643. * This can help limiting how the Camera is able to move in the scene.
  41644. */
  41645. upperBetaLimit: number;
  41646. /**
  41647. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41648. * This can help limiting how the Camera is able to move in the scene.
  41649. */
  41650. lowerRadiusLimit: Nullable<number>;
  41651. /**
  41652. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41653. * This can help limiting how the Camera is able to move in the scene.
  41654. */
  41655. upperRadiusLimit: Nullable<number>;
  41656. /**
  41657. * Defines the current inertia value used during panning of the camera along the X axis.
  41658. */
  41659. inertialPanningX: number;
  41660. /**
  41661. * Defines the current inertia value used during panning of the camera along the Y axis.
  41662. */
  41663. inertialPanningY: number;
  41664. /**
  41665. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41666. * Basically if your fingers moves away from more than this distance you will be considered
  41667. * in pinch mode.
  41668. */
  41669. pinchToPanMaxDistance: number;
  41670. /**
  41671. * Defines the maximum distance the camera can pan.
  41672. * This could help keeping the cammera always in your scene.
  41673. */
  41674. panningDistanceLimit: Nullable<number>;
  41675. /**
  41676. * Defines the target of the camera before paning.
  41677. */
  41678. panningOriginTarget: Vector3;
  41679. /**
  41680. * Defines the value of the inertia used during panning.
  41681. * 0 would mean stop inertia and one would mean no decelleration at all.
  41682. */
  41683. panningInertia: number;
  41684. /**
  41685. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41686. */
  41687. get angularSensibilityX(): number;
  41688. set angularSensibilityX(value: number);
  41689. /**
  41690. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41691. */
  41692. get angularSensibilityY(): number;
  41693. set angularSensibilityY(value: number);
  41694. /**
  41695. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41696. */
  41697. get pinchPrecision(): number;
  41698. set pinchPrecision(value: number);
  41699. /**
  41700. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41701. * It will be used instead of pinchDeltaPrecision if different from 0.
  41702. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41703. */
  41704. get pinchDeltaPercentage(): number;
  41705. set pinchDeltaPercentage(value: number);
  41706. /**
  41707. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41708. * and pinch delta percentage.
  41709. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41710. * that any object in the plane at the camera's target point will scale
  41711. * perfectly with finger motion.
  41712. */
  41713. get useNaturalPinchZoom(): boolean;
  41714. set useNaturalPinchZoom(value: boolean);
  41715. /**
  41716. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41717. */
  41718. get panningSensibility(): number;
  41719. set panningSensibility(value: number);
  41720. /**
  41721. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41722. */
  41723. get keysUp(): number[];
  41724. set keysUp(value: number[]);
  41725. /**
  41726. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41727. */
  41728. get keysDown(): number[];
  41729. set keysDown(value: number[]);
  41730. /**
  41731. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41732. */
  41733. get keysLeft(): number[];
  41734. set keysLeft(value: number[]);
  41735. /**
  41736. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41737. */
  41738. get keysRight(): number[];
  41739. set keysRight(value: number[]);
  41740. /**
  41741. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41742. */
  41743. get wheelPrecision(): number;
  41744. set wheelPrecision(value: number);
  41745. /**
  41746. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41747. * It will be used instead of pinchDeltaPrecision if different from 0.
  41748. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41749. */
  41750. get wheelDeltaPercentage(): number;
  41751. set wheelDeltaPercentage(value: number);
  41752. /**
  41753. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41754. */
  41755. zoomOnFactor: number;
  41756. /**
  41757. * Defines a screen offset for the camera position.
  41758. */
  41759. targetScreenOffset: Vector2;
  41760. /**
  41761. * Allows the camera to be completely reversed.
  41762. * If false the camera can not arrive upside down.
  41763. */
  41764. allowUpsideDown: boolean;
  41765. /**
  41766. * Define if double tap/click is used to restore the previously saved state of the camera.
  41767. */
  41768. useInputToRestoreState: boolean;
  41769. /** @hidden */
  41770. _viewMatrix: Matrix;
  41771. /** @hidden */
  41772. _useCtrlForPanning: boolean;
  41773. /** @hidden */
  41774. _panningMouseButton: number;
  41775. /**
  41776. * Defines the input associated to the camera.
  41777. */
  41778. inputs: ArcRotateCameraInputsManager;
  41779. /** @hidden */
  41780. _reset: () => void;
  41781. /**
  41782. * Defines the allowed panning axis.
  41783. */
  41784. panningAxis: Vector3;
  41785. protected _localDirection: Vector3;
  41786. protected _transformedDirection: Vector3;
  41787. private _bouncingBehavior;
  41788. /**
  41789. * Gets the bouncing behavior of the camera if it has been enabled.
  41790. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41791. */
  41792. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41793. /**
  41794. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41795. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41796. */
  41797. get useBouncingBehavior(): boolean;
  41798. set useBouncingBehavior(value: boolean);
  41799. private _framingBehavior;
  41800. /**
  41801. * Gets the framing behavior of the camera if it has been enabled.
  41802. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41803. */
  41804. get framingBehavior(): Nullable<FramingBehavior>;
  41805. /**
  41806. * Defines if the framing behavior of the camera is enabled on the camera.
  41807. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41808. */
  41809. get useFramingBehavior(): boolean;
  41810. set useFramingBehavior(value: boolean);
  41811. private _autoRotationBehavior;
  41812. /**
  41813. * Gets the auto rotation behavior of the camera if it has been enabled.
  41814. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41815. */
  41816. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41817. /**
  41818. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41819. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41820. */
  41821. get useAutoRotationBehavior(): boolean;
  41822. set useAutoRotationBehavior(value: boolean);
  41823. /**
  41824. * Observable triggered when the mesh target has been changed on the camera.
  41825. */
  41826. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41827. /**
  41828. * Event raised when the camera is colliding with a mesh.
  41829. */
  41830. onCollide: (collidedMesh: AbstractMesh) => void;
  41831. /**
  41832. * Defines whether the camera should check collision with the objects oh the scene.
  41833. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41834. */
  41835. checkCollisions: boolean;
  41836. /**
  41837. * Defines the collision radius of the camera.
  41838. * This simulates a sphere around the camera.
  41839. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41840. */
  41841. collisionRadius: Vector3;
  41842. protected _collider: Collider;
  41843. protected _previousPosition: Vector3;
  41844. protected _collisionVelocity: Vector3;
  41845. protected _newPosition: Vector3;
  41846. protected _previousAlpha: number;
  41847. protected _previousBeta: number;
  41848. protected _previousRadius: number;
  41849. protected _collisionTriggered: boolean;
  41850. protected _targetBoundingCenter: Nullable<Vector3>;
  41851. private _computationVector;
  41852. /**
  41853. * Instantiates a new ArcRotateCamera in a given scene
  41854. * @param name Defines the name of the camera
  41855. * @param alpha Defines the camera rotation along the logitudinal axis
  41856. * @param beta Defines the camera rotation along the latitudinal axis
  41857. * @param radius Defines the camera distance from its target
  41858. * @param target Defines the camera target
  41859. * @param scene Defines the scene the camera belongs to
  41860. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41861. */
  41862. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41863. /** @hidden */
  41864. _initCache(): void;
  41865. /** @hidden */
  41866. _updateCache(ignoreParentClass?: boolean): void;
  41867. protected _getTargetPosition(): Vector3;
  41868. private _storedAlpha;
  41869. private _storedBeta;
  41870. private _storedRadius;
  41871. private _storedTarget;
  41872. private _storedTargetScreenOffset;
  41873. /**
  41874. * Stores the current state of the camera (alpha, beta, radius and target)
  41875. * @returns the camera itself
  41876. */
  41877. storeState(): Camera;
  41878. /**
  41879. * @hidden
  41880. * Restored camera state. You must call storeState() first
  41881. */
  41882. _restoreStateValues(): boolean;
  41883. /** @hidden */
  41884. _isSynchronizedViewMatrix(): boolean;
  41885. /**
  41886. * Attached controls to the current camera.
  41887. * @param element Defines the element the controls should be listened from
  41888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41889. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41890. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41891. */
  41892. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41893. /**
  41894. * Detach the current controls from the camera.
  41895. * The camera will stop reacting to inputs.
  41896. * @param element Defines the element to stop listening the inputs from
  41897. */
  41898. detachControl(element: HTMLElement): void;
  41899. /** @hidden */
  41900. _checkInputs(): void;
  41901. protected _checkLimits(): void;
  41902. /**
  41903. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41904. */
  41905. rebuildAnglesAndRadius(): void;
  41906. /**
  41907. * Use a position to define the current camera related information like alpha, beta and radius
  41908. * @param position Defines the position to set the camera at
  41909. */
  41910. setPosition(position: Vector3): void;
  41911. /**
  41912. * Defines the target the camera should look at.
  41913. * This will automatically adapt alpha beta and radius to fit within the new target.
  41914. * @param target Defines the new target as a Vector or a mesh
  41915. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41916. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41917. */
  41918. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41919. /** @hidden */
  41920. _getViewMatrix(): Matrix;
  41921. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41922. /**
  41923. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41924. * @param meshes Defines the mesh to zoom on
  41925. * @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)
  41926. */
  41927. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  41928. /**
  41929. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  41930. * The target will be changed but the radius
  41931. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  41932. * @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)
  41933. */
  41934. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  41935. min: Vector3;
  41936. max: Vector3;
  41937. distance: number;
  41938. }, doNotUpdateMaxZ?: boolean): void;
  41939. /**
  41940. * @override
  41941. * Override Camera.createRigCamera
  41942. */
  41943. createRigCamera(name: string, cameraIndex: number): Camera;
  41944. /**
  41945. * @hidden
  41946. * @override
  41947. * Override Camera._updateRigCameras
  41948. */
  41949. _updateRigCameras(): void;
  41950. /**
  41951. * Destroy the camera and release the current resources hold by it.
  41952. */
  41953. dispose(): void;
  41954. /**
  41955. * Gets the current object class name.
  41956. * @return the class name
  41957. */
  41958. getClassName(): string;
  41959. }
  41960. }
  41961. declare module BABYLON {
  41962. /**
  41963. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  41964. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41965. */
  41966. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  41967. /**
  41968. * Gets the name of the behavior.
  41969. */
  41970. get name(): string;
  41971. private _zoomStopsAnimation;
  41972. private _idleRotationSpeed;
  41973. private _idleRotationWaitTime;
  41974. private _idleRotationSpinupTime;
  41975. /**
  41976. * Sets the flag that indicates if user zooming should stop animation.
  41977. */
  41978. set zoomStopsAnimation(flag: boolean);
  41979. /**
  41980. * Gets the flag that indicates if user zooming should stop animation.
  41981. */
  41982. get zoomStopsAnimation(): boolean;
  41983. /**
  41984. * Sets the default speed at which the camera rotates around the model.
  41985. */
  41986. set idleRotationSpeed(speed: number);
  41987. /**
  41988. * Gets the default speed at which the camera rotates around the model.
  41989. */
  41990. get idleRotationSpeed(): number;
  41991. /**
  41992. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  41993. */
  41994. set idleRotationWaitTime(time: number);
  41995. /**
  41996. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  41997. */
  41998. get idleRotationWaitTime(): number;
  41999. /**
  42000. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42001. */
  42002. set idleRotationSpinupTime(time: number);
  42003. /**
  42004. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42005. */
  42006. get idleRotationSpinupTime(): number;
  42007. /**
  42008. * Gets a value indicating if the camera is currently rotating because of this behavior
  42009. */
  42010. get rotationInProgress(): boolean;
  42011. private _onPrePointerObservableObserver;
  42012. private _onAfterCheckInputsObserver;
  42013. private _attachedCamera;
  42014. private _isPointerDown;
  42015. private _lastFrameTime;
  42016. private _lastInteractionTime;
  42017. private _cameraRotationSpeed;
  42018. /**
  42019. * Initializes the behavior.
  42020. */
  42021. init(): void;
  42022. /**
  42023. * Attaches the behavior to its arc rotate camera.
  42024. * @param camera Defines the camera to attach the behavior to
  42025. */
  42026. attach(camera: ArcRotateCamera): void;
  42027. /**
  42028. * Detaches the behavior from its current arc rotate camera.
  42029. */
  42030. detach(): void;
  42031. /**
  42032. * Returns true if user is scrolling.
  42033. * @return true if user is scrolling.
  42034. */
  42035. private _userIsZooming;
  42036. private _lastFrameRadius;
  42037. private _shouldAnimationStopForInteraction;
  42038. /**
  42039. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42040. */
  42041. private _applyUserInteraction;
  42042. private _userIsMoving;
  42043. }
  42044. }
  42045. declare module BABYLON {
  42046. /**
  42047. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42048. */
  42049. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42050. private ui;
  42051. /**
  42052. * The name of the behavior
  42053. */
  42054. name: string;
  42055. /**
  42056. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42057. */
  42058. distanceAwayFromFace: number;
  42059. /**
  42060. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42061. */
  42062. distanceAwayFromBottomOfFace: number;
  42063. private _faceVectors;
  42064. private _target;
  42065. private _scene;
  42066. private _onRenderObserver;
  42067. private _tmpMatrix;
  42068. private _tmpVector;
  42069. /**
  42070. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42071. * @param ui The transform node that should be attched to the mesh
  42072. */
  42073. constructor(ui: TransformNode);
  42074. /**
  42075. * Initializes the behavior
  42076. */
  42077. init(): void;
  42078. private _closestFace;
  42079. private _zeroVector;
  42080. private _lookAtTmpMatrix;
  42081. private _lookAtToRef;
  42082. /**
  42083. * Attaches the AttachToBoxBehavior to the passed in mesh
  42084. * @param target The mesh that the specified node will be attached to
  42085. */
  42086. attach(target: Mesh): void;
  42087. /**
  42088. * Detaches the behavior from the mesh
  42089. */
  42090. detach(): void;
  42091. }
  42092. }
  42093. declare module BABYLON {
  42094. /**
  42095. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42096. */
  42097. export class FadeInOutBehavior implements Behavior<Mesh> {
  42098. /**
  42099. * Time in milliseconds to delay before fading in (Default: 0)
  42100. */
  42101. delay: number;
  42102. /**
  42103. * Time in milliseconds for the mesh to fade in (Default: 300)
  42104. */
  42105. fadeInTime: number;
  42106. private _millisecondsPerFrame;
  42107. private _hovered;
  42108. private _hoverValue;
  42109. private _ownerNode;
  42110. /**
  42111. * Instatiates the FadeInOutBehavior
  42112. */
  42113. constructor();
  42114. /**
  42115. * The name of the behavior
  42116. */
  42117. get name(): string;
  42118. /**
  42119. * Initializes the behavior
  42120. */
  42121. init(): void;
  42122. /**
  42123. * Attaches the fade behavior on the passed in mesh
  42124. * @param ownerNode The mesh that will be faded in/out once attached
  42125. */
  42126. attach(ownerNode: Mesh): void;
  42127. /**
  42128. * Detaches the behavior from the mesh
  42129. */
  42130. detach(): void;
  42131. /**
  42132. * Triggers the mesh to begin fading in or out
  42133. * @param value if the object should fade in or out (true to fade in)
  42134. */
  42135. fadeIn(value: boolean): void;
  42136. private _update;
  42137. private _setAllVisibility;
  42138. }
  42139. }
  42140. declare module BABYLON {
  42141. /**
  42142. * Class containing a set of static utilities functions for managing Pivots
  42143. * @hidden
  42144. */
  42145. export class PivotTools {
  42146. private static _PivotCached;
  42147. private static _OldPivotPoint;
  42148. private static _PivotTranslation;
  42149. private static _PivotTmpVector;
  42150. /** @hidden */
  42151. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42152. /** @hidden */
  42153. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42154. }
  42155. }
  42156. declare module BABYLON {
  42157. /**
  42158. * Class containing static functions to help procedurally build meshes
  42159. */
  42160. export class PlaneBuilder {
  42161. /**
  42162. * Creates a plane mesh
  42163. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42164. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42165. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42167. * * 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
  42168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42169. * @param name defines the name of the mesh
  42170. * @param options defines the options used to create the mesh
  42171. * @param scene defines the hosting scene
  42172. * @returns the plane mesh
  42173. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42174. */
  42175. static CreatePlane(name: string, options: {
  42176. size?: number;
  42177. width?: number;
  42178. height?: number;
  42179. sideOrientation?: number;
  42180. frontUVs?: Vector4;
  42181. backUVs?: Vector4;
  42182. updatable?: boolean;
  42183. sourcePlane?: Plane;
  42184. }, scene?: Nullable<Scene>): Mesh;
  42185. }
  42186. }
  42187. declare module BABYLON {
  42188. /**
  42189. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42190. */
  42191. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42192. private static _AnyMouseID;
  42193. /**
  42194. * Abstract mesh the behavior is set on
  42195. */
  42196. attachedNode: AbstractMesh;
  42197. private _dragPlane;
  42198. private _scene;
  42199. private _pointerObserver;
  42200. private _beforeRenderObserver;
  42201. private static _planeScene;
  42202. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42203. /**
  42204. * 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)
  42205. */
  42206. maxDragAngle: number;
  42207. /**
  42208. * @hidden
  42209. */
  42210. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42211. /**
  42212. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42213. */
  42214. currentDraggingPointerID: number;
  42215. /**
  42216. * The last position where the pointer hit the drag plane in world space
  42217. */
  42218. lastDragPosition: Vector3;
  42219. /**
  42220. * If the behavior is currently in a dragging state
  42221. */
  42222. dragging: boolean;
  42223. /**
  42224. * 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)
  42225. */
  42226. dragDeltaRatio: number;
  42227. /**
  42228. * If the drag plane orientation should be updated during the dragging (Default: true)
  42229. */
  42230. updateDragPlane: boolean;
  42231. private _debugMode;
  42232. private _moving;
  42233. /**
  42234. * Fires each time the attached mesh is dragged with the pointer
  42235. * * delta between last drag position and current drag position in world space
  42236. * * dragDistance along the drag axis
  42237. * * dragPlaneNormal normal of the current drag plane used during the drag
  42238. * * dragPlanePoint in world space where the drag intersects the drag plane
  42239. */
  42240. onDragObservable: Observable<{
  42241. delta: Vector3;
  42242. dragPlanePoint: Vector3;
  42243. dragPlaneNormal: Vector3;
  42244. dragDistance: number;
  42245. pointerId: number;
  42246. }>;
  42247. /**
  42248. * Fires each time a drag begins (eg. mouse down on mesh)
  42249. */
  42250. onDragStartObservable: Observable<{
  42251. dragPlanePoint: Vector3;
  42252. pointerId: number;
  42253. }>;
  42254. /**
  42255. * Fires each time a drag ends (eg. mouse release after drag)
  42256. */
  42257. onDragEndObservable: Observable<{
  42258. dragPlanePoint: Vector3;
  42259. pointerId: number;
  42260. }>;
  42261. /**
  42262. * If the attached mesh should be moved when dragged
  42263. */
  42264. moveAttached: boolean;
  42265. /**
  42266. * If the drag behavior will react to drag events (Default: true)
  42267. */
  42268. enabled: boolean;
  42269. /**
  42270. * If pointer events should start and release the drag (Default: true)
  42271. */
  42272. startAndReleaseDragOnPointerEvents: boolean;
  42273. /**
  42274. * If camera controls should be detached during the drag
  42275. */
  42276. detachCameraControls: boolean;
  42277. /**
  42278. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42279. */
  42280. useObjectOrientationForDragging: boolean;
  42281. private _options;
  42282. /**
  42283. * Gets the options used by the behavior
  42284. */
  42285. get options(): {
  42286. dragAxis?: Vector3;
  42287. dragPlaneNormal?: Vector3;
  42288. };
  42289. /**
  42290. * Sets the options used by the behavior
  42291. */
  42292. set options(options: {
  42293. dragAxis?: Vector3;
  42294. dragPlaneNormal?: Vector3;
  42295. });
  42296. /**
  42297. * Creates a pointer drag behavior that can be attached to a mesh
  42298. * @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)
  42299. */
  42300. constructor(options?: {
  42301. dragAxis?: Vector3;
  42302. dragPlaneNormal?: Vector3;
  42303. });
  42304. /**
  42305. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42306. */
  42307. validateDrag: (targetPosition: Vector3) => boolean;
  42308. /**
  42309. * The name of the behavior
  42310. */
  42311. get name(): string;
  42312. /**
  42313. * Initializes the behavior
  42314. */
  42315. init(): void;
  42316. private _tmpVector;
  42317. private _alternatePickedPoint;
  42318. private _worldDragAxis;
  42319. private _targetPosition;
  42320. private _attachedElement;
  42321. /**
  42322. * Attaches the drag behavior the passed in mesh
  42323. * @param ownerNode The mesh that will be dragged around once attached
  42324. * @param predicate Predicate to use for pick filtering
  42325. */
  42326. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42327. /**
  42328. * Force relase the drag action by code.
  42329. */
  42330. releaseDrag(): void;
  42331. private _startDragRay;
  42332. private _lastPointerRay;
  42333. /**
  42334. * Simulates the start of a pointer drag event on the behavior
  42335. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42336. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42337. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42338. */
  42339. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42340. private _startDrag;
  42341. private _dragDelta;
  42342. private _moveDrag;
  42343. private _pickWithRayOnDragPlane;
  42344. private _pointA;
  42345. private _pointB;
  42346. private _pointC;
  42347. private _lineA;
  42348. private _lineB;
  42349. private _localAxis;
  42350. private _lookAt;
  42351. private _updateDragPlanePosition;
  42352. /**
  42353. * Detaches the behavior from the mesh
  42354. */
  42355. detach(): void;
  42356. }
  42357. }
  42358. declare module BABYLON {
  42359. /**
  42360. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42361. */
  42362. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42363. private _dragBehaviorA;
  42364. private _dragBehaviorB;
  42365. private _startDistance;
  42366. private _initialScale;
  42367. private _targetScale;
  42368. private _ownerNode;
  42369. private _sceneRenderObserver;
  42370. /**
  42371. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42372. */
  42373. constructor();
  42374. /**
  42375. * The name of the behavior
  42376. */
  42377. get name(): string;
  42378. /**
  42379. * Initializes the behavior
  42380. */
  42381. init(): void;
  42382. private _getCurrentDistance;
  42383. /**
  42384. * Attaches the scale behavior the passed in mesh
  42385. * @param ownerNode The mesh that will be scaled around once attached
  42386. */
  42387. attach(ownerNode: Mesh): void;
  42388. /**
  42389. * Detaches the behavior from the mesh
  42390. */
  42391. detach(): void;
  42392. }
  42393. }
  42394. declare module BABYLON {
  42395. /**
  42396. * 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
  42397. */
  42398. export class SixDofDragBehavior implements Behavior<Mesh> {
  42399. private static _virtualScene;
  42400. private _ownerNode;
  42401. private _sceneRenderObserver;
  42402. private _scene;
  42403. private _targetPosition;
  42404. private _virtualOriginMesh;
  42405. private _virtualDragMesh;
  42406. private _pointerObserver;
  42407. private _moving;
  42408. private _startingOrientation;
  42409. private _attachedElement;
  42410. /**
  42411. * 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)
  42412. */
  42413. private zDragFactor;
  42414. /**
  42415. * If the object should rotate to face the drag origin
  42416. */
  42417. rotateDraggedObject: boolean;
  42418. /**
  42419. * If the behavior is currently in a dragging state
  42420. */
  42421. dragging: boolean;
  42422. /**
  42423. * 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)
  42424. */
  42425. dragDeltaRatio: number;
  42426. /**
  42427. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42428. */
  42429. currentDraggingPointerID: number;
  42430. /**
  42431. * If camera controls should be detached during the drag
  42432. */
  42433. detachCameraControls: boolean;
  42434. /**
  42435. * Fires each time a drag starts
  42436. */
  42437. onDragStartObservable: Observable<{}>;
  42438. /**
  42439. * Fires each time a drag ends (eg. mouse release after drag)
  42440. */
  42441. onDragEndObservable: Observable<{}>;
  42442. /**
  42443. * 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
  42444. */
  42445. constructor();
  42446. /**
  42447. * The name of the behavior
  42448. */
  42449. get name(): string;
  42450. /**
  42451. * Initializes the behavior
  42452. */
  42453. init(): void;
  42454. /**
  42455. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42456. */
  42457. private get _pointerCamera();
  42458. /**
  42459. * Attaches the scale behavior the passed in mesh
  42460. * @param ownerNode The mesh that will be scaled around once attached
  42461. */
  42462. attach(ownerNode: Mesh): void;
  42463. /**
  42464. * Detaches the behavior from the mesh
  42465. */
  42466. detach(): void;
  42467. }
  42468. }
  42469. declare module BABYLON {
  42470. /**
  42471. * Class used to apply inverse kinematics to bones
  42472. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42473. */
  42474. export class BoneIKController {
  42475. private static _tmpVecs;
  42476. private static _tmpQuat;
  42477. private static _tmpMats;
  42478. /**
  42479. * Gets or sets the target mesh
  42480. */
  42481. targetMesh: AbstractMesh;
  42482. /** Gets or sets the mesh used as pole */
  42483. poleTargetMesh: AbstractMesh;
  42484. /**
  42485. * Gets or sets the bone used as pole
  42486. */
  42487. poleTargetBone: Nullable<Bone>;
  42488. /**
  42489. * Gets or sets the target position
  42490. */
  42491. targetPosition: Vector3;
  42492. /**
  42493. * Gets or sets the pole target position
  42494. */
  42495. poleTargetPosition: Vector3;
  42496. /**
  42497. * Gets or sets the pole target local offset
  42498. */
  42499. poleTargetLocalOffset: Vector3;
  42500. /**
  42501. * Gets or sets the pole angle
  42502. */
  42503. poleAngle: number;
  42504. /**
  42505. * Gets or sets the mesh associated with the controller
  42506. */
  42507. mesh: AbstractMesh;
  42508. /**
  42509. * 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)
  42510. */
  42511. slerpAmount: number;
  42512. private _bone1Quat;
  42513. private _bone1Mat;
  42514. private _bone2Ang;
  42515. private _bone1;
  42516. private _bone2;
  42517. private _bone1Length;
  42518. private _bone2Length;
  42519. private _maxAngle;
  42520. private _maxReach;
  42521. private _rightHandedSystem;
  42522. private _bendAxis;
  42523. private _slerping;
  42524. private _adjustRoll;
  42525. /**
  42526. * Gets or sets maximum allowed angle
  42527. */
  42528. get maxAngle(): number;
  42529. set maxAngle(value: number);
  42530. /**
  42531. * Creates a new BoneIKController
  42532. * @param mesh defines the mesh to control
  42533. * @param bone defines the bone to control
  42534. * @param options defines options to set up the controller
  42535. */
  42536. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42537. targetMesh?: AbstractMesh;
  42538. poleTargetMesh?: AbstractMesh;
  42539. poleTargetBone?: Bone;
  42540. poleTargetLocalOffset?: Vector3;
  42541. poleAngle?: number;
  42542. bendAxis?: Vector3;
  42543. maxAngle?: number;
  42544. slerpAmount?: number;
  42545. });
  42546. private _setMaxAngle;
  42547. /**
  42548. * Force the controller to update the bones
  42549. */
  42550. update(): void;
  42551. }
  42552. }
  42553. declare module BABYLON {
  42554. /**
  42555. * Class used to make a bone look toward a point in space
  42556. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42557. */
  42558. export class BoneLookController {
  42559. private static _tmpVecs;
  42560. private static _tmpQuat;
  42561. private static _tmpMats;
  42562. /**
  42563. * The target Vector3 that the bone will look at
  42564. */
  42565. target: Vector3;
  42566. /**
  42567. * The mesh that the bone is attached to
  42568. */
  42569. mesh: AbstractMesh;
  42570. /**
  42571. * The bone that will be looking to the target
  42572. */
  42573. bone: Bone;
  42574. /**
  42575. * The up axis of the coordinate system that is used when the bone is rotated
  42576. */
  42577. upAxis: Vector3;
  42578. /**
  42579. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42580. */
  42581. upAxisSpace: Space;
  42582. /**
  42583. * Used to make an adjustment to the yaw of the bone
  42584. */
  42585. adjustYaw: number;
  42586. /**
  42587. * Used to make an adjustment to the pitch of the bone
  42588. */
  42589. adjustPitch: number;
  42590. /**
  42591. * Used to make an adjustment to the roll of the bone
  42592. */
  42593. adjustRoll: number;
  42594. /**
  42595. * 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)
  42596. */
  42597. slerpAmount: number;
  42598. private _minYaw;
  42599. private _maxYaw;
  42600. private _minPitch;
  42601. private _maxPitch;
  42602. private _minYawSin;
  42603. private _minYawCos;
  42604. private _maxYawSin;
  42605. private _maxYawCos;
  42606. private _midYawConstraint;
  42607. private _minPitchTan;
  42608. private _maxPitchTan;
  42609. private _boneQuat;
  42610. private _slerping;
  42611. private _transformYawPitch;
  42612. private _transformYawPitchInv;
  42613. private _firstFrameSkipped;
  42614. private _yawRange;
  42615. private _fowardAxis;
  42616. /**
  42617. * Gets or sets the minimum yaw angle that the bone can look to
  42618. */
  42619. get minYaw(): number;
  42620. set minYaw(value: number);
  42621. /**
  42622. * Gets or sets the maximum yaw angle that the bone can look to
  42623. */
  42624. get maxYaw(): number;
  42625. set maxYaw(value: number);
  42626. /**
  42627. * Gets or sets the minimum pitch angle that the bone can look to
  42628. */
  42629. get minPitch(): number;
  42630. set minPitch(value: number);
  42631. /**
  42632. * Gets or sets the maximum pitch angle that the bone can look to
  42633. */
  42634. get maxPitch(): number;
  42635. set maxPitch(value: number);
  42636. /**
  42637. * Create a BoneLookController
  42638. * @param mesh the mesh that the bone belongs to
  42639. * @param bone the bone that will be looking to the target
  42640. * @param target the target Vector3 to look at
  42641. * @param options optional settings:
  42642. * * maxYaw: the maximum angle the bone will yaw to
  42643. * * minYaw: the minimum angle the bone will yaw to
  42644. * * maxPitch: the maximum angle the bone will pitch to
  42645. * * minPitch: the minimum angle the bone will yaw to
  42646. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42647. * * upAxis: the up axis of the coordinate system
  42648. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42649. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42650. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42651. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42652. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42653. * * adjustRoll: used to make an adjustment to the roll of the bone
  42654. **/
  42655. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42656. maxYaw?: number;
  42657. minYaw?: number;
  42658. maxPitch?: number;
  42659. minPitch?: number;
  42660. slerpAmount?: number;
  42661. upAxis?: Vector3;
  42662. upAxisSpace?: Space;
  42663. yawAxis?: Vector3;
  42664. pitchAxis?: Vector3;
  42665. adjustYaw?: number;
  42666. adjustPitch?: number;
  42667. adjustRoll?: number;
  42668. });
  42669. /**
  42670. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42671. */
  42672. update(): void;
  42673. private _getAngleDiff;
  42674. private _getAngleBetween;
  42675. private _isAngleBetween;
  42676. }
  42677. }
  42678. declare module BABYLON {
  42679. /**
  42680. * Manage the gamepad inputs to control an arc rotate camera.
  42681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42682. */
  42683. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42684. /**
  42685. * Defines the camera the input is attached to.
  42686. */
  42687. camera: ArcRotateCamera;
  42688. /**
  42689. * Defines the gamepad the input is gathering event from.
  42690. */
  42691. gamepad: Nullable<Gamepad>;
  42692. /**
  42693. * Defines the gamepad rotation sensiblity.
  42694. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42695. */
  42696. gamepadRotationSensibility: number;
  42697. /**
  42698. * Defines the gamepad move sensiblity.
  42699. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42700. */
  42701. gamepadMoveSensibility: number;
  42702. private _yAxisScale;
  42703. /**
  42704. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42705. */
  42706. get invertYAxis(): boolean;
  42707. set invertYAxis(value: boolean);
  42708. private _onGamepadConnectedObserver;
  42709. private _onGamepadDisconnectedObserver;
  42710. /**
  42711. * Attach the input controls to a specific dom element to get the input from.
  42712. * @param element Defines the element the controls should be listened from
  42713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42714. */
  42715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42716. /**
  42717. * Detach the current controls from the specified dom element.
  42718. * @param element Defines the element to stop listening the inputs from
  42719. */
  42720. detachControl(element: Nullable<HTMLElement>): void;
  42721. /**
  42722. * Update the current camera state depending on the inputs that have been used this frame.
  42723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42724. */
  42725. checkInputs(): void;
  42726. /**
  42727. * Gets the class name of the current intput.
  42728. * @returns the class name
  42729. */
  42730. getClassName(): string;
  42731. /**
  42732. * Get the friendly name associated with the input class.
  42733. * @returns the input friendly name
  42734. */
  42735. getSimpleName(): string;
  42736. }
  42737. }
  42738. declare module BABYLON {
  42739. interface ArcRotateCameraInputsManager {
  42740. /**
  42741. * Add orientation input support to the input manager.
  42742. * @returns the current input manager
  42743. */
  42744. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42745. }
  42746. /**
  42747. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42748. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42749. */
  42750. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42751. /**
  42752. * Defines the camera the input is attached to.
  42753. */
  42754. camera: ArcRotateCamera;
  42755. /**
  42756. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42757. */
  42758. alphaCorrection: number;
  42759. /**
  42760. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42761. */
  42762. gammaCorrection: number;
  42763. private _alpha;
  42764. private _gamma;
  42765. private _dirty;
  42766. private _deviceOrientationHandler;
  42767. /**
  42768. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42769. */
  42770. constructor();
  42771. /**
  42772. * Attach the input controls to a specific dom element to get the input from.
  42773. * @param element Defines the element the controls should be listened from
  42774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42775. */
  42776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42777. /** @hidden */
  42778. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42779. /**
  42780. * Update the current camera state depending on the inputs that have been used this frame.
  42781. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42782. */
  42783. checkInputs(): void;
  42784. /**
  42785. * Detach the current controls from the specified dom element.
  42786. * @param element Defines the element to stop listening the inputs from
  42787. */
  42788. detachControl(element: Nullable<HTMLElement>): void;
  42789. /**
  42790. * Gets the class name of the current intput.
  42791. * @returns the class name
  42792. */
  42793. getClassName(): string;
  42794. /**
  42795. * Get the friendly name associated with the input class.
  42796. * @returns the input friendly name
  42797. */
  42798. getSimpleName(): string;
  42799. }
  42800. }
  42801. declare module BABYLON {
  42802. /**
  42803. * Listen to mouse events to control the camera.
  42804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42805. */
  42806. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42807. /**
  42808. * Defines the camera the input is attached to.
  42809. */
  42810. camera: FlyCamera;
  42811. /**
  42812. * Defines if touch is enabled. (Default is true.)
  42813. */
  42814. touchEnabled: boolean;
  42815. /**
  42816. * Defines the buttons associated with the input to handle camera rotation.
  42817. */
  42818. buttons: number[];
  42819. /**
  42820. * Assign buttons for Yaw control.
  42821. */
  42822. buttonsYaw: number[];
  42823. /**
  42824. * Assign buttons for Pitch control.
  42825. */
  42826. buttonsPitch: number[];
  42827. /**
  42828. * Assign buttons for Roll control.
  42829. */
  42830. buttonsRoll: number[];
  42831. /**
  42832. * Detect if any button is being pressed while mouse is moved.
  42833. * -1 = Mouse locked.
  42834. * 0 = Left button.
  42835. * 1 = Middle Button.
  42836. * 2 = Right Button.
  42837. */
  42838. activeButton: number;
  42839. /**
  42840. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42841. * Higher values reduce its sensitivity.
  42842. */
  42843. angularSensibility: number;
  42844. private _mousemoveCallback;
  42845. private _observer;
  42846. private _rollObserver;
  42847. private previousPosition;
  42848. private noPreventDefault;
  42849. private element;
  42850. /**
  42851. * Listen to mouse events to control the camera.
  42852. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42854. */
  42855. constructor(touchEnabled?: boolean);
  42856. /**
  42857. * Attach the mouse control to the HTML DOM element.
  42858. * @param element Defines the element that listens to the input events.
  42859. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42860. */
  42861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42862. /**
  42863. * Detach the current controls from the specified dom element.
  42864. * @param element Defines the element to stop listening the inputs from
  42865. */
  42866. detachControl(element: Nullable<HTMLElement>): void;
  42867. /**
  42868. * Gets the class name of the current input.
  42869. * @returns the class name.
  42870. */
  42871. getClassName(): string;
  42872. /**
  42873. * Get the friendly name associated with the input class.
  42874. * @returns the input's friendly name.
  42875. */
  42876. getSimpleName(): string;
  42877. private _pointerInput;
  42878. private _onMouseMove;
  42879. /**
  42880. * Rotate camera by mouse offset.
  42881. */
  42882. private rotateCamera;
  42883. }
  42884. }
  42885. declare module BABYLON {
  42886. /**
  42887. * Default Inputs manager for the FlyCamera.
  42888. * It groups all the default supported inputs for ease of use.
  42889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42890. */
  42891. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42892. /**
  42893. * Instantiates a new FlyCameraInputsManager.
  42894. * @param camera Defines the camera the inputs belong to.
  42895. */
  42896. constructor(camera: FlyCamera);
  42897. /**
  42898. * Add keyboard input support to the input manager.
  42899. * @returns the new FlyCameraKeyboardMoveInput().
  42900. */
  42901. addKeyboard(): FlyCameraInputsManager;
  42902. /**
  42903. * Add mouse input support to the input manager.
  42904. * @param touchEnabled Enable touch screen support.
  42905. * @returns the new FlyCameraMouseInput().
  42906. */
  42907. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42908. }
  42909. }
  42910. declare module BABYLON {
  42911. /**
  42912. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42913. * such as in a 3D Space Shooter or a Flight Simulator.
  42914. */
  42915. export class FlyCamera extends TargetCamera {
  42916. /**
  42917. * Define the collision ellipsoid of the camera.
  42918. * This is helpful for simulating a camera body, like a player's body.
  42919. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42920. */
  42921. ellipsoid: Vector3;
  42922. /**
  42923. * Define an offset for the position of the ellipsoid around the camera.
  42924. * This can be helpful if the camera is attached away from the player's body center,
  42925. * such as at its head.
  42926. */
  42927. ellipsoidOffset: Vector3;
  42928. /**
  42929. * Enable or disable collisions of the camera with the rest of the scene objects.
  42930. */
  42931. checkCollisions: boolean;
  42932. /**
  42933. * Enable or disable gravity on the camera.
  42934. */
  42935. applyGravity: boolean;
  42936. /**
  42937. * Define the current direction the camera is moving to.
  42938. */
  42939. cameraDirection: Vector3;
  42940. /**
  42941. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  42942. * This overrides and empties cameraRotation.
  42943. */
  42944. rotationQuaternion: Quaternion;
  42945. /**
  42946. * Track Roll to maintain the wanted Rolling when looking around.
  42947. */
  42948. _trackRoll: number;
  42949. /**
  42950. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  42951. */
  42952. rollCorrect: number;
  42953. /**
  42954. * Mimic a banked turn, Rolling the camera when Yawing.
  42955. * It's recommended to use rollCorrect = 10 for faster banking correction.
  42956. */
  42957. bankedTurn: boolean;
  42958. /**
  42959. * Limit in radians for how much Roll banking will add. (Default: 90°)
  42960. */
  42961. bankedTurnLimit: number;
  42962. /**
  42963. * Value of 0 disables the banked Roll.
  42964. * Value of 1 is equal to the Yaw angle in radians.
  42965. */
  42966. bankedTurnMultiplier: number;
  42967. /**
  42968. * The inputs manager loads all the input sources, such as keyboard and mouse.
  42969. */
  42970. inputs: FlyCameraInputsManager;
  42971. /**
  42972. * Gets the input sensibility for mouse input.
  42973. * Higher values reduce sensitivity.
  42974. */
  42975. get angularSensibility(): number;
  42976. /**
  42977. * Sets the input sensibility for a mouse input.
  42978. * Higher values reduce sensitivity.
  42979. */
  42980. set angularSensibility(value: number);
  42981. /**
  42982. * Get the keys for camera movement forward.
  42983. */
  42984. get keysForward(): number[];
  42985. /**
  42986. * Set the keys for camera movement forward.
  42987. */
  42988. set keysForward(value: number[]);
  42989. /**
  42990. * Get the keys for camera movement backward.
  42991. */
  42992. get keysBackward(): number[];
  42993. set keysBackward(value: number[]);
  42994. /**
  42995. * Get the keys for camera movement up.
  42996. */
  42997. get keysUp(): number[];
  42998. /**
  42999. * Set the keys for camera movement up.
  43000. */
  43001. set keysUp(value: number[]);
  43002. /**
  43003. * Get the keys for camera movement down.
  43004. */
  43005. get keysDown(): number[];
  43006. /**
  43007. * Set the keys for camera movement down.
  43008. */
  43009. set keysDown(value: number[]);
  43010. /**
  43011. * Get the keys for camera movement left.
  43012. */
  43013. get keysLeft(): number[];
  43014. /**
  43015. * Set the keys for camera movement left.
  43016. */
  43017. set keysLeft(value: number[]);
  43018. /**
  43019. * Set the keys for camera movement right.
  43020. */
  43021. get keysRight(): number[];
  43022. /**
  43023. * Set the keys for camera movement right.
  43024. */
  43025. set keysRight(value: number[]);
  43026. /**
  43027. * Event raised when the camera collides with a mesh in the scene.
  43028. */
  43029. onCollide: (collidedMesh: AbstractMesh) => void;
  43030. private _collider;
  43031. private _needMoveForGravity;
  43032. private _oldPosition;
  43033. private _diffPosition;
  43034. private _newPosition;
  43035. /** @hidden */
  43036. _localDirection: Vector3;
  43037. /** @hidden */
  43038. _transformedDirection: Vector3;
  43039. /**
  43040. * Instantiates a FlyCamera.
  43041. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43042. * such as in a 3D Space Shooter or a Flight Simulator.
  43043. * @param name Define the name of the camera in the scene.
  43044. * @param position Define the starting position of the camera in the scene.
  43045. * @param scene Define the scene the camera belongs to.
  43046. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43047. */
  43048. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43049. /**
  43050. * Attach a control to the HTML DOM element.
  43051. * @param element Defines the element that listens to the input events.
  43052. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43053. */
  43054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43055. /**
  43056. * Detach a control from the HTML DOM element.
  43057. * The camera will stop reacting to that input.
  43058. * @param element Defines the element that listens to the input events.
  43059. */
  43060. detachControl(element: HTMLElement): void;
  43061. private _collisionMask;
  43062. /**
  43063. * Get the mask that the camera ignores in collision events.
  43064. */
  43065. get collisionMask(): number;
  43066. /**
  43067. * Set the mask that the camera ignores in collision events.
  43068. */
  43069. set collisionMask(mask: number);
  43070. /** @hidden */
  43071. _collideWithWorld(displacement: Vector3): void;
  43072. /** @hidden */
  43073. private _onCollisionPositionChange;
  43074. /** @hidden */
  43075. _checkInputs(): void;
  43076. /** @hidden */
  43077. _decideIfNeedsToMove(): boolean;
  43078. /** @hidden */
  43079. _updatePosition(): void;
  43080. /**
  43081. * Restore the Roll to its target value at the rate specified.
  43082. * @param rate - Higher means slower restoring.
  43083. * @hidden
  43084. */
  43085. restoreRoll(rate: number): void;
  43086. /**
  43087. * Destroy the camera and release the current resources held by it.
  43088. */
  43089. dispose(): void;
  43090. /**
  43091. * Get the current object class name.
  43092. * @returns the class name.
  43093. */
  43094. getClassName(): string;
  43095. }
  43096. }
  43097. declare module BABYLON {
  43098. /**
  43099. * Listen to keyboard events to control the camera.
  43100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43101. */
  43102. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43103. /**
  43104. * Defines the camera the input is attached to.
  43105. */
  43106. camera: FlyCamera;
  43107. /**
  43108. * The list of keyboard keys used to control the forward move of the camera.
  43109. */
  43110. keysForward: number[];
  43111. /**
  43112. * The list of keyboard keys used to control the backward move of the camera.
  43113. */
  43114. keysBackward: number[];
  43115. /**
  43116. * The list of keyboard keys used to control the forward move of the camera.
  43117. */
  43118. keysUp: number[];
  43119. /**
  43120. * The list of keyboard keys used to control the backward move of the camera.
  43121. */
  43122. keysDown: number[];
  43123. /**
  43124. * The list of keyboard keys used to control the right strafe move of the camera.
  43125. */
  43126. keysRight: number[];
  43127. /**
  43128. * The list of keyboard keys used to control the left strafe move of the camera.
  43129. */
  43130. keysLeft: number[];
  43131. private _keys;
  43132. private _onCanvasBlurObserver;
  43133. private _onKeyboardObserver;
  43134. private _engine;
  43135. private _scene;
  43136. /**
  43137. * Attach the input controls to a specific dom element to get the input from.
  43138. * @param element Defines the element the controls should be listened from
  43139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43140. */
  43141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43142. /**
  43143. * Detach the current controls from the specified dom element.
  43144. * @param element Defines the element to stop listening the inputs from
  43145. */
  43146. detachControl(element: Nullable<HTMLElement>): void;
  43147. /**
  43148. * Gets the class name of the current intput.
  43149. * @returns the class name
  43150. */
  43151. getClassName(): string;
  43152. /** @hidden */
  43153. _onLostFocus(e: FocusEvent): void;
  43154. /**
  43155. * Get the friendly name associated with the input class.
  43156. * @returns the input friendly name
  43157. */
  43158. getSimpleName(): string;
  43159. /**
  43160. * Update the current camera state depending on the inputs that have been used this frame.
  43161. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43162. */
  43163. checkInputs(): void;
  43164. }
  43165. }
  43166. declare module BABYLON {
  43167. /**
  43168. * Manage the mouse wheel inputs to control a follow camera.
  43169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43170. */
  43171. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43172. /**
  43173. * Defines the camera the input is attached to.
  43174. */
  43175. camera: FollowCamera;
  43176. /**
  43177. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43178. */
  43179. axisControlRadius: boolean;
  43180. /**
  43181. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43182. */
  43183. axisControlHeight: boolean;
  43184. /**
  43185. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43186. */
  43187. axisControlRotation: boolean;
  43188. /**
  43189. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43190. * relation to mouseWheel events.
  43191. */
  43192. wheelPrecision: number;
  43193. /**
  43194. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43195. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43196. */
  43197. wheelDeltaPercentage: number;
  43198. private _wheel;
  43199. private _observer;
  43200. /**
  43201. * Attach the input controls to a specific dom element to get the input from.
  43202. * @param element Defines the element the controls should be listened from
  43203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43204. */
  43205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43206. /**
  43207. * Detach the current controls from the specified dom element.
  43208. * @param element Defines the element to stop listening the inputs from
  43209. */
  43210. detachControl(element: Nullable<HTMLElement>): void;
  43211. /**
  43212. * Gets the class name of the current intput.
  43213. * @returns the class name
  43214. */
  43215. getClassName(): string;
  43216. /**
  43217. * Get the friendly name associated with the input class.
  43218. * @returns the input friendly name
  43219. */
  43220. getSimpleName(): string;
  43221. }
  43222. }
  43223. declare module BABYLON {
  43224. /**
  43225. * Manage the pointers inputs to control an follow camera.
  43226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43227. */
  43228. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43229. /**
  43230. * Defines the camera the input is attached to.
  43231. */
  43232. camera: FollowCamera;
  43233. /**
  43234. * Gets the class name of the current input.
  43235. * @returns the class name
  43236. */
  43237. getClassName(): string;
  43238. /**
  43239. * Defines the pointer angular sensibility along the X axis or how fast is
  43240. * the camera rotating.
  43241. * A negative number will reverse the axis direction.
  43242. */
  43243. angularSensibilityX: number;
  43244. /**
  43245. * Defines the pointer angular sensibility along the Y axis or how fast is
  43246. * the camera rotating.
  43247. * A negative number will reverse the axis direction.
  43248. */
  43249. angularSensibilityY: number;
  43250. /**
  43251. * Defines the pointer pinch precision or how fast is the camera zooming.
  43252. * A negative number will reverse the axis direction.
  43253. */
  43254. pinchPrecision: number;
  43255. /**
  43256. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43257. * from 0.
  43258. * It defines the percentage of current camera.radius to use as delta when
  43259. * pinch zoom is used.
  43260. */
  43261. pinchDeltaPercentage: number;
  43262. /**
  43263. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43264. */
  43265. axisXControlRadius: boolean;
  43266. /**
  43267. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43268. */
  43269. axisXControlHeight: boolean;
  43270. /**
  43271. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43272. */
  43273. axisXControlRotation: boolean;
  43274. /**
  43275. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43276. */
  43277. axisYControlRadius: boolean;
  43278. /**
  43279. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43280. */
  43281. axisYControlHeight: boolean;
  43282. /**
  43283. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43284. */
  43285. axisYControlRotation: boolean;
  43286. /**
  43287. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43288. */
  43289. axisPinchControlRadius: boolean;
  43290. /**
  43291. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43292. */
  43293. axisPinchControlHeight: boolean;
  43294. /**
  43295. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43296. */
  43297. axisPinchControlRotation: boolean;
  43298. /**
  43299. * Log error messages if basic misconfiguration has occurred.
  43300. */
  43301. warningEnable: boolean;
  43302. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43303. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43304. private _warningCounter;
  43305. private _warning;
  43306. }
  43307. }
  43308. declare module BABYLON {
  43309. /**
  43310. * Default Inputs manager for the FollowCamera.
  43311. * It groups all the default supported inputs for ease of use.
  43312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43313. */
  43314. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43315. /**
  43316. * Instantiates a new FollowCameraInputsManager.
  43317. * @param camera Defines the camera the inputs belong to
  43318. */
  43319. constructor(camera: FollowCamera);
  43320. /**
  43321. * Add keyboard input support to the input manager.
  43322. * @returns the current input manager
  43323. */
  43324. addKeyboard(): FollowCameraInputsManager;
  43325. /**
  43326. * Add mouse wheel input support to the input manager.
  43327. * @returns the current input manager
  43328. */
  43329. addMouseWheel(): FollowCameraInputsManager;
  43330. /**
  43331. * Add pointers input support to the input manager.
  43332. * @returns the current input manager
  43333. */
  43334. addPointers(): FollowCameraInputsManager;
  43335. /**
  43336. * Add orientation input support to the input manager.
  43337. * @returns the current input manager
  43338. */
  43339. addVRDeviceOrientation(): FollowCameraInputsManager;
  43340. }
  43341. }
  43342. declare module BABYLON {
  43343. /**
  43344. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43345. * an arc rotate version arcFollowCamera are available.
  43346. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43347. */
  43348. export class FollowCamera extends TargetCamera {
  43349. /**
  43350. * Distance the follow camera should follow an object at
  43351. */
  43352. radius: number;
  43353. /**
  43354. * Minimum allowed distance of the camera to the axis of rotation
  43355. * (The camera can not get closer).
  43356. * This can help limiting how the Camera is able to move in the scene.
  43357. */
  43358. lowerRadiusLimit: Nullable<number>;
  43359. /**
  43360. * Maximum allowed distance of the camera to the axis of rotation
  43361. * (The camera can not get further).
  43362. * This can help limiting how the Camera is able to move in the scene.
  43363. */
  43364. upperRadiusLimit: Nullable<number>;
  43365. /**
  43366. * Define a rotation offset between the camera and the object it follows
  43367. */
  43368. rotationOffset: number;
  43369. /**
  43370. * Minimum allowed angle to camera position relative to target object.
  43371. * This can help limiting how the Camera is able to move in the scene.
  43372. */
  43373. lowerRotationOffsetLimit: Nullable<number>;
  43374. /**
  43375. * Maximum allowed angle to camera position relative to target object.
  43376. * This can help limiting how the Camera is able to move in the scene.
  43377. */
  43378. upperRotationOffsetLimit: Nullable<number>;
  43379. /**
  43380. * Define a height offset between the camera and the object it follows.
  43381. * It can help following an object from the top (like a car chaing a plane)
  43382. */
  43383. heightOffset: number;
  43384. /**
  43385. * Minimum allowed height of camera position relative to target object.
  43386. * This can help limiting how the Camera is able to move in the scene.
  43387. */
  43388. lowerHeightOffsetLimit: Nullable<number>;
  43389. /**
  43390. * Maximum allowed height of camera position relative to target object.
  43391. * This can help limiting how the Camera is able to move in the scene.
  43392. */
  43393. upperHeightOffsetLimit: Nullable<number>;
  43394. /**
  43395. * Define how fast the camera can accelerate to follow it s target.
  43396. */
  43397. cameraAcceleration: number;
  43398. /**
  43399. * Define the speed limit of the camera following an object.
  43400. */
  43401. maxCameraSpeed: number;
  43402. /**
  43403. * Define the target of the camera.
  43404. */
  43405. lockedTarget: Nullable<AbstractMesh>;
  43406. /**
  43407. * Defines the input associated with the camera.
  43408. */
  43409. inputs: FollowCameraInputsManager;
  43410. /**
  43411. * Instantiates the follow camera.
  43412. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43413. * @param name Define the name of the camera in the scene
  43414. * @param position Define the position of the camera
  43415. * @param scene Define the scene the camera belong to
  43416. * @param lockedTarget Define the target of the camera
  43417. */
  43418. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43419. private _follow;
  43420. /**
  43421. * Attached controls to the current camera.
  43422. * @param element Defines the element the controls should be listened from
  43423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43424. */
  43425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43426. /**
  43427. * Detach the current controls from the camera.
  43428. * The camera will stop reacting to inputs.
  43429. * @param element Defines the element to stop listening the inputs from
  43430. */
  43431. detachControl(element: HTMLElement): void;
  43432. /** @hidden */
  43433. _checkInputs(): void;
  43434. private _checkLimits;
  43435. /**
  43436. * Gets the camera class name.
  43437. * @returns the class name
  43438. */
  43439. getClassName(): string;
  43440. }
  43441. /**
  43442. * Arc Rotate version of the follow camera.
  43443. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43444. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43445. */
  43446. export class ArcFollowCamera extends TargetCamera {
  43447. /** The longitudinal angle of the camera */
  43448. alpha: number;
  43449. /** The latitudinal angle of the camera */
  43450. beta: number;
  43451. /** The radius of the camera from its target */
  43452. radius: number;
  43453. /** Define the camera target (the messh it should follow) */
  43454. target: Nullable<AbstractMesh>;
  43455. private _cartesianCoordinates;
  43456. /**
  43457. * Instantiates a new ArcFollowCamera
  43458. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43459. * @param name Define the name of the camera
  43460. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43461. * @param beta Define the rotation angle of the camera around the elevation axis
  43462. * @param radius Define the radius of the camera from its target point
  43463. * @param target Define the target of the camera
  43464. * @param scene Define the scene the camera belongs to
  43465. */
  43466. constructor(name: string,
  43467. /** The longitudinal angle of the camera */
  43468. alpha: number,
  43469. /** The latitudinal angle of the camera */
  43470. beta: number,
  43471. /** The radius of the camera from its target */
  43472. radius: number,
  43473. /** Define the camera target (the messh it should follow) */
  43474. target: Nullable<AbstractMesh>, scene: Scene);
  43475. private _follow;
  43476. /** @hidden */
  43477. _checkInputs(): void;
  43478. /**
  43479. * Returns the class name of the object.
  43480. * It is mostly used internally for serialization purposes.
  43481. */
  43482. getClassName(): string;
  43483. }
  43484. }
  43485. declare module BABYLON {
  43486. /**
  43487. * Manage the keyboard inputs to control the movement of a follow camera.
  43488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43489. */
  43490. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43491. /**
  43492. * Defines the camera the input is attached to.
  43493. */
  43494. camera: FollowCamera;
  43495. /**
  43496. * Defines the list of key codes associated with the up action (increase heightOffset)
  43497. */
  43498. keysHeightOffsetIncr: number[];
  43499. /**
  43500. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43501. */
  43502. keysHeightOffsetDecr: number[];
  43503. /**
  43504. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43505. */
  43506. keysHeightOffsetModifierAlt: boolean;
  43507. /**
  43508. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43509. */
  43510. keysHeightOffsetModifierCtrl: boolean;
  43511. /**
  43512. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43513. */
  43514. keysHeightOffsetModifierShift: boolean;
  43515. /**
  43516. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43517. */
  43518. keysRotationOffsetIncr: number[];
  43519. /**
  43520. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43521. */
  43522. keysRotationOffsetDecr: number[];
  43523. /**
  43524. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43525. */
  43526. keysRotationOffsetModifierAlt: boolean;
  43527. /**
  43528. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43529. */
  43530. keysRotationOffsetModifierCtrl: boolean;
  43531. /**
  43532. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43533. */
  43534. keysRotationOffsetModifierShift: boolean;
  43535. /**
  43536. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43537. */
  43538. keysRadiusIncr: number[];
  43539. /**
  43540. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43541. */
  43542. keysRadiusDecr: number[];
  43543. /**
  43544. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43545. */
  43546. keysRadiusModifierAlt: boolean;
  43547. /**
  43548. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43549. */
  43550. keysRadiusModifierCtrl: boolean;
  43551. /**
  43552. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43553. */
  43554. keysRadiusModifierShift: boolean;
  43555. /**
  43556. * Defines the rate of change of heightOffset.
  43557. */
  43558. heightSensibility: number;
  43559. /**
  43560. * Defines the rate of change of rotationOffset.
  43561. */
  43562. rotationSensibility: number;
  43563. /**
  43564. * Defines the rate of change of radius.
  43565. */
  43566. radiusSensibility: number;
  43567. private _keys;
  43568. private _ctrlPressed;
  43569. private _altPressed;
  43570. private _shiftPressed;
  43571. private _onCanvasBlurObserver;
  43572. private _onKeyboardObserver;
  43573. private _engine;
  43574. private _scene;
  43575. /**
  43576. * Attach the input controls to a specific dom element to get the input from.
  43577. * @param element Defines the element the controls should be listened from
  43578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43579. */
  43580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43581. /**
  43582. * Detach the current controls from the specified dom element.
  43583. * @param element Defines the element to stop listening the inputs from
  43584. */
  43585. detachControl(element: Nullable<HTMLElement>): void;
  43586. /**
  43587. * Update the current camera state depending on the inputs that have been used this frame.
  43588. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43589. */
  43590. checkInputs(): void;
  43591. /**
  43592. * Gets the class name of the current input.
  43593. * @returns the class name
  43594. */
  43595. getClassName(): string;
  43596. /**
  43597. * Get the friendly name associated with the input class.
  43598. * @returns the input friendly name
  43599. */
  43600. getSimpleName(): string;
  43601. /**
  43602. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43603. * allow modification of the heightOffset value.
  43604. */
  43605. private _modifierHeightOffset;
  43606. /**
  43607. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43608. * allow modification of the rotationOffset value.
  43609. */
  43610. private _modifierRotationOffset;
  43611. /**
  43612. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43613. * allow modification of the radius value.
  43614. */
  43615. private _modifierRadius;
  43616. }
  43617. }
  43618. declare module BABYLON {
  43619. interface FreeCameraInputsManager {
  43620. /**
  43621. * @hidden
  43622. */
  43623. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43624. /**
  43625. * Add orientation input support to the input manager.
  43626. * @returns the current input manager
  43627. */
  43628. addDeviceOrientation(): FreeCameraInputsManager;
  43629. }
  43630. /**
  43631. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43632. * Screen rotation is taken into account.
  43633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43634. */
  43635. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43636. private _camera;
  43637. private _screenOrientationAngle;
  43638. private _constantTranform;
  43639. private _screenQuaternion;
  43640. private _alpha;
  43641. private _beta;
  43642. private _gamma;
  43643. /**
  43644. * Can be used to detect if a device orientation sensor is available on a device
  43645. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43646. * @returns a promise that will resolve on orientation change
  43647. */
  43648. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43649. /**
  43650. * @hidden
  43651. */
  43652. _onDeviceOrientationChangedObservable: Observable<void>;
  43653. /**
  43654. * Instantiates a new input
  43655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43656. */
  43657. constructor();
  43658. /**
  43659. * Define the camera controlled by the input.
  43660. */
  43661. get camera(): FreeCamera;
  43662. set camera(camera: FreeCamera);
  43663. /**
  43664. * Attach the input controls to a specific dom element to get the input from.
  43665. * @param element Defines the element the controls should be listened from
  43666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43667. */
  43668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43669. private _orientationChanged;
  43670. private _deviceOrientation;
  43671. /**
  43672. * Detach the current controls from the specified dom element.
  43673. * @param element Defines the element to stop listening the inputs from
  43674. */
  43675. detachControl(element: Nullable<HTMLElement>): void;
  43676. /**
  43677. * Update the current camera state depending on the inputs that have been used this frame.
  43678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43679. */
  43680. checkInputs(): void;
  43681. /**
  43682. * Gets the class name of the current intput.
  43683. * @returns the class name
  43684. */
  43685. getClassName(): string;
  43686. /**
  43687. * Get the friendly name associated with the input class.
  43688. * @returns the input friendly name
  43689. */
  43690. getSimpleName(): string;
  43691. }
  43692. }
  43693. declare module BABYLON {
  43694. /**
  43695. * Manage the gamepad inputs to control a free camera.
  43696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43697. */
  43698. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43699. /**
  43700. * Define the camera the input is attached to.
  43701. */
  43702. camera: FreeCamera;
  43703. /**
  43704. * Define the Gamepad controlling the input
  43705. */
  43706. gamepad: Nullable<Gamepad>;
  43707. /**
  43708. * Defines the gamepad rotation sensiblity.
  43709. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43710. */
  43711. gamepadAngularSensibility: number;
  43712. /**
  43713. * Defines the gamepad move sensiblity.
  43714. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43715. */
  43716. gamepadMoveSensibility: number;
  43717. private _yAxisScale;
  43718. /**
  43719. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43720. */
  43721. get invertYAxis(): boolean;
  43722. set invertYAxis(value: boolean);
  43723. private _onGamepadConnectedObserver;
  43724. private _onGamepadDisconnectedObserver;
  43725. private _cameraTransform;
  43726. private _deltaTransform;
  43727. private _vector3;
  43728. private _vector2;
  43729. /**
  43730. * Attach the input controls to a specific dom element to get the input from.
  43731. * @param element Defines the element the controls should be listened from
  43732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43733. */
  43734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43735. /**
  43736. * Detach the current controls from the specified dom element.
  43737. * @param element Defines the element to stop listening the inputs from
  43738. */
  43739. detachControl(element: Nullable<HTMLElement>): void;
  43740. /**
  43741. * Update the current camera state depending on the inputs that have been used this frame.
  43742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43743. */
  43744. checkInputs(): void;
  43745. /**
  43746. * Gets the class name of the current intput.
  43747. * @returns the class name
  43748. */
  43749. getClassName(): string;
  43750. /**
  43751. * Get the friendly name associated with the input class.
  43752. * @returns the input friendly name
  43753. */
  43754. getSimpleName(): string;
  43755. }
  43756. }
  43757. declare module BABYLON {
  43758. /**
  43759. * Defines the potential axis of a Joystick
  43760. */
  43761. export enum JoystickAxis {
  43762. /** X axis */
  43763. X = 0,
  43764. /** Y axis */
  43765. Y = 1,
  43766. /** Z axis */
  43767. Z = 2
  43768. }
  43769. /**
  43770. * Class used to define virtual joystick (used in touch mode)
  43771. */
  43772. export class VirtualJoystick {
  43773. /**
  43774. * Gets or sets a boolean indicating that left and right values must be inverted
  43775. */
  43776. reverseLeftRight: boolean;
  43777. /**
  43778. * Gets or sets a boolean indicating that up and down values must be inverted
  43779. */
  43780. reverseUpDown: boolean;
  43781. /**
  43782. * Gets the offset value for the position (ie. the change of the position value)
  43783. */
  43784. deltaPosition: Vector3;
  43785. /**
  43786. * Gets a boolean indicating if the virtual joystick was pressed
  43787. */
  43788. pressed: boolean;
  43789. /**
  43790. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43791. */
  43792. static Canvas: Nullable<HTMLCanvasElement>;
  43793. private static _globalJoystickIndex;
  43794. private static vjCanvasContext;
  43795. private static vjCanvasWidth;
  43796. private static vjCanvasHeight;
  43797. private static halfWidth;
  43798. private _action;
  43799. private _axisTargetedByLeftAndRight;
  43800. private _axisTargetedByUpAndDown;
  43801. private _joystickSensibility;
  43802. private _inversedSensibility;
  43803. private _joystickPointerID;
  43804. private _joystickColor;
  43805. private _joystickPointerPos;
  43806. private _joystickPreviousPointerPos;
  43807. private _joystickPointerStartPos;
  43808. private _deltaJoystickVector;
  43809. private _leftJoystick;
  43810. private _touches;
  43811. private _onPointerDownHandlerRef;
  43812. private _onPointerMoveHandlerRef;
  43813. private _onPointerUpHandlerRef;
  43814. private _onResize;
  43815. /**
  43816. * Creates a new virtual joystick
  43817. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43818. */
  43819. constructor(leftJoystick?: boolean);
  43820. /**
  43821. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43822. * @param newJoystickSensibility defines the new sensibility
  43823. */
  43824. setJoystickSensibility(newJoystickSensibility: number): void;
  43825. private _onPointerDown;
  43826. private _onPointerMove;
  43827. private _onPointerUp;
  43828. /**
  43829. * Change the color of the virtual joystick
  43830. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43831. */
  43832. setJoystickColor(newColor: string): void;
  43833. /**
  43834. * Defines a callback to call when the joystick is touched
  43835. * @param action defines the callback
  43836. */
  43837. setActionOnTouch(action: () => any): void;
  43838. /**
  43839. * Defines which axis you'd like to control for left & right
  43840. * @param axis defines the axis to use
  43841. */
  43842. setAxisForLeftRight(axis: JoystickAxis): void;
  43843. /**
  43844. * Defines which axis you'd like to control for up & down
  43845. * @param axis defines the axis to use
  43846. */
  43847. setAxisForUpDown(axis: JoystickAxis): void;
  43848. private _drawVirtualJoystick;
  43849. /**
  43850. * Release internal HTML canvas
  43851. */
  43852. releaseCanvas(): void;
  43853. }
  43854. }
  43855. declare module BABYLON {
  43856. interface FreeCameraInputsManager {
  43857. /**
  43858. * Add virtual joystick input support to the input manager.
  43859. * @returns the current input manager
  43860. */
  43861. addVirtualJoystick(): FreeCameraInputsManager;
  43862. }
  43863. /**
  43864. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43866. */
  43867. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43868. /**
  43869. * Defines the camera the input is attached to.
  43870. */
  43871. camera: FreeCamera;
  43872. private _leftjoystick;
  43873. private _rightjoystick;
  43874. /**
  43875. * Gets the left stick of the virtual joystick.
  43876. * @returns The virtual Joystick
  43877. */
  43878. getLeftJoystick(): VirtualJoystick;
  43879. /**
  43880. * Gets the right stick of the virtual joystick.
  43881. * @returns The virtual Joystick
  43882. */
  43883. getRightJoystick(): VirtualJoystick;
  43884. /**
  43885. * Update the current camera state depending on the inputs that have been used this frame.
  43886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43887. */
  43888. checkInputs(): void;
  43889. /**
  43890. * Attach the input controls to a specific dom element to get the input from.
  43891. * @param element Defines the element the controls should be listened from
  43892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43893. */
  43894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43895. /**
  43896. * Detach the current controls from the specified dom element.
  43897. * @param element Defines the element to stop listening the inputs from
  43898. */
  43899. detachControl(element: Nullable<HTMLElement>): void;
  43900. /**
  43901. * Gets the class name of the current intput.
  43902. * @returns the class name
  43903. */
  43904. getClassName(): string;
  43905. /**
  43906. * Get the friendly name associated with the input class.
  43907. * @returns the input friendly name
  43908. */
  43909. getSimpleName(): string;
  43910. }
  43911. }
  43912. declare module BABYLON {
  43913. /**
  43914. * This represents a FPS type of camera controlled by touch.
  43915. * This is like a universal camera minus the Gamepad controls.
  43916. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43917. */
  43918. export class TouchCamera extends FreeCamera {
  43919. /**
  43920. * Defines the touch sensibility for rotation.
  43921. * The higher the faster.
  43922. */
  43923. get touchAngularSensibility(): number;
  43924. set touchAngularSensibility(value: number);
  43925. /**
  43926. * Defines the touch sensibility for move.
  43927. * The higher the faster.
  43928. */
  43929. get touchMoveSensibility(): number;
  43930. set touchMoveSensibility(value: number);
  43931. /**
  43932. * Instantiates a new touch camera.
  43933. * This represents a FPS type of camera controlled by touch.
  43934. * This is like a universal camera minus the Gamepad controls.
  43935. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43936. * @param name Define the name of the camera in the scene
  43937. * @param position Define the start position of the camera in the scene
  43938. * @param scene Define the scene the camera belongs to
  43939. */
  43940. constructor(name: string, position: Vector3, scene: Scene);
  43941. /**
  43942. * Gets the current object class name.
  43943. * @return the class name
  43944. */
  43945. getClassName(): string;
  43946. /** @hidden */
  43947. _setupInputs(): void;
  43948. }
  43949. }
  43950. declare module BABYLON {
  43951. /**
  43952. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  43953. * being tilted forward or back and left or right.
  43954. */
  43955. export class DeviceOrientationCamera extends FreeCamera {
  43956. private _initialQuaternion;
  43957. private _quaternionCache;
  43958. private _tmpDragQuaternion;
  43959. private _disablePointerInputWhenUsingDeviceOrientation;
  43960. /**
  43961. * Creates a new device orientation camera
  43962. * @param name The name of the camera
  43963. * @param position The start position camera
  43964. * @param scene The scene the camera belongs to
  43965. */
  43966. constructor(name: string, position: Vector3, scene: Scene);
  43967. /**
  43968. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  43969. */
  43970. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  43971. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  43972. private _dragFactor;
  43973. /**
  43974. * Enabled turning on the y axis when the orientation sensor is active
  43975. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  43976. */
  43977. enableHorizontalDragging(dragFactor?: number): void;
  43978. /**
  43979. * Gets the current instance class name ("DeviceOrientationCamera").
  43980. * This helps avoiding instanceof at run time.
  43981. * @returns the class name
  43982. */
  43983. getClassName(): string;
  43984. /**
  43985. * @hidden
  43986. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  43987. */
  43988. _checkInputs(): void;
  43989. /**
  43990. * Reset the camera to its default orientation on the specified axis only.
  43991. * @param axis The axis to reset
  43992. */
  43993. resetToCurrentRotation(axis?: Axis): void;
  43994. }
  43995. }
  43996. declare module BABYLON {
  43997. /**
  43998. * Defines supported buttons for XBox360 compatible gamepads
  43999. */
  44000. export enum Xbox360Button {
  44001. /** A */
  44002. A = 0,
  44003. /** B */
  44004. B = 1,
  44005. /** X */
  44006. X = 2,
  44007. /** Y */
  44008. Y = 3,
  44009. /** Left button */
  44010. LB = 4,
  44011. /** Right button */
  44012. RB = 5,
  44013. /** Back */
  44014. Back = 8,
  44015. /** Start */
  44016. Start = 9,
  44017. /** Left stick */
  44018. LeftStick = 10,
  44019. /** Right stick */
  44020. RightStick = 11
  44021. }
  44022. /** Defines values for XBox360 DPad */
  44023. export enum Xbox360Dpad {
  44024. /** Up */
  44025. Up = 12,
  44026. /** Down */
  44027. Down = 13,
  44028. /** Left */
  44029. Left = 14,
  44030. /** Right */
  44031. Right = 15
  44032. }
  44033. /**
  44034. * Defines a XBox360 gamepad
  44035. */
  44036. export class Xbox360Pad extends Gamepad {
  44037. private _leftTrigger;
  44038. private _rightTrigger;
  44039. private _onlefttriggerchanged;
  44040. private _onrighttriggerchanged;
  44041. private _onbuttondown;
  44042. private _onbuttonup;
  44043. private _ondpaddown;
  44044. private _ondpadup;
  44045. /** Observable raised when a button is pressed */
  44046. onButtonDownObservable: Observable<Xbox360Button>;
  44047. /** Observable raised when a button is released */
  44048. onButtonUpObservable: Observable<Xbox360Button>;
  44049. /** Observable raised when a pad is pressed */
  44050. onPadDownObservable: Observable<Xbox360Dpad>;
  44051. /** Observable raised when a pad is released */
  44052. onPadUpObservable: Observable<Xbox360Dpad>;
  44053. private _buttonA;
  44054. private _buttonB;
  44055. private _buttonX;
  44056. private _buttonY;
  44057. private _buttonBack;
  44058. private _buttonStart;
  44059. private _buttonLB;
  44060. private _buttonRB;
  44061. private _buttonLeftStick;
  44062. private _buttonRightStick;
  44063. private _dPadUp;
  44064. private _dPadDown;
  44065. private _dPadLeft;
  44066. private _dPadRight;
  44067. private _isXboxOnePad;
  44068. /**
  44069. * Creates a new XBox360 gamepad object
  44070. * @param id defines the id of this gamepad
  44071. * @param index defines its index
  44072. * @param gamepad defines the internal HTML gamepad object
  44073. * @param xboxOne defines if it is a XBox One gamepad
  44074. */
  44075. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44076. /**
  44077. * Defines the callback to call when left trigger is pressed
  44078. * @param callback defines the callback to use
  44079. */
  44080. onlefttriggerchanged(callback: (value: number) => void): void;
  44081. /**
  44082. * Defines the callback to call when right trigger is pressed
  44083. * @param callback defines the callback to use
  44084. */
  44085. onrighttriggerchanged(callback: (value: number) => void): void;
  44086. /**
  44087. * Gets the left trigger value
  44088. */
  44089. get leftTrigger(): number;
  44090. /**
  44091. * Sets the left trigger value
  44092. */
  44093. set leftTrigger(newValue: number);
  44094. /**
  44095. * Gets the right trigger value
  44096. */
  44097. get rightTrigger(): number;
  44098. /**
  44099. * Sets the right trigger value
  44100. */
  44101. set rightTrigger(newValue: number);
  44102. /**
  44103. * Defines the callback to call when a button is pressed
  44104. * @param callback defines the callback to use
  44105. */
  44106. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44107. /**
  44108. * Defines the callback to call when a button is released
  44109. * @param callback defines the callback to use
  44110. */
  44111. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44112. /**
  44113. * Defines the callback to call when a pad is pressed
  44114. * @param callback defines the callback to use
  44115. */
  44116. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44117. /**
  44118. * Defines the callback to call when a pad is released
  44119. * @param callback defines the callback to use
  44120. */
  44121. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44122. private _setButtonValue;
  44123. private _setDPadValue;
  44124. /**
  44125. * Gets the value of the `A` button
  44126. */
  44127. get buttonA(): number;
  44128. /**
  44129. * Sets the value of the `A` button
  44130. */
  44131. set buttonA(value: number);
  44132. /**
  44133. * Gets the value of the `B` button
  44134. */
  44135. get buttonB(): number;
  44136. /**
  44137. * Sets the value of the `B` button
  44138. */
  44139. set buttonB(value: number);
  44140. /**
  44141. * Gets the value of the `X` button
  44142. */
  44143. get buttonX(): number;
  44144. /**
  44145. * Sets the value of the `X` button
  44146. */
  44147. set buttonX(value: number);
  44148. /**
  44149. * Gets the value of the `Y` button
  44150. */
  44151. get buttonY(): number;
  44152. /**
  44153. * Sets the value of the `Y` button
  44154. */
  44155. set buttonY(value: number);
  44156. /**
  44157. * Gets the value of the `Start` button
  44158. */
  44159. get buttonStart(): number;
  44160. /**
  44161. * Sets the value of the `Start` button
  44162. */
  44163. set buttonStart(value: number);
  44164. /**
  44165. * Gets the value of the `Back` button
  44166. */
  44167. get buttonBack(): number;
  44168. /**
  44169. * Sets the value of the `Back` button
  44170. */
  44171. set buttonBack(value: number);
  44172. /**
  44173. * Gets the value of the `Left` button
  44174. */
  44175. get buttonLB(): number;
  44176. /**
  44177. * Sets the value of the `Left` button
  44178. */
  44179. set buttonLB(value: number);
  44180. /**
  44181. * Gets the value of the `Right` button
  44182. */
  44183. get buttonRB(): number;
  44184. /**
  44185. * Sets the value of the `Right` button
  44186. */
  44187. set buttonRB(value: number);
  44188. /**
  44189. * Gets the value of the Left joystick
  44190. */
  44191. get buttonLeftStick(): number;
  44192. /**
  44193. * Sets the value of the Left joystick
  44194. */
  44195. set buttonLeftStick(value: number);
  44196. /**
  44197. * Gets the value of the Right joystick
  44198. */
  44199. get buttonRightStick(): number;
  44200. /**
  44201. * Sets the value of the Right joystick
  44202. */
  44203. set buttonRightStick(value: number);
  44204. /**
  44205. * Gets the value of D-pad up
  44206. */
  44207. get dPadUp(): number;
  44208. /**
  44209. * Sets the value of D-pad up
  44210. */
  44211. set dPadUp(value: number);
  44212. /**
  44213. * Gets the value of D-pad down
  44214. */
  44215. get dPadDown(): number;
  44216. /**
  44217. * Sets the value of D-pad down
  44218. */
  44219. set dPadDown(value: number);
  44220. /**
  44221. * Gets the value of D-pad left
  44222. */
  44223. get dPadLeft(): number;
  44224. /**
  44225. * Sets the value of D-pad left
  44226. */
  44227. set dPadLeft(value: number);
  44228. /**
  44229. * Gets the value of D-pad right
  44230. */
  44231. get dPadRight(): number;
  44232. /**
  44233. * Sets the value of D-pad right
  44234. */
  44235. set dPadRight(value: number);
  44236. /**
  44237. * Force the gamepad to synchronize with device values
  44238. */
  44239. update(): void;
  44240. /**
  44241. * Disposes the gamepad
  44242. */
  44243. dispose(): void;
  44244. }
  44245. }
  44246. declare module BABYLON {
  44247. /**
  44248. * Defines supported buttons for DualShock compatible gamepads
  44249. */
  44250. export enum DualShockButton {
  44251. /** Cross */
  44252. Cross = 0,
  44253. /** Circle */
  44254. Circle = 1,
  44255. /** Square */
  44256. Square = 2,
  44257. /** Triangle */
  44258. Triangle = 3,
  44259. /** L1 */
  44260. L1 = 4,
  44261. /** R1 */
  44262. R1 = 5,
  44263. /** Share */
  44264. Share = 8,
  44265. /** Options */
  44266. Options = 9,
  44267. /** Left stick */
  44268. LeftStick = 10,
  44269. /** Right stick */
  44270. RightStick = 11
  44271. }
  44272. /** Defines values for DualShock DPad */
  44273. export enum DualShockDpad {
  44274. /** Up */
  44275. Up = 12,
  44276. /** Down */
  44277. Down = 13,
  44278. /** Left */
  44279. Left = 14,
  44280. /** Right */
  44281. Right = 15
  44282. }
  44283. /**
  44284. * Defines a DualShock gamepad
  44285. */
  44286. export class DualShockPad extends Gamepad {
  44287. private _leftTrigger;
  44288. private _rightTrigger;
  44289. private _onlefttriggerchanged;
  44290. private _onrighttriggerchanged;
  44291. private _onbuttondown;
  44292. private _onbuttonup;
  44293. private _ondpaddown;
  44294. private _ondpadup;
  44295. /** Observable raised when a button is pressed */
  44296. onButtonDownObservable: Observable<DualShockButton>;
  44297. /** Observable raised when a button is released */
  44298. onButtonUpObservable: Observable<DualShockButton>;
  44299. /** Observable raised when a pad is pressed */
  44300. onPadDownObservable: Observable<DualShockDpad>;
  44301. /** Observable raised when a pad is released */
  44302. onPadUpObservable: Observable<DualShockDpad>;
  44303. private _buttonCross;
  44304. private _buttonCircle;
  44305. private _buttonSquare;
  44306. private _buttonTriangle;
  44307. private _buttonShare;
  44308. private _buttonOptions;
  44309. private _buttonL1;
  44310. private _buttonR1;
  44311. private _buttonLeftStick;
  44312. private _buttonRightStick;
  44313. private _dPadUp;
  44314. private _dPadDown;
  44315. private _dPadLeft;
  44316. private _dPadRight;
  44317. /**
  44318. * Creates a new DualShock gamepad object
  44319. * @param id defines the id of this gamepad
  44320. * @param index defines its index
  44321. * @param gamepad defines the internal HTML gamepad object
  44322. */
  44323. constructor(id: string, index: number, gamepad: any);
  44324. /**
  44325. * Defines the callback to call when left trigger is pressed
  44326. * @param callback defines the callback to use
  44327. */
  44328. onlefttriggerchanged(callback: (value: number) => void): void;
  44329. /**
  44330. * Defines the callback to call when right trigger is pressed
  44331. * @param callback defines the callback to use
  44332. */
  44333. onrighttriggerchanged(callback: (value: number) => void): void;
  44334. /**
  44335. * Gets the left trigger value
  44336. */
  44337. get leftTrigger(): number;
  44338. /**
  44339. * Sets the left trigger value
  44340. */
  44341. set leftTrigger(newValue: number);
  44342. /**
  44343. * Gets the right trigger value
  44344. */
  44345. get rightTrigger(): number;
  44346. /**
  44347. * Sets the right trigger value
  44348. */
  44349. set rightTrigger(newValue: number);
  44350. /**
  44351. * Defines the callback to call when a button is pressed
  44352. * @param callback defines the callback to use
  44353. */
  44354. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44355. /**
  44356. * Defines the callback to call when a button is released
  44357. * @param callback defines the callback to use
  44358. */
  44359. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44360. /**
  44361. * Defines the callback to call when a pad is pressed
  44362. * @param callback defines the callback to use
  44363. */
  44364. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44365. /**
  44366. * Defines the callback to call when a pad is released
  44367. * @param callback defines the callback to use
  44368. */
  44369. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44370. private _setButtonValue;
  44371. private _setDPadValue;
  44372. /**
  44373. * Gets the value of the `Cross` button
  44374. */
  44375. get buttonCross(): number;
  44376. /**
  44377. * Sets the value of the `Cross` button
  44378. */
  44379. set buttonCross(value: number);
  44380. /**
  44381. * Gets the value of the `Circle` button
  44382. */
  44383. get buttonCircle(): number;
  44384. /**
  44385. * Sets the value of the `Circle` button
  44386. */
  44387. set buttonCircle(value: number);
  44388. /**
  44389. * Gets the value of the `Square` button
  44390. */
  44391. get buttonSquare(): number;
  44392. /**
  44393. * Sets the value of the `Square` button
  44394. */
  44395. set buttonSquare(value: number);
  44396. /**
  44397. * Gets the value of the `Triangle` button
  44398. */
  44399. get buttonTriangle(): number;
  44400. /**
  44401. * Sets the value of the `Triangle` button
  44402. */
  44403. set buttonTriangle(value: number);
  44404. /**
  44405. * Gets the value of the `Options` button
  44406. */
  44407. get buttonOptions(): number;
  44408. /**
  44409. * Sets the value of the `Options` button
  44410. */
  44411. set buttonOptions(value: number);
  44412. /**
  44413. * Gets the value of the `Share` button
  44414. */
  44415. get buttonShare(): number;
  44416. /**
  44417. * Sets the value of the `Share` button
  44418. */
  44419. set buttonShare(value: number);
  44420. /**
  44421. * Gets the value of the `L1` button
  44422. */
  44423. get buttonL1(): number;
  44424. /**
  44425. * Sets the value of the `L1` button
  44426. */
  44427. set buttonL1(value: number);
  44428. /**
  44429. * Gets the value of the `R1` button
  44430. */
  44431. get buttonR1(): number;
  44432. /**
  44433. * Sets the value of the `R1` button
  44434. */
  44435. set buttonR1(value: number);
  44436. /**
  44437. * Gets the value of the Left joystick
  44438. */
  44439. get buttonLeftStick(): number;
  44440. /**
  44441. * Sets the value of the Left joystick
  44442. */
  44443. set buttonLeftStick(value: number);
  44444. /**
  44445. * Gets the value of the Right joystick
  44446. */
  44447. get buttonRightStick(): number;
  44448. /**
  44449. * Sets the value of the Right joystick
  44450. */
  44451. set buttonRightStick(value: number);
  44452. /**
  44453. * Gets the value of D-pad up
  44454. */
  44455. get dPadUp(): number;
  44456. /**
  44457. * Sets the value of D-pad up
  44458. */
  44459. set dPadUp(value: number);
  44460. /**
  44461. * Gets the value of D-pad down
  44462. */
  44463. get dPadDown(): number;
  44464. /**
  44465. * Sets the value of D-pad down
  44466. */
  44467. set dPadDown(value: number);
  44468. /**
  44469. * Gets the value of D-pad left
  44470. */
  44471. get dPadLeft(): number;
  44472. /**
  44473. * Sets the value of D-pad left
  44474. */
  44475. set dPadLeft(value: number);
  44476. /**
  44477. * Gets the value of D-pad right
  44478. */
  44479. get dPadRight(): number;
  44480. /**
  44481. * Sets the value of D-pad right
  44482. */
  44483. set dPadRight(value: number);
  44484. /**
  44485. * Force the gamepad to synchronize with device values
  44486. */
  44487. update(): void;
  44488. /**
  44489. * Disposes the gamepad
  44490. */
  44491. dispose(): void;
  44492. }
  44493. }
  44494. declare module BABYLON {
  44495. /**
  44496. * Manager for handling gamepads
  44497. */
  44498. export class GamepadManager {
  44499. private _scene?;
  44500. private _babylonGamepads;
  44501. private _oneGamepadConnected;
  44502. /** @hidden */
  44503. _isMonitoring: boolean;
  44504. private _gamepadEventSupported;
  44505. private _gamepadSupport?;
  44506. /**
  44507. * observable to be triggered when the gamepad controller has been connected
  44508. */
  44509. onGamepadConnectedObservable: Observable<Gamepad>;
  44510. /**
  44511. * observable to be triggered when the gamepad controller has been disconnected
  44512. */
  44513. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44514. private _onGamepadConnectedEvent;
  44515. private _onGamepadDisconnectedEvent;
  44516. /**
  44517. * Initializes the gamepad manager
  44518. * @param _scene BabylonJS scene
  44519. */
  44520. constructor(_scene?: Scene | undefined);
  44521. /**
  44522. * The gamepads in the game pad manager
  44523. */
  44524. get gamepads(): Gamepad[];
  44525. /**
  44526. * Get the gamepad controllers based on type
  44527. * @param type The type of gamepad controller
  44528. * @returns Nullable gamepad
  44529. */
  44530. getGamepadByType(type?: number): Nullable<Gamepad>;
  44531. /**
  44532. * Disposes the gamepad manager
  44533. */
  44534. dispose(): void;
  44535. private _addNewGamepad;
  44536. private _startMonitoringGamepads;
  44537. private _stopMonitoringGamepads;
  44538. /** @hidden */
  44539. _checkGamepadsStatus(): void;
  44540. private _updateGamepadObjects;
  44541. }
  44542. }
  44543. declare module BABYLON {
  44544. interface Scene {
  44545. /** @hidden */
  44546. _gamepadManager: Nullable<GamepadManager>;
  44547. /**
  44548. * Gets the gamepad manager associated with the scene
  44549. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44550. */
  44551. gamepadManager: GamepadManager;
  44552. }
  44553. /**
  44554. * Interface representing a free camera inputs manager
  44555. */
  44556. interface FreeCameraInputsManager {
  44557. /**
  44558. * Adds gamepad input support to the FreeCameraInputsManager.
  44559. * @returns the FreeCameraInputsManager
  44560. */
  44561. addGamepad(): FreeCameraInputsManager;
  44562. }
  44563. /**
  44564. * Interface representing an arc rotate camera inputs manager
  44565. */
  44566. interface ArcRotateCameraInputsManager {
  44567. /**
  44568. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44569. * @returns the camera inputs manager
  44570. */
  44571. addGamepad(): ArcRotateCameraInputsManager;
  44572. }
  44573. /**
  44574. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44575. */
  44576. export class GamepadSystemSceneComponent implements ISceneComponent {
  44577. /**
  44578. * The component name helpfull to identify the component in the list of scene components.
  44579. */
  44580. readonly name: string;
  44581. /**
  44582. * The scene the component belongs to.
  44583. */
  44584. scene: Scene;
  44585. /**
  44586. * Creates a new instance of the component for the given scene
  44587. * @param scene Defines the scene to register the component in
  44588. */
  44589. constructor(scene: Scene);
  44590. /**
  44591. * Registers the component in a given scene
  44592. */
  44593. register(): void;
  44594. /**
  44595. * Rebuilds the elements related to this component in case of
  44596. * context lost for instance.
  44597. */
  44598. rebuild(): void;
  44599. /**
  44600. * Disposes the component and the associated ressources
  44601. */
  44602. dispose(): void;
  44603. private _beforeCameraUpdate;
  44604. }
  44605. }
  44606. declare module BABYLON {
  44607. /**
  44608. * 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,
  44609. * which still works and will still be found in many Playgrounds.
  44610. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44611. */
  44612. export class UniversalCamera extends TouchCamera {
  44613. /**
  44614. * Defines the gamepad rotation sensiblity.
  44615. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44616. */
  44617. get gamepadAngularSensibility(): number;
  44618. set gamepadAngularSensibility(value: number);
  44619. /**
  44620. * Defines the gamepad move sensiblity.
  44621. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44622. */
  44623. get gamepadMoveSensibility(): number;
  44624. set gamepadMoveSensibility(value: number);
  44625. /**
  44626. * 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,
  44627. * which still works and will still be found in many Playgrounds.
  44628. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44629. * @param name Define the name of the camera in the scene
  44630. * @param position Define the start position of the camera in the scene
  44631. * @param scene Define the scene the camera belongs to
  44632. */
  44633. constructor(name: string, position: Vector3, scene: Scene);
  44634. /**
  44635. * Gets the current object class name.
  44636. * @return the class name
  44637. */
  44638. getClassName(): string;
  44639. }
  44640. }
  44641. declare module BABYLON {
  44642. /**
  44643. * This represents a FPS type of camera. This is only here for back compat purpose.
  44644. * Please use the UniversalCamera instead as both are identical.
  44645. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44646. */
  44647. export class GamepadCamera extends UniversalCamera {
  44648. /**
  44649. * Instantiates a new Gamepad Camera
  44650. * This represents a FPS type of camera. This is only here for back compat purpose.
  44651. * Please use the UniversalCamera instead as both are identical.
  44652. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44653. * @param name Define the name of the camera in the scene
  44654. * @param position Define the start position of the camera in the scene
  44655. * @param scene Define the scene the camera belongs to
  44656. */
  44657. constructor(name: string, position: Vector3, scene: Scene);
  44658. /**
  44659. * Gets the current object class name.
  44660. * @return the class name
  44661. */
  44662. getClassName(): string;
  44663. }
  44664. }
  44665. declare module BABYLON {
  44666. /** @hidden */
  44667. export var passPixelShader: {
  44668. name: string;
  44669. shader: string;
  44670. };
  44671. }
  44672. declare module BABYLON {
  44673. /** @hidden */
  44674. export var passCubePixelShader: {
  44675. name: string;
  44676. shader: string;
  44677. };
  44678. }
  44679. declare module BABYLON {
  44680. /**
  44681. * PassPostProcess which produces an output the same as it's input
  44682. */
  44683. export class PassPostProcess extends PostProcess {
  44684. /**
  44685. * Creates the PassPostProcess
  44686. * @param name The name of the effect.
  44687. * @param options The required width/height ratio to downsize to before computing the render pass.
  44688. * @param camera The camera to apply the render pass to.
  44689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44690. * @param engine The engine which the post process will be applied. (default: current engine)
  44691. * @param reusable If the post process can be reused on the same frame. (default: false)
  44692. * @param textureType The type of texture to be used when performing the post processing.
  44693. * @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)
  44694. */
  44695. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44696. }
  44697. /**
  44698. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44699. */
  44700. export class PassCubePostProcess extends PostProcess {
  44701. private _face;
  44702. /**
  44703. * Gets or sets the cube face to display.
  44704. * * 0 is +X
  44705. * * 1 is -X
  44706. * * 2 is +Y
  44707. * * 3 is -Y
  44708. * * 4 is +Z
  44709. * * 5 is -Z
  44710. */
  44711. get face(): number;
  44712. set face(value: number);
  44713. /**
  44714. * Creates the PassCubePostProcess
  44715. * @param name The name of the effect.
  44716. * @param options The required width/height ratio to downsize to before computing the render pass.
  44717. * @param camera The camera to apply the render pass to.
  44718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44719. * @param engine The engine which the post process will be applied. (default: current engine)
  44720. * @param reusable If the post process can be reused on the same frame. (default: false)
  44721. * @param textureType The type of texture to be used when performing the post processing.
  44722. * @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)
  44723. */
  44724. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44725. }
  44726. }
  44727. declare module BABYLON {
  44728. /** @hidden */
  44729. export var anaglyphPixelShader: {
  44730. name: string;
  44731. shader: string;
  44732. };
  44733. }
  44734. declare module BABYLON {
  44735. /**
  44736. * Postprocess used to generate anaglyphic rendering
  44737. */
  44738. export class AnaglyphPostProcess extends PostProcess {
  44739. private _passedProcess;
  44740. /**
  44741. * Creates a new AnaglyphPostProcess
  44742. * @param name defines postprocess name
  44743. * @param options defines creation options or target ratio scale
  44744. * @param rigCameras defines cameras using this postprocess
  44745. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44746. * @param engine defines hosting engine
  44747. * @param reusable defines if the postprocess will be reused multiple times per frame
  44748. */
  44749. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44750. }
  44751. }
  44752. declare module BABYLON {
  44753. /**
  44754. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44755. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44756. */
  44757. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44758. /**
  44759. * Creates a new AnaglyphArcRotateCamera
  44760. * @param name defines camera name
  44761. * @param alpha defines alpha angle (in radians)
  44762. * @param beta defines beta angle (in radians)
  44763. * @param radius defines radius
  44764. * @param target defines camera target
  44765. * @param interaxialDistance defines distance between each color axis
  44766. * @param scene defines the hosting scene
  44767. */
  44768. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44769. /**
  44770. * Gets camera class name
  44771. * @returns AnaglyphArcRotateCamera
  44772. */
  44773. getClassName(): string;
  44774. }
  44775. }
  44776. declare module BABYLON {
  44777. /**
  44778. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44779. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44780. */
  44781. export class AnaglyphFreeCamera extends FreeCamera {
  44782. /**
  44783. * Creates a new AnaglyphFreeCamera
  44784. * @param name defines camera name
  44785. * @param position defines initial position
  44786. * @param interaxialDistance defines distance between each color axis
  44787. * @param scene defines the hosting scene
  44788. */
  44789. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44790. /**
  44791. * Gets camera class name
  44792. * @returns AnaglyphFreeCamera
  44793. */
  44794. getClassName(): string;
  44795. }
  44796. }
  44797. declare module BABYLON {
  44798. /**
  44799. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44800. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44801. */
  44802. export class AnaglyphGamepadCamera extends GamepadCamera {
  44803. /**
  44804. * Creates a new AnaglyphGamepadCamera
  44805. * @param name defines camera name
  44806. * @param position defines initial position
  44807. * @param interaxialDistance defines distance between each color axis
  44808. * @param scene defines the hosting scene
  44809. */
  44810. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44811. /**
  44812. * Gets camera class name
  44813. * @returns AnaglyphGamepadCamera
  44814. */
  44815. getClassName(): string;
  44816. }
  44817. }
  44818. declare module BABYLON {
  44819. /**
  44820. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44821. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44822. */
  44823. export class AnaglyphUniversalCamera extends UniversalCamera {
  44824. /**
  44825. * Creates a new AnaglyphUniversalCamera
  44826. * @param name defines camera name
  44827. * @param position defines initial position
  44828. * @param interaxialDistance defines distance between each color axis
  44829. * @param scene defines the hosting scene
  44830. */
  44831. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44832. /**
  44833. * Gets camera class name
  44834. * @returns AnaglyphUniversalCamera
  44835. */
  44836. getClassName(): string;
  44837. }
  44838. }
  44839. declare module BABYLON {
  44840. /**
  44841. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44842. * @see http://doc.babylonjs.com/features/cameras
  44843. */
  44844. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44845. /**
  44846. * Creates a new StereoscopicArcRotateCamera
  44847. * @param name defines camera name
  44848. * @param alpha defines alpha angle (in radians)
  44849. * @param beta defines beta angle (in radians)
  44850. * @param radius defines radius
  44851. * @param target defines camera target
  44852. * @param interaxialDistance defines distance between each color axis
  44853. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44854. * @param scene defines the hosting scene
  44855. */
  44856. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44857. /**
  44858. * Gets camera class name
  44859. * @returns StereoscopicArcRotateCamera
  44860. */
  44861. getClassName(): string;
  44862. }
  44863. }
  44864. declare module BABYLON {
  44865. /**
  44866. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44867. * @see http://doc.babylonjs.com/features/cameras
  44868. */
  44869. export class StereoscopicFreeCamera extends FreeCamera {
  44870. /**
  44871. * Creates a new StereoscopicFreeCamera
  44872. * @param name defines camera name
  44873. * @param position defines initial position
  44874. * @param interaxialDistance defines distance between each color axis
  44875. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44876. * @param scene defines the hosting scene
  44877. */
  44878. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44879. /**
  44880. * Gets camera class name
  44881. * @returns StereoscopicFreeCamera
  44882. */
  44883. getClassName(): string;
  44884. }
  44885. }
  44886. declare module BABYLON {
  44887. /**
  44888. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44889. * @see http://doc.babylonjs.com/features/cameras
  44890. */
  44891. export class StereoscopicGamepadCamera extends GamepadCamera {
  44892. /**
  44893. * Creates a new StereoscopicGamepadCamera
  44894. * @param name defines camera name
  44895. * @param position defines initial position
  44896. * @param interaxialDistance defines distance between each color axis
  44897. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44898. * @param scene defines the hosting scene
  44899. */
  44900. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44901. /**
  44902. * Gets camera class name
  44903. * @returns StereoscopicGamepadCamera
  44904. */
  44905. getClassName(): string;
  44906. }
  44907. }
  44908. declare module BABYLON {
  44909. /**
  44910. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44911. * @see http://doc.babylonjs.com/features/cameras
  44912. */
  44913. export class StereoscopicUniversalCamera extends UniversalCamera {
  44914. /**
  44915. * Creates a new StereoscopicUniversalCamera
  44916. * @param name defines camera name
  44917. * @param position defines initial position
  44918. * @param interaxialDistance defines distance between each color axis
  44919. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44920. * @param scene defines the hosting scene
  44921. */
  44922. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44923. /**
  44924. * Gets camera class name
  44925. * @returns StereoscopicUniversalCamera
  44926. */
  44927. getClassName(): string;
  44928. }
  44929. }
  44930. declare module BABYLON {
  44931. /**
  44932. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44933. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44934. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44935. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44936. */
  44937. export class VirtualJoysticksCamera extends FreeCamera {
  44938. /**
  44939. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  44940. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44941. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44942. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44943. * @param name Define the name of the camera in the scene
  44944. * @param position Define the start position of the camera in the scene
  44945. * @param scene Define the scene the camera belongs to
  44946. */
  44947. constructor(name: string, position: Vector3, scene: Scene);
  44948. /**
  44949. * Gets the current object class name.
  44950. * @return the class name
  44951. */
  44952. getClassName(): string;
  44953. }
  44954. }
  44955. declare module BABYLON {
  44956. /**
  44957. * This represents all the required metrics to create a VR camera.
  44958. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  44959. */
  44960. export class VRCameraMetrics {
  44961. /**
  44962. * Define the horizontal resolution off the screen.
  44963. */
  44964. hResolution: number;
  44965. /**
  44966. * Define the vertical resolution off the screen.
  44967. */
  44968. vResolution: number;
  44969. /**
  44970. * Define the horizontal screen size.
  44971. */
  44972. hScreenSize: number;
  44973. /**
  44974. * Define the vertical screen size.
  44975. */
  44976. vScreenSize: number;
  44977. /**
  44978. * Define the vertical screen center position.
  44979. */
  44980. vScreenCenter: number;
  44981. /**
  44982. * Define the distance of the eyes to the screen.
  44983. */
  44984. eyeToScreenDistance: number;
  44985. /**
  44986. * Define the distance between both lenses
  44987. */
  44988. lensSeparationDistance: number;
  44989. /**
  44990. * Define the distance between both viewer's eyes.
  44991. */
  44992. interpupillaryDistance: number;
  44993. /**
  44994. * Define the distortion factor of the VR postprocess.
  44995. * Please, touch with care.
  44996. */
  44997. distortionK: number[];
  44998. /**
  44999. * Define the chromatic aberration correction factors for the VR post process.
  45000. */
  45001. chromaAbCorrection: number[];
  45002. /**
  45003. * Define the scale factor of the post process.
  45004. * The smaller the better but the slower.
  45005. */
  45006. postProcessScaleFactor: number;
  45007. /**
  45008. * Define an offset for the lens center.
  45009. */
  45010. lensCenterOffset: number;
  45011. /**
  45012. * Define if the current vr camera should compensate the distortion of the lense or not.
  45013. */
  45014. compensateDistortion: boolean;
  45015. /**
  45016. * Defines if multiview should be enabled when rendering (Default: false)
  45017. */
  45018. multiviewEnabled: boolean;
  45019. /**
  45020. * Gets the rendering aspect ratio based on the provided resolutions.
  45021. */
  45022. get aspectRatio(): number;
  45023. /**
  45024. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45025. */
  45026. get aspectRatioFov(): number;
  45027. /**
  45028. * @hidden
  45029. */
  45030. get leftHMatrix(): Matrix;
  45031. /**
  45032. * @hidden
  45033. */
  45034. get rightHMatrix(): Matrix;
  45035. /**
  45036. * @hidden
  45037. */
  45038. get leftPreViewMatrix(): Matrix;
  45039. /**
  45040. * @hidden
  45041. */
  45042. get rightPreViewMatrix(): Matrix;
  45043. /**
  45044. * Get the default VRMetrics based on the most generic setup.
  45045. * @returns the default vr metrics
  45046. */
  45047. static GetDefault(): VRCameraMetrics;
  45048. }
  45049. }
  45050. declare module BABYLON {
  45051. /** @hidden */
  45052. export var vrDistortionCorrectionPixelShader: {
  45053. name: string;
  45054. shader: string;
  45055. };
  45056. }
  45057. declare module BABYLON {
  45058. /**
  45059. * VRDistortionCorrectionPostProcess used for mobile VR
  45060. */
  45061. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45062. private _isRightEye;
  45063. private _distortionFactors;
  45064. private _postProcessScaleFactor;
  45065. private _lensCenterOffset;
  45066. private _scaleIn;
  45067. private _scaleFactor;
  45068. private _lensCenter;
  45069. /**
  45070. * Initializes the VRDistortionCorrectionPostProcess
  45071. * @param name The name of the effect.
  45072. * @param camera The camera to apply the render pass to.
  45073. * @param isRightEye If this is for the right eye distortion
  45074. * @param vrMetrics All the required metrics for the VR camera
  45075. */
  45076. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45077. }
  45078. }
  45079. declare module BABYLON {
  45080. /**
  45081. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45082. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45083. */
  45084. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45085. /**
  45086. * Creates a new VRDeviceOrientationArcRotateCamera
  45087. * @param name defines camera name
  45088. * @param alpha defines the camera rotation along the logitudinal axis
  45089. * @param beta defines the camera rotation along the latitudinal axis
  45090. * @param radius defines the camera distance from its target
  45091. * @param target defines the camera target
  45092. * @param scene defines the scene the camera belongs to
  45093. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45094. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45095. */
  45096. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45097. /**
  45098. * Gets camera class name
  45099. * @returns VRDeviceOrientationArcRotateCamera
  45100. */
  45101. getClassName(): string;
  45102. }
  45103. }
  45104. declare module BABYLON {
  45105. /**
  45106. * Camera used to simulate VR rendering (based on FreeCamera)
  45107. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45108. */
  45109. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45110. /**
  45111. * Creates a new VRDeviceOrientationFreeCamera
  45112. * @param name defines camera name
  45113. * @param position defines the start position of the camera
  45114. * @param scene defines the scene the camera belongs to
  45115. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45116. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45117. */
  45118. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45119. /**
  45120. * Gets camera class name
  45121. * @returns VRDeviceOrientationFreeCamera
  45122. */
  45123. getClassName(): string;
  45124. }
  45125. }
  45126. declare module BABYLON {
  45127. /**
  45128. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45129. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45130. */
  45131. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45132. /**
  45133. * Creates a new VRDeviceOrientationGamepadCamera
  45134. * @param name defines camera name
  45135. * @param position defines the start position of the camera
  45136. * @param scene defines the scene the camera belongs to
  45137. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45138. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45139. */
  45140. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45141. /**
  45142. * Gets camera class name
  45143. * @returns VRDeviceOrientationGamepadCamera
  45144. */
  45145. getClassName(): string;
  45146. }
  45147. }
  45148. declare module BABYLON {
  45149. /** @hidden */
  45150. export var imageProcessingPixelShader: {
  45151. name: string;
  45152. shader: string;
  45153. };
  45154. }
  45155. declare module BABYLON {
  45156. /**
  45157. * ImageProcessingPostProcess
  45158. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45159. */
  45160. export class ImageProcessingPostProcess extends PostProcess {
  45161. /**
  45162. * Default configuration related to image processing available in the PBR Material.
  45163. */
  45164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45165. /**
  45166. * Gets the image processing configuration used either in this material.
  45167. */
  45168. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45169. /**
  45170. * Sets the Default image processing configuration used either in the this material.
  45171. *
  45172. * If sets to null, the scene one is in use.
  45173. */
  45174. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45175. /**
  45176. * Keep track of the image processing observer to allow dispose and replace.
  45177. */
  45178. private _imageProcessingObserver;
  45179. /**
  45180. * Attaches a new image processing configuration to the PBR Material.
  45181. * @param configuration
  45182. */
  45183. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45184. /**
  45185. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45186. */
  45187. get colorCurves(): Nullable<ColorCurves>;
  45188. /**
  45189. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45190. */
  45191. set colorCurves(value: Nullable<ColorCurves>);
  45192. /**
  45193. * Gets wether the color curves effect is enabled.
  45194. */
  45195. get colorCurvesEnabled(): boolean;
  45196. /**
  45197. * Sets wether the color curves effect is enabled.
  45198. */
  45199. set colorCurvesEnabled(value: boolean);
  45200. /**
  45201. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45202. */
  45203. get colorGradingTexture(): Nullable<BaseTexture>;
  45204. /**
  45205. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45206. */
  45207. set colorGradingTexture(value: Nullable<BaseTexture>);
  45208. /**
  45209. * Gets wether the color grading effect is enabled.
  45210. */
  45211. get colorGradingEnabled(): boolean;
  45212. /**
  45213. * Gets wether the color grading effect is enabled.
  45214. */
  45215. set colorGradingEnabled(value: boolean);
  45216. /**
  45217. * Gets exposure used in the effect.
  45218. */
  45219. get exposure(): number;
  45220. /**
  45221. * Sets exposure used in the effect.
  45222. */
  45223. set exposure(value: number);
  45224. /**
  45225. * Gets wether tonemapping is enabled or not.
  45226. */
  45227. get toneMappingEnabled(): boolean;
  45228. /**
  45229. * Sets wether tonemapping is enabled or not
  45230. */
  45231. set toneMappingEnabled(value: boolean);
  45232. /**
  45233. * Gets the type of tone mapping effect.
  45234. */
  45235. get toneMappingType(): number;
  45236. /**
  45237. * Sets the type of tone mapping effect.
  45238. */
  45239. set toneMappingType(value: number);
  45240. /**
  45241. * Gets contrast used in the effect.
  45242. */
  45243. get contrast(): number;
  45244. /**
  45245. * Sets contrast used in the effect.
  45246. */
  45247. set contrast(value: number);
  45248. /**
  45249. * Gets Vignette stretch size.
  45250. */
  45251. get vignetteStretch(): number;
  45252. /**
  45253. * Sets Vignette stretch size.
  45254. */
  45255. set vignetteStretch(value: number);
  45256. /**
  45257. * Gets Vignette centre X Offset.
  45258. */
  45259. get vignetteCentreX(): number;
  45260. /**
  45261. * Sets Vignette centre X Offset.
  45262. */
  45263. set vignetteCentreX(value: number);
  45264. /**
  45265. * Gets Vignette centre Y Offset.
  45266. */
  45267. get vignetteCentreY(): number;
  45268. /**
  45269. * Sets Vignette centre Y Offset.
  45270. */
  45271. set vignetteCentreY(value: number);
  45272. /**
  45273. * Gets Vignette weight or intensity of the vignette effect.
  45274. */
  45275. get vignetteWeight(): number;
  45276. /**
  45277. * Sets Vignette weight or intensity of the vignette effect.
  45278. */
  45279. set vignetteWeight(value: number);
  45280. /**
  45281. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45282. * if vignetteEnabled is set to true.
  45283. */
  45284. get vignetteColor(): Color4;
  45285. /**
  45286. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45287. * if vignetteEnabled is set to true.
  45288. */
  45289. set vignetteColor(value: Color4);
  45290. /**
  45291. * Gets Camera field of view used by the Vignette effect.
  45292. */
  45293. get vignetteCameraFov(): number;
  45294. /**
  45295. * Sets Camera field of view used by the Vignette effect.
  45296. */
  45297. set vignetteCameraFov(value: number);
  45298. /**
  45299. * Gets the vignette blend mode allowing different kind of effect.
  45300. */
  45301. get vignetteBlendMode(): number;
  45302. /**
  45303. * Sets the vignette blend mode allowing different kind of effect.
  45304. */
  45305. set vignetteBlendMode(value: number);
  45306. /**
  45307. * Gets wether the vignette effect is enabled.
  45308. */
  45309. get vignetteEnabled(): boolean;
  45310. /**
  45311. * Sets wether the vignette effect is enabled.
  45312. */
  45313. set vignetteEnabled(value: boolean);
  45314. private _fromLinearSpace;
  45315. /**
  45316. * Gets wether the input of the processing is in Gamma or Linear Space.
  45317. */
  45318. get fromLinearSpace(): boolean;
  45319. /**
  45320. * Sets wether the input of the processing is in Gamma or Linear Space.
  45321. */
  45322. set fromLinearSpace(value: boolean);
  45323. /**
  45324. * Defines cache preventing GC.
  45325. */
  45326. private _defines;
  45327. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45328. /**
  45329. * "ImageProcessingPostProcess"
  45330. * @returns "ImageProcessingPostProcess"
  45331. */
  45332. getClassName(): string;
  45333. protected _updateParameters(): void;
  45334. dispose(camera?: Camera): void;
  45335. }
  45336. }
  45337. declare module BABYLON {
  45338. /**
  45339. * Class containing static functions to help procedurally build meshes
  45340. */
  45341. export class GroundBuilder {
  45342. /**
  45343. * Creates a ground mesh
  45344. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45345. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45347. * @param name defines the name of the mesh
  45348. * @param options defines the options used to create the mesh
  45349. * @param scene defines the hosting scene
  45350. * @returns the ground mesh
  45351. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45352. */
  45353. static CreateGround(name: string, options: {
  45354. width?: number;
  45355. height?: number;
  45356. subdivisions?: number;
  45357. subdivisionsX?: number;
  45358. subdivisionsY?: number;
  45359. updatable?: boolean;
  45360. }, scene: any): Mesh;
  45361. /**
  45362. * Creates a tiled ground mesh
  45363. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45364. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45365. * * 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
  45366. * * 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
  45367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45368. * @param name defines the name of the mesh
  45369. * @param options defines the options used to create the mesh
  45370. * @param scene defines the hosting scene
  45371. * @returns the tiled ground mesh
  45372. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45373. */
  45374. static CreateTiledGround(name: string, options: {
  45375. xmin: number;
  45376. zmin: number;
  45377. xmax: number;
  45378. zmax: number;
  45379. subdivisions?: {
  45380. w: number;
  45381. h: number;
  45382. };
  45383. precision?: {
  45384. w: number;
  45385. h: number;
  45386. };
  45387. updatable?: boolean;
  45388. }, scene?: Nullable<Scene>): Mesh;
  45389. /**
  45390. * Creates a ground mesh from a height map
  45391. * * The parameter `url` sets the URL of the height map image resource.
  45392. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45393. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45394. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45395. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45396. * * 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.
  45397. * * 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).
  45398. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45400. * @param name defines the name of the mesh
  45401. * @param url defines the url to the height map
  45402. * @param options defines the options used to create the mesh
  45403. * @param scene defines the hosting scene
  45404. * @returns the ground mesh
  45405. * @see https://doc.babylonjs.com/babylon101/height_map
  45406. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45407. */
  45408. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45409. width?: number;
  45410. height?: number;
  45411. subdivisions?: number;
  45412. minHeight?: number;
  45413. maxHeight?: number;
  45414. colorFilter?: Color3;
  45415. alphaFilter?: number;
  45416. updatable?: boolean;
  45417. onReady?: (mesh: GroundMesh) => void;
  45418. }, scene?: Nullable<Scene>): GroundMesh;
  45419. }
  45420. }
  45421. declare module BABYLON {
  45422. /**
  45423. * Class containing static functions to help procedurally build meshes
  45424. */
  45425. export class TorusBuilder {
  45426. /**
  45427. * Creates a torus mesh
  45428. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45429. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45430. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45432. * * 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
  45433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45434. * @param name defines the name of the mesh
  45435. * @param options defines the options used to create the mesh
  45436. * @param scene defines the hosting scene
  45437. * @returns the torus mesh
  45438. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45439. */
  45440. static CreateTorus(name: string, options: {
  45441. diameter?: number;
  45442. thickness?: number;
  45443. tessellation?: number;
  45444. updatable?: boolean;
  45445. sideOrientation?: number;
  45446. frontUVs?: Vector4;
  45447. backUVs?: Vector4;
  45448. }, scene: any): Mesh;
  45449. }
  45450. }
  45451. declare module BABYLON {
  45452. /**
  45453. * Class containing static functions to help procedurally build meshes
  45454. */
  45455. export class CylinderBuilder {
  45456. /**
  45457. * Creates a cylinder or a cone mesh
  45458. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45459. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45460. * * 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.
  45461. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45462. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45463. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45464. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45465. * * 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).
  45466. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45467. * * 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).
  45468. * * 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
  45469. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45470. * * 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
  45471. * * 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.
  45472. * * If `enclose` is false, a ring surface is one element.
  45473. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45474. * * 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
  45475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45476. * * 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
  45477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45478. * @param name defines the name of the mesh
  45479. * @param options defines the options used to create the mesh
  45480. * @param scene defines the hosting scene
  45481. * @returns the cylinder mesh
  45482. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45483. */
  45484. static CreateCylinder(name: string, options: {
  45485. height?: number;
  45486. diameterTop?: number;
  45487. diameterBottom?: number;
  45488. diameter?: number;
  45489. tessellation?: number;
  45490. subdivisions?: number;
  45491. arc?: number;
  45492. faceColors?: Color4[];
  45493. faceUV?: Vector4[];
  45494. updatable?: boolean;
  45495. hasRings?: boolean;
  45496. enclose?: boolean;
  45497. cap?: number;
  45498. sideOrientation?: number;
  45499. frontUVs?: Vector4;
  45500. backUVs?: Vector4;
  45501. }, scene: any): Mesh;
  45502. }
  45503. }
  45504. declare module BABYLON {
  45505. /**
  45506. * States of the webXR experience
  45507. */
  45508. export enum WebXRState {
  45509. /**
  45510. * Transitioning to being in XR mode
  45511. */
  45512. ENTERING_XR = 0,
  45513. /**
  45514. * Transitioning to non XR mode
  45515. */
  45516. EXITING_XR = 1,
  45517. /**
  45518. * In XR mode and presenting
  45519. */
  45520. IN_XR = 2,
  45521. /**
  45522. * Not entered XR mode
  45523. */
  45524. NOT_IN_XR = 3
  45525. }
  45526. /**
  45527. * Abstraction of the XR render target
  45528. */
  45529. export interface WebXRRenderTarget extends IDisposable {
  45530. /**
  45531. * xrpresent context of the canvas which can be used to display/mirror xr content
  45532. */
  45533. canvasContext: WebGLRenderingContext;
  45534. /**
  45535. * xr layer for the canvas
  45536. */
  45537. xrLayer: Nullable<XRWebGLLayer>;
  45538. /**
  45539. * Initializes the xr layer for the session
  45540. * @param xrSession xr session
  45541. * @returns a promise that will resolve once the XR Layer has been created
  45542. */
  45543. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45544. }
  45545. }
  45546. declare module BABYLON {
  45547. /**
  45548. * COnfiguration object for WebXR output canvas
  45549. */
  45550. export class WebXRManagedOutputCanvasOptions {
  45551. /**
  45552. * An optional canvas in case you wish to create it yourself and provide it here.
  45553. * If not provided, a new canvas will be created
  45554. */
  45555. canvasElement?: HTMLCanvasElement;
  45556. /**
  45557. * Options for this XR Layer output
  45558. */
  45559. canvasOptions?: XRWebGLLayerOptions;
  45560. /**
  45561. * CSS styling for a newly created canvas (if not provided)
  45562. */
  45563. newCanvasCssStyle?: string;
  45564. /**
  45565. * Get the default values of the configuration object
  45566. * @returns default values of this configuration object
  45567. */
  45568. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45569. }
  45570. /**
  45571. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45572. */
  45573. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45574. private _options;
  45575. private _canvas;
  45576. private _engine;
  45577. /**
  45578. * Rendering context of the canvas which can be used to display/mirror xr content
  45579. */
  45580. canvasContext: WebGLRenderingContext;
  45581. /**
  45582. * xr layer for the canvas
  45583. */
  45584. xrLayer: Nullable<XRWebGLLayer>;
  45585. /**
  45586. * Initializes the canvas to be added/removed upon entering/exiting xr
  45587. * @param _xrSessionManager The XR Session manager
  45588. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45589. */
  45590. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45591. /**
  45592. * Disposes of the object
  45593. */
  45594. dispose(): void;
  45595. /**
  45596. * Initializes the xr layer for the session
  45597. * @param xrSession xr session
  45598. * @returns a promise that will resolve once the XR Layer has been created
  45599. */
  45600. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45601. private _addCanvas;
  45602. private _removeCanvas;
  45603. private _setManagedOutputCanvas;
  45604. }
  45605. }
  45606. declare module BABYLON {
  45607. /**
  45608. * Manages an XRSession to work with Babylon's engine
  45609. * @see https://doc.babylonjs.com/how_to/webxr
  45610. */
  45611. export class WebXRSessionManager implements IDisposable {
  45612. /** The scene which the session should be created for */
  45613. scene: Scene;
  45614. private _referenceSpace;
  45615. private _rttProvider;
  45616. private _sessionEnded;
  45617. private _xrNavigator;
  45618. private baseLayer;
  45619. /**
  45620. * The base reference space from which the session started. good if you want to reset your
  45621. * reference space
  45622. */
  45623. baseReferenceSpace: XRReferenceSpace;
  45624. /**
  45625. * Current XR frame
  45626. */
  45627. currentFrame: Nullable<XRFrame>;
  45628. /** WebXR timestamp updated every frame */
  45629. currentTimestamp: number;
  45630. /**
  45631. * Used just in case of a failure to initialize an immersive session.
  45632. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45633. */
  45634. defaultHeightCompensation: number;
  45635. /**
  45636. * Fires every time a new xrFrame arrives which can be used to update the camera
  45637. */
  45638. onXRFrameObservable: Observable<XRFrame>;
  45639. /**
  45640. * Fires when the reference space changed
  45641. */
  45642. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45643. /**
  45644. * Fires when the xr session is ended either by the device or manually done
  45645. */
  45646. onXRSessionEnded: Observable<any>;
  45647. /**
  45648. * Fires when the xr session is ended either by the device or manually done
  45649. */
  45650. onXRSessionInit: Observable<XRSession>;
  45651. /**
  45652. * Underlying xr session
  45653. */
  45654. session: XRSession;
  45655. /**
  45656. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45657. * or get the offset the player is currently at.
  45658. */
  45659. viewerReferenceSpace: XRReferenceSpace;
  45660. /**
  45661. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45662. * @param scene The scene which the session should be created for
  45663. */
  45664. constructor(
  45665. /** The scene which the session should be created for */
  45666. scene: Scene);
  45667. /**
  45668. * The current reference space used in this session. This reference space can constantly change!
  45669. * It is mainly used to offset the camera's position.
  45670. */
  45671. get referenceSpace(): XRReferenceSpace;
  45672. /**
  45673. * Set a new reference space and triggers the observable
  45674. */
  45675. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45676. /**
  45677. * Disposes of the session manager
  45678. */
  45679. dispose(): void;
  45680. /**
  45681. * Stops the xrSession and restores the render loop
  45682. * @returns Promise which resolves after it exits XR
  45683. */
  45684. exitXRAsync(): Promise<void>;
  45685. /**
  45686. * Gets the correct render target texture to be rendered this frame for this eye
  45687. * @param eye the eye for which to get the render target
  45688. * @returns the render target for the specified eye
  45689. */
  45690. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45691. /**
  45692. * Creates a WebXRRenderTarget object for the XR session
  45693. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45694. * @param options optional options to provide when creating a new render target
  45695. * @returns a WebXR render target to which the session can render
  45696. */
  45697. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45698. /**
  45699. * Initializes the manager
  45700. * After initialization enterXR can be called to start an XR session
  45701. * @returns Promise which resolves after it is initialized
  45702. */
  45703. initializeAsync(): Promise<void>;
  45704. /**
  45705. * Initializes an xr session
  45706. * @param xrSessionMode mode to initialize
  45707. * @param xrSessionInit defines optional and required values to pass to the session builder
  45708. * @returns a promise which will resolve once the session has been initialized
  45709. */
  45710. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45711. /**
  45712. * Checks if a session would be supported for the creation options specified
  45713. * @param sessionMode session mode to check if supported eg. immersive-vr
  45714. * @returns A Promise that resolves to true if supported and false if not
  45715. */
  45716. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45717. /**
  45718. * Resets the reference space to the one started the session
  45719. */
  45720. resetReferenceSpace(): void;
  45721. /**
  45722. * Starts rendering to the xr layer
  45723. */
  45724. runXRRenderLoop(): void;
  45725. /**
  45726. * Sets the reference space on the xr session
  45727. * @param referenceSpaceType space to set
  45728. * @returns a promise that will resolve once the reference space has been set
  45729. */
  45730. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45731. /**
  45732. * Updates the render state of the session
  45733. * @param state state to set
  45734. * @returns a promise that resolves once the render state has been updated
  45735. */
  45736. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45737. /**
  45738. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45739. * @param sessionMode defines the session to test
  45740. * @returns a promise with boolean as final value
  45741. */
  45742. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45743. private _createRenderTargetTexture;
  45744. }
  45745. }
  45746. declare module BABYLON {
  45747. /**
  45748. * WebXR Camera which holds the views for the xrSession
  45749. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45750. */
  45751. export class WebXRCamera extends FreeCamera {
  45752. private _xrSessionManager;
  45753. private _firstFrame;
  45754. private _referenceQuaternion;
  45755. private _referencedPosition;
  45756. private _xrInvPositionCache;
  45757. private _xrInvQuaternionCache;
  45758. /**
  45759. * Should position compensation execute on first frame.
  45760. * This is used when copying the position from a native (non XR) camera
  45761. */
  45762. compensateOnFirstFrame: boolean;
  45763. /**
  45764. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45765. * @param name the name of the camera
  45766. * @param scene the scene to add the camera to
  45767. * @param _xrSessionManager a constructed xr session manager
  45768. */
  45769. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45770. /**
  45771. * Return the user's height, unrelated to the current ground.
  45772. * This will be the y position of this camera, when ground level is 0.
  45773. */
  45774. get realWorldHeight(): number;
  45775. /** @hidden */
  45776. _updateForDualEyeDebugging(): void;
  45777. /**
  45778. * Sets this camera's transformation based on a non-vr camera
  45779. * @param otherCamera the non-vr camera to copy the transformation from
  45780. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45781. */
  45782. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45783. /**
  45784. * Gets the current instance class name ("WebXRCamera").
  45785. * @returns the class name
  45786. */
  45787. getClassName(): string;
  45788. /**
  45789. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45790. */
  45791. _getViewMatrix(): Matrix;
  45792. private _updateFromXRSession;
  45793. private _updateNumberOfRigCameras;
  45794. private _updateReferenceSpace;
  45795. private _updateReferenceSpaceOffset;
  45796. }
  45797. }
  45798. declare module BABYLON {
  45799. /**
  45800. * Defining the interface required for a (webxr) feature
  45801. */
  45802. export interface IWebXRFeature extends IDisposable {
  45803. /**
  45804. * Is this feature attached
  45805. */
  45806. attached: boolean;
  45807. /**
  45808. * Should auto-attach be disabled?
  45809. */
  45810. disableAutoAttach: boolean;
  45811. /**
  45812. * Attach the feature to the session
  45813. * Will usually be called by the features manager
  45814. *
  45815. * @param force should attachment be forced (even when already attached)
  45816. * @returns true if successful.
  45817. */
  45818. attach(force?: boolean): boolean;
  45819. /**
  45820. * Detach the feature from the session
  45821. * Will usually be called by the features manager
  45822. *
  45823. * @returns true if successful.
  45824. */
  45825. detach(): boolean;
  45826. }
  45827. /**
  45828. * A list of the currently available features without referencing them
  45829. */
  45830. export class WebXRFeatureName {
  45831. /**
  45832. * The name of the anchor system feature
  45833. */
  45834. static ANCHOR_SYSTEM: string;
  45835. /**
  45836. * The name of the background remover feature
  45837. */
  45838. static BACKGROUND_REMOVER: string;
  45839. /**
  45840. * The name of the hit test feature
  45841. */
  45842. static HIT_TEST: string;
  45843. /**
  45844. * physics impostors for xr controllers feature
  45845. */
  45846. static PHYSICS_CONTROLLERS: string;
  45847. /**
  45848. * The name of the plane detection feature
  45849. */
  45850. static PLANE_DETECTION: string;
  45851. /**
  45852. * The name of the pointer selection feature
  45853. */
  45854. static POINTER_SELECTION: string;
  45855. /**
  45856. * The name of the teleportation feature
  45857. */
  45858. static TELEPORTATION: string;
  45859. }
  45860. /**
  45861. * Defining the constructor of a feature. Used to register the modules.
  45862. */
  45863. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45864. /**
  45865. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45866. * It is mainly used in AR sessions.
  45867. *
  45868. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45869. */
  45870. export class WebXRFeaturesManager implements IDisposable {
  45871. private _xrSessionManager;
  45872. private static readonly _AvailableFeatures;
  45873. private _features;
  45874. /**
  45875. * constructs a new features manages.
  45876. *
  45877. * @param _xrSessionManager an instance of WebXRSessionManager
  45878. */
  45879. constructor(_xrSessionManager: WebXRSessionManager);
  45880. /**
  45881. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45882. * Mainly used internally.
  45883. *
  45884. * @param featureName the name of the feature to register
  45885. * @param constructorFunction the function used to construct the module
  45886. * @param version the (babylon) version of the module
  45887. * @param stable is that a stable version of this module
  45888. */
  45889. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45890. /**
  45891. * Returns a constructor of a specific feature.
  45892. *
  45893. * @param featureName the name of the feature to construct
  45894. * @param version the version of the feature to load
  45895. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45896. * @param options optional options provided to the module.
  45897. * @returns a function that, when called, will return a new instance of this feature
  45898. */
  45899. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45900. /**
  45901. * Can be used to return the list of features currently registered
  45902. *
  45903. * @returns an Array of available features
  45904. */
  45905. static GetAvailableFeatures(): string[];
  45906. /**
  45907. * Gets the versions available for a specific feature
  45908. * @param featureName the name of the feature
  45909. * @returns an array with the available versions
  45910. */
  45911. static GetAvailableVersions(featureName: string): string[];
  45912. /**
  45913. * Return the latest unstable version of this feature
  45914. * @param featureName the name of the feature to search
  45915. * @returns the version number. if not found will return -1
  45916. */
  45917. static GetLatestVersionOfFeature(featureName: string): number;
  45918. /**
  45919. * Return the latest stable version of this feature
  45920. * @param featureName the name of the feature to search
  45921. * @returns the version number. if not found will return -1
  45922. */
  45923. static GetStableVersionOfFeature(featureName: string): number;
  45924. /**
  45925. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45926. * Can be used during a session to start a feature
  45927. * @param featureName the name of feature to attach
  45928. */
  45929. attachFeature(featureName: string): void;
  45930. /**
  45931. * Can be used inside a session or when the session ends to detach a specific feature
  45932. * @param featureName the name of the feature to detach
  45933. */
  45934. detachFeature(featureName: string): void;
  45935. /**
  45936. * Used to disable an already-enabled feature
  45937. * The feature will be disposed and will be recreated once enabled.
  45938. * @param featureName the feature to disable
  45939. * @returns true if disable was successful
  45940. */
  45941. disableFeature(featureName: string | {
  45942. Name: string;
  45943. }): boolean;
  45944. /**
  45945. * dispose this features manager
  45946. */
  45947. dispose(): void;
  45948. /**
  45949. * 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.
  45950. * 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.
  45951. *
  45952. * @param featureName the name of the feature to load or the class of the feature
  45953. * @param version optional version to load. if not provided the latest version will be enabled
  45954. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  45955. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  45956. * @returns a new constructed feature or throws an error if feature not found.
  45957. */
  45958. enableFeature(featureName: string | {
  45959. Name: string;
  45960. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  45961. /**
  45962. * get the implementation of an enabled feature.
  45963. * @param featureName the name of the feature to load
  45964. * @returns the feature class, if found
  45965. */
  45966. getEnabledFeature(featureName: string): IWebXRFeature;
  45967. /**
  45968. * Get the list of enabled features
  45969. * @returns an array of enabled features
  45970. */
  45971. getEnabledFeatures(): string[];
  45972. }
  45973. }
  45974. declare module BABYLON {
  45975. /**
  45976. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  45977. * @see https://doc.babylonjs.com/how_to/webxr
  45978. */
  45979. export class WebXRExperienceHelper implements IDisposable {
  45980. private scene;
  45981. private _nonVRCamera;
  45982. private _originalSceneAutoClear;
  45983. private _supported;
  45984. /**
  45985. * Camera used to render xr content
  45986. */
  45987. camera: WebXRCamera;
  45988. /** A features manager for this xr session */
  45989. featuresManager: WebXRFeaturesManager;
  45990. /**
  45991. * Observers registered here will be triggered after the camera's initial transformation is set
  45992. * This can be used to set a different ground level or an extra rotation.
  45993. *
  45994. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  45995. * to the position set after this observable is done executing.
  45996. */
  45997. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  45998. /**
  45999. * Fires when the state of the experience helper has changed
  46000. */
  46001. onStateChangedObservable: Observable<WebXRState>;
  46002. /** Session manager used to keep track of xr session */
  46003. sessionManager: WebXRSessionManager;
  46004. /**
  46005. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46006. */
  46007. state: WebXRState;
  46008. /**
  46009. * Creates a WebXRExperienceHelper
  46010. * @param scene The scene the helper should be created in
  46011. */
  46012. private constructor();
  46013. /**
  46014. * Creates the experience helper
  46015. * @param scene the scene to attach the experience helper to
  46016. * @returns a promise for the experience helper
  46017. */
  46018. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46019. /**
  46020. * Disposes of the experience helper
  46021. */
  46022. dispose(): void;
  46023. /**
  46024. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46025. * @param sessionMode options for the XR session
  46026. * @param referenceSpaceType frame of reference of the XR session
  46027. * @param renderTarget the output canvas that will be used to enter XR mode
  46028. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46029. * @returns promise that resolves after xr mode has entered
  46030. */
  46031. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46032. /**
  46033. * Exits XR mode and returns the scene to its original state
  46034. * @returns promise that resolves after xr mode has exited
  46035. */
  46036. exitXRAsync(): Promise<void>;
  46037. private _nonXRToXRCamera;
  46038. private _setState;
  46039. }
  46040. }
  46041. declare module BABYLON {
  46042. /**
  46043. * X-Y values for axes in WebXR
  46044. */
  46045. export interface IWebXRMotionControllerAxesValue {
  46046. /**
  46047. * The value of the x axis
  46048. */
  46049. x: number;
  46050. /**
  46051. * The value of the y-axis
  46052. */
  46053. y: number;
  46054. }
  46055. /**
  46056. * changed / previous values for the values of this component
  46057. */
  46058. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46059. /**
  46060. * current (this frame) value
  46061. */
  46062. current: T;
  46063. /**
  46064. * previous (last change) value
  46065. */
  46066. previous: T;
  46067. }
  46068. /**
  46069. * Represents changes in the component between current frame and last values recorded
  46070. */
  46071. export interface IWebXRMotionControllerComponentChanges {
  46072. /**
  46073. * will be populated with previous and current values if axes changed
  46074. */
  46075. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46076. /**
  46077. * will be populated with previous and current values if pressed changed
  46078. */
  46079. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46080. /**
  46081. * will be populated with previous and current values if touched changed
  46082. */
  46083. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46084. /**
  46085. * will be populated with previous and current values if value changed
  46086. */
  46087. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46088. }
  46089. /**
  46090. * This class represents a single component (for example button or thumbstick) of a motion controller
  46091. */
  46092. export class WebXRControllerComponent implements IDisposable {
  46093. /**
  46094. * the id of this component
  46095. */
  46096. id: string;
  46097. /**
  46098. * the type of the component
  46099. */
  46100. type: MotionControllerComponentType;
  46101. private _buttonIndex;
  46102. private _axesIndices;
  46103. private _axes;
  46104. private _changes;
  46105. private _currentValue;
  46106. private _hasChanges;
  46107. private _pressed;
  46108. private _touched;
  46109. /**
  46110. * button component type
  46111. */
  46112. static BUTTON_TYPE: MotionControllerComponentType;
  46113. /**
  46114. * squeeze component type
  46115. */
  46116. static SQUEEZE_TYPE: MotionControllerComponentType;
  46117. /**
  46118. * Thumbstick component type
  46119. */
  46120. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46121. /**
  46122. * Touchpad component type
  46123. */
  46124. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46125. /**
  46126. * trigger component type
  46127. */
  46128. static TRIGGER_TYPE: MotionControllerComponentType;
  46129. /**
  46130. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46131. * the axes data changes
  46132. */
  46133. onAxisValueChangedObservable: Observable<{
  46134. x: number;
  46135. y: number;
  46136. }>;
  46137. /**
  46138. * Observers registered here will be triggered when the state of a button changes
  46139. * State change is either pressed / touched / value
  46140. */
  46141. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46142. /**
  46143. * Creates a new component for a motion controller.
  46144. * It is created by the motion controller itself
  46145. *
  46146. * @param id the id of this component
  46147. * @param type the type of the component
  46148. * @param _buttonIndex index in the buttons array of the gamepad
  46149. * @param _axesIndices indices of the values in the axes array of the gamepad
  46150. */
  46151. constructor(
  46152. /**
  46153. * the id of this component
  46154. */
  46155. id: string,
  46156. /**
  46157. * the type of the component
  46158. */
  46159. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46160. /**
  46161. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46162. */
  46163. get axes(): IWebXRMotionControllerAxesValue;
  46164. /**
  46165. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46166. */
  46167. get changes(): IWebXRMotionControllerComponentChanges;
  46168. /**
  46169. * Return whether or not the component changed the last frame
  46170. */
  46171. get hasChanges(): boolean;
  46172. /**
  46173. * is the button currently pressed
  46174. */
  46175. get pressed(): boolean;
  46176. /**
  46177. * is the button currently touched
  46178. */
  46179. get touched(): boolean;
  46180. /**
  46181. * Get the current value of this component
  46182. */
  46183. get value(): number;
  46184. /**
  46185. * Dispose this component
  46186. */
  46187. dispose(): void;
  46188. /**
  46189. * Are there axes correlating to this component
  46190. * @return true is axes data is available
  46191. */
  46192. isAxes(): boolean;
  46193. /**
  46194. * Is this component a button (hence - pressable)
  46195. * @returns true if can be pressed
  46196. */
  46197. isButton(): boolean;
  46198. /**
  46199. * update this component using the gamepad object it is in. Called on every frame
  46200. * @param nativeController the native gamepad controller object
  46201. */
  46202. update(nativeController: IMinimalMotionControllerObject): void;
  46203. }
  46204. }
  46205. declare module BABYLON {
  46206. /**
  46207. * Class used to represent data loading progression
  46208. */
  46209. export class SceneLoaderProgressEvent {
  46210. /** defines if data length to load can be evaluated */
  46211. readonly lengthComputable: boolean;
  46212. /** defines the loaded data length */
  46213. readonly loaded: number;
  46214. /** defines the data length to load */
  46215. readonly total: number;
  46216. /**
  46217. * Create a new progress event
  46218. * @param lengthComputable defines if data length to load can be evaluated
  46219. * @param loaded defines the loaded data length
  46220. * @param total defines the data length to load
  46221. */
  46222. constructor(
  46223. /** defines if data length to load can be evaluated */
  46224. lengthComputable: boolean,
  46225. /** defines the loaded data length */
  46226. loaded: number,
  46227. /** defines the data length to load */
  46228. total: number);
  46229. /**
  46230. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46231. * @param event defines the source event
  46232. * @returns a new SceneLoaderProgressEvent
  46233. */
  46234. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46235. }
  46236. /**
  46237. * Interface used by SceneLoader plugins to define supported file extensions
  46238. */
  46239. export interface ISceneLoaderPluginExtensions {
  46240. /**
  46241. * Defines the list of supported extensions
  46242. */
  46243. [extension: string]: {
  46244. isBinary: boolean;
  46245. };
  46246. }
  46247. /**
  46248. * Interface used by SceneLoader plugin factory
  46249. */
  46250. export interface ISceneLoaderPluginFactory {
  46251. /**
  46252. * Defines the name of the factory
  46253. */
  46254. name: string;
  46255. /**
  46256. * Function called to create a new plugin
  46257. * @return the new plugin
  46258. */
  46259. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46260. /**
  46261. * The callback that returns true if the data can be directly loaded.
  46262. * @param data string containing the file data
  46263. * @returns if the data can be loaded directly
  46264. */
  46265. canDirectLoad?(data: string): boolean;
  46266. }
  46267. /**
  46268. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46269. */
  46270. export interface ISceneLoaderPluginBase {
  46271. /**
  46272. * The friendly name of this plugin.
  46273. */
  46274. name: string;
  46275. /**
  46276. * The file extensions supported by this plugin.
  46277. */
  46278. extensions: string | ISceneLoaderPluginExtensions;
  46279. /**
  46280. * The callback called when loading from a url.
  46281. * @param scene scene loading this url
  46282. * @param url url to load
  46283. * @param onSuccess callback called when the file successfully loads
  46284. * @param onProgress callback called while file is loading (if the server supports this mode)
  46285. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46286. * @param onError callback called when the file fails to load
  46287. * @returns a file request object
  46288. */
  46289. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46290. /**
  46291. * The callback called when loading from a file object.
  46292. * @param scene scene loading this file
  46293. * @param file defines the file to load
  46294. * @param onSuccess defines the callback to call when data is loaded
  46295. * @param onProgress defines the callback to call during loading process
  46296. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46297. * @param onError defines the callback to call when an error occurs
  46298. * @returns a file request object
  46299. */
  46300. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46301. /**
  46302. * The callback that returns true if the data can be directly loaded.
  46303. * @param data string containing the file data
  46304. * @returns if the data can be loaded directly
  46305. */
  46306. canDirectLoad?(data: string): boolean;
  46307. /**
  46308. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46309. * @param scene scene loading this data
  46310. * @param data string containing the data
  46311. * @returns data to pass to the plugin
  46312. */
  46313. directLoad?(scene: Scene, data: string): any;
  46314. /**
  46315. * The callback that allows custom handling of the root url based on the response url.
  46316. * @param rootUrl the original root url
  46317. * @param responseURL the response url if available
  46318. * @returns the new root url
  46319. */
  46320. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46321. }
  46322. /**
  46323. * Interface used to define a SceneLoader plugin
  46324. */
  46325. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46326. /**
  46327. * Import meshes into a scene.
  46328. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46329. * @param scene The scene to import into
  46330. * @param data The data to import
  46331. * @param rootUrl The root url for scene and resources
  46332. * @param meshes The meshes array to import into
  46333. * @param particleSystems The particle systems array to import into
  46334. * @param skeletons The skeletons array to import into
  46335. * @param onError The callback when import fails
  46336. * @returns True if successful or false otherwise
  46337. */
  46338. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46339. /**
  46340. * Load into a scene.
  46341. * @param scene The scene to load into
  46342. * @param data The data to import
  46343. * @param rootUrl The root url for scene and resources
  46344. * @param onError The callback when import fails
  46345. * @returns True if successful or false otherwise
  46346. */
  46347. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46348. /**
  46349. * Load into an asset container.
  46350. * @param scene The scene to load into
  46351. * @param data The data to import
  46352. * @param rootUrl The root url for scene and resources
  46353. * @param onError The callback when import fails
  46354. * @returns The loaded asset container
  46355. */
  46356. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46357. }
  46358. /**
  46359. * Interface used to define an async SceneLoader plugin
  46360. */
  46361. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46362. /**
  46363. * Import meshes into a scene.
  46364. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46365. * @param scene The scene to import into
  46366. * @param data The data to import
  46367. * @param rootUrl The root url for scene and resources
  46368. * @param onProgress The callback when the load progresses
  46369. * @param fileName Defines the name of the file to load
  46370. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46371. */
  46372. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46373. meshes: AbstractMesh[];
  46374. particleSystems: IParticleSystem[];
  46375. skeletons: Skeleton[];
  46376. animationGroups: AnimationGroup[];
  46377. }>;
  46378. /**
  46379. * Load into a scene.
  46380. * @param scene The scene to load into
  46381. * @param data The data to import
  46382. * @param rootUrl The root url for scene and resources
  46383. * @param onProgress The callback when the load progresses
  46384. * @param fileName Defines the name of the file to load
  46385. * @returns Nothing
  46386. */
  46387. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46388. /**
  46389. * Load into an asset container.
  46390. * @param scene The scene to load into
  46391. * @param data The data to import
  46392. * @param rootUrl The root url for scene and resources
  46393. * @param onProgress The callback when the load progresses
  46394. * @param fileName Defines the name of the file to load
  46395. * @returns The loaded asset container
  46396. */
  46397. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46398. }
  46399. /**
  46400. * Mode that determines how to handle old animation groups before loading new ones.
  46401. */
  46402. export enum SceneLoaderAnimationGroupLoadingMode {
  46403. /**
  46404. * Reset all old animations to initial state then dispose them.
  46405. */
  46406. Clean = 0,
  46407. /**
  46408. * Stop all old animations.
  46409. */
  46410. Stop = 1,
  46411. /**
  46412. * Restart old animations from first frame.
  46413. */
  46414. Sync = 2,
  46415. /**
  46416. * Old animations remains untouched.
  46417. */
  46418. NoSync = 3
  46419. }
  46420. /**
  46421. * Class used to load scene from various file formats using registered plugins
  46422. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46423. */
  46424. export class SceneLoader {
  46425. /**
  46426. * No logging while loading
  46427. */
  46428. static readonly NO_LOGGING: number;
  46429. /**
  46430. * Minimal logging while loading
  46431. */
  46432. static readonly MINIMAL_LOGGING: number;
  46433. /**
  46434. * Summary logging while loading
  46435. */
  46436. static readonly SUMMARY_LOGGING: number;
  46437. /**
  46438. * Detailled logging while loading
  46439. */
  46440. static readonly DETAILED_LOGGING: number;
  46441. /**
  46442. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46443. */
  46444. static get ForceFullSceneLoadingForIncremental(): boolean;
  46445. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46446. /**
  46447. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46448. */
  46449. static get ShowLoadingScreen(): boolean;
  46450. static set ShowLoadingScreen(value: boolean);
  46451. /**
  46452. * Defines the current logging level (while loading the scene)
  46453. * @ignorenaming
  46454. */
  46455. static get loggingLevel(): number;
  46456. static set loggingLevel(value: number);
  46457. /**
  46458. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46459. */
  46460. static get CleanBoneMatrixWeights(): boolean;
  46461. static set CleanBoneMatrixWeights(value: boolean);
  46462. /**
  46463. * Event raised when a plugin is used to load a scene
  46464. */
  46465. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46466. private static _registeredPlugins;
  46467. private static _getDefaultPlugin;
  46468. private static _getPluginForExtension;
  46469. private static _getPluginForDirectLoad;
  46470. private static _getPluginForFilename;
  46471. private static _getDirectLoad;
  46472. private static _loadData;
  46473. private static _getFileInfo;
  46474. /**
  46475. * Gets a plugin that can load the given extension
  46476. * @param extension defines the extension to load
  46477. * @returns a plugin or null if none works
  46478. */
  46479. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46480. /**
  46481. * Gets a boolean indicating that the given extension can be loaded
  46482. * @param extension defines the extension to load
  46483. * @returns true if the extension is supported
  46484. */
  46485. static IsPluginForExtensionAvailable(extension: string): boolean;
  46486. /**
  46487. * Adds a new plugin to the list of registered plugins
  46488. * @param plugin defines the plugin to add
  46489. */
  46490. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46491. /**
  46492. * Import meshes into a scene
  46493. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46494. * @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)
  46495. * @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)
  46496. * @param scene the instance of BABYLON.Scene to append to
  46497. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46498. * @param onProgress a callback with a progress event for each file being loaded
  46499. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46500. * @param pluginExtension the extension used to determine the plugin
  46501. * @returns The loaded plugin
  46502. */
  46503. 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>;
  46504. /**
  46505. * Import meshes into a scene
  46506. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46507. * @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)
  46508. * @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)
  46509. * @param scene the instance of BABYLON.Scene to append to
  46510. * @param onProgress a callback with a progress event for each file being loaded
  46511. * @param pluginExtension the extension used to determine the plugin
  46512. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46513. */
  46514. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46515. meshes: AbstractMesh[];
  46516. particleSystems: IParticleSystem[];
  46517. skeletons: Skeleton[];
  46518. animationGroups: AnimationGroup[];
  46519. }>;
  46520. /**
  46521. * Load a scene
  46522. * @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)
  46523. * @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)
  46524. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46525. * @param onSuccess a callback with the scene when import succeeds
  46526. * @param onProgress a callback with a progress event for each file being loaded
  46527. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46528. * @param pluginExtension the extension used to determine the plugin
  46529. * @returns The loaded plugin
  46530. */
  46531. 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>;
  46532. /**
  46533. * Load a scene
  46534. * @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)
  46535. * @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)
  46536. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46537. * @param onProgress a callback with a progress event for each file being loaded
  46538. * @param pluginExtension the extension used to determine the plugin
  46539. * @returns The loaded scene
  46540. */
  46541. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46542. /**
  46543. * Append a scene
  46544. * @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)
  46545. * @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)
  46546. * @param scene is the instance of BABYLON.Scene to append to
  46547. * @param onSuccess a callback with the scene when import succeeds
  46548. * @param onProgress a callback with a progress event for each file being loaded
  46549. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46550. * @param pluginExtension the extension used to determine the plugin
  46551. * @returns The loaded plugin
  46552. */
  46553. 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>;
  46554. /**
  46555. * Append a scene
  46556. * @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)
  46557. * @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)
  46558. * @param scene is the instance of BABYLON.Scene to append to
  46559. * @param onProgress a callback with a progress event for each file being loaded
  46560. * @param pluginExtension the extension used to determine the plugin
  46561. * @returns The given scene
  46562. */
  46563. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46564. /**
  46565. * Load a scene into an asset container
  46566. * @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)
  46567. * @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)
  46568. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46569. * @param onSuccess a callback with the scene when import succeeds
  46570. * @param onProgress a callback with a progress event for each file being loaded
  46571. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46572. * @param pluginExtension the extension used to determine the plugin
  46573. * @returns The loaded plugin
  46574. */
  46575. 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>;
  46576. /**
  46577. * Load a scene into an asset container
  46578. * @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)
  46579. * @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)
  46580. * @param scene is the instance of Scene to append to
  46581. * @param onProgress a callback with a progress event for each file being loaded
  46582. * @param pluginExtension the extension used to determine the plugin
  46583. * @returns The loaded asset container
  46584. */
  46585. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46586. /**
  46587. * Import animations from a file into a scene
  46588. * @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)
  46589. * @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)
  46590. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46591. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46592. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46593. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46594. * @param onSuccess a callback with the scene when import succeeds
  46595. * @param onProgress a callback with a progress event for each file being loaded
  46596. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46597. */
  46598. 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;
  46599. /**
  46600. * Import animations from a file into a scene
  46601. * @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)
  46602. * @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)
  46603. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46604. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46605. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46606. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46607. * @param onSuccess a callback with the scene when import succeeds
  46608. * @param onProgress a callback with a progress event for each file being loaded
  46609. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46610. * @returns the updated scene with imported animations
  46611. */
  46612. 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>;
  46613. }
  46614. }
  46615. declare module BABYLON {
  46616. /**
  46617. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46618. */
  46619. export type MotionControllerHandedness = "none" | "left" | "right";
  46620. /**
  46621. * The type of components available in motion controllers.
  46622. * This is not the name of the component.
  46623. */
  46624. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46625. /**
  46626. * The state of a controller component
  46627. */
  46628. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46629. /**
  46630. * The schema of motion controller layout.
  46631. * No object will be initialized using this interface
  46632. * This is used just to define the profile.
  46633. */
  46634. export interface IMotionControllerLayout {
  46635. /**
  46636. * Path to load the assets. Usually relative to the base path
  46637. */
  46638. assetPath: string;
  46639. /**
  46640. * Available components (unsorted)
  46641. */
  46642. components: {
  46643. /**
  46644. * A map of component Ids
  46645. */
  46646. [componentId: string]: {
  46647. /**
  46648. * The type of input the component outputs
  46649. */
  46650. type: MotionControllerComponentType;
  46651. /**
  46652. * The indices of this component in the gamepad object
  46653. */
  46654. gamepadIndices: {
  46655. /**
  46656. * Index of button
  46657. */
  46658. button?: number;
  46659. /**
  46660. * If available, index of x-axis
  46661. */
  46662. xAxis?: number;
  46663. /**
  46664. * If available, index of y-axis
  46665. */
  46666. yAxis?: number;
  46667. };
  46668. /**
  46669. * The mesh's root node name
  46670. */
  46671. rootNodeName: string;
  46672. /**
  46673. * Animation definitions for this model
  46674. */
  46675. visualResponses: {
  46676. [stateKey: string]: {
  46677. /**
  46678. * What property will be animated
  46679. */
  46680. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46681. /**
  46682. * What states influence this visual response
  46683. */
  46684. states: MotionControllerComponentStateType[];
  46685. /**
  46686. * Type of animation - movement or visibility
  46687. */
  46688. valueNodeProperty: "transform" | "visibility";
  46689. /**
  46690. * Base node name to move. Its position will be calculated according to the min and max nodes
  46691. */
  46692. valueNodeName?: string;
  46693. /**
  46694. * Minimum movement node
  46695. */
  46696. minNodeName?: string;
  46697. /**
  46698. * Max movement node
  46699. */
  46700. maxNodeName?: string;
  46701. };
  46702. };
  46703. /**
  46704. * If touch enabled, what is the name of node to display user feedback
  46705. */
  46706. touchPointNodeName?: string;
  46707. };
  46708. };
  46709. /**
  46710. * Is it xr standard mapping or not
  46711. */
  46712. gamepadMapping: "" | "xr-standard";
  46713. /**
  46714. * Base root node of this entire model
  46715. */
  46716. rootNodeName: string;
  46717. /**
  46718. * Defines the main button component id
  46719. */
  46720. selectComponentId: string;
  46721. }
  46722. /**
  46723. * A definition for the layout map in the input profile
  46724. */
  46725. export interface IMotionControllerLayoutMap {
  46726. /**
  46727. * Layouts with handedness type as a key
  46728. */
  46729. [handedness: string]: IMotionControllerLayout;
  46730. }
  46731. /**
  46732. * The XR Input profile schema
  46733. * Profiles can be found here:
  46734. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46735. */
  46736. export interface IMotionControllerProfile {
  46737. /**
  46738. * fallback profiles for this profileId
  46739. */
  46740. fallbackProfileIds: string[];
  46741. /**
  46742. * The layout map, with handedness as key
  46743. */
  46744. layouts: IMotionControllerLayoutMap;
  46745. /**
  46746. * The id of this profile
  46747. * correlates to the profile(s) in the xrInput.profiles array
  46748. */
  46749. profileId: string;
  46750. }
  46751. /**
  46752. * A helper-interface for the 3 meshes needed for controller button animation
  46753. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46754. */
  46755. export interface IMotionControllerButtonMeshMap {
  46756. /**
  46757. * the mesh that defines the pressed value mesh position.
  46758. * This is used to find the max-position of this button
  46759. */
  46760. pressedMesh: AbstractMesh;
  46761. /**
  46762. * the mesh that defines the unpressed value mesh position.
  46763. * This is used to find the min (or initial) position of this button
  46764. */
  46765. unpressedMesh: AbstractMesh;
  46766. /**
  46767. * The mesh that will be changed when value changes
  46768. */
  46769. valueMesh: AbstractMesh;
  46770. }
  46771. /**
  46772. * A helper-interface for the 3 meshes needed for controller axis animation.
  46773. * This will be expanded when touchpad animations are fully supported
  46774. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46775. */
  46776. export interface IMotionControllerMeshMap {
  46777. /**
  46778. * the mesh that defines the maximum value mesh position.
  46779. */
  46780. maxMesh?: AbstractMesh;
  46781. /**
  46782. * the mesh that defines the minimum value mesh position.
  46783. */
  46784. minMesh?: AbstractMesh;
  46785. /**
  46786. * The mesh that will be changed when axis value changes
  46787. */
  46788. valueMesh: AbstractMesh;
  46789. }
  46790. /**
  46791. * The elements needed for change-detection of the gamepad objects in motion controllers
  46792. */
  46793. export interface IMinimalMotionControllerObject {
  46794. /**
  46795. * Available axes of this controller
  46796. */
  46797. axes: number[];
  46798. /**
  46799. * An array of available buttons
  46800. */
  46801. buttons: Array<{
  46802. /**
  46803. * Value of the button/trigger
  46804. */
  46805. value: number;
  46806. /**
  46807. * If the button/trigger is currently touched
  46808. */
  46809. touched: boolean;
  46810. /**
  46811. * If the button/trigger is currently pressed
  46812. */
  46813. pressed: boolean;
  46814. }>;
  46815. /**
  46816. * EXPERIMENTAL haptic support.
  46817. */
  46818. hapticActuators?: Array<{
  46819. pulse: (value: number, duration: number) => Promise<boolean>;
  46820. }>;
  46821. }
  46822. /**
  46823. * An Abstract Motion controller
  46824. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46825. * Each component has an observable to check for changes in value and state
  46826. */
  46827. export abstract class WebXRAbstractMotionController implements IDisposable {
  46828. protected scene: Scene;
  46829. protected layout: IMotionControllerLayout;
  46830. /**
  46831. * The gamepad object correlating to this controller
  46832. */
  46833. gamepadObject: IMinimalMotionControllerObject;
  46834. /**
  46835. * handedness (left/right/none) of this controller
  46836. */
  46837. handedness: MotionControllerHandedness;
  46838. private _initComponent;
  46839. private _modelReady;
  46840. /**
  46841. * A map of components (WebXRControllerComponent) in this motion controller
  46842. * Components have a ComponentType and can also have both button and axis definitions
  46843. */
  46844. readonly components: {
  46845. [id: string]: WebXRControllerComponent;
  46846. };
  46847. /**
  46848. * Disable the model's animation. Can be set at any time.
  46849. */
  46850. disableAnimation: boolean;
  46851. /**
  46852. * Observers registered here will be triggered when the model of this controller is done loading
  46853. */
  46854. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46855. /**
  46856. * The profile id of this motion controller
  46857. */
  46858. abstract profileId: string;
  46859. /**
  46860. * The root mesh of the model. It is null if the model was not yet initialized
  46861. */
  46862. rootMesh: Nullable<AbstractMesh>;
  46863. /**
  46864. * constructs a new abstract motion controller
  46865. * @param scene the scene to which the model of the controller will be added
  46866. * @param layout The profile layout to load
  46867. * @param gamepadObject The gamepad object correlating to this controller
  46868. * @param handedness handedness (left/right/none) of this controller
  46869. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46870. */
  46871. constructor(scene: Scene, layout: IMotionControllerLayout,
  46872. /**
  46873. * The gamepad object correlating to this controller
  46874. */
  46875. gamepadObject: IMinimalMotionControllerObject,
  46876. /**
  46877. * handedness (left/right/none) of this controller
  46878. */
  46879. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46880. /**
  46881. * Dispose this controller, the model mesh and all its components
  46882. */
  46883. dispose(): void;
  46884. /**
  46885. * Returns all components of specific type
  46886. * @param type the type to search for
  46887. * @return an array of components with this type
  46888. */
  46889. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46890. /**
  46891. * get a component based an its component id as defined in layout.components
  46892. * @param id the id of the component
  46893. * @returns the component correlates to the id or undefined if not found
  46894. */
  46895. getComponent(id: string): WebXRControllerComponent;
  46896. /**
  46897. * Get the list of components available in this motion controller
  46898. * @returns an array of strings correlating to available components
  46899. */
  46900. getComponentIds(): string[];
  46901. /**
  46902. * Get the first component of specific type
  46903. * @param type type of component to find
  46904. * @return a controller component or null if not found
  46905. */
  46906. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46907. /**
  46908. * Get the main (Select) component of this controller as defined in the layout
  46909. * @returns the main component of this controller
  46910. */
  46911. getMainComponent(): WebXRControllerComponent;
  46912. /**
  46913. * Loads the model correlating to this controller
  46914. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46915. * @returns A promise fulfilled with the result of the model loading
  46916. */
  46917. loadModel(): Promise<boolean>;
  46918. /**
  46919. * Update this model using the current XRFrame
  46920. * @param xrFrame the current xr frame to use and update the model
  46921. */
  46922. updateFromXRFrame(xrFrame: XRFrame): void;
  46923. /**
  46924. * Backwards compatibility due to a deeply-integrated typo
  46925. */
  46926. get handness(): XREye;
  46927. /**
  46928. * Pulse (vibrate) this controller
  46929. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46930. * Consecutive calls to this function will cancel the last pulse call
  46931. *
  46932. * @param value the strength of the pulse in 0.0...1.0 range
  46933. * @param duration Duration of the pulse in milliseconds
  46934. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46935. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  46936. */
  46937. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46938. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46939. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46940. /**
  46941. * Moves the axis on the controller mesh based on its current state
  46942. * @param axis the index of the axis
  46943. * @param axisValue the value of the axis which determines the meshes new position
  46944. * @hidden
  46945. */
  46946. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  46947. /**
  46948. * Update the model itself with the current frame data
  46949. * @param xrFrame the frame to use for updating the model mesh
  46950. */
  46951. protected updateModel(xrFrame: XRFrame): void;
  46952. /**
  46953. * Get the filename and path for this controller's model
  46954. * @returns a map of filename and path
  46955. */
  46956. protected abstract _getFilenameAndPath(): {
  46957. filename: string;
  46958. path: string;
  46959. };
  46960. /**
  46961. * This function is called before the mesh is loaded. It checks for loading constraints.
  46962. * For example, this function can check if the GLB loader is available
  46963. * If this function returns false, the generic controller will be loaded instead
  46964. * @returns Is the client ready to load the mesh
  46965. */
  46966. protected abstract _getModelLoadingConstraints(): boolean;
  46967. /**
  46968. * This function will be called after the model was successfully loaded and can be used
  46969. * for mesh transformations before it is available for the user
  46970. * @param meshes the loaded meshes
  46971. */
  46972. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  46973. /**
  46974. * Set the root mesh for this controller. Important for the WebXR controller class
  46975. * @param meshes the loaded meshes
  46976. */
  46977. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  46978. /**
  46979. * A function executed each frame that updates the mesh (if needed)
  46980. * @param xrFrame the current xrFrame
  46981. */
  46982. protected abstract _updateModel(xrFrame: XRFrame): void;
  46983. private _getGenericFilenameAndPath;
  46984. private _getGenericParentMesh;
  46985. }
  46986. }
  46987. declare module BABYLON {
  46988. /**
  46989. * A generic trigger-only motion controller for WebXR
  46990. */
  46991. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  46992. /**
  46993. * Static version of the profile id of this controller
  46994. */
  46995. static ProfileId: string;
  46996. profileId: string;
  46997. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  46998. protected _getFilenameAndPath(): {
  46999. filename: string;
  47000. path: string;
  47001. };
  47002. protected _getModelLoadingConstraints(): boolean;
  47003. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47004. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47005. protected _updateModel(): void;
  47006. }
  47007. }
  47008. declare module BABYLON {
  47009. /**
  47010. * Class containing static functions to help procedurally build meshes
  47011. */
  47012. export class SphereBuilder {
  47013. /**
  47014. * Creates a sphere mesh
  47015. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47016. * * 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`)
  47017. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47018. * * 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
  47019. * * 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)
  47020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47021. * * 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
  47022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47023. * @param name defines the name of the mesh
  47024. * @param options defines the options used to create the mesh
  47025. * @param scene defines the hosting scene
  47026. * @returns the sphere mesh
  47027. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47028. */
  47029. static CreateSphere(name: string, options: {
  47030. segments?: number;
  47031. diameter?: number;
  47032. diameterX?: number;
  47033. diameterY?: number;
  47034. diameterZ?: number;
  47035. arc?: number;
  47036. slice?: number;
  47037. sideOrientation?: number;
  47038. frontUVs?: Vector4;
  47039. backUVs?: Vector4;
  47040. updatable?: boolean;
  47041. }, scene?: Nullable<Scene>): Mesh;
  47042. }
  47043. }
  47044. declare module BABYLON {
  47045. /**
  47046. * A profiled motion controller has its profile loaded from an online repository.
  47047. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47048. */
  47049. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47050. private _repositoryUrl;
  47051. private _buttonMeshMapping;
  47052. private _touchDots;
  47053. /**
  47054. * The profile ID of this controller. Will be populated when the controller initializes.
  47055. */
  47056. profileId: string;
  47057. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47058. dispose(): void;
  47059. protected _getFilenameAndPath(): {
  47060. filename: string;
  47061. path: string;
  47062. };
  47063. protected _getModelLoadingConstraints(): boolean;
  47064. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47065. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47066. protected _updateModel(_xrFrame: XRFrame): void;
  47067. }
  47068. }
  47069. declare module BABYLON {
  47070. /**
  47071. * A construction function type to create a new controller based on an xrInput object
  47072. */
  47073. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47074. /**
  47075. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47076. *
  47077. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47078. * it should be replaced with auto-loaded controllers.
  47079. *
  47080. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47081. */
  47082. export class WebXRMotionControllerManager {
  47083. private static _AvailableControllers;
  47084. private static _Fallbacks;
  47085. private static _ProfileLoadingPromises;
  47086. private static _ProfilesList;
  47087. /**
  47088. * The base URL of the online controller repository. Can be changed at any time.
  47089. */
  47090. static BaseRepositoryUrl: string;
  47091. /**
  47092. * Which repository gets priority - local or online
  47093. */
  47094. static PrioritizeOnlineRepository: boolean;
  47095. /**
  47096. * Use the online repository, or use only locally-defined controllers
  47097. */
  47098. static UseOnlineRepository: boolean;
  47099. /**
  47100. * Clear the cache used for profile loading and reload when requested again
  47101. */
  47102. static ClearProfilesCache(): void;
  47103. /**
  47104. * Register the default fallbacks.
  47105. * This function is called automatically when this file is imported.
  47106. */
  47107. static DefaultFallbacks(): void;
  47108. /**
  47109. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47110. * @param profileId the profile to which a fallback needs to be found
  47111. * @return an array with corresponding fallback profiles
  47112. */
  47113. static FindFallbackWithProfileId(profileId: string): string[];
  47114. /**
  47115. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47116. * The order of search:
  47117. *
  47118. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47119. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47120. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47121. * 4) return the generic trigger controller if none were found
  47122. *
  47123. * @param xrInput the xrInput to which a new controller is initialized
  47124. * @param scene the scene to which the model will be added
  47125. * @param forceProfile force a certain profile for this controller
  47126. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47127. */
  47128. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47129. /**
  47130. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47131. *
  47132. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47133. *
  47134. * @param type the profile type to register
  47135. * @param constructFunction the function to be called when loading this profile
  47136. */
  47137. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47138. /**
  47139. * Register a fallback to a specific profile.
  47140. * @param profileId the profileId that will receive the fallbacks
  47141. * @param fallbacks A list of fallback profiles
  47142. */
  47143. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47144. /**
  47145. * Will update the list of profiles available in the repository
  47146. * @return a promise that resolves to a map of profiles available online
  47147. */
  47148. static UpdateProfilesList(): Promise<{
  47149. [profile: string]: string;
  47150. }>;
  47151. private static _LoadProfileFromRepository;
  47152. private static _LoadProfilesFromAvailableControllers;
  47153. }
  47154. }
  47155. declare module BABYLON {
  47156. /**
  47157. * Configuration options for the WebXR controller creation
  47158. */
  47159. export interface IWebXRControllerOptions {
  47160. /**
  47161. * Should the controller mesh be animated when a user interacts with it
  47162. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47163. */
  47164. disableMotionControllerAnimation?: boolean;
  47165. /**
  47166. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47167. */
  47168. doNotLoadControllerMesh?: boolean;
  47169. /**
  47170. * Force a specific controller type for this controller.
  47171. * This can be used when creating your own profile or when testing different controllers
  47172. */
  47173. forceControllerProfile?: string;
  47174. /**
  47175. * Defines a rendering group ID for meshes that will be loaded.
  47176. * This is for the default controllers only.
  47177. */
  47178. renderingGroupId?: number;
  47179. }
  47180. /**
  47181. * Represents an XR controller
  47182. */
  47183. export class WebXRInputSource {
  47184. private _scene;
  47185. /** The underlying input source for the controller */
  47186. inputSource: XRInputSource;
  47187. private _options;
  47188. private _tmpVector;
  47189. private _uniqueId;
  47190. /**
  47191. * 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
  47192. */
  47193. grip?: AbstractMesh;
  47194. /**
  47195. * If available, this is the gamepad object related to this controller.
  47196. * Using this object it is possible to get click events and trackpad changes of the
  47197. * webxr controller that is currently being used.
  47198. */
  47199. motionController?: WebXRAbstractMotionController;
  47200. /**
  47201. * Event that fires when the controller is removed/disposed.
  47202. * The object provided as event data is this controller, after associated assets were disposed.
  47203. * uniqueId is still available.
  47204. */
  47205. onDisposeObservable: Observable<WebXRInputSource>;
  47206. /**
  47207. * Will be triggered when the mesh associated with the motion controller is done loading.
  47208. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47209. * A shortened version of controller -> motion controller -> on mesh loaded.
  47210. */
  47211. onMeshLoadedObservable: Observable<AbstractMesh>;
  47212. /**
  47213. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47214. */
  47215. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47216. /**
  47217. * Pointer which can be used to select objects or attach a visible laser to
  47218. */
  47219. pointer: AbstractMesh;
  47220. /**
  47221. * Creates the controller
  47222. * @see https://doc.babylonjs.com/how_to/webxr
  47223. * @param _scene the scene which the controller should be associated to
  47224. * @param inputSource the underlying input source for the controller
  47225. * @param _options options for this controller creation
  47226. */
  47227. constructor(_scene: Scene,
  47228. /** The underlying input source for the controller */
  47229. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47230. /**
  47231. * Get this controllers unique id
  47232. */
  47233. get uniqueId(): string;
  47234. /**
  47235. * Disposes of the object
  47236. */
  47237. dispose(): void;
  47238. /**
  47239. * Gets a world space ray coming from the pointer or grip
  47240. * @param result the resulting ray
  47241. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47242. */
  47243. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47244. /**
  47245. * Updates the controller pose based on the given XRFrame
  47246. * @param xrFrame xr frame to update the pose with
  47247. * @param referenceSpace reference space to use
  47248. */
  47249. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47250. }
  47251. }
  47252. declare module BABYLON {
  47253. /**
  47254. * The schema for initialization options of the XR Input class
  47255. */
  47256. export interface IWebXRInputOptions {
  47257. /**
  47258. * If set to true no model will be automatically loaded
  47259. */
  47260. doNotLoadControllerMeshes?: boolean;
  47261. /**
  47262. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47263. * If not found, the xr input profile data will be used.
  47264. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47265. */
  47266. forceInputProfile?: string;
  47267. /**
  47268. * Do not send a request to the controller repository to load the profile.
  47269. *
  47270. * Instead, use the controllers available in babylon itself.
  47271. */
  47272. disableOnlineControllerRepository?: boolean;
  47273. /**
  47274. * A custom URL for the controllers repository
  47275. */
  47276. customControllersRepositoryURL?: string;
  47277. /**
  47278. * Should the controller model's components not move according to the user input
  47279. */
  47280. disableControllerAnimation?: boolean;
  47281. /**
  47282. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47283. */
  47284. controllerOptions?: IWebXRControllerOptions;
  47285. }
  47286. /**
  47287. * XR input used to track XR inputs such as controllers/rays
  47288. */
  47289. export class WebXRInput implements IDisposable {
  47290. /**
  47291. * the xr session manager for this session
  47292. */
  47293. xrSessionManager: WebXRSessionManager;
  47294. /**
  47295. * the WebXR camera for this session. Mainly used for teleportation
  47296. */
  47297. xrCamera: WebXRCamera;
  47298. private readonly options;
  47299. /**
  47300. * XR controllers being tracked
  47301. */
  47302. controllers: Array<WebXRInputSource>;
  47303. private _frameObserver;
  47304. private _sessionEndedObserver;
  47305. private _sessionInitObserver;
  47306. /**
  47307. * Event when a controller has been connected/added
  47308. */
  47309. onControllerAddedObservable: Observable<WebXRInputSource>;
  47310. /**
  47311. * Event when a controller has been removed/disconnected
  47312. */
  47313. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47314. /**
  47315. * Initializes the WebXRInput
  47316. * @param xrSessionManager the xr session manager for this session
  47317. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47318. * @param options = initialization options for this xr input
  47319. */
  47320. constructor(
  47321. /**
  47322. * the xr session manager for this session
  47323. */
  47324. xrSessionManager: WebXRSessionManager,
  47325. /**
  47326. * the WebXR camera for this session. Mainly used for teleportation
  47327. */
  47328. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47329. private _onInputSourcesChange;
  47330. private _addAndRemoveControllers;
  47331. /**
  47332. * Disposes of the object
  47333. */
  47334. dispose(): void;
  47335. }
  47336. }
  47337. declare module BABYLON {
  47338. /**
  47339. * This is the base class for all WebXR features.
  47340. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47341. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47342. */
  47343. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47344. protected _xrSessionManager: WebXRSessionManager;
  47345. private _attached;
  47346. private _removeOnDetach;
  47347. /**
  47348. * Should auto-attach be disabled?
  47349. */
  47350. disableAutoAttach: boolean;
  47351. /**
  47352. * Construct a new (abstract) WebXR feature
  47353. * @param _xrSessionManager the xr session manager for this feature
  47354. */
  47355. constructor(_xrSessionManager: WebXRSessionManager);
  47356. /**
  47357. * Is this feature attached
  47358. */
  47359. get attached(): boolean;
  47360. /**
  47361. * attach this feature
  47362. *
  47363. * @param force should attachment be forced (even when already attached)
  47364. * @returns true if successful, false is failed or already attached
  47365. */
  47366. attach(force?: boolean): boolean;
  47367. /**
  47368. * detach this feature.
  47369. *
  47370. * @returns true if successful, false if failed or already detached
  47371. */
  47372. detach(): boolean;
  47373. /**
  47374. * Dispose this feature and all of the resources attached
  47375. */
  47376. dispose(): void;
  47377. /**
  47378. * This is used to register callbacks that will automatically be removed when detach is called.
  47379. * @param observable the observable to which the observer will be attached
  47380. * @param callback the callback to register
  47381. */
  47382. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47383. /**
  47384. * Code in this function will be executed on each xrFrame received from the browser.
  47385. * This function will not execute after the feature is detached.
  47386. * @param _xrFrame the current frame
  47387. */
  47388. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47389. }
  47390. }
  47391. declare module BABYLON {
  47392. /**
  47393. * Renders a layer on top of an existing scene
  47394. */
  47395. export class UtilityLayerRenderer implements IDisposable {
  47396. /** the original scene that will be rendered on top of */
  47397. originalScene: Scene;
  47398. private _pointerCaptures;
  47399. private _lastPointerEvents;
  47400. private static _DefaultUtilityLayer;
  47401. private static _DefaultKeepDepthUtilityLayer;
  47402. private _sharedGizmoLight;
  47403. private _renderCamera;
  47404. /**
  47405. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47406. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47407. * @returns the camera that is used when rendering the utility layer
  47408. */
  47409. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47410. /**
  47411. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47412. * @param cam the camera that should be used when rendering the utility layer
  47413. */
  47414. setRenderCamera(cam: Nullable<Camera>): void;
  47415. /**
  47416. * @hidden
  47417. * Light which used by gizmos to get light shading
  47418. */
  47419. _getSharedGizmoLight(): HemisphericLight;
  47420. /**
  47421. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47422. */
  47423. pickUtilitySceneFirst: boolean;
  47424. /**
  47425. * 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)
  47426. */
  47427. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47428. /**
  47429. * 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)
  47430. */
  47431. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47432. /**
  47433. * The scene that is rendered on top of the original scene
  47434. */
  47435. utilityLayerScene: Scene;
  47436. /**
  47437. * If the utility layer should automatically be rendered on top of existing scene
  47438. */
  47439. shouldRender: boolean;
  47440. /**
  47441. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47442. */
  47443. onlyCheckPointerDownEvents: boolean;
  47444. /**
  47445. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47446. */
  47447. processAllEvents: boolean;
  47448. /**
  47449. * Observable raised when the pointer move from the utility layer scene to the main scene
  47450. */
  47451. onPointerOutObservable: Observable<number>;
  47452. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47453. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47454. private _afterRenderObserver;
  47455. private _sceneDisposeObserver;
  47456. private _originalPointerObserver;
  47457. /**
  47458. * Instantiates a UtilityLayerRenderer
  47459. * @param originalScene the original scene that will be rendered on top of
  47460. * @param handleEvents boolean indicating if the utility layer should handle events
  47461. */
  47462. constructor(
  47463. /** the original scene that will be rendered on top of */
  47464. originalScene: Scene, handleEvents?: boolean);
  47465. private _notifyObservers;
  47466. /**
  47467. * Renders the utility layers scene on top of the original scene
  47468. */
  47469. render(): void;
  47470. /**
  47471. * Disposes of the renderer
  47472. */
  47473. dispose(): void;
  47474. private _updateCamera;
  47475. }
  47476. }
  47477. declare module BABYLON {
  47478. /**
  47479. * Options interface for the pointer selection module
  47480. */
  47481. export interface IWebXRControllerPointerSelectionOptions {
  47482. /**
  47483. * if provided, this scene will be used to render meshes.
  47484. */
  47485. customUtilityLayerScene?: Scene;
  47486. /**
  47487. * 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)
  47488. * If not disabled, the last picked point will be used to execute a pointer up event
  47489. * If disabled, pointer up event will be triggered right after the pointer down event.
  47490. * Used in screen and gaze target ray mode only
  47491. */
  47492. disablePointerUpOnTouchOut: boolean;
  47493. /**
  47494. * For gaze mode (time to select instead of press)
  47495. */
  47496. forceGazeMode: boolean;
  47497. /**
  47498. * 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
  47499. * to start a new countdown to the pointer down event.
  47500. * Defaults to 1.
  47501. */
  47502. gazeModePointerMovedFactor?: number;
  47503. /**
  47504. * Different button type to use instead of the main component
  47505. */
  47506. overrideButtonId?: string;
  47507. /**
  47508. * use this rendering group id for the meshes (optional)
  47509. */
  47510. renderingGroupId?: number;
  47511. /**
  47512. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47513. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47514. * 3000 means 3 seconds between pointing at something and selecting it
  47515. */
  47516. timeToSelect?: number;
  47517. /**
  47518. * Should meshes created here be added to a utility layer or the main scene
  47519. */
  47520. useUtilityLayer?: boolean;
  47521. /**
  47522. * the xr input to use with this pointer selection
  47523. */
  47524. xrInput: WebXRInput;
  47525. }
  47526. /**
  47527. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47528. */
  47529. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47530. private readonly _options;
  47531. private static _idCounter;
  47532. private _attachController;
  47533. private _controllers;
  47534. private _scene;
  47535. private _tmpVectorForPickCompare;
  47536. /**
  47537. * The module's name
  47538. */
  47539. static readonly Name: string;
  47540. /**
  47541. * The (Babylon) version of this module.
  47542. * This is an integer representing the implementation version.
  47543. * This number does not correspond to the WebXR specs version
  47544. */
  47545. static readonly Version: number;
  47546. /**
  47547. * Disable lighting on the laser pointer (so it will always be visible)
  47548. */
  47549. disablePointerLighting: boolean;
  47550. /**
  47551. * Disable lighting on the selection mesh (so it will always be visible)
  47552. */
  47553. disableSelectionMeshLighting: boolean;
  47554. /**
  47555. * Should the laser pointer be displayed
  47556. */
  47557. displayLaserPointer: boolean;
  47558. /**
  47559. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47560. */
  47561. displaySelectionMesh: boolean;
  47562. /**
  47563. * This color will be set to the laser pointer when selection is triggered
  47564. */
  47565. laserPointerPickedColor: Color3;
  47566. /**
  47567. * Default color of the laser pointer
  47568. */
  47569. lasterPointerDefaultColor: Color3;
  47570. /**
  47571. * default color of the selection ring
  47572. */
  47573. selectionMeshDefaultColor: Color3;
  47574. /**
  47575. * This color will be applied to the selection ring when selection is triggered
  47576. */
  47577. selectionMeshPickedColor: Color3;
  47578. /**
  47579. * Optional filter to be used for ray selection. This predicate shares behavior with
  47580. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47581. */
  47582. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47583. /**
  47584. * constructs a new background remover module
  47585. * @param _xrSessionManager the session manager for this module
  47586. * @param _options read-only options to be used in this module
  47587. */
  47588. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47589. /**
  47590. * attach this feature
  47591. * Will usually be called by the features manager
  47592. *
  47593. * @returns true if successful.
  47594. */
  47595. attach(): boolean;
  47596. /**
  47597. * detach this feature.
  47598. * Will usually be called by the features manager
  47599. *
  47600. * @returns true if successful.
  47601. */
  47602. detach(): boolean;
  47603. /**
  47604. * Will get the mesh under a specific pointer.
  47605. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47606. * @param controllerId the controllerId to check
  47607. * @returns The mesh under pointer or null if no mesh is under the pointer
  47608. */
  47609. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47610. /**
  47611. * Get the xr controller that correlates to the pointer id in the pointer event
  47612. *
  47613. * @param id the pointer id to search for
  47614. * @returns the controller that correlates to this id or null if not found
  47615. */
  47616. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47617. protected _onXRFrame(_xrFrame: XRFrame): void;
  47618. private _attachGazeMode;
  47619. private _attachScreenRayMode;
  47620. private _attachTrackedPointerRayMode;
  47621. private _convertNormalToDirectionOfRay;
  47622. private _detachController;
  47623. private _generateNewMeshPair;
  47624. private _pickingMoved;
  47625. private _updatePointerDistance;
  47626. }
  47627. }
  47628. declare module BABYLON {
  47629. /**
  47630. * Button which can be used to enter a different mode of XR
  47631. */
  47632. export class WebXREnterExitUIButton {
  47633. /** button element */
  47634. element: HTMLElement;
  47635. /** XR initialization options for the button */
  47636. sessionMode: XRSessionMode;
  47637. /** Reference space type */
  47638. referenceSpaceType: XRReferenceSpaceType;
  47639. /**
  47640. * Creates a WebXREnterExitUIButton
  47641. * @param element button element
  47642. * @param sessionMode XR initialization session mode
  47643. * @param referenceSpaceType the type of reference space to be used
  47644. */
  47645. constructor(
  47646. /** button element */
  47647. element: HTMLElement,
  47648. /** XR initialization options for the button */
  47649. sessionMode: XRSessionMode,
  47650. /** Reference space type */
  47651. referenceSpaceType: XRReferenceSpaceType);
  47652. /**
  47653. * Extendable function which can be used to update the button's visuals when the state changes
  47654. * @param activeButton the current active button in the UI
  47655. */
  47656. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47657. }
  47658. /**
  47659. * Options to create the webXR UI
  47660. */
  47661. export class WebXREnterExitUIOptions {
  47662. /**
  47663. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47664. */
  47665. customButtons?: Array<WebXREnterExitUIButton>;
  47666. /**
  47667. * A reference space type to use when creating the default button.
  47668. * Default is local-floor
  47669. */
  47670. referenceSpaceType?: XRReferenceSpaceType;
  47671. /**
  47672. * Context to enter xr with
  47673. */
  47674. renderTarget?: Nullable<WebXRRenderTarget>;
  47675. /**
  47676. * A session mode to use when creating the default button.
  47677. * Default is immersive-vr
  47678. */
  47679. sessionMode?: XRSessionMode;
  47680. /**
  47681. * A list of optional features to init the session with
  47682. */
  47683. optionalFeatures?: string[];
  47684. }
  47685. /**
  47686. * UI to allow the user to enter/exit XR mode
  47687. */
  47688. export class WebXREnterExitUI implements IDisposable {
  47689. private scene;
  47690. /** version of the options passed to this UI */
  47691. options: WebXREnterExitUIOptions;
  47692. private _activeButton;
  47693. private _buttons;
  47694. private _overlay;
  47695. /**
  47696. * Fired every time the active button is changed.
  47697. *
  47698. * When xr is entered via a button that launches xr that button will be the callback parameter
  47699. *
  47700. * When exiting xr the callback parameter will be null)
  47701. */
  47702. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47703. /**
  47704. *
  47705. * @param scene babylon scene object to use
  47706. * @param options (read-only) version of the options passed to this UI
  47707. */
  47708. private constructor();
  47709. /**
  47710. * Creates UI to allow the user to enter/exit XR mode
  47711. * @param scene the scene to add the ui to
  47712. * @param helper the xr experience helper to enter/exit xr with
  47713. * @param options options to configure the UI
  47714. * @returns the created ui
  47715. */
  47716. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47717. /**
  47718. * Disposes of the XR UI component
  47719. */
  47720. dispose(): void;
  47721. private _updateButtons;
  47722. }
  47723. }
  47724. declare module BABYLON {
  47725. /**
  47726. * Class containing static functions to help procedurally build meshes
  47727. */
  47728. export class LinesBuilder {
  47729. /**
  47730. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47731. * * 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
  47732. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47733. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47734. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47735. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47736. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47737. * * 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
  47738. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47741. * @param name defines the name of the new line system
  47742. * @param options defines the options used to create the line system
  47743. * @param scene defines the hosting scene
  47744. * @returns a new line system mesh
  47745. */
  47746. static CreateLineSystem(name: string, options: {
  47747. lines: Vector3[][];
  47748. updatable?: boolean;
  47749. instance?: Nullable<LinesMesh>;
  47750. colors?: Nullable<Color4[][]>;
  47751. useVertexAlpha?: boolean;
  47752. }, scene: Nullable<Scene>): LinesMesh;
  47753. /**
  47754. * Creates a line mesh
  47755. * 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
  47756. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47757. * * The parameter `points` is an array successive Vector3
  47758. * * 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
  47759. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47760. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47761. * * When updating an instance, remember that only point positions can change, not the number of points
  47762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47764. * @param name defines the name of the new line system
  47765. * @param options defines the options used to create the line system
  47766. * @param scene defines the hosting scene
  47767. * @returns a new line mesh
  47768. */
  47769. static CreateLines(name: string, options: {
  47770. points: Vector3[];
  47771. updatable?: boolean;
  47772. instance?: Nullable<LinesMesh>;
  47773. colors?: Color4[];
  47774. useVertexAlpha?: boolean;
  47775. }, scene?: Nullable<Scene>): LinesMesh;
  47776. /**
  47777. * Creates a dashed line mesh
  47778. * * 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
  47779. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47780. * * The parameter `points` is an array successive Vector3
  47781. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47782. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47783. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47784. * * 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
  47785. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47786. * * When updating an instance, remember that only point positions can change, not the number of points
  47787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47788. * @param name defines the name of the mesh
  47789. * @param options defines the options used to create the mesh
  47790. * @param scene defines the hosting scene
  47791. * @returns the dashed line mesh
  47792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47793. */
  47794. static CreateDashedLines(name: string, options: {
  47795. points: Vector3[];
  47796. dashSize?: number;
  47797. gapSize?: number;
  47798. dashNb?: number;
  47799. updatable?: boolean;
  47800. instance?: LinesMesh;
  47801. useVertexAlpha?: boolean;
  47802. }, scene?: Nullable<Scene>): LinesMesh;
  47803. }
  47804. }
  47805. declare module BABYLON {
  47806. /**
  47807. * The options container for the teleportation module
  47808. */
  47809. export interface IWebXRTeleportationOptions {
  47810. /**
  47811. * if provided, this scene will be used to render meshes.
  47812. */
  47813. customUtilityLayerScene?: Scene;
  47814. /**
  47815. * Values to configure the default target mesh
  47816. */
  47817. defaultTargetMeshOptions?: {
  47818. /**
  47819. * Fill color of the teleportation area
  47820. */
  47821. teleportationFillColor?: string;
  47822. /**
  47823. * Border color for the teleportation area
  47824. */
  47825. teleportationBorderColor?: string;
  47826. /**
  47827. * Disable the mesh's animation sequence
  47828. */
  47829. disableAnimation?: boolean;
  47830. /**
  47831. * Disable lighting on the material or the ring and arrow
  47832. */
  47833. disableLighting?: boolean;
  47834. /**
  47835. * Override the default material of the torus and arrow
  47836. */
  47837. torusArrowMaterial?: Material;
  47838. };
  47839. /**
  47840. * A list of meshes to use as floor meshes.
  47841. * Meshes can be added and removed after initializing the feature using the
  47842. * addFloorMesh and removeFloorMesh functions
  47843. * If empty, rotation will still work
  47844. */
  47845. floorMeshes?: AbstractMesh[];
  47846. /**
  47847. * use this rendering group id for the meshes (optional)
  47848. */
  47849. renderingGroupId?: number;
  47850. /**
  47851. * Should teleportation move only to snap points
  47852. */
  47853. snapPointsOnly?: boolean;
  47854. /**
  47855. * An array of points to which the teleportation will snap to.
  47856. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47857. */
  47858. snapPositions?: Vector3[];
  47859. /**
  47860. * How close should the teleportation ray be in order to snap to position.
  47861. * Default to 0.8 units (meters)
  47862. */
  47863. snapToPositionRadius?: number;
  47864. /**
  47865. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47866. * If you want to support rotation, make sure your mesh has a direction indicator.
  47867. *
  47868. * When left untouched, the default mesh will be initialized.
  47869. */
  47870. teleportationTargetMesh?: AbstractMesh;
  47871. /**
  47872. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47873. */
  47874. timeToTeleport?: number;
  47875. /**
  47876. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47877. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47878. */
  47879. useMainComponentOnly?: boolean;
  47880. /**
  47881. * Should meshes created here be added to a utility layer or the main scene
  47882. */
  47883. useUtilityLayer?: boolean;
  47884. /**
  47885. * Babylon XR Input class for controller
  47886. */
  47887. xrInput: WebXRInput;
  47888. }
  47889. /**
  47890. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47891. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47892. * the input of the attached controllers.
  47893. */
  47894. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47895. private _options;
  47896. private _controllers;
  47897. private _currentTeleportationControllerId;
  47898. private _floorMeshes;
  47899. private _quadraticBezierCurve;
  47900. private _selectionFeature;
  47901. private _snapToPositions;
  47902. private _snappedToPoint;
  47903. private _teleportationRingMaterial?;
  47904. private _tmpRay;
  47905. private _tmpVector;
  47906. /**
  47907. * The module's name
  47908. */
  47909. static readonly Name: string;
  47910. /**
  47911. * The (Babylon) version of this module.
  47912. * This is an integer representing the implementation version.
  47913. * This number does not correspond to the webxr specs version
  47914. */
  47915. static readonly Version: number;
  47916. /**
  47917. * Is movement backwards enabled
  47918. */
  47919. backwardsMovementEnabled: boolean;
  47920. /**
  47921. * Distance to travel when moving backwards
  47922. */
  47923. backwardsTeleportationDistance: number;
  47924. /**
  47925. * The distance from the user to the inspection point in the direction of the controller
  47926. * A higher number will allow the user to move further
  47927. * defaults to 5 (meters, in xr units)
  47928. */
  47929. parabolicCheckRadius: number;
  47930. /**
  47931. * Should the module support parabolic ray on top of direct ray
  47932. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47933. * Very helpful when moving between floors / different heights
  47934. */
  47935. parabolicRayEnabled: boolean;
  47936. /**
  47937. * How much rotation should be applied when rotating right and left
  47938. */
  47939. rotationAngle: number;
  47940. /**
  47941. * Is rotation enabled when moving forward?
  47942. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47943. */
  47944. rotationEnabled: boolean;
  47945. /**
  47946. * constructs a new anchor system
  47947. * @param _xrSessionManager an instance of WebXRSessionManager
  47948. * @param _options configuration object for this feature
  47949. */
  47950. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  47951. /**
  47952. * Get the snapPointsOnly flag
  47953. */
  47954. get snapPointsOnly(): boolean;
  47955. /**
  47956. * Sets the snapPointsOnly flag
  47957. * @param snapToPoints should teleportation be exclusively to snap points
  47958. */
  47959. set snapPointsOnly(snapToPoints: boolean);
  47960. /**
  47961. * Add a new mesh to the floor meshes array
  47962. * @param mesh the mesh to use as floor mesh
  47963. */
  47964. addFloorMesh(mesh: AbstractMesh): void;
  47965. /**
  47966. * Add a new snap-to point to fix teleportation to this position
  47967. * @param newSnapPoint The new Snap-To point
  47968. */
  47969. addSnapPoint(newSnapPoint: Vector3): void;
  47970. attach(): boolean;
  47971. detach(): boolean;
  47972. dispose(): void;
  47973. /**
  47974. * Remove a mesh from the floor meshes array
  47975. * @param mesh the mesh to remove
  47976. */
  47977. removeFloorMesh(mesh: AbstractMesh): void;
  47978. /**
  47979. * Remove a mesh from the floor meshes array using its name
  47980. * @param name the mesh name to remove
  47981. */
  47982. removeFloorMeshByName(name: string): void;
  47983. /**
  47984. * 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
  47985. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  47986. * @returns was the point found and removed or not
  47987. */
  47988. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  47989. /**
  47990. * This function sets a selection feature that will be disabled when
  47991. * the forward ray is shown and will be reattached when hidden.
  47992. * This is used to remove the selection rays when moving.
  47993. * @param selectionFeature the feature to disable when forward movement is enabled
  47994. */
  47995. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  47996. protected _onXRFrame(_xrFrame: XRFrame): void;
  47997. private _attachController;
  47998. private _createDefaultTargetMesh;
  47999. private _detachController;
  48000. private _findClosestSnapPointWithRadius;
  48001. private _setTargetMeshPosition;
  48002. private _setTargetMeshVisibility;
  48003. private _showParabolicPath;
  48004. private _teleportForward;
  48005. }
  48006. }
  48007. declare module BABYLON {
  48008. /**
  48009. * Options for the default xr helper
  48010. */
  48011. export class WebXRDefaultExperienceOptions {
  48012. /**
  48013. * Enable or disable default UI to enter XR
  48014. */
  48015. disableDefaultUI?: boolean;
  48016. /**
  48017. * Should teleportation not initialize. defaults to false.
  48018. */
  48019. disableTeleportation?: boolean;
  48020. /**
  48021. * Floor meshes that will be used for teleport
  48022. */
  48023. floorMeshes?: Array<AbstractMesh>;
  48024. /**
  48025. * If set to true, the first frame will not be used to reset position
  48026. * The first frame is mainly used when copying transformation from the old camera
  48027. * Mainly used in AR
  48028. */
  48029. ignoreNativeCameraTransformation?: boolean;
  48030. /**
  48031. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48032. */
  48033. inputOptions?: IWebXRInputOptions;
  48034. /**
  48035. * optional configuration for the output canvas
  48036. */
  48037. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48038. /**
  48039. * optional UI options. This can be used among other to change session mode and reference space type
  48040. */
  48041. uiOptions?: WebXREnterExitUIOptions;
  48042. /**
  48043. * When loading teleportation and pointer select, use stable versions instead of latest.
  48044. */
  48045. useStablePlugins?: boolean;
  48046. /**
  48047. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48048. */
  48049. renderingGroupId?: number;
  48050. /**
  48051. * A list of optional features to init the session with
  48052. * If set to true, all features we support will be added
  48053. */
  48054. optionalFeatures?: boolean | string[];
  48055. }
  48056. /**
  48057. * Default experience which provides a similar setup to the previous webVRExperience
  48058. */
  48059. export class WebXRDefaultExperience {
  48060. /**
  48061. * Base experience
  48062. */
  48063. baseExperience: WebXRExperienceHelper;
  48064. /**
  48065. * Enables ui for entering/exiting xr
  48066. */
  48067. enterExitUI: WebXREnterExitUI;
  48068. /**
  48069. * Input experience extension
  48070. */
  48071. input: WebXRInput;
  48072. /**
  48073. * Enables laser pointer and selection
  48074. */
  48075. pointerSelection: WebXRControllerPointerSelection;
  48076. /**
  48077. * Default target xr should render to
  48078. */
  48079. renderTarget: WebXRRenderTarget;
  48080. /**
  48081. * Enables teleportation
  48082. */
  48083. teleportation: WebXRMotionControllerTeleportation;
  48084. private constructor();
  48085. /**
  48086. * Creates the default xr experience
  48087. * @param scene scene
  48088. * @param options options for basic configuration
  48089. * @returns resulting WebXRDefaultExperience
  48090. */
  48091. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48092. /**
  48093. * DIsposes of the experience helper
  48094. */
  48095. dispose(): void;
  48096. }
  48097. }
  48098. declare module BABYLON {
  48099. /**
  48100. * Options to modify the vr teleportation behavior.
  48101. */
  48102. export interface VRTeleportationOptions {
  48103. /**
  48104. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48105. */
  48106. floorMeshName?: string;
  48107. /**
  48108. * A list of meshes to be used as the teleportation floor. (default: empty)
  48109. */
  48110. floorMeshes?: Mesh[];
  48111. /**
  48112. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48113. */
  48114. teleportationMode?: number;
  48115. /**
  48116. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48117. */
  48118. teleportationTime?: number;
  48119. /**
  48120. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48121. */
  48122. teleportationSpeed?: number;
  48123. /**
  48124. * The easing function used in the animation or null for Linear. (default CircleEase)
  48125. */
  48126. easingFunction?: EasingFunction;
  48127. }
  48128. /**
  48129. * Options to modify the vr experience helper's behavior.
  48130. */
  48131. export interface VRExperienceHelperOptions extends WebVROptions {
  48132. /**
  48133. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48134. */
  48135. createDeviceOrientationCamera?: boolean;
  48136. /**
  48137. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48138. */
  48139. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48140. /**
  48141. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48142. */
  48143. laserToggle?: boolean;
  48144. /**
  48145. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48146. */
  48147. floorMeshes?: Mesh[];
  48148. /**
  48149. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48150. */
  48151. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48152. /**
  48153. * Defines if WebXR should be used instead of WebVR (if available)
  48154. */
  48155. useXR?: boolean;
  48156. }
  48157. /**
  48158. * Event containing information after VR has been entered
  48159. */
  48160. export class OnAfterEnteringVRObservableEvent {
  48161. /**
  48162. * If entering vr was successful
  48163. */
  48164. success: boolean;
  48165. }
  48166. /**
  48167. * Helps to quickly add VR support to an existing scene.
  48168. * See http://doc.babylonjs.com/how_to/webvr_helper
  48169. */
  48170. export class VRExperienceHelper {
  48171. /** Options to modify the vr experience helper's behavior. */
  48172. webVROptions: VRExperienceHelperOptions;
  48173. private _scene;
  48174. private _position;
  48175. private _btnVR;
  48176. private _btnVRDisplayed;
  48177. private _webVRsupported;
  48178. private _webVRready;
  48179. private _webVRrequesting;
  48180. private _webVRpresenting;
  48181. private _hasEnteredVR;
  48182. private _fullscreenVRpresenting;
  48183. private _inputElement;
  48184. private _webVRCamera;
  48185. private _vrDeviceOrientationCamera;
  48186. private _deviceOrientationCamera;
  48187. private _existingCamera;
  48188. private _onKeyDown;
  48189. private _onVrDisplayPresentChange;
  48190. private _onVRDisplayChanged;
  48191. private _onVRRequestPresentStart;
  48192. private _onVRRequestPresentComplete;
  48193. /**
  48194. * 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)
  48195. */
  48196. enableGazeEvenWhenNoPointerLock: boolean;
  48197. /**
  48198. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48199. */
  48200. exitVROnDoubleTap: boolean;
  48201. /**
  48202. * Observable raised right before entering VR.
  48203. */
  48204. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48205. /**
  48206. * Observable raised when entering VR has completed.
  48207. */
  48208. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48209. /**
  48210. * Observable raised when exiting VR.
  48211. */
  48212. onExitingVRObservable: Observable<VRExperienceHelper>;
  48213. /**
  48214. * Observable raised when controller mesh is loaded.
  48215. */
  48216. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48217. /** Return this.onEnteringVRObservable
  48218. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48219. */
  48220. get onEnteringVR(): Observable<VRExperienceHelper>;
  48221. /** Return this.onExitingVRObservable
  48222. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48223. */
  48224. get onExitingVR(): Observable<VRExperienceHelper>;
  48225. /** Return this.onControllerMeshLoadedObservable
  48226. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48227. */
  48228. get onControllerMeshLoaded(): Observable<WebVRController>;
  48229. private _rayLength;
  48230. private _useCustomVRButton;
  48231. private _teleportationRequested;
  48232. private _teleportActive;
  48233. private _floorMeshName;
  48234. private _floorMeshesCollection;
  48235. private _teleportationMode;
  48236. private _teleportationTime;
  48237. private _teleportationSpeed;
  48238. private _teleportationEasing;
  48239. private _rotationAllowed;
  48240. private _teleportBackwardsVector;
  48241. private _teleportationTarget;
  48242. private _isDefaultTeleportationTarget;
  48243. private _postProcessMove;
  48244. private _teleportationFillColor;
  48245. private _teleportationBorderColor;
  48246. private _rotationAngle;
  48247. private _haloCenter;
  48248. private _cameraGazer;
  48249. private _padSensibilityUp;
  48250. private _padSensibilityDown;
  48251. private _leftController;
  48252. private _rightController;
  48253. private _gazeColor;
  48254. private _laserColor;
  48255. private _pickedLaserColor;
  48256. private _pickedGazeColor;
  48257. /**
  48258. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48259. */
  48260. onNewMeshSelected: Observable<AbstractMesh>;
  48261. /**
  48262. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48263. * This observable will provide the mesh and the controller used to select the mesh
  48264. */
  48265. onMeshSelectedWithController: Observable<{
  48266. mesh: AbstractMesh;
  48267. controller: WebVRController;
  48268. }>;
  48269. /**
  48270. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48271. */
  48272. onNewMeshPicked: Observable<PickingInfo>;
  48273. private _circleEase;
  48274. /**
  48275. * Observable raised before camera teleportation
  48276. */
  48277. onBeforeCameraTeleport: Observable<Vector3>;
  48278. /**
  48279. * Observable raised after camera teleportation
  48280. */
  48281. onAfterCameraTeleport: Observable<Vector3>;
  48282. /**
  48283. * Observable raised when current selected mesh gets unselected
  48284. */
  48285. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48286. private _raySelectionPredicate;
  48287. /**
  48288. * To be optionaly changed by user to define custom ray selection
  48289. */
  48290. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48291. /**
  48292. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48293. */
  48294. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48295. /**
  48296. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48297. */
  48298. teleportationEnabled: boolean;
  48299. private _defaultHeight;
  48300. private _teleportationInitialized;
  48301. private _interactionsEnabled;
  48302. private _interactionsRequested;
  48303. private _displayGaze;
  48304. private _displayLaserPointer;
  48305. /**
  48306. * The mesh used to display where the user is going to teleport.
  48307. */
  48308. get teleportationTarget(): Mesh;
  48309. /**
  48310. * Sets the mesh to be used to display where the user is going to teleport.
  48311. */
  48312. set teleportationTarget(value: Mesh);
  48313. /**
  48314. * 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
  48315. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48316. * See http://doc.babylonjs.com/resources/baking_transformations
  48317. */
  48318. get gazeTrackerMesh(): Mesh;
  48319. set gazeTrackerMesh(value: Mesh);
  48320. /**
  48321. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48322. */
  48323. updateGazeTrackerScale: boolean;
  48324. /**
  48325. * If the gaze trackers color should be updated when selecting meshes
  48326. */
  48327. updateGazeTrackerColor: boolean;
  48328. /**
  48329. * If the controller laser color should be updated when selecting meshes
  48330. */
  48331. updateControllerLaserColor: boolean;
  48332. /**
  48333. * The gaze tracking mesh corresponding to the left controller
  48334. */
  48335. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48336. /**
  48337. * The gaze tracking mesh corresponding to the right controller
  48338. */
  48339. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48340. /**
  48341. * If the ray of the gaze should be displayed.
  48342. */
  48343. get displayGaze(): boolean;
  48344. /**
  48345. * Sets if the ray of the gaze should be displayed.
  48346. */
  48347. set displayGaze(value: boolean);
  48348. /**
  48349. * If the ray of the LaserPointer should be displayed.
  48350. */
  48351. get displayLaserPointer(): boolean;
  48352. /**
  48353. * Sets if the ray of the LaserPointer should be displayed.
  48354. */
  48355. set displayLaserPointer(value: boolean);
  48356. /**
  48357. * The deviceOrientationCamera used as the camera when not in VR.
  48358. */
  48359. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48360. /**
  48361. * Based on the current WebVR support, returns the current VR camera used.
  48362. */
  48363. get currentVRCamera(): Nullable<Camera>;
  48364. /**
  48365. * The webVRCamera which is used when in VR.
  48366. */
  48367. get webVRCamera(): WebVRFreeCamera;
  48368. /**
  48369. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48370. */
  48371. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48372. /**
  48373. * The html button that is used to trigger entering into VR.
  48374. */
  48375. get vrButton(): Nullable<HTMLButtonElement>;
  48376. private get _teleportationRequestInitiated();
  48377. /**
  48378. * Defines whether or not Pointer lock should be requested when switching to
  48379. * full screen.
  48380. */
  48381. requestPointerLockOnFullScreen: boolean;
  48382. /**
  48383. * If asking to force XR, this will be populated with the default xr experience
  48384. */
  48385. xr: WebXRDefaultExperience;
  48386. /**
  48387. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48388. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48389. */
  48390. xrTestDone: boolean;
  48391. /**
  48392. * Instantiates a VRExperienceHelper.
  48393. * Helps to quickly add VR support to an existing scene.
  48394. * @param scene The scene the VRExperienceHelper belongs to.
  48395. * @param webVROptions Options to modify the vr experience helper's behavior.
  48396. */
  48397. constructor(scene: Scene,
  48398. /** Options to modify the vr experience helper's behavior. */
  48399. webVROptions?: VRExperienceHelperOptions);
  48400. private completeVRInit;
  48401. private _onDefaultMeshLoaded;
  48402. private _onResize;
  48403. private _onFullscreenChange;
  48404. /**
  48405. * Gets a value indicating if we are currently in VR mode.
  48406. */
  48407. get isInVRMode(): boolean;
  48408. private onVrDisplayPresentChange;
  48409. private onVRDisplayChanged;
  48410. private moveButtonToBottomRight;
  48411. private displayVRButton;
  48412. private updateButtonVisibility;
  48413. private _cachedAngularSensibility;
  48414. /**
  48415. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48416. * Otherwise, will use the fullscreen API.
  48417. */
  48418. enterVR(): void;
  48419. /**
  48420. * Attempt to exit VR, or fullscreen.
  48421. */
  48422. exitVR(): void;
  48423. /**
  48424. * The position of the vr experience helper.
  48425. */
  48426. get position(): Vector3;
  48427. /**
  48428. * Sets the position of the vr experience helper.
  48429. */
  48430. set position(value: Vector3);
  48431. /**
  48432. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48433. */
  48434. enableInteractions(): void;
  48435. private get _noControllerIsActive();
  48436. private beforeRender;
  48437. private _isTeleportationFloor;
  48438. /**
  48439. * Adds a floor mesh to be used for teleportation.
  48440. * @param floorMesh the mesh to be used for teleportation.
  48441. */
  48442. addFloorMesh(floorMesh: Mesh): void;
  48443. /**
  48444. * Removes a floor mesh from being used for teleportation.
  48445. * @param floorMesh the mesh to be removed.
  48446. */
  48447. removeFloorMesh(floorMesh: Mesh): void;
  48448. /**
  48449. * Enables interactions and teleportation using the VR controllers and gaze.
  48450. * @param vrTeleportationOptions options to modify teleportation behavior.
  48451. */
  48452. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48453. private _onNewGamepadConnected;
  48454. private _tryEnableInteractionOnController;
  48455. private _onNewGamepadDisconnected;
  48456. private _enableInteractionOnController;
  48457. private _checkTeleportWithRay;
  48458. private _checkRotate;
  48459. private _checkTeleportBackwards;
  48460. private _enableTeleportationOnController;
  48461. private _createTeleportationCircles;
  48462. private _displayTeleportationTarget;
  48463. private _hideTeleportationTarget;
  48464. private _rotateCamera;
  48465. private _moveTeleportationSelectorTo;
  48466. private _workingVector;
  48467. private _workingQuaternion;
  48468. private _workingMatrix;
  48469. /**
  48470. * Time Constant Teleportation Mode
  48471. */
  48472. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48473. /**
  48474. * Speed Constant Teleportation Mode
  48475. */
  48476. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48477. /**
  48478. * Teleports the users feet to the desired location
  48479. * @param location The location where the user's feet should be placed
  48480. */
  48481. teleportCamera(location: Vector3): void;
  48482. private _convertNormalToDirectionOfRay;
  48483. private _castRayAndSelectObject;
  48484. private _notifySelectedMeshUnselected;
  48485. /**
  48486. * Permanently set new colors for the laser pointer
  48487. * @param color the new laser color
  48488. * @param pickedColor the new laser color when picked mesh detected
  48489. */
  48490. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48491. /**
  48492. * Set lighting enabled / disabled on the laser pointer of both controllers
  48493. * @param enabled should the lighting be enabled on the laser pointer
  48494. */
  48495. setLaserLightingState(enabled?: boolean): void;
  48496. /**
  48497. * Permanently set new colors for the gaze pointer
  48498. * @param color the new gaze color
  48499. * @param pickedColor the new gaze color when picked mesh detected
  48500. */
  48501. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48502. /**
  48503. * Sets the color of the laser ray from the vr controllers.
  48504. * @param color new color for the ray.
  48505. */
  48506. changeLaserColor(color: Color3): void;
  48507. /**
  48508. * Sets the color of the ray from the vr headsets gaze.
  48509. * @param color new color for the ray.
  48510. */
  48511. changeGazeColor(color: Color3): void;
  48512. /**
  48513. * Exits VR and disposes of the vr experience helper
  48514. */
  48515. dispose(): void;
  48516. /**
  48517. * Gets the name of the VRExperienceHelper class
  48518. * @returns "VRExperienceHelper"
  48519. */
  48520. getClassName(): string;
  48521. }
  48522. }
  48523. declare module BABYLON {
  48524. /**
  48525. * Contains an array of blocks representing the octree
  48526. */
  48527. export interface IOctreeContainer<T> {
  48528. /**
  48529. * Blocks within the octree
  48530. */
  48531. blocks: Array<OctreeBlock<T>>;
  48532. }
  48533. /**
  48534. * Class used to store a cell in an octree
  48535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48536. */
  48537. export class OctreeBlock<T> {
  48538. /**
  48539. * Gets the content of the current block
  48540. */
  48541. entries: T[];
  48542. /**
  48543. * Gets the list of block children
  48544. */
  48545. blocks: Array<OctreeBlock<T>>;
  48546. private _depth;
  48547. private _maxDepth;
  48548. private _capacity;
  48549. private _minPoint;
  48550. private _maxPoint;
  48551. private _boundingVectors;
  48552. private _creationFunc;
  48553. /**
  48554. * Creates a new block
  48555. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48556. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48557. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48558. * @param depth defines the current depth of this block in the octree
  48559. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48560. * @param creationFunc defines a callback to call when an element is added to the block
  48561. */
  48562. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48563. /**
  48564. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48565. */
  48566. get capacity(): number;
  48567. /**
  48568. * Gets the minimum vector (in world space) of the block's bounding box
  48569. */
  48570. get minPoint(): Vector3;
  48571. /**
  48572. * Gets the maximum vector (in world space) of the block's bounding box
  48573. */
  48574. get maxPoint(): Vector3;
  48575. /**
  48576. * Add a new element to this block
  48577. * @param entry defines the element to add
  48578. */
  48579. addEntry(entry: T): void;
  48580. /**
  48581. * Remove an element from this block
  48582. * @param entry defines the element to remove
  48583. */
  48584. removeEntry(entry: T): void;
  48585. /**
  48586. * Add an array of elements to this block
  48587. * @param entries defines the array of elements to add
  48588. */
  48589. addEntries(entries: T[]): void;
  48590. /**
  48591. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48592. * @param frustumPlanes defines the frustum planes to test
  48593. * @param selection defines the array to store current content if selection is positive
  48594. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48595. */
  48596. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48597. /**
  48598. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48599. * @param sphereCenter defines the bounding sphere center
  48600. * @param sphereRadius defines the bounding sphere radius
  48601. * @param selection defines the array to store current content if selection is positive
  48602. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48603. */
  48604. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48605. /**
  48606. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48607. * @param ray defines the ray to test with
  48608. * @param selection defines the array to store current content if selection is positive
  48609. */
  48610. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48611. /**
  48612. * Subdivide the content into child blocks (this block will then be empty)
  48613. */
  48614. createInnerBlocks(): void;
  48615. /**
  48616. * @hidden
  48617. */
  48618. 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;
  48619. }
  48620. }
  48621. declare module BABYLON {
  48622. /**
  48623. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48624. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48625. */
  48626. export class Octree<T> {
  48627. /** 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.) */
  48628. maxDepth: number;
  48629. /**
  48630. * Blocks within the octree containing objects
  48631. */
  48632. blocks: Array<OctreeBlock<T>>;
  48633. /**
  48634. * Content stored in the octree
  48635. */
  48636. dynamicContent: T[];
  48637. private _maxBlockCapacity;
  48638. private _selectionContent;
  48639. private _creationFunc;
  48640. /**
  48641. * Creates a octree
  48642. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48643. * @param creationFunc function to be used to instatiate the octree
  48644. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48645. * @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.)
  48646. */
  48647. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48648. /** 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.) */
  48649. maxDepth?: number);
  48650. /**
  48651. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48652. * @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);
  48653. * @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);
  48654. * @param entries meshes to be added to the octree blocks
  48655. */
  48656. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48657. /**
  48658. * Adds a mesh to the octree
  48659. * @param entry Mesh to add to the octree
  48660. */
  48661. addMesh(entry: T): void;
  48662. /**
  48663. * Remove an element from the octree
  48664. * @param entry defines the element to remove
  48665. */
  48666. removeMesh(entry: T): void;
  48667. /**
  48668. * Selects an array of meshes within the frustum
  48669. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48670. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48671. * @returns array of meshes within the frustum
  48672. */
  48673. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48674. /**
  48675. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48676. * @param sphereCenter defines the bounding sphere center
  48677. * @param sphereRadius defines the bounding sphere radius
  48678. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48679. * @returns an array of objects that intersect the sphere
  48680. */
  48681. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48682. /**
  48683. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48684. * @param ray defines the ray to test with
  48685. * @returns array of intersected objects
  48686. */
  48687. intersectsRay(ray: Ray): SmartArray<T>;
  48688. /**
  48689. * Adds a mesh into the octree block if it intersects the block
  48690. */
  48691. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48692. /**
  48693. * Adds a submesh into the octree block if it intersects the block
  48694. */
  48695. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48696. }
  48697. }
  48698. declare module BABYLON {
  48699. interface Scene {
  48700. /**
  48701. * @hidden
  48702. * Backing Filed
  48703. */
  48704. _selectionOctree: Octree<AbstractMesh>;
  48705. /**
  48706. * Gets the octree used to boost mesh selection (picking)
  48707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48708. */
  48709. selectionOctree: Octree<AbstractMesh>;
  48710. /**
  48711. * Creates or updates the octree used to boost selection (picking)
  48712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48713. * @param maxCapacity defines the maximum capacity per leaf
  48714. * @param maxDepth defines the maximum depth of the octree
  48715. * @returns an octree of AbstractMesh
  48716. */
  48717. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48718. }
  48719. interface AbstractMesh {
  48720. /**
  48721. * @hidden
  48722. * Backing Field
  48723. */
  48724. _submeshesOctree: Octree<SubMesh>;
  48725. /**
  48726. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48727. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48728. * @param maxCapacity defines the maximum size of each block (64 by default)
  48729. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48730. * @returns the new octree
  48731. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48733. */
  48734. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48735. }
  48736. /**
  48737. * Defines the octree scene component responsible to manage any octrees
  48738. * in a given scene.
  48739. */
  48740. export class OctreeSceneComponent {
  48741. /**
  48742. * The component name help to identify the component in the list of scene components.
  48743. */
  48744. readonly name: string;
  48745. /**
  48746. * The scene the component belongs to.
  48747. */
  48748. scene: Scene;
  48749. /**
  48750. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48751. */
  48752. readonly checksIsEnabled: boolean;
  48753. /**
  48754. * Creates a new instance of the component for the given scene
  48755. * @param scene Defines the scene to register the component in
  48756. */
  48757. constructor(scene: Scene);
  48758. /**
  48759. * Registers the component in a given scene
  48760. */
  48761. register(): void;
  48762. /**
  48763. * Return the list of active meshes
  48764. * @returns the list of active meshes
  48765. */
  48766. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48767. /**
  48768. * Return the list of active sub meshes
  48769. * @param mesh The mesh to get the candidates sub meshes from
  48770. * @returns the list of active sub meshes
  48771. */
  48772. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48773. private _tempRay;
  48774. /**
  48775. * Return the list of sub meshes intersecting with a given local ray
  48776. * @param mesh defines the mesh to find the submesh for
  48777. * @param localRay defines the ray in local space
  48778. * @returns the list of intersecting sub meshes
  48779. */
  48780. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48781. /**
  48782. * Return the list of sub meshes colliding with a collider
  48783. * @param mesh defines the mesh to find the submesh for
  48784. * @param collider defines the collider to evaluate the collision against
  48785. * @returns the list of colliding sub meshes
  48786. */
  48787. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48788. /**
  48789. * Rebuilds the elements related to this component in case of
  48790. * context lost for instance.
  48791. */
  48792. rebuild(): void;
  48793. /**
  48794. * Disposes the component and the associated ressources.
  48795. */
  48796. dispose(): void;
  48797. }
  48798. }
  48799. declare module BABYLON {
  48800. /**
  48801. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48802. */
  48803. export class Gizmo implements IDisposable {
  48804. /** The utility layer the gizmo will be added to */
  48805. gizmoLayer: UtilityLayerRenderer;
  48806. /**
  48807. * The root mesh of the gizmo
  48808. */
  48809. _rootMesh: Mesh;
  48810. private _attachedMesh;
  48811. /**
  48812. * Ratio for the scale of the gizmo (Default: 1)
  48813. */
  48814. scaleRatio: number;
  48815. /**
  48816. * If a custom mesh has been set (Default: false)
  48817. */
  48818. protected _customMeshSet: boolean;
  48819. /**
  48820. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48821. * * When set, interactions will be enabled
  48822. */
  48823. get attachedMesh(): Nullable<AbstractMesh>;
  48824. set attachedMesh(value: Nullable<AbstractMesh>);
  48825. /**
  48826. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48827. * @param mesh The mesh to replace the default mesh of the gizmo
  48828. */
  48829. setCustomMesh(mesh: Mesh): void;
  48830. /**
  48831. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48832. */
  48833. updateGizmoRotationToMatchAttachedMesh: boolean;
  48834. /**
  48835. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48836. */
  48837. updateGizmoPositionToMatchAttachedMesh: boolean;
  48838. /**
  48839. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48840. */
  48841. updateScale: boolean;
  48842. protected _interactionsEnabled: boolean;
  48843. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48844. private _beforeRenderObserver;
  48845. private _tempVector;
  48846. /**
  48847. * Creates a gizmo
  48848. * @param gizmoLayer The utility layer the gizmo will be added to
  48849. */
  48850. constructor(
  48851. /** The utility layer the gizmo will be added to */
  48852. gizmoLayer?: UtilityLayerRenderer);
  48853. /**
  48854. * Updates the gizmo to match the attached mesh's position/rotation
  48855. */
  48856. protected _update(): void;
  48857. /**
  48858. * Disposes of the gizmo
  48859. */
  48860. dispose(): void;
  48861. }
  48862. }
  48863. declare module BABYLON {
  48864. /**
  48865. * Single plane drag gizmo
  48866. */
  48867. export class PlaneDragGizmo extends Gizmo {
  48868. /**
  48869. * Drag behavior responsible for the gizmos dragging interactions
  48870. */
  48871. dragBehavior: PointerDragBehavior;
  48872. private _pointerObserver;
  48873. /**
  48874. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48875. */
  48876. snapDistance: number;
  48877. /**
  48878. * Event that fires each time the gizmo snaps to a new location.
  48879. * * snapDistance is the the change in distance
  48880. */
  48881. onSnapObservable: Observable<{
  48882. snapDistance: number;
  48883. }>;
  48884. private _plane;
  48885. private _coloredMaterial;
  48886. private _hoverMaterial;
  48887. private _isEnabled;
  48888. private _parent;
  48889. /** @hidden */
  48890. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48891. /** @hidden */
  48892. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48893. /**
  48894. * Creates a PlaneDragGizmo
  48895. * @param gizmoLayer The utility layer the gizmo will be added to
  48896. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48897. * @param color The color of the gizmo
  48898. */
  48899. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48900. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48901. /**
  48902. * If the gizmo is enabled
  48903. */
  48904. set isEnabled(value: boolean);
  48905. get isEnabled(): boolean;
  48906. /**
  48907. * Disposes of the gizmo
  48908. */
  48909. dispose(): void;
  48910. }
  48911. }
  48912. declare module BABYLON {
  48913. /**
  48914. * Gizmo that enables dragging a mesh along 3 axis
  48915. */
  48916. export class PositionGizmo extends Gizmo {
  48917. /**
  48918. * Internal gizmo used for interactions on the x axis
  48919. */
  48920. xGizmo: AxisDragGizmo;
  48921. /**
  48922. * Internal gizmo used for interactions on the y axis
  48923. */
  48924. yGizmo: AxisDragGizmo;
  48925. /**
  48926. * Internal gizmo used for interactions on the z axis
  48927. */
  48928. zGizmo: AxisDragGizmo;
  48929. /**
  48930. * Internal gizmo used for interactions on the yz plane
  48931. */
  48932. xPlaneGizmo: PlaneDragGizmo;
  48933. /**
  48934. * Internal gizmo used for interactions on the xz plane
  48935. */
  48936. yPlaneGizmo: PlaneDragGizmo;
  48937. /**
  48938. * Internal gizmo used for interactions on the xy plane
  48939. */
  48940. zPlaneGizmo: PlaneDragGizmo;
  48941. /**
  48942. * private variables
  48943. */
  48944. private _meshAttached;
  48945. private _updateGizmoRotationToMatchAttachedMesh;
  48946. private _snapDistance;
  48947. private _scaleRatio;
  48948. /** Fires an event when any of it's sub gizmos are dragged */
  48949. onDragStartObservable: Observable<unknown>;
  48950. /** Fires an event when any of it's sub gizmos are released from dragging */
  48951. onDragEndObservable: Observable<unknown>;
  48952. /**
  48953. * If set to true, planar drag is enabled
  48954. */
  48955. private _planarGizmoEnabled;
  48956. get attachedMesh(): Nullable<AbstractMesh>;
  48957. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48958. /**
  48959. * Creates a PositionGizmo
  48960. * @param gizmoLayer The utility layer the gizmo will be added to
  48961. */
  48962. constructor(gizmoLayer?: UtilityLayerRenderer);
  48963. /**
  48964. * If the planar drag gizmo is enabled
  48965. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48966. */
  48967. set planarGizmoEnabled(value: boolean);
  48968. get planarGizmoEnabled(): boolean;
  48969. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48970. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48971. /**
  48972. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48973. */
  48974. set snapDistance(value: number);
  48975. get snapDistance(): number;
  48976. /**
  48977. * Ratio for the scale of the gizmo (Default: 1)
  48978. */
  48979. set scaleRatio(value: number);
  48980. get scaleRatio(): number;
  48981. /**
  48982. * Disposes of the gizmo
  48983. */
  48984. dispose(): void;
  48985. /**
  48986. * CustomMeshes are not supported by this gizmo
  48987. * @param mesh The mesh to replace the default mesh of the gizmo
  48988. */
  48989. setCustomMesh(mesh: Mesh): void;
  48990. }
  48991. }
  48992. declare module BABYLON {
  48993. /**
  48994. * Single axis drag gizmo
  48995. */
  48996. export class AxisDragGizmo extends Gizmo {
  48997. /**
  48998. * Drag behavior responsible for the gizmos dragging interactions
  48999. */
  49000. dragBehavior: PointerDragBehavior;
  49001. private _pointerObserver;
  49002. /**
  49003. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49004. */
  49005. snapDistance: number;
  49006. /**
  49007. * Event that fires each time the gizmo snaps to a new location.
  49008. * * snapDistance is the the change in distance
  49009. */
  49010. onSnapObservable: Observable<{
  49011. snapDistance: number;
  49012. }>;
  49013. private _isEnabled;
  49014. private _parent;
  49015. private _arrow;
  49016. private _coloredMaterial;
  49017. private _hoverMaterial;
  49018. /** @hidden */
  49019. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49020. /** @hidden */
  49021. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49022. /**
  49023. * Creates an AxisDragGizmo
  49024. * @param gizmoLayer The utility layer the gizmo will be added to
  49025. * @param dragAxis The axis which the gizmo will be able to drag on
  49026. * @param color The color of the gizmo
  49027. */
  49028. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49029. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49030. /**
  49031. * If the gizmo is enabled
  49032. */
  49033. set isEnabled(value: boolean);
  49034. get isEnabled(): boolean;
  49035. /**
  49036. * Disposes of the gizmo
  49037. */
  49038. dispose(): void;
  49039. }
  49040. }
  49041. declare module BABYLON.Debug {
  49042. /**
  49043. * The Axes viewer will show 3 axes in a specific point in space
  49044. */
  49045. export class AxesViewer {
  49046. private _xAxis;
  49047. private _yAxis;
  49048. private _zAxis;
  49049. private _scaleLinesFactor;
  49050. private _instanced;
  49051. /**
  49052. * Gets the hosting scene
  49053. */
  49054. scene: Scene;
  49055. /**
  49056. * Gets or sets a number used to scale line length
  49057. */
  49058. scaleLines: number;
  49059. /** Gets the node hierarchy used to render x-axis */
  49060. get xAxis(): TransformNode;
  49061. /** Gets the node hierarchy used to render y-axis */
  49062. get yAxis(): TransformNode;
  49063. /** Gets the node hierarchy used to render z-axis */
  49064. get zAxis(): TransformNode;
  49065. /**
  49066. * Creates a new AxesViewer
  49067. * @param scene defines the hosting scene
  49068. * @param scaleLines defines a number used to scale line length (1 by default)
  49069. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49070. * @param xAxis defines the node hierarchy used to render the x-axis
  49071. * @param yAxis defines the node hierarchy used to render the y-axis
  49072. * @param zAxis defines the node hierarchy used to render the z-axis
  49073. */
  49074. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49075. /**
  49076. * Force the viewer to update
  49077. * @param position defines the position of the viewer
  49078. * @param xaxis defines the x axis of the viewer
  49079. * @param yaxis defines the y axis of the viewer
  49080. * @param zaxis defines the z axis of the viewer
  49081. */
  49082. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49083. /**
  49084. * Creates an instance of this axes viewer.
  49085. * @returns a new axes viewer with instanced meshes
  49086. */
  49087. createInstance(): AxesViewer;
  49088. /** Releases resources */
  49089. dispose(): void;
  49090. private static _SetRenderingGroupId;
  49091. }
  49092. }
  49093. declare module BABYLON.Debug {
  49094. /**
  49095. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49096. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49097. */
  49098. export class BoneAxesViewer extends AxesViewer {
  49099. /**
  49100. * Gets or sets the target mesh where to display the axes viewer
  49101. */
  49102. mesh: Nullable<Mesh>;
  49103. /**
  49104. * Gets or sets the target bone where to display the axes viewer
  49105. */
  49106. bone: Nullable<Bone>;
  49107. /** Gets current position */
  49108. pos: Vector3;
  49109. /** Gets direction of X axis */
  49110. xaxis: Vector3;
  49111. /** Gets direction of Y axis */
  49112. yaxis: Vector3;
  49113. /** Gets direction of Z axis */
  49114. zaxis: Vector3;
  49115. /**
  49116. * Creates a new BoneAxesViewer
  49117. * @param scene defines the hosting scene
  49118. * @param bone defines the target bone
  49119. * @param mesh defines the target mesh
  49120. * @param scaleLines defines a scaling factor for line length (1 by default)
  49121. */
  49122. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49123. /**
  49124. * Force the viewer to update
  49125. */
  49126. update(): void;
  49127. /** Releases resources */
  49128. dispose(): void;
  49129. }
  49130. }
  49131. declare module BABYLON {
  49132. /**
  49133. * Interface used to define scene explorer extensibility option
  49134. */
  49135. export interface IExplorerExtensibilityOption {
  49136. /**
  49137. * Define the option label
  49138. */
  49139. label: string;
  49140. /**
  49141. * Defines the action to execute on click
  49142. */
  49143. action: (entity: any) => void;
  49144. }
  49145. /**
  49146. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49147. */
  49148. export interface IExplorerExtensibilityGroup {
  49149. /**
  49150. * Defines a predicate to test if a given type mut be extended
  49151. */
  49152. predicate: (entity: any) => boolean;
  49153. /**
  49154. * Gets the list of options added to a type
  49155. */
  49156. entries: IExplorerExtensibilityOption[];
  49157. }
  49158. /**
  49159. * Interface used to define the options to use to create the Inspector
  49160. */
  49161. export interface IInspectorOptions {
  49162. /**
  49163. * Display in overlay mode (default: false)
  49164. */
  49165. overlay?: boolean;
  49166. /**
  49167. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49168. */
  49169. globalRoot?: HTMLElement;
  49170. /**
  49171. * Display the Scene explorer
  49172. */
  49173. showExplorer?: boolean;
  49174. /**
  49175. * Display the property inspector
  49176. */
  49177. showInspector?: boolean;
  49178. /**
  49179. * Display in embed mode (both panes on the right)
  49180. */
  49181. embedMode?: boolean;
  49182. /**
  49183. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49184. */
  49185. handleResize?: boolean;
  49186. /**
  49187. * Allow the panes to popup (default: true)
  49188. */
  49189. enablePopup?: boolean;
  49190. /**
  49191. * Allow the panes to be closed by users (default: true)
  49192. */
  49193. enableClose?: boolean;
  49194. /**
  49195. * Optional list of extensibility entries
  49196. */
  49197. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49198. /**
  49199. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49200. */
  49201. inspectorURL?: string;
  49202. /**
  49203. * Optional initial tab (default to DebugLayerTab.Properties)
  49204. */
  49205. initialTab?: DebugLayerTab;
  49206. }
  49207. interface Scene {
  49208. /**
  49209. * @hidden
  49210. * Backing field
  49211. */
  49212. _debugLayer: DebugLayer;
  49213. /**
  49214. * Gets the debug layer (aka Inspector) associated with the scene
  49215. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49216. */
  49217. debugLayer: DebugLayer;
  49218. }
  49219. /**
  49220. * Enum of inspector action tab
  49221. */
  49222. export enum DebugLayerTab {
  49223. /**
  49224. * Properties tag (default)
  49225. */
  49226. Properties = 0,
  49227. /**
  49228. * Debug tab
  49229. */
  49230. Debug = 1,
  49231. /**
  49232. * Statistics tab
  49233. */
  49234. Statistics = 2,
  49235. /**
  49236. * Tools tab
  49237. */
  49238. Tools = 3,
  49239. /**
  49240. * Settings tab
  49241. */
  49242. Settings = 4
  49243. }
  49244. /**
  49245. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49246. * what is happening in your scene
  49247. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49248. */
  49249. export class DebugLayer {
  49250. /**
  49251. * Define the url to get the inspector script from.
  49252. * By default it uses the babylonjs CDN.
  49253. * @ignoreNaming
  49254. */
  49255. static InspectorURL: string;
  49256. private _scene;
  49257. private BJSINSPECTOR;
  49258. private _onPropertyChangedObservable?;
  49259. /**
  49260. * Observable triggered when a property is changed through the inspector.
  49261. */
  49262. get onPropertyChangedObservable(): any;
  49263. /**
  49264. * Instantiates a new debug layer.
  49265. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49266. * what is happening in your scene
  49267. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49268. * @param scene Defines the scene to inspect
  49269. */
  49270. constructor(scene: Scene);
  49271. /** Creates the inspector window. */
  49272. private _createInspector;
  49273. /**
  49274. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49275. * @param entity defines the entity to select
  49276. * @param lineContainerTitle defines the specific block to highlight
  49277. */
  49278. select(entity: any, lineContainerTitle?: string): void;
  49279. /** Get the inspector from bundle or global */
  49280. private _getGlobalInspector;
  49281. /**
  49282. * Get if the inspector is visible or not.
  49283. * @returns true if visible otherwise, false
  49284. */
  49285. isVisible(): boolean;
  49286. /**
  49287. * Hide the inspector and close its window.
  49288. */
  49289. hide(): void;
  49290. /**
  49291. * Update the scene in the inspector
  49292. */
  49293. setAsActiveScene(): void;
  49294. /**
  49295. * Launch the debugLayer.
  49296. * @param config Define the configuration of the inspector
  49297. * @return a promise fulfilled when the debug layer is visible
  49298. */
  49299. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49300. }
  49301. }
  49302. declare module BABYLON {
  49303. /**
  49304. * Class containing static functions to help procedurally build meshes
  49305. */
  49306. export class BoxBuilder {
  49307. /**
  49308. * Creates a box mesh
  49309. * * The parameter `size` sets the size (float) of each box side (default 1)
  49310. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49311. * * 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)
  49312. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49314. * * 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
  49315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49316. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49317. * @param name defines the name of the mesh
  49318. * @param options defines the options used to create the mesh
  49319. * @param scene defines the hosting scene
  49320. * @returns the box mesh
  49321. */
  49322. static CreateBox(name: string, options: {
  49323. size?: number;
  49324. width?: number;
  49325. height?: number;
  49326. depth?: number;
  49327. faceUV?: Vector4[];
  49328. faceColors?: Color4[];
  49329. sideOrientation?: number;
  49330. frontUVs?: Vector4;
  49331. backUVs?: Vector4;
  49332. wrap?: boolean;
  49333. topBaseAt?: number;
  49334. bottomBaseAt?: number;
  49335. updatable?: boolean;
  49336. }, scene?: Nullable<Scene>): Mesh;
  49337. }
  49338. }
  49339. declare module BABYLON.Debug {
  49340. /**
  49341. * Used to show the physics impostor around the specific mesh
  49342. */
  49343. export class PhysicsViewer {
  49344. /** @hidden */
  49345. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49346. /** @hidden */
  49347. protected _meshes: Array<Nullable<AbstractMesh>>;
  49348. /** @hidden */
  49349. protected _scene: Nullable<Scene>;
  49350. /** @hidden */
  49351. protected _numMeshes: number;
  49352. /** @hidden */
  49353. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49354. private _renderFunction;
  49355. private _utilityLayer;
  49356. private _debugBoxMesh;
  49357. private _debugSphereMesh;
  49358. private _debugCylinderMesh;
  49359. private _debugMaterial;
  49360. private _debugMeshMeshes;
  49361. /**
  49362. * Creates a new PhysicsViewer
  49363. * @param scene defines the hosting scene
  49364. */
  49365. constructor(scene: Scene);
  49366. /** @hidden */
  49367. protected _updateDebugMeshes(): void;
  49368. /**
  49369. * Renders a specified physic impostor
  49370. * @param impostor defines the impostor to render
  49371. * @param targetMesh defines the mesh represented by the impostor
  49372. * @returns the new debug mesh used to render the impostor
  49373. */
  49374. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49375. /**
  49376. * Hides a specified physic impostor
  49377. * @param impostor defines the impostor to hide
  49378. */
  49379. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49380. private _getDebugMaterial;
  49381. private _getDebugBoxMesh;
  49382. private _getDebugSphereMesh;
  49383. private _getDebugCylinderMesh;
  49384. private _getDebugMeshMesh;
  49385. private _getDebugMesh;
  49386. /** Releases all resources */
  49387. dispose(): void;
  49388. }
  49389. }
  49390. declare module BABYLON {
  49391. /**
  49392. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49393. * in order to better appreciate the issue one might have.
  49394. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49395. */
  49396. export class RayHelper {
  49397. /**
  49398. * Defines the ray we are currently tryin to visualize.
  49399. */
  49400. ray: Nullable<Ray>;
  49401. private _renderPoints;
  49402. private _renderLine;
  49403. private _renderFunction;
  49404. private _scene;
  49405. private _updateToMeshFunction;
  49406. private _attachedToMesh;
  49407. private _meshSpaceDirection;
  49408. private _meshSpaceOrigin;
  49409. /**
  49410. * Helper function to create a colored helper in a scene in one line.
  49411. * @param ray Defines the ray we are currently tryin to visualize
  49412. * @param scene Defines the scene the ray is used in
  49413. * @param color Defines the color we want to see the ray in
  49414. * @returns The newly created ray helper.
  49415. */
  49416. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49417. /**
  49418. * Instantiate a new ray helper.
  49419. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49420. * in order to better appreciate the issue one might have.
  49421. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49422. * @param ray Defines the ray we are currently tryin to visualize
  49423. */
  49424. constructor(ray: Ray);
  49425. /**
  49426. * Shows the ray we are willing to debug.
  49427. * @param scene Defines the scene the ray needs to be rendered in
  49428. * @param color Defines the color the ray needs to be rendered in
  49429. */
  49430. show(scene: Scene, color?: Color3): void;
  49431. /**
  49432. * Hides the ray we are debugging.
  49433. */
  49434. hide(): void;
  49435. private _render;
  49436. /**
  49437. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49438. * @param mesh Defines the mesh we want the helper attached to
  49439. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49440. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49441. * @param length Defines the length of the ray
  49442. */
  49443. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49444. /**
  49445. * Detach the ray helper from the mesh it has previously been attached to.
  49446. */
  49447. detachFromMesh(): void;
  49448. private _updateToMesh;
  49449. /**
  49450. * Dispose the helper and release its associated resources.
  49451. */
  49452. dispose(): void;
  49453. }
  49454. }
  49455. declare module BABYLON.Debug {
  49456. /**
  49457. * Class used to render a debug view of a given skeleton
  49458. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49459. */
  49460. export class SkeletonViewer {
  49461. /** defines the skeleton to render */
  49462. skeleton: Skeleton;
  49463. /** defines the mesh attached to the skeleton */
  49464. mesh: AbstractMesh;
  49465. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49466. autoUpdateBonesMatrices: boolean;
  49467. /** defines the rendering group id to use with the viewer */
  49468. renderingGroupId: number;
  49469. /** Gets or sets the color used to render the skeleton */
  49470. color: Color3;
  49471. private _scene;
  49472. private _debugLines;
  49473. private _debugMesh;
  49474. private _isEnabled;
  49475. private _renderFunction;
  49476. private _utilityLayer;
  49477. /**
  49478. * Returns the mesh used to render the bones
  49479. */
  49480. get debugMesh(): Nullable<LinesMesh>;
  49481. /**
  49482. * Creates a new SkeletonViewer
  49483. * @param skeleton defines the skeleton to render
  49484. * @param mesh defines the mesh attached to the skeleton
  49485. * @param scene defines the hosting scene
  49486. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49487. * @param renderingGroupId defines the rendering group id to use with the viewer
  49488. */
  49489. constructor(
  49490. /** defines the skeleton to render */
  49491. skeleton: Skeleton,
  49492. /** defines the mesh attached to the skeleton */
  49493. mesh: AbstractMesh, scene: Scene,
  49494. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49495. autoUpdateBonesMatrices?: boolean,
  49496. /** defines the rendering group id to use with the viewer */
  49497. renderingGroupId?: number);
  49498. /** Gets or sets a boolean indicating if the viewer is enabled */
  49499. set isEnabled(value: boolean);
  49500. get isEnabled(): boolean;
  49501. private _getBonePosition;
  49502. private _getLinesForBonesWithLength;
  49503. private _getLinesForBonesNoLength;
  49504. /** Update the viewer to sync with current skeleton state */
  49505. update(): void;
  49506. /** Release associated resources */
  49507. dispose(): void;
  49508. }
  49509. }
  49510. declare module BABYLON {
  49511. /**
  49512. * Enum for Device Types
  49513. */
  49514. export enum DeviceType {
  49515. /** Generic */
  49516. Generic = 0,
  49517. /** Keyboard */
  49518. Keyboard = 1,
  49519. /** Mouse */
  49520. Mouse = 2,
  49521. /** Touch Pointers */
  49522. Touch = 3,
  49523. /** PS4 Dual Shock */
  49524. DualShock = 4,
  49525. /** Xbox */
  49526. Xbox = 5,
  49527. /** Switch Controller */
  49528. Switch = 6
  49529. }
  49530. /**
  49531. * Enum for All Pointers (Touch/Mouse)
  49532. */
  49533. export enum PointerInput {
  49534. /** Horizontal Axis */
  49535. Horizontal = 0,
  49536. /** Vertical Axis */
  49537. Vertical = 1,
  49538. /** Left Click or Touch */
  49539. LeftClick = 2,
  49540. /** Middle Click */
  49541. MiddleClick = 3,
  49542. /** Right Click */
  49543. RightClick = 4,
  49544. /** Browser Back */
  49545. BrowserBack = 5,
  49546. /** Browser Forward */
  49547. BrowserForward = 6
  49548. }
  49549. /**
  49550. * Enum for Dual Shock Gamepad
  49551. */
  49552. export enum DualShockInput {
  49553. /** Cross */
  49554. Cross = 0,
  49555. /** Circle */
  49556. Circle = 1,
  49557. /** Square */
  49558. Square = 2,
  49559. /** Triangle */
  49560. Triangle = 3,
  49561. /** L1 */
  49562. L1 = 4,
  49563. /** R1 */
  49564. R1 = 5,
  49565. /** L2 */
  49566. L2 = 6,
  49567. /** R2 */
  49568. R2 = 7,
  49569. /** Share */
  49570. Share = 8,
  49571. /** Options */
  49572. Options = 9,
  49573. /** L3 */
  49574. L3 = 10,
  49575. /** R3 */
  49576. R3 = 11,
  49577. /** DPadUp */
  49578. DPadUp = 12,
  49579. /** DPadDown */
  49580. DPadDown = 13,
  49581. /** DPadLeft */
  49582. DPadLeft = 14,
  49583. /** DRight */
  49584. DPadRight = 15,
  49585. /** Home */
  49586. Home = 16,
  49587. /** TouchPad */
  49588. TouchPad = 17,
  49589. /** LStickXAxis */
  49590. LStickXAxis = 18,
  49591. /** LStickYAxis */
  49592. LStickYAxis = 19,
  49593. /** RStickXAxis */
  49594. RStickXAxis = 20,
  49595. /** RStickYAxis */
  49596. RStickYAxis = 21
  49597. }
  49598. /**
  49599. * Enum for Xbox Gamepad
  49600. */
  49601. export enum XboxInput {
  49602. /** A */
  49603. A = 0,
  49604. /** B */
  49605. B = 1,
  49606. /** X */
  49607. X = 2,
  49608. /** Y */
  49609. Y = 3,
  49610. /** LB */
  49611. LB = 4,
  49612. /** RB */
  49613. RB = 5,
  49614. /** LT */
  49615. LT = 6,
  49616. /** RT */
  49617. RT = 7,
  49618. /** Back */
  49619. Back = 8,
  49620. /** Start */
  49621. Start = 9,
  49622. /** LS */
  49623. LS = 10,
  49624. /** RS */
  49625. RS = 11,
  49626. /** DPadUp */
  49627. DPadUp = 12,
  49628. /** DPadDown */
  49629. DPadDown = 13,
  49630. /** DPadLeft */
  49631. DPadLeft = 14,
  49632. /** DRight */
  49633. DPadRight = 15,
  49634. /** Home */
  49635. Home = 16,
  49636. /** LStickXAxis */
  49637. LStickXAxis = 17,
  49638. /** LStickYAxis */
  49639. LStickYAxis = 18,
  49640. /** RStickXAxis */
  49641. RStickXAxis = 19,
  49642. /** RStickYAxis */
  49643. RStickYAxis = 20
  49644. }
  49645. /**
  49646. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49647. */
  49648. export enum SwitchInput {
  49649. /** B */
  49650. B = 0,
  49651. /** A */
  49652. A = 1,
  49653. /** Y */
  49654. Y = 2,
  49655. /** X */
  49656. X = 3,
  49657. /** L */
  49658. L = 4,
  49659. /** R */
  49660. R = 5,
  49661. /** ZL */
  49662. ZL = 6,
  49663. /** ZR */
  49664. ZR = 7,
  49665. /** Minus */
  49666. Minus = 8,
  49667. /** Plus */
  49668. Plus = 9,
  49669. /** LS */
  49670. LS = 10,
  49671. /** RS */
  49672. RS = 11,
  49673. /** DPadUp */
  49674. DPadUp = 12,
  49675. /** DPadDown */
  49676. DPadDown = 13,
  49677. /** DPadLeft */
  49678. DPadLeft = 14,
  49679. /** DRight */
  49680. DPadRight = 15,
  49681. /** Home */
  49682. Home = 16,
  49683. /** Capture */
  49684. Capture = 17,
  49685. /** LStickXAxis */
  49686. LStickXAxis = 18,
  49687. /** LStickYAxis */
  49688. LStickYAxis = 19,
  49689. /** RStickXAxis */
  49690. RStickXAxis = 20,
  49691. /** RStickYAxis */
  49692. RStickYAxis = 21
  49693. }
  49694. }
  49695. declare module BABYLON {
  49696. /**
  49697. * This class will take all inputs from Keyboard, Pointer, and
  49698. * any Gamepads and provide a polling system that all devices
  49699. * will use. This class assumes that there will only be one
  49700. * pointer device and one keyboard.
  49701. */
  49702. export class DeviceInputSystem implements IDisposable {
  49703. /**
  49704. * Callback to be triggered when a device is connected
  49705. */
  49706. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49707. /**
  49708. * Callback to be triggered when a device is disconnected
  49709. */
  49710. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49711. /**
  49712. * Callback to be triggered when event driven input is updated
  49713. */
  49714. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  49715. private _inputs;
  49716. private _gamepads;
  49717. private _keyboardActive;
  49718. private _pointerActive;
  49719. private _elementToAttachTo;
  49720. private _keyboardDownEvent;
  49721. private _keyboardUpEvent;
  49722. private _pointerMoveEvent;
  49723. private _pointerDownEvent;
  49724. private _pointerUpEvent;
  49725. private _gamepadConnectedEvent;
  49726. private _gamepadDisconnectedEvent;
  49727. private static _MAX_KEYCODES;
  49728. private static _MAX_POINTER_INPUTS;
  49729. /**
  49730. * Default Constructor
  49731. * @param engine - engine to pull input element from
  49732. */
  49733. constructor(engine: Engine);
  49734. /**
  49735. * Checks for current device input value, given an id and input index
  49736. * @param deviceName Id of connected device
  49737. * @param inputIndex Index of device input
  49738. * @returns Current value of input
  49739. */
  49740. /**
  49741. * Checks for current device input value, given an id and input index
  49742. * @param deviceType Enum specifiying device type
  49743. * @param deviceSlot "Slot" or index that device is referenced in
  49744. * @param inputIndex Id of input to be checked
  49745. * @returns Current value of input
  49746. */
  49747. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  49748. /**
  49749. * Dispose of all the eventlisteners
  49750. */
  49751. dispose(): void;
  49752. /**
  49753. * Add device and inputs to device array
  49754. * @param deviceType Enum specifiying device type
  49755. * @param deviceSlot "Slot" or index that device is referenced in
  49756. * @param numberOfInputs Number of input entries to create for given device
  49757. */
  49758. private _registerDevice;
  49759. /**
  49760. * Given a specific device name, remove that device from the device map
  49761. * @param deviceType Enum specifiying device type
  49762. * @param deviceSlot "Slot" or index that device is referenced in
  49763. */
  49764. private _unregisterDevice;
  49765. /**
  49766. * Handle all actions that come from keyboard interaction
  49767. */
  49768. private _handleKeyActions;
  49769. /**
  49770. * Handle all actions that come from pointer interaction
  49771. */
  49772. private _handlePointerActions;
  49773. /**
  49774. * Handle all actions that come from gamepad interaction
  49775. */
  49776. private _handleGamepadActions;
  49777. /**
  49778. * Update all non-event based devices with each frame
  49779. * @param deviceType Enum specifiying device type
  49780. * @param deviceSlot "Slot" or index that device is referenced in
  49781. * @param inputIndex Id of input to be checked
  49782. */
  49783. private _updateDevice;
  49784. /**
  49785. * Gets DeviceType from the device name
  49786. * @param deviceName Name of Device from DeviceInputSystem
  49787. * @returns DeviceType enum value
  49788. */
  49789. private _getGamepadDeviceType;
  49790. }
  49791. }
  49792. declare module BABYLON {
  49793. /**
  49794. * Type to handle enforcement of inputs
  49795. */
  49796. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  49797. }
  49798. declare module BABYLON {
  49799. /**
  49800. * Class that handles all input for a specific device
  49801. */
  49802. export class DeviceSource<T extends DeviceType> {
  49803. /** Type of device */
  49804. readonly deviceType: DeviceType;
  49805. /** "Slot" or index that device is referenced in */
  49806. readonly deviceSlot: number;
  49807. /**
  49808. * Observable to handle device input changes per device
  49809. */
  49810. readonly onInputChangedObservable: Observable<{
  49811. inputIndex: DeviceInput<T>;
  49812. previousState: Nullable<number>;
  49813. currentState: Nullable<number>;
  49814. }>;
  49815. private readonly _deviceInputSystem;
  49816. /**
  49817. * Default Constructor
  49818. * @param deviceInputSystem Reference to DeviceInputSystem
  49819. * @param deviceType Type of device
  49820. * @param deviceSlot "Slot" or index that device is referenced in
  49821. */
  49822. constructor(deviceInputSystem: DeviceInputSystem,
  49823. /** Type of device */
  49824. deviceType: DeviceType,
  49825. /** "Slot" or index that device is referenced in */
  49826. deviceSlot?: number);
  49827. /**
  49828. * Get input for specific input
  49829. * @param inputIndex index of specific input on device
  49830. * @returns Input value from DeviceInputSystem
  49831. */
  49832. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  49833. }
  49834. /**
  49835. * Class to keep track of devices
  49836. */
  49837. export class DeviceSourceManager implements IDisposable {
  49838. /**
  49839. * Observable to be triggered when before a device is connected
  49840. */
  49841. readonly onBeforeDeviceConnectedObservable: Observable<{
  49842. deviceType: DeviceType;
  49843. deviceSlot: number;
  49844. }>;
  49845. /**
  49846. * Observable to be triggered when before a device is disconnected
  49847. */
  49848. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  49849. deviceType: DeviceType;
  49850. deviceSlot: number;
  49851. }>;
  49852. /**
  49853. * Observable to be triggered when after a device is connected
  49854. */
  49855. readonly onAfterDeviceConnectedObservable: Observable<{
  49856. deviceType: DeviceType;
  49857. deviceSlot: number;
  49858. }>;
  49859. /**
  49860. * Observable to be triggered when after a device is disconnected
  49861. */
  49862. readonly onAfterDeviceDisconnectedObservable: Observable<{
  49863. deviceType: DeviceType;
  49864. deviceSlot: number;
  49865. }>;
  49866. private readonly _devices;
  49867. private readonly _firstDevice;
  49868. private readonly _deviceInputSystem;
  49869. /**
  49870. * Default Constructor
  49871. * @param engine engine to pull input element from
  49872. */
  49873. constructor(engine: Engine);
  49874. /**
  49875. * Gets a DeviceSource, given a type and slot
  49876. * @param deviceType Enum specifying device type
  49877. * @param deviceSlot "Slot" or index that device is referenced in
  49878. * @returns DeviceSource object
  49879. */
  49880. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  49881. /**
  49882. * Gets an array of DeviceSource objects for a given device type
  49883. * @param deviceType Enum specifying device type
  49884. * @returns Array of DeviceSource objects
  49885. */
  49886. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  49887. /**
  49888. * Dispose of DeviceInputSystem and other parts
  49889. */
  49890. dispose(): void;
  49891. /**
  49892. * Function to add device name to device list
  49893. * @param deviceType Enum specifying device type
  49894. * @param deviceSlot "Slot" or index that device is referenced in
  49895. */
  49896. private _addDevice;
  49897. /**
  49898. * Function to remove device name to device list
  49899. * @param deviceType Enum specifying device type
  49900. * @param deviceSlot "Slot" or index that device is referenced in
  49901. */
  49902. private _removeDevice;
  49903. /**
  49904. * Updates array storing first connected device of each type
  49905. * @param type Type of Device
  49906. */
  49907. private _updateFirstDevices;
  49908. }
  49909. }
  49910. declare module BABYLON {
  49911. /**
  49912. * Options to create the null engine
  49913. */
  49914. export class NullEngineOptions {
  49915. /**
  49916. * Render width (Default: 512)
  49917. */
  49918. renderWidth: number;
  49919. /**
  49920. * Render height (Default: 256)
  49921. */
  49922. renderHeight: number;
  49923. /**
  49924. * Texture size (Default: 512)
  49925. */
  49926. textureSize: number;
  49927. /**
  49928. * If delta time between frames should be constant
  49929. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49930. */
  49931. deterministicLockstep: boolean;
  49932. /**
  49933. * Maximum about of steps between frames (Default: 4)
  49934. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49935. */
  49936. lockstepMaxSteps: number;
  49937. }
  49938. /**
  49939. * The null engine class provides support for headless version of babylon.js.
  49940. * This can be used in server side scenario or for testing purposes
  49941. */
  49942. export class NullEngine extends Engine {
  49943. private _options;
  49944. /**
  49945. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  49946. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49947. * @returns true if engine is in deterministic lock step mode
  49948. */
  49949. isDeterministicLockStep(): boolean;
  49950. /**
  49951. * Gets the max steps when engine is running in deterministic lock step
  49952. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49953. * @returns the max steps
  49954. */
  49955. getLockstepMaxSteps(): number;
  49956. /**
  49957. * Gets the current hardware scaling level.
  49958. * By default the hardware scaling level is computed from the window device ratio.
  49959. * 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.
  49960. * @returns a number indicating the current hardware scaling level
  49961. */
  49962. getHardwareScalingLevel(): number;
  49963. constructor(options?: NullEngineOptions);
  49964. /**
  49965. * Creates a vertex buffer
  49966. * @param vertices the data for the vertex buffer
  49967. * @returns the new WebGL static buffer
  49968. */
  49969. createVertexBuffer(vertices: FloatArray): DataBuffer;
  49970. /**
  49971. * Creates a new index buffer
  49972. * @param indices defines the content of the index buffer
  49973. * @param updatable defines if the index buffer must be updatable
  49974. * @returns a new webGL buffer
  49975. */
  49976. createIndexBuffer(indices: IndicesArray): DataBuffer;
  49977. /**
  49978. * Clear the current render buffer or the current render target (if any is set up)
  49979. * @param color defines the color to use
  49980. * @param backBuffer defines if the back buffer must be cleared
  49981. * @param depth defines if the depth buffer must be cleared
  49982. * @param stencil defines if the stencil buffer must be cleared
  49983. */
  49984. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49985. /**
  49986. * Gets the current render width
  49987. * @param useScreen defines if screen size must be used (or the current render target if any)
  49988. * @returns a number defining the current render width
  49989. */
  49990. getRenderWidth(useScreen?: boolean): number;
  49991. /**
  49992. * Gets the current render height
  49993. * @param useScreen defines if screen size must be used (or the current render target if any)
  49994. * @returns a number defining the current render height
  49995. */
  49996. getRenderHeight(useScreen?: boolean): number;
  49997. /**
  49998. * Set the WebGL's viewport
  49999. * @param viewport defines the viewport element to be used
  50000. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50001. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50002. */
  50003. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50004. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50005. /**
  50006. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50007. * @param pipelineContext defines the pipeline context to use
  50008. * @param uniformsNames defines the list of uniform names
  50009. * @returns an array of webGL uniform locations
  50010. */
  50011. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50012. /**
  50013. * Gets the lsit of active attributes for a given webGL program
  50014. * @param pipelineContext defines the pipeline context to use
  50015. * @param attributesNames defines the list of attribute names to get
  50016. * @returns an array of indices indicating the offset of each attribute
  50017. */
  50018. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50019. /**
  50020. * Binds an effect to the webGL context
  50021. * @param effect defines the effect to bind
  50022. */
  50023. bindSamplers(effect: Effect): void;
  50024. /**
  50025. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50026. * @param effect defines the effect to activate
  50027. */
  50028. enableEffect(effect: Effect): void;
  50029. /**
  50030. * Set various states to the webGL context
  50031. * @param culling defines backface culling state
  50032. * @param zOffset defines the value to apply to zOffset (0 by default)
  50033. * @param force defines if states must be applied even if cache is up to date
  50034. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50035. */
  50036. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50037. /**
  50038. * Set the value of an uniform to an array of int32
  50039. * @param uniform defines the webGL uniform location where to store the value
  50040. * @param array defines the array of int32 to store
  50041. */
  50042. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50043. /**
  50044. * Set the value of an uniform to an array of int32 (stored as vec2)
  50045. * @param uniform defines the webGL uniform location where to store the value
  50046. * @param array defines the array of int32 to store
  50047. */
  50048. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50049. /**
  50050. * Set the value of an uniform to an array of int32 (stored as vec3)
  50051. * @param uniform defines the webGL uniform location where to store the value
  50052. * @param array defines the array of int32 to store
  50053. */
  50054. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50055. /**
  50056. * Set the value of an uniform to an array of int32 (stored as vec4)
  50057. * @param uniform defines the webGL uniform location where to store the value
  50058. * @param array defines the array of int32 to store
  50059. */
  50060. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50061. /**
  50062. * Set the value of an uniform to an array of float32
  50063. * @param uniform defines the webGL uniform location where to store the value
  50064. * @param array defines the array of float32 to store
  50065. */
  50066. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50067. /**
  50068. * Set the value of an uniform to an array of float32 (stored as vec2)
  50069. * @param uniform defines the webGL uniform location where to store the value
  50070. * @param array defines the array of float32 to store
  50071. */
  50072. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50073. /**
  50074. * Set the value of an uniform to an array of float32 (stored as vec3)
  50075. * @param uniform defines the webGL uniform location where to store the value
  50076. * @param array defines the array of float32 to store
  50077. */
  50078. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50079. /**
  50080. * Set the value of an uniform to an array of float32 (stored as vec4)
  50081. * @param uniform defines the webGL uniform location where to store the value
  50082. * @param array defines the array of float32 to store
  50083. */
  50084. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50085. /**
  50086. * Set the value of an uniform to an array of number
  50087. * @param uniform defines the webGL uniform location where to store the value
  50088. * @param array defines the array of number to store
  50089. */
  50090. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50091. /**
  50092. * Set the value of an uniform to an array of number (stored as vec2)
  50093. * @param uniform defines the webGL uniform location where to store the value
  50094. * @param array defines the array of number to store
  50095. */
  50096. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50097. /**
  50098. * Set the value of an uniform to an array of number (stored as vec3)
  50099. * @param uniform defines the webGL uniform location where to store the value
  50100. * @param array defines the array of number to store
  50101. */
  50102. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50103. /**
  50104. * Set the value of an uniform to an array of number (stored as vec4)
  50105. * @param uniform defines the webGL uniform location where to store the value
  50106. * @param array defines the array of number to store
  50107. */
  50108. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50109. /**
  50110. * Set the value of an uniform to an array of float32 (stored as matrices)
  50111. * @param uniform defines the webGL uniform location where to store the value
  50112. * @param matrices defines the array of float32 to store
  50113. */
  50114. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50115. /**
  50116. * Set the value of an uniform to a matrix (3x3)
  50117. * @param uniform defines the webGL uniform location where to store the value
  50118. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50119. */
  50120. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50121. /**
  50122. * Set the value of an uniform to a matrix (2x2)
  50123. * @param uniform defines the webGL uniform location where to store the value
  50124. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50125. */
  50126. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50127. /**
  50128. * Set the value of an uniform to a number (float)
  50129. * @param uniform defines the webGL uniform location where to store the value
  50130. * @param value defines the float number to store
  50131. */
  50132. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50133. /**
  50134. * Set the value of an uniform to a vec2
  50135. * @param uniform defines the webGL uniform location where to store the value
  50136. * @param x defines the 1st component of the value
  50137. * @param y defines the 2nd component of the value
  50138. */
  50139. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50140. /**
  50141. * Set the value of an uniform to a vec3
  50142. * @param uniform defines the webGL uniform location where to store the value
  50143. * @param x defines the 1st component of the value
  50144. * @param y defines the 2nd component of the value
  50145. * @param z defines the 3rd component of the value
  50146. */
  50147. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50148. /**
  50149. * Set the value of an uniform to a boolean
  50150. * @param uniform defines the webGL uniform location where to store the value
  50151. * @param bool defines the boolean to store
  50152. */
  50153. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50154. /**
  50155. * Set the value of an uniform to a vec4
  50156. * @param uniform defines the webGL uniform location where to store the value
  50157. * @param x defines the 1st component of the value
  50158. * @param y defines the 2nd component of the value
  50159. * @param z defines the 3rd component of the value
  50160. * @param w defines the 4th component of the value
  50161. */
  50162. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50163. /**
  50164. * Sets the current alpha mode
  50165. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50166. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50167. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50168. */
  50169. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50170. /**
  50171. * Bind webGl buffers directly to the webGL context
  50172. * @param vertexBuffers defines the vertex buffer to bind
  50173. * @param indexBuffer defines the index buffer to bind
  50174. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50175. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50176. * @param effect defines the effect associated with the vertex buffer
  50177. */
  50178. bindBuffers(vertexBuffers: {
  50179. [key: string]: VertexBuffer;
  50180. }, indexBuffer: DataBuffer, effect: Effect): void;
  50181. /**
  50182. * Force the entire cache to be cleared
  50183. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50184. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50185. */
  50186. wipeCaches(bruteForce?: boolean): void;
  50187. /**
  50188. * Send a draw order
  50189. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50190. * @param indexStart defines the starting index
  50191. * @param indexCount defines the number of index to draw
  50192. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50193. */
  50194. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50195. /**
  50196. * Draw a list of indexed primitives
  50197. * @param fillMode defines the primitive to use
  50198. * @param indexStart defines the starting index
  50199. * @param indexCount defines the number of index to draw
  50200. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50201. */
  50202. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50203. /**
  50204. * Draw a list of unindexed primitives
  50205. * @param fillMode defines the primitive to use
  50206. * @param verticesStart defines the index of first vertex to draw
  50207. * @param verticesCount defines the count of vertices to draw
  50208. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50209. */
  50210. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50211. /** @hidden */
  50212. _createTexture(): WebGLTexture;
  50213. /** @hidden */
  50214. _releaseTexture(texture: InternalTexture): void;
  50215. /**
  50216. * Usually called from Texture.ts.
  50217. * Passed information to create a WebGLTexture
  50218. * @param urlArg defines a value which contains one of the following:
  50219. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50220. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50221. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50222. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50223. * @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)
  50224. * @param scene needed for loading to the correct scene
  50225. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50226. * @param onLoad optional callback to be called upon successful completion
  50227. * @param onError optional callback to be called upon failure
  50228. * @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
  50229. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50230. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50231. * @param forcedExtension defines the extension to use to pick the right loader
  50232. * @param mimeType defines an optional mime type
  50233. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50234. */
  50235. 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;
  50236. /**
  50237. * Creates a new render target texture
  50238. * @param size defines the size of the texture
  50239. * @param options defines the options used to create the texture
  50240. * @returns a new render target texture stored in an InternalTexture
  50241. */
  50242. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50243. /**
  50244. * Update the sampling mode of a given texture
  50245. * @param samplingMode defines the required sampling mode
  50246. * @param texture defines the texture to update
  50247. */
  50248. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50249. /**
  50250. * Binds the frame buffer to the specified texture.
  50251. * @param texture The texture to render to or null for the default canvas
  50252. * @param faceIndex The face of the texture to render to in case of cube texture
  50253. * @param requiredWidth The width of the target to render to
  50254. * @param requiredHeight The height of the target to render to
  50255. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50256. * @param lodLevel defines le lod level to bind to the frame buffer
  50257. */
  50258. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50259. /**
  50260. * Unbind the current render target texture from the webGL context
  50261. * @param texture defines the render target texture to unbind
  50262. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50263. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50264. */
  50265. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50266. /**
  50267. * Creates a dynamic vertex buffer
  50268. * @param vertices the data for the dynamic vertex buffer
  50269. * @returns the new WebGL dynamic buffer
  50270. */
  50271. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50272. /**
  50273. * Update the content of a dynamic texture
  50274. * @param texture defines the texture to update
  50275. * @param canvas defines the canvas containing the source
  50276. * @param invertY defines if data must be stored with Y axis inverted
  50277. * @param premulAlpha defines if alpha is stored as premultiplied
  50278. * @param format defines the format of the data
  50279. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50280. */
  50281. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50282. /**
  50283. * Gets a boolean indicating if all created effects are ready
  50284. * @returns true if all effects are ready
  50285. */
  50286. areAllEffectsReady(): boolean;
  50287. /**
  50288. * @hidden
  50289. * Get the current error code of the webGL context
  50290. * @returns the error code
  50291. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50292. */
  50293. getError(): number;
  50294. /** @hidden */
  50295. _getUnpackAlignement(): number;
  50296. /** @hidden */
  50297. _unpackFlipY(value: boolean): void;
  50298. /**
  50299. * Update a dynamic index buffer
  50300. * @param indexBuffer defines the target index buffer
  50301. * @param indices defines the data to update
  50302. * @param offset defines the offset in the target index buffer where update should start
  50303. */
  50304. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50305. /**
  50306. * Updates a dynamic vertex buffer.
  50307. * @param vertexBuffer the vertex buffer to update
  50308. * @param vertices the data used to update the vertex buffer
  50309. * @param byteOffset the byte offset of the data (optional)
  50310. * @param byteLength the byte length of the data (optional)
  50311. */
  50312. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50313. /** @hidden */
  50314. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50315. /** @hidden */
  50316. _bindTexture(channel: number, texture: InternalTexture): void;
  50317. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50318. /**
  50319. * 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
  50320. */
  50321. releaseEffects(): void;
  50322. displayLoadingUI(): void;
  50323. hideLoadingUI(): void;
  50324. /** @hidden */
  50325. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50326. /** @hidden */
  50327. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50328. /** @hidden */
  50329. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50330. /** @hidden */
  50331. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50332. }
  50333. }
  50334. declare module BABYLON {
  50335. /**
  50336. * @hidden
  50337. **/
  50338. export class _TimeToken {
  50339. _startTimeQuery: Nullable<WebGLQuery>;
  50340. _endTimeQuery: Nullable<WebGLQuery>;
  50341. _timeElapsedQuery: Nullable<WebGLQuery>;
  50342. _timeElapsedQueryEnded: boolean;
  50343. }
  50344. }
  50345. declare module BABYLON {
  50346. /** @hidden */
  50347. export class _OcclusionDataStorage {
  50348. /** @hidden */
  50349. occlusionInternalRetryCounter: number;
  50350. /** @hidden */
  50351. isOcclusionQueryInProgress: boolean;
  50352. /** @hidden */
  50353. isOccluded: boolean;
  50354. /** @hidden */
  50355. occlusionRetryCount: number;
  50356. /** @hidden */
  50357. occlusionType: number;
  50358. /** @hidden */
  50359. occlusionQueryAlgorithmType: number;
  50360. }
  50361. interface Engine {
  50362. /**
  50363. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50364. * @return the new query
  50365. */
  50366. createQuery(): WebGLQuery;
  50367. /**
  50368. * Delete and release a webGL query
  50369. * @param query defines the query to delete
  50370. * @return the current engine
  50371. */
  50372. deleteQuery(query: WebGLQuery): Engine;
  50373. /**
  50374. * Check if a given query has resolved and got its value
  50375. * @param query defines the query to check
  50376. * @returns true if the query got its value
  50377. */
  50378. isQueryResultAvailable(query: WebGLQuery): boolean;
  50379. /**
  50380. * Gets the value of a given query
  50381. * @param query defines the query to check
  50382. * @returns the value of the query
  50383. */
  50384. getQueryResult(query: WebGLQuery): number;
  50385. /**
  50386. * Initiates an occlusion query
  50387. * @param algorithmType defines the algorithm to use
  50388. * @param query defines the query to use
  50389. * @returns the current engine
  50390. * @see http://doc.babylonjs.com/features/occlusionquery
  50391. */
  50392. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50393. /**
  50394. * Ends an occlusion query
  50395. * @see http://doc.babylonjs.com/features/occlusionquery
  50396. * @param algorithmType defines the algorithm to use
  50397. * @returns the current engine
  50398. */
  50399. endOcclusionQuery(algorithmType: number): Engine;
  50400. /**
  50401. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50402. * Please note that only one query can be issued at a time
  50403. * @returns a time token used to track the time span
  50404. */
  50405. startTimeQuery(): Nullable<_TimeToken>;
  50406. /**
  50407. * Ends a time query
  50408. * @param token defines the token used to measure the time span
  50409. * @returns the time spent (in ns)
  50410. */
  50411. endTimeQuery(token: _TimeToken): int;
  50412. /** @hidden */
  50413. _currentNonTimestampToken: Nullable<_TimeToken>;
  50414. /** @hidden */
  50415. _createTimeQuery(): WebGLQuery;
  50416. /** @hidden */
  50417. _deleteTimeQuery(query: WebGLQuery): void;
  50418. /** @hidden */
  50419. _getGlAlgorithmType(algorithmType: number): number;
  50420. /** @hidden */
  50421. _getTimeQueryResult(query: WebGLQuery): any;
  50422. /** @hidden */
  50423. _getTimeQueryAvailability(query: WebGLQuery): any;
  50424. }
  50425. interface AbstractMesh {
  50426. /**
  50427. * Backing filed
  50428. * @hidden
  50429. */
  50430. __occlusionDataStorage: _OcclusionDataStorage;
  50431. /**
  50432. * Access property
  50433. * @hidden
  50434. */
  50435. _occlusionDataStorage: _OcclusionDataStorage;
  50436. /**
  50437. * 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.
  50438. * The default value is -1 which means don't break the query and wait till the result
  50439. * @see http://doc.babylonjs.com/features/occlusionquery
  50440. */
  50441. occlusionRetryCount: number;
  50442. /**
  50443. * 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:
  50444. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50445. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50446. * * 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.
  50447. * @see http://doc.babylonjs.com/features/occlusionquery
  50448. */
  50449. occlusionType: number;
  50450. /**
  50451. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50452. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50453. * * 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.
  50454. * @see http://doc.babylonjs.com/features/occlusionquery
  50455. */
  50456. occlusionQueryAlgorithmType: number;
  50457. /**
  50458. * 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
  50459. * @see http://doc.babylonjs.com/features/occlusionquery
  50460. */
  50461. isOccluded: boolean;
  50462. /**
  50463. * Flag to check the progress status of the query
  50464. * @see http://doc.babylonjs.com/features/occlusionquery
  50465. */
  50466. isOcclusionQueryInProgress: boolean;
  50467. }
  50468. }
  50469. declare module BABYLON {
  50470. /** @hidden */
  50471. export var _forceTransformFeedbackToBundle: boolean;
  50472. interface Engine {
  50473. /**
  50474. * Creates a webGL transform feedback object
  50475. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50476. * @returns the webGL transform feedback object
  50477. */
  50478. createTransformFeedback(): WebGLTransformFeedback;
  50479. /**
  50480. * Delete a webGL transform feedback object
  50481. * @param value defines the webGL transform feedback object to delete
  50482. */
  50483. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50484. /**
  50485. * Bind a webGL transform feedback object to the webgl context
  50486. * @param value defines the webGL transform feedback object to bind
  50487. */
  50488. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50489. /**
  50490. * Begins a transform feedback operation
  50491. * @param usePoints defines if points or triangles must be used
  50492. */
  50493. beginTransformFeedback(usePoints: boolean): void;
  50494. /**
  50495. * Ends a transform feedback operation
  50496. */
  50497. endTransformFeedback(): void;
  50498. /**
  50499. * Specify the varyings to use with transform feedback
  50500. * @param program defines the associated webGL program
  50501. * @param value defines the list of strings representing the varying names
  50502. */
  50503. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50504. /**
  50505. * Bind a webGL buffer for a transform feedback operation
  50506. * @param value defines the webGL buffer to bind
  50507. */
  50508. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50509. }
  50510. }
  50511. declare module BABYLON {
  50512. /**
  50513. * Creation options of the multi render target texture.
  50514. */
  50515. export interface IMultiRenderTargetOptions {
  50516. /**
  50517. * Define if the texture needs to create mip maps after render.
  50518. */
  50519. generateMipMaps?: boolean;
  50520. /**
  50521. * Define the types of all the draw buffers we want to create
  50522. */
  50523. types?: number[];
  50524. /**
  50525. * Define the sampling modes of all the draw buffers we want to create
  50526. */
  50527. samplingModes?: number[];
  50528. /**
  50529. * Define if a depth buffer is required
  50530. */
  50531. generateDepthBuffer?: boolean;
  50532. /**
  50533. * Define if a stencil buffer is required
  50534. */
  50535. generateStencilBuffer?: boolean;
  50536. /**
  50537. * Define if a depth texture is required instead of a depth buffer
  50538. */
  50539. generateDepthTexture?: boolean;
  50540. /**
  50541. * Define the number of desired draw buffers
  50542. */
  50543. textureCount?: number;
  50544. /**
  50545. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50546. */
  50547. doNotChangeAspectRatio?: boolean;
  50548. /**
  50549. * Define the default type of the buffers we are creating
  50550. */
  50551. defaultType?: number;
  50552. }
  50553. /**
  50554. * A multi render target, like a render target provides the ability to render to a texture.
  50555. * Unlike the render target, it can render to several draw buffers in one draw.
  50556. * This is specially interesting in deferred rendering or for any effects requiring more than
  50557. * just one color from a single pass.
  50558. */
  50559. export class MultiRenderTarget extends RenderTargetTexture {
  50560. private _internalTextures;
  50561. private _textures;
  50562. private _multiRenderTargetOptions;
  50563. /**
  50564. * Get if draw buffers are currently supported by the used hardware and browser.
  50565. */
  50566. get isSupported(): boolean;
  50567. /**
  50568. * Get the list of textures generated by the multi render target.
  50569. */
  50570. get textures(): Texture[];
  50571. /**
  50572. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50573. */
  50574. get depthTexture(): Texture;
  50575. /**
  50576. * Set the wrapping mode on U of all the textures we are rendering to.
  50577. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50578. */
  50579. set wrapU(wrap: number);
  50580. /**
  50581. * Set the wrapping mode on V of all the textures we are rendering to.
  50582. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50583. */
  50584. set wrapV(wrap: number);
  50585. /**
  50586. * Instantiate a new multi render target texture.
  50587. * A multi render target, like a render target provides the ability to render to a texture.
  50588. * Unlike the render target, it can render to several draw buffers in one draw.
  50589. * This is specially interesting in deferred rendering or for any effects requiring more than
  50590. * just one color from a single pass.
  50591. * @param name Define the name of the texture
  50592. * @param size Define the size of the buffers to render to
  50593. * @param count Define the number of target we are rendering into
  50594. * @param scene Define the scene the texture belongs to
  50595. * @param options Define the options used to create the multi render target
  50596. */
  50597. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50598. /** @hidden */
  50599. _rebuild(): void;
  50600. private _createInternalTextures;
  50601. private _createTextures;
  50602. /**
  50603. * Define the number of samples used if MSAA is enabled.
  50604. */
  50605. get samples(): number;
  50606. set samples(value: number);
  50607. /**
  50608. * Resize all the textures in the multi render target.
  50609. * Be carrefull as it will recreate all the data in the new texture.
  50610. * @param size Define the new size
  50611. */
  50612. resize(size: any): void;
  50613. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50614. /**
  50615. * Dispose the render targets and their associated resources
  50616. */
  50617. dispose(): void;
  50618. /**
  50619. * Release all the underlying texture used as draw buffers.
  50620. */
  50621. releaseInternalTextures(): void;
  50622. }
  50623. }
  50624. declare module BABYLON {
  50625. interface ThinEngine {
  50626. /**
  50627. * Unbind a list of render target textures from the webGL context
  50628. * This is used only when drawBuffer extension or webGL2 are active
  50629. * @param textures defines the render target textures to unbind
  50630. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50631. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50632. */
  50633. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50634. /**
  50635. * Create a multi render target texture
  50636. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50637. * @param size defines the size of the texture
  50638. * @param options defines the creation options
  50639. * @returns the cube texture as an InternalTexture
  50640. */
  50641. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50642. /**
  50643. * Update the sample count for a given multiple render target texture
  50644. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50645. * @param textures defines the textures to update
  50646. * @param samples defines the sample count to set
  50647. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50648. */
  50649. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50650. }
  50651. }
  50652. declare module BABYLON {
  50653. /**
  50654. * Class used to define an additional view for the engine
  50655. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50656. */
  50657. export class EngineView {
  50658. /** Defines the canvas where to render the view */
  50659. target: HTMLCanvasElement;
  50660. /** Defines an optional camera used to render the view (will use active camera else) */
  50661. camera?: Camera;
  50662. }
  50663. interface Engine {
  50664. /**
  50665. * Gets or sets the HTML element to use for attaching events
  50666. */
  50667. inputElement: Nullable<HTMLElement>;
  50668. /**
  50669. * Gets the current engine view
  50670. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50671. */
  50672. activeView: Nullable<EngineView>;
  50673. /** Gets or sets the list of views */
  50674. views: EngineView[];
  50675. /**
  50676. * Register a new child canvas
  50677. * @param canvas defines the canvas to register
  50678. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50679. * @returns the associated view
  50680. */
  50681. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50682. /**
  50683. * Remove a registered child canvas
  50684. * @param canvas defines the canvas to remove
  50685. * @returns the current engine
  50686. */
  50687. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50688. }
  50689. }
  50690. declare module BABYLON {
  50691. interface Engine {
  50692. /** @hidden */
  50693. _excludedCompressedTextures: string[];
  50694. /** @hidden */
  50695. _textureFormatInUse: string;
  50696. /**
  50697. * Gets the list of texture formats supported
  50698. */
  50699. readonly texturesSupported: Array<string>;
  50700. /**
  50701. * Gets the texture format in use
  50702. */
  50703. readonly textureFormatInUse: Nullable<string>;
  50704. /**
  50705. * Set the compressed texture extensions or file names to skip.
  50706. *
  50707. * @param skippedFiles defines the list of those texture files you want to skip
  50708. * Example: [".dds", ".env", "myfile.png"]
  50709. */
  50710. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50711. /**
  50712. * Set the compressed texture format to use, based on the formats you have, and the formats
  50713. * supported by the hardware / browser.
  50714. *
  50715. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50716. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50717. * to API arguments needed to compressed textures. This puts the burden on the container
  50718. * generator to house the arcane code for determining these for current & future formats.
  50719. *
  50720. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50721. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50722. *
  50723. * Note: The result of this call is not taken into account when a texture is base64.
  50724. *
  50725. * @param formatsAvailable defines the list of those format families you have created
  50726. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50727. *
  50728. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50729. * @returns The extension selected.
  50730. */
  50731. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50732. }
  50733. }
  50734. declare module BABYLON {
  50735. /**
  50736. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50737. */
  50738. export interface CubeMapInfo {
  50739. /**
  50740. * The pixel array for the front face.
  50741. * This is stored in format, left to right, up to down format.
  50742. */
  50743. front: Nullable<ArrayBufferView>;
  50744. /**
  50745. * The pixel array for the back face.
  50746. * This is stored in format, left to right, up to down format.
  50747. */
  50748. back: Nullable<ArrayBufferView>;
  50749. /**
  50750. * The pixel array for the left face.
  50751. * This is stored in format, left to right, up to down format.
  50752. */
  50753. left: Nullable<ArrayBufferView>;
  50754. /**
  50755. * The pixel array for the right face.
  50756. * This is stored in format, left to right, up to down format.
  50757. */
  50758. right: Nullable<ArrayBufferView>;
  50759. /**
  50760. * The pixel array for the up face.
  50761. * This is stored in format, left to right, up to down format.
  50762. */
  50763. up: Nullable<ArrayBufferView>;
  50764. /**
  50765. * The pixel array for the down face.
  50766. * This is stored in format, left to right, up to down format.
  50767. */
  50768. down: Nullable<ArrayBufferView>;
  50769. /**
  50770. * The size of the cubemap stored.
  50771. *
  50772. * Each faces will be size * size pixels.
  50773. */
  50774. size: number;
  50775. /**
  50776. * The format of the texture.
  50777. *
  50778. * RGBA, RGB.
  50779. */
  50780. format: number;
  50781. /**
  50782. * The type of the texture data.
  50783. *
  50784. * UNSIGNED_INT, FLOAT.
  50785. */
  50786. type: number;
  50787. /**
  50788. * Specifies whether the texture is in gamma space.
  50789. */
  50790. gammaSpace: boolean;
  50791. }
  50792. /**
  50793. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50794. */
  50795. export class PanoramaToCubeMapTools {
  50796. private static FACE_LEFT;
  50797. private static FACE_RIGHT;
  50798. private static FACE_FRONT;
  50799. private static FACE_BACK;
  50800. private static FACE_DOWN;
  50801. private static FACE_UP;
  50802. /**
  50803. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50804. *
  50805. * @param float32Array The source data.
  50806. * @param inputWidth The width of the input panorama.
  50807. * @param inputHeight The height of the input panorama.
  50808. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50809. * @return The cubemap data
  50810. */
  50811. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50812. private static CreateCubemapTexture;
  50813. private static CalcProjectionSpherical;
  50814. }
  50815. }
  50816. declare module BABYLON {
  50817. /**
  50818. * Helper class dealing with the extraction of spherical polynomial dataArray
  50819. * from a cube map.
  50820. */
  50821. export class CubeMapToSphericalPolynomialTools {
  50822. private static FileFaces;
  50823. /**
  50824. * Converts a texture to the according Spherical Polynomial data.
  50825. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50826. *
  50827. * @param texture The texture to extract the information from.
  50828. * @return The Spherical Polynomial data.
  50829. */
  50830. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50831. /**
  50832. * Converts a cubemap to the according Spherical Polynomial data.
  50833. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50834. *
  50835. * @param cubeInfo The Cube map to extract the information from.
  50836. * @return The Spherical Polynomial data.
  50837. */
  50838. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50839. }
  50840. }
  50841. declare module BABYLON {
  50842. interface BaseTexture {
  50843. /**
  50844. * Get the polynomial representation of the texture data.
  50845. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50846. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50847. */
  50848. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50849. }
  50850. }
  50851. declare module BABYLON {
  50852. /** @hidden */
  50853. export var rgbdEncodePixelShader: {
  50854. name: string;
  50855. shader: string;
  50856. };
  50857. }
  50858. declare module BABYLON {
  50859. /** @hidden */
  50860. export var rgbdDecodePixelShader: {
  50861. name: string;
  50862. shader: string;
  50863. };
  50864. }
  50865. declare module BABYLON {
  50866. /**
  50867. * Raw texture data and descriptor sufficient for WebGL texture upload
  50868. */
  50869. export interface EnvironmentTextureInfo {
  50870. /**
  50871. * Version of the environment map
  50872. */
  50873. version: number;
  50874. /**
  50875. * Width of image
  50876. */
  50877. width: number;
  50878. /**
  50879. * Irradiance information stored in the file.
  50880. */
  50881. irradiance: any;
  50882. /**
  50883. * Specular information stored in the file.
  50884. */
  50885. specular: any;
  50886. }
  50887. /**
  50888. * Defines One Image in the file. It requires only the position in the file
  50889. * as well as the length.
  50890. */
  50891. interface BufferImageData {
  50892. /**
  50893. * Length of the image data.
  50894. */
  50895. length: number;
  50896. /**
  50897. * Position of the data from the null terminator delimiting the end of the JSON.
  50898. */
  50899. position: number;
  50900. }
  50901. /**
  50902. * Defines the specular data enclosed in the file.
  50903. * This corresponds to the version 1 of the data.
  50904. */
  50905. export interface EnvironmentTextureSpecularInfoV1 {
  50906. /**
  50907. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50908. */
  50909. specularDataPosition?: number;
  50910. /**
  50911. * This contains all the images data needed to reconstruct the cubemap.
  50912. */
  50913. mipmaps: Array<BufferImageData>;
  50914. /**
  50915. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50916. */
  50917. lodGenerationScale: number;
  50918. }
  50919. /**
  50920. * Sets of helpers addressing the serialization and deserialization of environment texture
  50921. * stored in a BabylonJS env file.
  50922. * Those files are usually stored as .env files.
  50923. */
  50924. export class EnvironmentTextureTools {
  50925. /**
  50926. * Magic number identifying the env file.
  50927. */
  50928. private static _MagicBytes;
  50929. /**
  50930. * Gets the environment info from an env file.
  50931. * @param data The array buffer containing the .env bytes.
  50932. * @returns the environment file info (the json header) if successfully parsed.
  50933. */
  50934. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50935. /**
  50936. * Creates an environment texture from a loaded cube texture.
  50937. * @param texture defines the cube texture to convert in env file
  50938. * @return a promise containing the environment data if succesfull.
  50939. */
  50940. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50941. /**
  50942. * Creates a JSON representation of the spherical data.
  50943. * @param texture defines the texture containing the polynomials
  50944. * @return the JSON representation of the spherical info
  50945. */
  50946. private static _CreateEnvTextureIrradiance;
  50947. /**
  50948. * Creates the ArrayBufferViews used for initializing environment texture image data.
  50949. * @param data the image data
  50950. * @param info parameters that determine what views will be created for accessing the underlying buffer
  50951. * @return the views described by info providing access to the underlying buffer
  50952. */
  50953. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  50954. /**
  50955. * Uploads the texture info contained in the env file to the GPU.
  50956. * @param texture defines the internal texture to upload to
  50957. * @param data defines the data to load
  50958. * @param info defines the texture info retrieved through the GetEnvInfo method
  50959. * @returns a promise
  50960. */
  50961. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  50962. private static _OnImageReadyAsync;
  50963. /**
  50964. * Uploads the levels of image data to the GPU.
  50965. * @param texture defines the internal texture to upload to
  50966. * @param imageData defines the array buffer views of image data [mipmap][face]
  50967. * @returns a promise
  50968. */
  50969. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  50970. /**
  50971. * Uploads spherical polynomials information to the texture.
  50972. * @param texture defines the texture we are trying to upload the information to
  50973. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  50974. */
  50975. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  50976. /** @hidden */
  50977. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50978. }
  50979. }
  50980. declare module BABYLON {
  50981. /** @hidden */
  50982. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  50983. private _genericAttributeLocation;
  50984. private _varyingLocationCount;
  50985. private _varyingLocationMap;
  50986. private _replacements;
  50987. private _textureCount;
  50988. private _uniforms;
  50989. lineProcessor(line: string): string;
  50990. attributeProcessor(attribute: string): string;
  50991. varyingProcessor(varying: string, isFragment: boolean): string;
  50992. uniformProcessor(uniform: string): string;
  50993. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  50994. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  50995. }
  50996. }
  50997. declare module BABYLON {
  50998. /**
  50999. * Container for accessors for natively-stored mesh data buffers.
  51000. */
  51001. class NativeDataBuffer extends DataBuffer {
  51002. /**
  51003. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51004. */
  51005. nativeIndexBuffer?: any;
  51006. /**
  51007. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51008. */
  51009. nativeVertexBuffer?: any;
  51010. }
  51011. /** @hidden */
  51012. class NativeTexture extends InternalTexture {
  51013. getInternalTexture(): InternalTexture;
  51014. getViewCount(): number;
  51015. }
  51016. /** @hidden */
  51017. export class NativeEngine extends Engine {
  51018. private readonly _native;
  51019. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51020. private readonly INVALID_HANDLE;
  51021. getHardwareScalingLevel(): number;
  51022. constructor();
  51023. dispose(): void;
  51024. /**
  51025. * Can be used to override the current requestAnimationFrame requester.
  51026. * @hidden
  51027. */
  51028. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51029. /**
  51030. * Override default engine behavior.
  51031. * @param color
  51032. * @param backBuffer
  51033. * @param depth
  51034. * @param stencil
  51035. */
  51036. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51037. /**
  51038. * Gets host document
  51039. * @returns the host document object
  51040. */
  51041. getHostDocument(): Nullable<Document>;
  51042. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51043. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51044. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51045. recordVertexArrayObject(vertexBuffers: {
  51046. [key: string]: VertexBuffer;
  51047. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51048. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51049. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51050. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51051. /**
  51052. * Draw a list of indexed primitives
  51053. * @param fillMode defines the primitive to use
  51054. * @param indexStart defines the starting index
  51055. * @param indexCount defines the number of index to draw
  51056. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51057. */
  51058. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51059. /**
  51060. * Draw a list of unindexed primitives
  51061. * @param fillMode defines the primitive to use
  51062. * @param verticesStart defines the index of first vertex to draw
  51063. * @param verticesCount defines the count of vertices to draw
  51064. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51065. */
  51066. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51067. createPipelineContext(): IPipelineContext;
  51068. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51069. /** @hidden */
  51070. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51071. /** @hidden */
  51072. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51073. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51074. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51075. protected _setProgram(program: WebGLProgram): void;
  51076. _releaseEffect(effect: Effect): void;
  51077. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51078. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51079. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51080. bindSamplers(effect: Effect): void;
  51081. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51082. getRenderWidth(useScreen?: boolean): number;
  51083. getRenderHeight(useScreen?: boolean): number;
  51084. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51085. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51086. /**
  51087. * Set the z offset to apply to current rendering
  51088. * @param value defines the offset to apply
  51089. */
  51090. setZOffset(value: number): void;
  51091. /**
  51092. * Gets the current value of the zOffset
  51093. * @returns the current zOffset state
  51094. */
  51095. getZOffset(): number;
  51096. /**
  51097. * Enable or disable depth buffering
  51098. * @param enable defines the state to set
  51099. */
  51100. setDepthBuffer(enable: boolean): void;
  51101. /**
  51102. * Gets a boolean indicating if depth writing is enabled
  51103. * @returns the current depth writing state
  51104. */
  51105. getDepthWrite(): boolean;
  51106. /**
  51107. * Enable or disable depth writing
  51108. * @param enable defines the state to set
  51109. */
  51110. setDepthWrite(enable: boolean): void;
  51111. /**
  51112. * Enable or disable color writing
  51113. * @param enable defines the state to set
  51114. */
  51115. setColorWrite(enable: boolean): void;
  51116. /**
  51117. * Gets a boolean indicating if color writing is enabled
  51118. * @returns the current color writing state
  51119. */
  51120. getColorWrite(): boolean;
  51121. /**
  51122. * Sets alpha constants used by some alpha blending modes
  51123. * @param r defines the red component
  51124. * @param g defines the green component
  51125. * @param b defines the blue component
  51126. * @param a defines the alpha component
  51127. */
  51128. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51129. /**
  51130. * Sets the current alpha mode
  51131. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51132. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51133. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51134. */
  51135. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51136. /**
  51137. * Gets the current alpha mode
  51138. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51139. * @returns the current alpha mode
  51140. */
  51141. getAlphaMode(): number;
  51142. setInt(uniform: WebGLUniformLocation, int: number): void;
  51143. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51144. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51145. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51146. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51147. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51148. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51149. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51150. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51151. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51152. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51153. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51154. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51155. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51156. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51157. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51158. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51159. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51160. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51161. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51162. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51163. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51164. wipeCaches(bruteForce?: boolean): void;
  51165. _createTexture(): WebGLTexture;
  51166. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51167. /**
  51168. * Usually called from Texture.ts.
  51169. * Passed information to create a WebGLTexture
  51170. * @param url defines a value which contains one of the following:
  51171. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51172. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51173. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51174. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51175. * @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)
  51176. * @param scene needed for loading to the correct scene
  51177. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51178. * @param onLoad optional callback to be called upon successful completion
  51179. * @param onError optional callback to be called upon failure
  51180. * @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
  51181. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51182. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51183. * @param forcedExtension defines the extension to use to pick the right loader
  51184. * @param mimeType defines an optional mime type
  51185. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51186. */
  51187. 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;
  51188. /**
  51189. * Creates a cube texture
  51190. * @param rootUrl defines the url where the files to load is located
  51191. * @param scene defines the current scene
  51192. * @param files defines the list of files to load (1 per face)
  51193. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51194. * @param onLoad defines an optional callback raised when the texture is loaded
  51195. * @param onError defines an optional callback raised if there is an issue to load the texture
  51196. * @param format defines the format of the data
  51197. * @param forcedExtension defines the extension to use to pick the right loader
  51198. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51199. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51200. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51201. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51202. * @returns the cube texture as an InternalTexture
  51203. */
  51204. 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;
  51205. private _getSamplingFilter;
  51206. private static _GetNativeTextureFormat;
  51207. createRenderTargetTexture(size: number | {
  51208. width: number;
  51209. height: number;
  51210. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51211. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51212. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51213. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51214. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51215. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51216. /**
  51217. * Updates a dynamic vertex buffer.
  51218. * @param vertexBuffer the vertex buffer to update
  51219. * @param data the data used to update the vertex buffer
  51220. * @param byteOffset the byte offset of the data (optional)
  51221. * @param byteLength the byte length of the data (optional)
  51222. */
  51223. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51224. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51225. private _updateAnisotropicLevel;
  51226. private _getAddressMode;
  51227. /** @hidden */
  51228. _bindTexture(channel: number, texture: InternalTexture): void;
  51229. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51230. releaseEffects(): void;
  51231. /** @hidden */
  51232. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51233. /** @hidden */
  51234. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51235. /** @hidden */
  51236. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51237. /** @hidden */
  51238. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51239. }
  51240. }
  51241. declare module BABYLON {
  51242. /**
  51243. * Gather the list of clipboard event types as constants.
  51244. */
  51245. export class ClipboardEventTypes {
  51246. /**
  51247. * The clipboard event is fired when a copy command is active (pressed).
  51248. */
  51249. static readonly COPY: number;
  51250. /**
  51251. * The clipboard event is fired when a cut command is active (pressed).
  51252. */
  51253. static readonly CUT: number;
  51254. /**
  51255. * The clipboard event is fired when a paste command is active (pressed).
  51256. */
  51257. static readonly PASTE: number;
  51258. }
  51259. /**
  51260. * This class is used to store clipboard related info for the onClipboardObservable event.
  51261. */
  51262. export class ClipboardInfo {
  51263. /**
  51264. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51265. */
  51266. type: number;
  51267. /**
  51268. * Defines the related dom event
  51269. */
  51270. event: ClipboardEvent;
  51271. /**
  51272. *Creates an instance of ClipboardInfo.
  51273. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51274. * @param event Defines the related dom event
  51275. */
  51276. constructor(
  51277. /**
  51278. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51279. */
  51280. type: number,
  51281. /**
  51282. * Defines the related dom event
  51283. */
  51284. event: ClipboardEvent);
  51285. /**
  51286. * Get the clipboard event's type from the keycode.
  51287. * @param keyCode Defines the keyCode for the current keyboard event.
  51288. * @return {number}
  51289. */
  51290. static GetTypeFromCharacter(keyCode: number): number;
  51291. }
  51292. }
  51293. declare module BABYLON {
  51294. /**
  51295. * Google Daydream controller
  51296. */
  51297. export class DaydreamController extends WebVRController {
  51298. /**
  51299. * Base Url for the controller model.
  51300. */
  51301. static MODEL_BASE_URL: string;
  51302. /**
  51303. * File name for the controller model.
  51304. */
  51305. static MODEL_FILENAME: string;
  51306. /**
  51307. * Gamepad Id prefix used to identify Daydream Controller.
  51308. */
  51309. static readonly GAMEPAD_ID_PREFIX: string;
  51310. /**
  51311. * Creates a new DaydreamController from a gamepad
  51312. * @param vrGamepad the gamepad that the controller should be created from
  51313. */
  51314. constructor(vrGamepad: any);
  51315. /**
  51316. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51317. * @param scene scene in which to add meshes
  51318. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51319. */
  51320. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51321. /**
  51322. * Called once for each button that changed state since the last frame
  51323. * @param buttonIdx Which button index changed
  51324. * @param state New state of the button
  51325. * @param changes Which properties on the state changed since last frame
  51326. */
  51327. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51328. }
  51329. }
  51330. declare module BABYLON {
  51331. /**
  51332. * Gear VR Controller
  51333. */
  51334. export class GearVRController extends WebVRController {
  51335. /**
  51336. * Base Url for the controller model.
  51337. */
  51338. static MODEL_BASE_URL: string;
  51339. /**
  51340. * File name for the controller model.
  51341. */
  51342. static MODEL_FILENAME: string;
  51343. /**
  51344. * Gamepad Id prefix used to identify this controller.
  51345. */
  51346. static readonly GAMEPAD_ID_PREFIX: string;
  51347. private readonly _buttonIndexToObservableNameMap;
  51348. /**
  51349. * Creates a new GearVRController from a gamepad
  51350. * @param vrGamepad the gamepad that the controller should be created from
  51351. */
  51352. constructor(vrGamepad: any);
  51353. /**
  51354. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51355. * @param scene scene in which to add meshes
  51356. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51357. */
  51358. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51359. /**
  51360. * Called once for each button that changed state since the last frame
  51361. * @param buttonIdx Which button index changed
  51362. * @param state New state of the button
  51363. * @param changes Which properties on the state changed since last frame
  51364. */
  51365. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51366. }
  51367. }
  51368. declare module BABYLON {
  51369. /**
  51370. * Generic Controller
  51371. */
  51372. export class GenericController extends WebVRController {
  51373. /**
  51374. * Base Url for the controller model.
  51375. */
  51376. static readonly MODEL_BASE_URL: string;
  51377. /**
  51378. * File name for the controller model.
  51379. */
  51380. static readonly MODEL_FILENAME: string;
  51381. /**
  51382. * Creates a new GenericController from a gamepad
  51383. * @param vrGamepad the gamepad that the controller should be created from
  51384. */
  51385. constructor(vrGamepad: any);
  51386. /**
  51387. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51388. * @param scene scene in which to add meshes
  51389. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51390. */
  51391. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51392. /**
  51393. * Called once for each button that changed state since the last frame
  51394. * @param buttonIdx Which button index changed
  51395. * @param state New state of the button
  51396. * @param changes Which properties on the state changed since last frame
  51397. */
  51398. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51399. }
  51400. }
  51401. declare module BABYLON {
  51402. /**
  51403. * Oculus Touch Controller
  51404. */
  51405. export class OculusTouchController extends WebVRController {
  51406. /**
  51407. * Base Url for the controller model.
  51408. */
  51409. static MODEL_BASE_URL: string;
  51410. /**
  51411. * File name for the left controller model.
  51412. */
  51413. static MODEL_LEFT_FILENAME: string;
  51414. /**
  51415. * File name for the right controller model.
  51416. */
  51417. static MODEL_RIGHT_FILENAME: string;
  51418. /**
  51419. * Base Url for the Quest controller model.
  51420. */
  51421. static QUEST_MODEL_BASE_URL: string;
  51422. /**
  51423. * @hidden
  51424. * If the controllers are running on a device that needs the updated Quest controller models
  51425. */
  51426. static _IsQuest: boolean;
  51427. /**
  51428. * Fired when the secondary trigger on this controller is modified
  51429. */
  51430. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51431. /**
  51432. * Fired when the thumb rest on this controller is modified
  51433. */
  51434. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51435. /**
  51436. * Creates a new OculusTouchController from a gamepad
  51437. * @param vrGamepad the gamepad that the controller should be created from
  51438. */
  51439. constructor(vrGamepad: any);
  51440. /**
  51441. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51442. * @param scene scene in which to add meshes
  51443. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51444. */
  51445. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51446. /**
  51447. * Fired when the A button on this controller is modified
  51448. */
  51449. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51450. /**
  51451. * Fired when the B button on this controller is modified
  51452. */
  51453. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51454. /**
  51455. * Fired when the X button on this controller is modified
  51456. */
  51457. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51458. /**
  51459. * Fired when the Y button on this controller is modified
  51460. */
  51461. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51462. /**
  51463. * Called once for each button that changed state since the last frame
  51464. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51465. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51466. * 2) secondary trigger (same)
  51467. * 3) A (right) X (left), touch, pressed = value
  51468. * 4) B / Y
  51469. * 5) thumb rest
  51470. * @param buttonIdx Which button index changed
  51471. * @param state New state of the button
  51472. * @param changes Which properties on the state changed since last frame
  51473. */
  51474. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51475. }
  51476. }
  51477. declare module BABYLON {
  51478. /**
  51479. * Vive Controller
  51480. */
  51481. export class ViveController extends WebVRController {
  51482. /**
  51483. * Base Url for the controller model.
  51484. */
  51485. static MODEL_BASE_URL: string;
  51486. /**
  51487. * File name for the controller model.
  51488. */
  51489. static MODEL_FILENAME: string;
  51490. /**
  51491. * Creates a new ViveController from a gamepad
  51492. * @param vrGamepad the gamepad that the controller should be created from
  51493. */
  51494. constructor(vrGamepad: any);
  51495. /**
  51496. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51497. * @param scene scene in which to add meshes
  51498. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51499. */
  51500. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51501. /**
  51502. * Fired when the left button on this controller is modified
  51503. */
  51504. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51505. /**
  51506. * Fired when the right button on this controller is modified
  51507. */
  51508. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51509. /**
  51510. * Fired when the menu button on this controller is modified
  51511. */
  51512. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51513. /**
  51514. * Called once for each button that changed state since the last frame
  51515. * Vive mapping:
  51516. * 0: touchpad
  51517. * 1: trigger
  51518. * 2: left AND right buttons
  51519. * 3: menu button
  51520. * @param buttonIdx Which button index changed
  51521. * @param state New state of the button
  51522. * @param changes Which properties on the state changed since last frame
  51523. */
  51524. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51525. }
  51526. }
  51527. declare module BABYLON {
  51528. /**
  51529. * Defines the WindowsMotionController object that the state of the windows motion controller
  51530. */
  51531. export class WindowsMotionController extends WebVRController {
  51532. /**
  51533. * The base url used to load the left and right controller models
  51534. */
  51535. static MODEL_BASE_URL: string;
  51536. /**
  51537. * The name of the left controller model file
  51538. */
  51539. static MODEL_LEFT_FILENAME: string;
  51540. /**
  51541. * The name of the right controller model file
  51542. */
  51543. static MODEL_RIGHT_FILENAME: string;
  51544. /**
  51545. * The controller name prefix for this controller type
  51546. */
  51547. static readonly GAMEPAD_ID_PREFIX: string;
  51548. /**
  51549. * The controller id pattern for this controller type
  51550. */
  51551. private static readonly GAMEPAD_ID_PATTERN;
  51552. private _loadedMeshInfo;
  51553. protected readonly _mapping: {
  51554. buttons: string[];
  51555. buttonMeshNames: {
  51556. trigger: string;
  51557. menu: string;
  51558. grip: string;
  51559. thumbstick: string;
  51560. trackpad: string;
  51561. };
  51562. buttonObservableNames: {
  51563. trigger: string;
  51564. menu: string;
  51565. grip: string;
  51566. thumbstick: string;
  51567. trackpad: string;
  51568. };
  51569. axisMeshNames: string[];
  51570. pointingPoseMeshName: string;
  51571. };
  51572. /**
  51573. * Fired when the trackpad on this controller is clicked
  51574. */
  51575. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51576. /**
  51577. * Fired when the trackpad on this controller is modified
  51578. */
  51579. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51580. /**
  51581. * The current x and y values of this controller's trackpad
  51582. */
  51583. trackpad: StickValues;
  51584. /**
  51585. * Creates a new WindowsMotionController from a gamepad
  51586. * @param vrGamepad the gamepad that the controller should be created from
  51587. */
  51588. constructor(vrGamepad: any);
  51589. /**
  51590. * Fired when the trigger on this controller is modified
  51591. */
  51592. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51593. /**
  51594. * Fired when the menu button on this controller is modified
  51595. */
  51596. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51597. /**
  51598. * Fired when the grip button on this controller is modified
  51599. */
  51600. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51601. /**
  51602. * Fired when the thumbstick button on this controller is modified
  51603. */
  51604. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51605. /**
  51606. * Fired when the touchpad button on this controller is modified
  51607. */
  51608. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51609. /**
  51610. * Fired when the touchpad values on this controller are modified
  51611. */
  51612. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51613. protected _updateTrackpad(): void;
  51614. /**
  51615. * Called once per frame by the engine.
  51616. */
  51617. update(): void;
  51618. /**
  51619. * Called once for each button that changed state since the last frame
  51620. * @param buttonIdx Which button index changed
  51621. * @param state New state of the button
  51622. * @param changes Which properties on the state changed since last frame
  51623. */
  51624. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51625. /**
  51626. * Moves the buttons on the controller mesh based on their current state
  51627. * @param buttonName the name of the button to move
  51628. * @param buttonValue the value of the button which determines the buttons new position
  51629. */
  51630. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51631. /**
  51632. * Moves the axis on the controller mesh based on its current state
  51633. * @param axis the index of the axis
  51634. * @param axisValue the value of the axis which determines the meshes new position
  51635. * @hidden
  51636. */
  51637. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51638. /**
  51639. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51640. * @param scene scene in which to add meshes
  51641. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51642. */
  51643. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51644. /**
  51645. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51646. * can be transformed by button presses and axes values, based on this._mapping.
  51647. *
  51648. * @param scene scene in which the meshes exist
  51649. * @param meshes list of meshes that make up the controller model to process
  51650. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51651. */
  51652. private processModel;
  51653. private createMeshInfo;
  51654. /**
  51655. * Gets the ray of the controller in the direction the controller is pointing
  51656. * @param length the length the resulting ray should be
  51657. * @returns a ray in the direction the controller is pointing
  51658. */
  51659. getForwardRay(length?: number): Ray;
  51660. /**
  51661. * Disposes of the controller
  51662. */
  51663. dispose(): void;
  51664. }
  51665. /**
  51666. * This class represents a new windows motion controller in XR.
  51667. */
  51668. export class XRWindowsMotionController extends WindowsMotionController {
  51669. /**
  51670. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51671. */
  51672. protected readonly _mapping: {
  51673. buttons: string[];
  51674. buttonMeshNames: {
  51675. trigger: string;
  51676. menu: string;
  51677. grip: string;
  51678. thumbstick: string;
  51679. trackpad: string;
  51680. };
  51681. buttonObservableNames: {
  51682. trigger: string;
  51683. menu: string;
  51684. grip: string;
  51685. thumbstick: string;
  51686. trackpad: string;
  51687. };
  51688. axisMeshNames: string[];
  51689. pointingPoseMeshName: string;
  51690. };
  51691. /**
  51692. * Construct a new XR-Based windows motion controller
  51693. *
  51694. * @param gamepadInfo the gamepad object from the browser
  51695. */
  51696. constructor(gamepadInfo: any);
  51697. /**
  51698. * holds the thumbstick values (X,Y)
  51699. */
  51700. thumbstickValues: StickValues;
  51701. /**
  51702. * Fired when the thumbstick on this controller is clicked
  51703. */
  51704. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51705. /**
  51706. * Fired when the thumbstick on this controller is modified
  51707. */
  51708. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51709. /**
  51710. * Fired when the touchpad button on this controller is modified
  51711. */
  51712. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51713. /**
  51714. * Fired when the touchpad values on this controller are modified
  51715. */
  51716. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51717. /**
  51718. * Fired when the thumbstick button on this controller is modified
  51719. * here to prevent breaking changes
  51720. */
  51721. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51722. /**
  51723. * updating the thumbstick(!) and not the trackpad.
  51724. * This is named this way due to the difference between WebVR and XR and to avoid
  51725. * changing the parent class.
  51726. */
  51727. protected _updateTrackpad(): void;
  51728. /**
  51729. * Disposes the class with joy
  51730. */
  51731. dispose(): void;
  51732. }
  51733. }
  51734. declare module BABYLON {
  51735. /**
  51736. * Class containing static functions to help procedurally build meshes
  51737. */
  51738. export class PolyhedronBuilder {
  51739. /**
  51740. * Creates a polyhedron mesh
  51741. * * 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
  51742. * * The parameter `size` (positive float, default 1) sets the polygon size
  51743. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51744. * * 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`
  51745. * * 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
  51746. * * 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)`)
  51747. * * 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
  51748. * * 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
  51749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51750. * * 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
  51751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51752. * @param name defines the name of the mesh
  51753. * @param options defines the options used to create the mesh
  51754. * @param scene defines the hosting scene
  51755. * @returns the polyhedron mesh
  51756. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51757. */
  51758. static CreatePolyhedron(name: string, options: {
  51759. type?: number;
  51760. size?: number;
  51761. sizeX?: number;
  51762. sizeY?: number;
  51763. sizeZ?: number;
  51764. custom?: any;
  51765. faceUV?: Vector4[];
  51766. faceColors?: Color4[];
  51767. flat?: boolean;
  51768. updatable?: boolean;
  51769. sideOrientation?: number;
  51770. frontUVs?: Vector4;
  51771. backUVs?: Vector4;
  51772. }, scene?: Nullable<Scene>): Mesh;
  51773. }
  51774. }
  51775. declare module BABYLON {
  51776. /**
  51777. * Gizmo that enables scaling a mesh along 3 axis
  51778. */
  51779. export class ScaleGizmo extends Gizmo {
  51780. /**
  51781. * Internal gizmo used for interactions on the x axis
  51782. */
  51783. xGizmo: AxisScaleGizmo;
  51784. /**
  51785. * Internal gizmo used for interactions on the y axis
  51786. */
  51787. yGizmo: AxisScaleGizmo;
  51788. /**
  51789. * Internal gizmo used for interactions on the z axis
  51790. */
  51791. zGizmo: AxisScaleGizmo;
  51792. /**
  51793. * Internal gizmo used to scale all axis equally
  51794. */
  51795. uniformScaleGizmo: AxisScaleGizmo;
  51796. private _meshAttached;
  51797. private _updateGizmoRotationToMatchAttachedMesh;
  51798. private _snapDistance;
  51799. private _scaleRatio;
  51800. private _uniformScalingMesh;
  51801. private _octahedron;
  51802. private _sensitivity;
  51803. /** Fires an event when any of it's sub gizmos are dragged */
  51804. onDragStartObservable: Observable<unknown>;
  51805. /** Fires an event when any of it's sub gizmos are released from dragging */
  51806. onDragEndObservable: Observable<unknown>;
  51807. get attachedMesh(): Nullable<AbstractMesh>;
  51808. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51809. /**
  51810. * Creates a ScaleGizmo
  51811. * @param gizmoLayer The utility layer the gizmo will be added to
  51812. */
  51813. constructor(gizmoLayer?: UtilityLayerRenderer);
  51814. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51815. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51816. /**
  51817. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51818. */
  51819. set snapDistance(value: number);
  51820. get snapDistance(): number;
  51821. /**
  51822. * Ratio for the scale of the gizmo (Default: 1)
  51823. */
  51824. set scaleRatio(value: number);
  51825. get scaleRatio(): number;
  51826. /**
  51827. * Sensitivity factor for dragging (Default: 1)
  51828. */
  51829. set sensitivity(value: number);
  51830. get sensitivity(): number;
  51831. /**
  51832. * Disposes of the gizmo
  51833. */
  51834. dispose(): void;
  51835. }
  51836. }
  51837. declare module BABYLON {
  51838. /**
  51839. * Single axis scale gizmo
  51840. */
  51841. export class AxisScaleGizmo extends Gizmo {
  51842. /**
  51843. * Drag behavior responsible for the gizmos dragging interactions
  51844. */
  51845. dragBehavior: PointerDragBehavior;
  51846. private _pointerObserver;
  51847. /**
  51848. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51849. */
  51850. snapDistance: number;
  51851. /**
  51852. * Event that fires each time the gizmo snaps to a new location.
  51853. * * snapDistance is the the change in distance
  51854. */
  51855. onSnapObservable: Observable<{
  51856. snapDistance: number;
  51857. }>;
  51858. /**
  51859. * If the scaling operation should be done on all axis (default: false)
  51860. */
  51861. uniformScaling: boolean;
  51862. /**
  51863. * Custom sensitivity value for the drag strength
  51864. */
  51865. sensitivity: number;
  51866. private _isEnabled;
  51867. private _parent;
  51868. private _arrow;
  51869. private _coloredMaterial;
  51870. private _hoverMaterial;
  51871. /**
  51872. * Creates an AxisScaleGizmo
  51873. * @param gizmoLayer The utility layer the gizmo will be added to
  51874. * @param dragAxis The axis which the gizmo will be able to scale on
  51875. * @param color The color of the gizmo
  51876. */
  51877. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51878. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51879. /**
  51880. * If the gizmo is enabled
  51881. */
  51882. set isEnabled(value: boolean);
  51883. get isEnabled(): boolean;
  51884. /**
  51885. * Disposes of the gizmo
  51886. */
  51887. dispose(): void;
  51888. /**
  51889. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51890. * @param mesh The mesh to replace the default mesh of the gizmo
  51891. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51892. */
  51893. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51894. }
  51895. }
  51896. declare module BABYLON {
  51897. /**
  51898. * Bounding box gizmo
  51899. */
  51900. export class BoundingBoxGizmo extends Gizmo {
  51901. private _lineBoundingBox;
  51902. private _rotateSpheresParent;
  51903. private _scaleBoxesParent;
  51904. private _boundingDimensions;
  51905. private _renderObserver;
  51906. private _pointerObserver;
  51907. private _scaleDragSpeed;
  51908. private _tmpQuaternion;
  51909. private _tmpVector;
  51910. private _tmpRotationMatrix;
  51911. /**
  51912. * 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)
  51913. */
  51914. ignoreChildren: boolean;
  51915. /**
  51916. * 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)
  51917. */
  51918. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  51919. /**
  51920. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  51921. */
  51922. rotationSphereSize: number;
  51923. /**
  51924. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  51925. */
  51926. scaleBoxSize: number;
  51927. /**
  51928. * 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)
  51929. */
  51930. fixedDragMeshScreenSize: boolean;
  51931. /**
  51932. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  51933. */
  51934. fixedDragMeshScreenSizeDistanceFactor: number;
  51935. /**
  51936. * Fired when a rotation sphere or scale box is dragged
  51937. */
  51938. onDragStartObservable: Observable<{}>;
  51939. /**
  51940. * Fired when a scale box is dragged
  51941. */
  51942. onScaleBoxDragObservable: Observable<{}>;
  51943. /**
  51944. * Fired when a scale box drag is ended
  51945. */
  51946. onScaleBoxDragEndObservable: Observable<{}>;
  51947. /**
  51948. * Fired when a rotation sphere is dragged
  51949. */
  51950. onRotationSphereDragObservable: Observable<{}>;
  51951. /**
  51952. * Fired when a rotation sphere drag is ended
  51953. */
  51954. onRotationSphereDragEndObservable: Observable<{}>;
  51955. /**
  51956. * 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)
  51957. */
  51958. scalePivot: Nullable<Vector3>;
  51959. /**
  51960. * Mesh used as a pivot to rotate the attached mesh
  51961. */
  51962. private _anchorMesh;
  51963. private _existingMeshScale;
  51964. private _dragMesh;
  51965. private pointerDragBehavior;
  51966. private coloredMaterial;
  51967. private hoverColoredMaterial;
  51968. /**
  51969. * Sets the color of the bounding box gizmo
  51970. * @param color the color to set
  51971. */
  51972. setColor(color: Color3): void;
  51973. /**
  51974. * Creates an BoundingBoxGizmo
  51975. * @param gizmoLayer The utility layer the gizmo will be added to
  51976. * @param color The color of the gizmo
  51977. */
  51978. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  51979. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51980. private _selectNode;
  51981. /**
  51982. * Updates the bounding box information for the Gizmo
  51983. */
  51984. updateBoundingBox(): void;
  51985. private _updateRotationSpheres;
  51986. private _updateScaleBoxes;
  51987. /**
  51988. * Enables rotation on the specified axis and disables rotation on the others
  51989. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  51990. */
  51991. setEnabledRotationAxis(axis: string): void;
  51992. /**
  51993. * Enables/disables scaling
  51994. * @param enable if scaling should be enabled
  51995. * @param homogeneousScaling defines if scaling should only be homogeneous
  51996. */
  51997. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  51998. private _updateDummy;
  51999. /**
  52000. * Enables a pointer drag behavior on the bounding box of the gizmo
  52001. */
  52002. enableDragBehavior(): void;
  52003. /**
  52004. * Disposes of the gizmo
  52005. */
  52006. dispose(): void;
  52007. /**
  52008. * 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)
  52009. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52010. * @returns the bounding box mesh with the passed in mesh as a child
  52011. */
  52012. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52013. /**
  52014. * CustomMeshes are not supported by this gizmo
  52015. * @param mesh The mesh to replace the default mesh of the gizmo
  52016. */
  52017. setCustomMesh(mesh: Mesh): void;
  52018. }
  52019. }
  52020. declare module BABYLON {
  52021. /**
  52022. * Single plane rotation gizmo
  52023. */
  52024. export class PlaneRotationGizmo extends Gizmo {
  52025. /**
  52026. * Drag behavior responsible for the gizmos dragging interactions
  52027. */
  52028. dragBehavior: PointerDragBehavior;
  52029. private _pointerObserver;
  52030. /**
  52031. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52032. */
  52033. snapDistance: number;
  52034. /**
  52035. * Event that fires each time the gizmo snaps to a new location.
  52036. * * snapDistance is the the change in distance
  52037. */
  52038. onSnapObservable: Observable<{
  52039. snapDistance: number;
  52040. }>;
  52041. private _isEnabled;
  52042. private _parent;
  52043. /**
  52044. * Creates a PlaneRotationGizmo
  52045. * @param gizmoLayer The utility layer the gizmo will be added to
  52046. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52047. * @param color The color of the gizmo
  52048. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52049. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52050. */
  52051. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52052. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52053. /**
  52054. * If the gizmo is enabled
  52055. */
  52056. set isEnabled(value: boolean);
  52057. get isEnabled(): boolean;
  52058. /**
  52059. * Disposes of the gizmo
  52060. */
  52061. dispose(): void;
  52062. }
  52063. }
  52064. declare module BABYLON {
  52065. /**
  52066. * Gizmo that enables rotating a mesh along 3 axis
  52067. */
  52068. export class RotationGizmo extends Gizmo {
  52069. /**
  52070. * Internal gizmo used for interactions on the x axis
  52071. */
  52072. xGizmo: PlaneRotationGizmo;
  52073. /**
  52074. * Internal gizmo used for interactions on the y axis
  52075. */
  52076. yGizmo: PlaneRotationGizmo;
  52077. /**
  52078. * Internal gizmo used for interactions on the z axis
  52079. */
  52080. zGizmo: PlaneRotationGizmo;
  52081. /** Fires an event when any of it's sub gizmos are dragged */
  52082. onDragStartObservable: Observable<unknown>;
  52083. /** Fires an event when any of it's sub gizmos are released from dragging */
  52084. onDragEndObservable: Observable<unknown>;
  52085. private _meshAttached;
  52086. get attachedMesh(): Nullable<AbstractMesh>;
  52087. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52088. /**
  52089. * Creates a RotationGizmo
  52090. * @param gizmoLayer The utility layer the gizmo will be added to
  52091. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52092. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52093. */
  52094. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52095. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52096. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52097. /**
  52098. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52099. */
  52100. set snapDistance(value: number);
  52101. get snapDistance(): number;
  52102. /**
  52103. * Ratio for the scale of the gizmo (Default: 1)
  52104. */
  52105. set scaleRatio(value: number);
  52106. get scaleRatio(): number;
  52107. /**
  52108. * Disposes of the gizmo
  52109. */
  52110. dispose(): void;
  52111. /**
  52112. * CustomMeshes are not supported by this gizmo
  52113. * @param mesh The mesh to replace the default mesh of the gizmo
  52114. */
  52115. setCustomMesh(mesh: Mesh): void;
  52116. }
  52117. }
  52118. declare module BABYLON {
  52119. /**
  52120. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52121. */
  52122. export class GizmoManager implements IDisposable {
  52123. private scene;
  52124. /**
  52125. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52126. */
  52127. gizmos: {
  52128. positionGizmo: Nullable<PositionGizmo>;
  52129. rotationGizmo: Nullable<RotationGizmo>;
  52130. scaleGizmo: Nullable<ScaleGizmo>;
  52131. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52132. };
  52133. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52134. clearGizmoOnEmptyPointerEvent: boolean;
  52135. /** Fires an event when the manager is attached to a mesh */
  52136. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52137. private _gizmosEnabled;
  52138. private _pointerObserver;
  52139. private _attachedMesh;
  52140. private _boundingBoxColor;
  52141. private _defaultUtilityLayer;
  52142. private _defaultKeepDepthUtilityLayer;
  52143. /**
  52144. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52145. */
  52146. boundingBoxDragBehavior: SixDofDragBehavior;
  52147. /**
  52148. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52149. */
  52150. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52151. /**
  52152. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52153. */
  52154. usePointerToAttachGizmos: boolean;
  52155. /**
  52156. * Utility layer that the bounding box gizmo belongs to
  52157. */
  52158. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52159. /**
  52160. * Utility layer that all gizmos besides bounding box belong to
  52161. */
  52162. get utilityLayer(): UtilityLayerRenderer;
  52163. /**
  52164. * Instatiates a gizmo manager
  52165. * @param scene the scene to overlay the gizmos on top of
  52166. */
  52167. constructor(scene: Scene);
  52168. /**
  52169. * Attaches a set of gizmos to the specified mesh
  52170. * @param mesh The mesh the gizmo's should be attached to
  52171. */
  52172. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52173. /**
  52174. * If the position gizmo is enabled
  52175. */
  52176. set positionGizmoEnabled(value: boolean);
  52177. get positionGizmoEnabled(): boolean;
  52178. /**
  52179. * If the rotation gizmo is enabled
  52180. */
  52181. set rotationGizmoEnabled(value: boolean);
  52182. get rotationGizmoEnabled(): boolean;
  52183. /**
  52184. * If the scale gizmo is enabled
  52185. */
  52186. set scaleGizmoEnabled(value: boolean);
  52187. get scaleGizmoEnabled(): boolean;
  52188. /**
  52189. * If the boundingBox gizmo is enabled
  52190. */
  52191. set boundingBoxGizmoEnabled(value: boolean);
  52192. get boundingBoxGizmoEnabled(): boolean;
  52193. /**
  52194. * Disposes of the gizmo manager
  52195. */
  52196. dispose(): void;
  52197. }
  52198. }
  52199. declare module BABYLON {
  52200. /**
  52201. * A directional light is defined by a direction (what a surprise!).
  52202. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52203. * 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.
  52204. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52205. */
  52206. export class DirectionalLight extends ShadowLight {
  52207. private _shadowFrustumSize;
  52208. /**
  52209. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52210. */
  52211. get shadowFrustumSize(): number;
  52212. /**
  52213. * Specifies a fix frustum size for the shadow generation.
  52214. */
  52215. set shadowFrustumSize(value: number);
  52216. private _shadowOrthoScale;
  52217. /**
  52218. * Gets the shadow projection scale against the optimal computed one.
  52219. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52220. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52221. */
  52222. get shadowOrthoScale(): number;
  52223. /**
  52224. * Sets the shadow projection scale against the optimal computed one.
  52225. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52226. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52227. */
  52228. set shadowOrthoScale(value: number);
  52229. /**
  52230. * Automatically compute the projection matrix to best fit (including all the casters)
  52231. * on each frame.
  52232. */
  52233. autoUpdateExtends: boolean;
  52234. /**
  52235. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52236. * on each frame. autoUpdateExtends must be set to true for this to work
  52237. */
  52238. autoCalcShadowZBounds: boolean;
  52239. private _orthoLeft;
  52240. private _orthoRight;
  52241. private _orthoTop;
  52242. private _orthoBottom;
  52243. /**
  52244. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52245. * The directional light is emitted from everywhere in the given direction.
  52246. * It can cast shadows.
  52247. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52248. * @param name The friendly name of the light
  52249. * @param direction The direction of the light
  52250. * @param scene The scene the light belongs to
  52251. */
  52252. constructor(name: string, direction: Vector3, scene: Scene);
  52253. /**
  52254. * Returns the string "DirectionalLight".
  52255. * @return The class name
  52256. */
  52257. getClassName(): string;
  52258. /**
  52259. * Returns the integer 1.
  52260. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52261. */
  52262. getTypeID(): number;
  52263. /**
  52264. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52265. * Returns the DirectionalLight Shadow projection matrix.
  52266. */
  52267. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52268. /**
  52269. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52270. * Returns the DirectionalLight Shadow projection matrix.
  52271. */
  52272. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52273. /**
  52274. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52275. * Returns the DirectionalLight Shadow projection matrix.
  52276. */
  52277. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52278. protected _buildUniformLayout(): void;
  52279. /**
  52280. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52281. * @param effect The effect to update
  52282. * @param lightIndex The index of the light in the effect to update
  52283. * @returns The directional light
  52284. */
  52285. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52286. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52287. /**
  52288. * Gets the minZ used for shadow according to both the scene and the light.
  52289. *
  52290. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52291. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52292. * @param activeCamera The camera we are returning the min for
  52293. * @returns the depth min z
  52294. */
  52295. getDepthMinZ(activeCamera: Camera): number;
  52296. /**
  52297. * Gets the maxZ used for shadow according to both the scene and the light.
  52298. *
  52299. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52300. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52301. * @param activeCamera The camera we are returning the max for
  52302. * @returns the depth max z
  52303. */
  52304. getDepthMaxZ(activeCamera: Camera): number;
  52305. /**
  52306. * Prepares the list of defines specific to the light type.
  52307. * @param defines the list of defines
  52308. * @param lightIndex defines the index of the light for the effect
  52309. */
  52310. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52311. }
  52312. }
  52313. declare module BABYLON {
  52314. /**
  52315. * Class containing static functions to help procedurally build meshes
  52316. */
  52317. export class HemisphereBuilder {
  52318. /**
  52319. * Creates a hemisphere mesh
  52320. * @param name defines the name of the mesh
  52321. * @param options defines the options used to create the mesh
  52322. * @param scene defines the hosting scene
  52323. * @returns the hemisphere mesh
  52324. */
  52325. static CreateHemisphere(name: string, options: {
  52326. segments?: number;
  52327. diameter?: number;
  52328. sideOrientation?: number;
  52329. }, scene: any): Mesh;
  52330. }
  52331. }
  52332. declare module BABYLON {
  52333. /**
  52334. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52335. * These values define a cone of light starting from the position, emitting toward the direction.
  52336. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52337. * and the exponent defines the speed of the decay of the light with distance (reach).
  52338. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52339. */
  52340. export class SpotLight extends ShadowLight {
  52341. private _angle;
  52342. private _innerAngle;
  52343. private _cosHalfAngle;
  52344. private _lightAngleScale;
  52345. private _lightAngleOffset;
  52346. /**
  52347. * Gets the cone angle of the spot light in Radians.
  52348. */
  52349. get angle(): number;
  52350. /**
  52351. * Sets the cone angle of the spot light in Radians.
  52352. */
  52353. set angle(value: number);
  52354. /**
  52355. * Only used in gltf falloff mode, this defines the angle where
  52356. * the directional falloff will start before cutting at angle which could be seen
  52357. * as outer angle.
  52358. */
  52359. get innerAngle(): number;
  52360. /**
  52361. * Only used in gltf falloff mode, this defines the angle where
  52362. * the directional falloff will start before cutting at angle which could be seen
  52363. * as outer angle.
  52364. */
  52365. set innerAngle(value: number);
  52366. private _shadowAngleScale;
  52367. /**
  52368. * Allows scaling the angle of the light for shadow generation only.
  52369. */
  52370. get shadowAngleScale(): number;
  52371. /**
  52372. * Allows scaling the angle of the light for shadow generation only.
  52373. */
  52374. set shadowAngleScale(value: number);
  52375. /**
  52376. * The light decay speed with the distance from the emission spot.
  52377. */
  52378. exponent: number;
  52379. private _projectionTextureMatrix;
  52380. /**
  52381. * Allows reading the projecton texture
  52382. */
  52383. get projectionTextureMatrix(): Matrix;
  52384. protected _projectionTextureLightNear: number;
  52385. /**
  52386. * Gets the near clip of the Spotlight for texture projection.
  52387. */
  52388. get projectionTextureLightNear(): number;
  52389. /**
  52390. * Sets the near clip of the Spotlight for texture projection.
  52391. */
  52392. set projectionTextureLightNear(value: number);
  52393. protected _projectionTextureLightFar: number;
  52394. /**
  52395. * Gets the far clip of the Spotlight for texture projection.
  52396. */
  52397. get projectionTextureLightFar(): number;
  52398. /**
  52399. * Sets the far clip of the Spotlight for texture projection.
  52400. */
  52401. set projectionTextureLightFar(value: number);
  52402. protected _projectionTextureUpDirection: Vector3;
  52403. /**
  52404. * Gets the Up vector of the Spotlight for texture projection.
  52405. */
  52406. get projectionTextureUpDirection(): Vector3;
  52407. /**
  52408. * Sets the Up vector of the Spotlight for texture projection.
  52409. */
  52410. set projectionTextureUpDirection(value: Vector3);
  52411. private _projectionTexture;
  52412. /**
  52413. * Gets the projection texture of the light.
  52414. */
  52415. get projectionTexture(): Nullable<BaseTexture>;
  52416. /**
  52417. * Sets the projection texture of the light.
  52418. */
  52419. set projectionTexture(value: Nullable<BaseTexture>);
  52420. private _projectionTextureViewLightDirty;
  52421. private _projectionTextureProjectionLightDirty;
  52422. private _projectionTextureDirty;
  52423. private _projectionTextureViewTargetVector;
  52424. private _projectionTextureViewLightMatrix;
  52425. private _projectionTextureProjectionLightMatrix;
  52426. private _projectionTextureScalingMatrix;
  52427. /**
  52428. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52429. * It can cast shadows.
  52430. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52431. * @param name The light friendly name
  52432. * @param position The position of the spot light in the scene
  52433. * @param direction The direction of the light in the scene
  52434. * @param angle The cone angle of the light in Radians
  52435. * @param exponent The light decay speed with the distance from the emission spot
  52436. * @param scene The scene the lights belongs to
  52437. */
  52438. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52439. /**
  52440. * Returns the string "SpotLight".
  52441. * @returns the class name
  52442. */
  52443. getClassName(): string;
  52444. /**
  52445. * Returns the integer 2.
  52446. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52447. */
  52448. getTypeID(): number;
  52449. /**
  52450. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52451. */
  52452. protected _setDirection(value: Vector3): void;
  52453. /**
  52454. * Overrides the position setter to recompute the projection texture view light Matrix.
  52455. */
  52456. protected _setPosition(value: Vector3): void;
  52457. /**
  52458. * 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.
  52459. * Returns the SpotLight.
  52460. */
  52461. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52462. protected _computeProjectionTextureViewLightMatrix(): void;
  52463. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52464. /**
  52465. * Main function for light texture projection matrix computing.
  52466. */
  52467. protected _computeProjectionTextureMatrix(): void;
  52468. protected _buildUniformLayout(): void;
  52469. private _computeAngleValues;
  52470. /**
  52471. * Sets the passed Effect "effect" with the Light textures.
  52472. * @param effect The effect to update
  52473. * @param lightIndex The index of the light in the effect to update
  52474. * @returns The light
  52475. */
  52476. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52477. /**
  52478. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52479. * @param effect The effect to update
  52480. * @param lightIndex The index of the light in the effect to update
  52481. * @returns The spot light
  52482. */
  52483. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52484. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52485. /**
  52486. * Disposes the light and the associated resources.
  52487. */
  52488. dispose(): void;
  52489. /**
  52490. * Prepares the list of defines specific to the light type.
  52491. * @param defines the list of defines
  52492. * @param lightIndex defines the index of the light for the effect
  52493. */
  52494. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52495. }
  52496. }
  52497. declare module BABYLON {
  52498. /**
  52499. * Gizmo that enables viewing a light
  52500. */
  52501. export class LightGizmo extends Gizmo {
  52502. private _lightMesh;
  52503. private _material;
  52504. private _cachedPosition;
  52505. private _cachedForward;
  52506. private _attachedMeshParent;
  52507. /**
  52508. * Creates a LightGizmo
  52509. * @param gizmoLayer The utility layer the gizmo will be added to
  52510. */
  52511. constructor(gizmoLayer?: UtilityLayerRenderer);
  52512. private _light;
  52513. /**
  52514. * The light that the gizmo is attached to
  52515. */
  52516. set light(light: Nullable<Light>);
  52517. get light(): Nullable<Light>;
  52518. /**
  52519. * Gets the material used to render the light gizmo
  52520. */
  52521. get material(): StandardMaterial;
  52522. /**
  52523. * @hidden
  52524. * Updates the gizmo to match the attached mesh's position/rotation
  52525. */
  52526. protected _update(): void;
  52527. private static _Scale;
  52528. /**
  52529. * Creates the lines for a light mesh
  52530. */
  52531. private static _CreateLightLines;
  52532. /**
  52533. * Disposes of the light gizmo
  52534. */
  52535. dispose(): void;
  52536. private static _CreateHemisphericLightMesh;
  52537. private static _CreatePointLightMesh;
  52538. private static _CreateSpotLightMesh;
  52539. private static _CreateDirectionalLightMesh;
  52540. }
  52541. }
  52542. declare module BABYLON {
  52543. /** @hidden */
  52544. export var backgroundFragmentDeclaration: {
  52545. name: string;
  52546. shader: string;
  52547. };
  52548. }
  52549. declare module BABYLON {
  52550. /** @hidden */
  52551. export var backgroundUboDeclaration: {
  52552. name: string;
  52553. shader: string;
  52554. };
  52555. }
  52556. declare module BABYLON {
  52557. /** @hidden */
  52558. export var backgroundPixelShader: {
  52559. name: string;
  52560. shader: string;
  52561. };
  52562. }
  52563. declare module BABYLON {
  52564. /** @hidden */
  52565. export var backgroundVertexDeclaration: {
  52566. name: string;
  52567. shader: string;
  52568. };
  52569. }
  52570. declare module BABYLON {
  52571. /** @hidden */
  52572. export var backgroundVertexShader: {
  52573. name: string;
  52574. shader: string;
  52575. };
  52576. }
  52577. declare module BABYLON {
  52578. /**
  52579. * Background material used to create an efficient environement around your scene.
  52580. */
  52581. export class BackgroundMaterial extends PushMaterial {
  52582. /**
  52583. * Standard reflectance value at parallel view angle.
  52584. */
  52585. static StandardReflectance0: number;
  52586. /**
  52587. * Standard reflectance value at grazing angle.
  52588. */
  52589. static StandardReflectance90: number;
  52590. protected _primaryColor: Color3;
  52591. /**
  52592. * Key light Color (multiply against the environement texture)
  52593. */
  52594. primaryColor: Color3;
  52595. protected __perceptualColor: Nullable<Color3>;
  52596. /**
  52597. * Experimental Internal Use Only.
  52598. *
  52599. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52600. * This acts as a helper to set the primary color to a more "human friendly" value.
  52601. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52602. * output color as close as possible from the chosen value.
  52603. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52604. * part of lighting setup.)
  52605. */
  52606. get _perceptualColor(): Nullable<Color3>;
  52607. set _perceptualColor(value: Nullable<Color3>);
  52608. protected _primaryColorShadowLevel: float;
  52609. /**
  52610. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52611. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52612. */
  52613. get primaryColorShadowLevel(): float;
  52614. set primaryColorShadowLevel(value: float);
  52615. protected _primaryColorHighlightLevel: float;
  52616. /**
  52617. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52618. * The primary color is used at the level chosen to define what the white area would look.
  52619. */
  52620. get primaryColorHighlightLevel(): float;
  52621. set primaryColorHighlightLevel(value: float);
  52622. protected _reflectionTexture: Nullable<BaseTexture>;
  52623. /**
  52624. * Reflection Texture used in the material.
  52625. * Should be author in a specific way for the best result (refer to the documentation).
  52626. */
  52627. reflectionTexture: Nullable<BaseTexture>;
  52628. protected _reflectionBlur: float;
  52629. /**
  52630. * Reflection Texture level of blur.
  52631. *
  52632. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52633. * texture twice.
  52634. */
  52635. reflectionBlur: float;
  52636. protected _diffuseTexture: Nullable<BaseTexture>;
  52637. /**
  52638. * Diffuse Texture used in the material.
  52639. * Should be author in a specific way for the best result (refer to the documentation).
  52640. */
  52641. diffuseTexture: Nullable<BaseTexture>;
  52642. protected _shadowLights: Nullable<IShadowLight[]>;
  52643. /**
  52644. * Specify the list of lights casting shadow on the material.
  52645. * All scene shadow lights will be included if null.
  52646. */
  52647. shadowLights: Nullable<IShadowLight[]>;
  52648. protected _shadowLevel: float;
  52649. /**
  52650. * Helps adjusting the shadow to a softer level if required.
  52651. * 0 means black shadows and 1 means no shadows.
  52652. */
  52653. shadowLevel: float;
  52654. protected _sceneCenter: Vector3;
  52655. /**
  52656. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52657. * It is usually zero but might be interesting to modify according to your setup.
  52658. */
  52659. sceneCenter: Vector3;
  52660. protected _opacityFresnel: boolean;
  52661. /**
  52662. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52663. * This helps ensuring a nice transition when the camera goes under the ground.
  52664. */
  52665. opacityFresnel: boolean;
  52666. protected _reflectionFresnel: boolean;
  52667. /**
  52668. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52669. * This helps adding a mirror texture on the ground.
  52670. */
  52671. reflectionFresnel: boolean;
  52672. protected _reflectionFalloffDistance: number;
  52673. /**
  52674. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52675. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52676. */
  52677. reflectionFalloffDistance: number;
  52678. protected _reflectionAmount: number;
  52679. /**
  52680. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52681. */
  52682. reflectionAmount: number;
  52683. protected _reflectionReflectance0: number;
  52684. /**
  52685. * This specifies the weight of the reflection at grazing angle.
  52686. */
  52687. reflectionReflectance0: number;
  52688. protected _reflectionReflectance90: number;
  52689. /**
  52690. * This specifies the weight of the reflection at a perpendicular point of view.
  52691. */
  52692. reflectionReflectance90: number;
  52693. /**
  52694. * Sets the reflection reflectance fresnel values according to the default standard
  52695. * empirically know to work well :-)
  52696. */
  52697. set reflectionStandardFresnelWeight(value: number);
  52698. protected _useRGBColor: boolean;
  52699. /**
  52700. * Helps to directly use the maps channels instead of their level.
  52701. */
  52702. useRGBColor: boolean;
  52703. protected _enableNoise: boolean;
  52704. /**
  52705. * This helps reducing the banding effect that could occur on the background.
  52706. */
  52707. enableNoise: boolean;
  52708. /**
  52709. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52710. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52711. * Recommended to be keep at 1.0 except for special cases.
  52712. */
  52713. get fovMultiplier(): number;
  52714. set fovMultiplier(value: number);
  52715. private _fovMultiplier;
  52716. /**
  52717. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52718. */
  52719. useEquirectangularFOV: boolean;
  52720. private _maxSimultaneousLights;
  52721. /**
  52722. * Number of Simultaneous lights allowed on the material.
  52723. */
  52724. maxSimultaneousLights: int;
  52725. /**
  52726. * Default configuration related to image processing available in the Background Material.
  52727. */
  52728. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52729. /**
  52730. * Keep track of the image processing observer to allow dispose and replace.
  52731. */
  52732. private _imageProcessingObserver;
  52733. /**
  52734. * Attaches a new image processing configuration to the PBR Material.
  52735. * @param configuration (if null the scene configuration will be use)
  52736. */
  52737. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52738. /**
  52739. * Gets the image processing configuration used either in this material.
  52740. */
  52741. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52742. /**
  52743. * Sets the Default image processing configuration used either in the this material.
  52744. *
  52745. * If sets to null, the scene one is in use.
  52746. */
  52747. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52748. /**
  52749. * Gets wether the color curves effect is enabled.
  52750. */
  52751. get cameraColorCurvesEnabled(): boolean;
  52752. /**
  52753. * Sets wether the color curves effect is enabled.
  52754. */
  52755. set cameraColorCurvesEnabled(value: boolean);
  52756. /**
  52757. * Gets wether the color grading effect is enabled.
  52758. */
  52759. get cameraColorGradingEnabled(): boolean;
  52760. /**
  52761. * Gets wether the color grading effect is enabled.
  52762. */
  52763. set cameraColorGradingEnabled(value: boolean);
  52764. /**
  52765. * Gets wether tonemapping is enabled or not.
  52766. */
  52767. get cameraToneMappingEnabled(): boolean;
  52768. /**
  52769. * Sets wether tonemapping is enabled or not
  52770. */
  52771. set cameraToneMappingEnabled(value: boolean);
  52772. /**
  52773. * The camera exposure used on this material.
  52774. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52775. * This corresponds to a photographic exposure.
  52776. */
  52777. get cameraExposure(): float;
  52778. /**
  52779. * The camera exposure used on this material.
  52780. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52781. * This corresponds to a photographic exposure.
  52782. */
  52783. set cameraExposure(value: float);
  52784. /**
  52785. * Gets The camera contrast used on this material.
  52786. */
  52787. get cameraContrast(): float;
  52788. /**
  52789. * Sets The camera contrast used on this material.
  52790. */
  52791. set cameraContrast(value: float);
  52792. /**
  52793. * Gets the Color Grading 2D Lookup Texture.
  52794. */
  52795. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52796. /**
  52797. * Sets the Color Grading 2D Lookup Texture.
  52798. */
  52799. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52800. /**
  52801. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52802. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52803. * 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;
  52804. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52805. */
  52806. get cameraColorCurves(): Nullable<ColorCurves>;
  52807. /**
  52808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52810. * 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;
  52811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52812. */
  52813. set cameraColorCurves(value: Nullable<ColorCurves>);
  52814. /**
  52815. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52816. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52817. */
  52818. switchToBGR: boolean;
  52819. private _renderTargets;
  52820. private _reflectionControls;
  52821. private _white;
  52822. private _primaryShadowColor;
  52823. private _primaryHighlightColor;
  52824. /**
  52825. * Instantiates a Background Material in the given scene
  52826. * @param name The friendly name of the material
  52827. * @param scene The scene to add the material to
  52828. */
  52829. constructor(name: string, scene: Scene);
  52830. /**
  52831. * Gets a boolean indicating that current material needs to register RTT
  52832. */
  52833. get hasRenderTargetTextures(): boolean;
  52834. /**
  52835. * The entire material has been created in order to prevent overdraw.
  52836. * @returns false
  52837. */
  52838. needAlphaTesting(): boolean;
  52839. /**
  52840. * The entire material has been created in order to prevent overdraw.
  52841. * @returns true if blending is enable
  52842. */
  52843. needAlphaBlending(): boolean;
  52844. /**
  52845. * Checks wether the material is ready to be rendered for a given mesh.
  52846. * @param mesh The mesh to render
  52847. * @param subMesh The submesh to check against
  52848. * @param useInstances Specify wether or not the material is used with instances
  52849. * @returns true if all the dependencies are ready (Textures, Effects...)
  52850. */
  52851. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52852. /**
  52853. * Compute the primary color according to the chosen perceptual color.
  52854. */
  52855. private _computePrimaryColorFromPerceptualColor;
  52856. /**
  52857. * Compute the highlights and shadow colors according to their chosen levels.
  52858. */
  52859. private _computePrimaryColors;
  52860. /**
  52861. * Build the uniform buffer used in the material.
  52862. */
  52863. buildUniformLayout(): void;
  52864. /**
  52865. * Unbind the material.
  52866. */
  52867. unbind(): void;
  52868. /**
  52869. * Bind only the world matrix to the material.
  52870. * @param world The world matrix to bind.
  52871. */
  52872. bindOnlyWorldMatrix(world: Matrix): void;
  52873. /**
  52874. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52875. * @param world The world matrix to bind.
  52876. * @param subMesh The submesh to bind for.
  52877. */
  52878. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52879. /**
  52880. * Checks to see if a texture is used in the material.
  52881. * @param texture - Base texture to use.
  52882. * @returns - Boolean specifying if a texture is used in the material.
  52883. */
  52884. hasTexture(texture: BaseTexture): boolean;
  52885. /**
  52886. * Dispose the material.
  52887. * @param forceDisposeEffect Force disposal of the associated effect.
  52888. * @param forceDisposeTextures Force disposal of the associated textures.
  52889. */
  52890. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52891. /**
  52892. * Clones the material.
  52893. * @param name The cloned name.
  52894. * @returns The cloned material.
  52895. */
  52896. clone(name: string): BackgroundMaterial;
  52897. /**
  52898. * Serializes the current material to its JSON representation.
  52899. * @returns The JSON representation.
  52900. */
  52901. serialize(): any;
  52902. /**
  52903. * Gets the class name of the material
  52904. * @returns "BackgroundMaterial"
  52905. */
  52906. getClassName(): string;
  52907. /**
  52908. * Parse a JSON input to create back a background material.
  52909. * @param source The JSON data to parse
  52910. * @param scene The scene to create the parsed material in
  52911. * @param rootUrl The root url of the assets the material depends upon
  52912. * @returns the instantiated BackgroundMaterial.
  52913. */
  52914. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  52915. }
  52916. }
  52917. declare module BABYLON {
  52918. /**
  52919. * Represents the different options available during the creation of
  52920. * a Environment helper.
  52921. *
  52922. * This can control the default ground, skybox and image processing setup of your scene.
  52923. */
  52924. export interface IEnvironmentHelperOptions {
  52925. /**
  52926. * Specifies whether or not to create a ground.
  52927. * True by default.
  52928. */
  52929. createGround: boolean;
  52930. /**
  52931. * Specifies the ground size.
  52932. * 15 by default.
  52933. */
  52934. groundSize: number;
  52935. /**
  52936. * The texture used on the ground for the main color.
  52937. * Comes from the BabylonJS CDN by default.
  52938. *
  52939. * Remarks: Can be either a texture or a url.
  52940. */
  52941. groundTexture: string | BaseTexture;
  52942. /**
  52943. * The color mixed in the ground texture by default.
  52944. * BabylonJS clearColor by default.
  52945. */
  52946. groundColor: Color3;
  52947. /**
  52948. * Specifies the ground opacity.
  52949. * 1 by default.
  52950. */
  52951. groundOpacity: number;
  52952. /**
  52953. * Enables the ground to receive shadows.
  52954. * True by default.
  52955. */
  52956. enableGroundShadow: boolean;
  52957. /**
  52958. * Helps preventing the shadow to be fully black on the ground.
  52959. * 0.5 by default.
  52960. */
  52961. groundShadowLevel: number;
  52962. /**
  52963. * Creates a mirror texture attach to the ground.
  52964. * false by default.
  52965. */
  52966. enableGroundMirror: boolean;
  52967. /**
  52968. * Specifies the ground mirror size ratio.
  52969. * 0.3 by default as the default kernel is 64.
  52970. */
  52971. groundMirrorSizeRatio: number;
  52972. /**
  52973. * Specifies the ground mirror blur kernel size.
  52974. * 64 by default.
  52975. */
  52976. groundMirrorBlurKernel: number;
  52977. /**
  52978. * Specifies the ground mirror visibility amount.
  52979. * 1 by default
  52980. */
  52981. groundMirrorAmount: number;
  52982. /**
  52983. * Specifies the ground mirror reflectance weight.
  52984. * This uses the standard weight of the background material to setup the fresnel effect
  52985. * of the mirror.
  52986. * 1 by default.
  52987. */
  52988. groundMirrorFresnelWeight: number;
  52989. /**
  52990. * Specifies the ground mirror Falloff distance.
  52991. * This can helps reducing the size of the reflection.
  52992. * 0 by Default.
  52993. */
  52994. groundMirrorFallOffDistance: number;
  52995. /**
  52996. * Specifies the ground mirror texture type.
  52997. * Unsigned Int by Default.
  52998. */
  52999. groundMirrorTextureType: number;
  53000. /**
  53001. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53002. * the shown objects.
  53003. */
  53004. groundYBias: number;
  53005. /**
  53006. * Specifies whether or not to create a skybox.
  53007. * True by default.
  53008. */
  53009. createSkybox: boolean;
  53010. /**
  53011. * Specifies the skybox size.
  53012. * 20 by default.
  53013. */
  53014. skyboxSize: number;
  53015. /**
  53016. * The texture used on the skybox for the main color.
  53017. * Comes from the BabylonJS CDN by default.
  53018. *
  53019. * Remarks: Can be either a texture or a url.
  53020. */
  53021. skyboxTexture: string | BaseTexture;
  53022. /**
  53023. * The color mixed in the skybox texture by default.
  53024. * BabylonJS clearColor by default.
  53025. */
  53026. skyboxColor: Color3;
  53027. /**
  53028. * The background rotation around the Y axis of the scene.
  53029. * This helps aligning the key lights of your scene with the background.
  53030. * 0 by default.
  53031. */
  53032. backgroundYRotation: number;
  53033. /**
  53034. * Compute automatically the size of the elements to best fit with the scene.
  53035. */
  53036. sizeAuto: boolean;
  53037. /**
  53038. * Default position of the rootMesh if autoSize is not true.
  53039. */
  53040. rootPosition: Vector3;
  53041. /**
  53042. * Sets up the image processing in the scene.
  53043. * true by default.
  53044. */
  53045. setupImageProcessing: boolean;
  53046. /**
  53047. * The texture used as your environment texture in the scene.
  53048. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53049. *
  53050. * Remarks: Can be either a texture or a url.
  53051. */
  53052. environmentTexture: string | BaseTexture;
  53053. /**
  53054. * The value of the exposure to apply to the scene.
  53055. * 0.6 by default if setupImageProcessing is true.
  53056. */
  53057. cameraExposure: number;
  53058. /**
  53059. * The value of the contrast to apply to the scene.
  53060. * 1.6 by default if setupImageProcessing is true.
  53061. */
  53062. cameraContrast: number;
  53063. /**
  53064. * Specifies whether or not tonemapping should be enabled in the scene.
  53065. * true by default if setupImageProcessing is true.
  53066. */
  53067. toneMappingEnabled: boolean;
  53068. }
  53069. /**
  53070. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53071. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53072. * It also helps with the default setup of your imageProcessing configuration.
  53073. */
  53074. export class EnvironmentHelper {
  53075. /**
  53076. * Default ground texture URL.
  53077. */
  53078. private static _groundTextureCDNUrl;
  53079. /**
  53080. * Default skybox texture URL.
  53081. */
  53082. private static _skyboxTextureCDNUrl;
  53083. /**
  53084. * Default environment texture URL.
  53085. */
  53086. private static _environmentTextureCDNUrl;
  53087. /**
  53088. * Creates the default options for the helper.
  53089. */
  53090. private static _getDefaultOptions;
  53091. private _rootMesh;
  53092. /**
  53093. * Gets the root mesh created by the helper.
  53094. */
  53095. get rootMesh(): Mesh;
  53096. private _skybox;
  53097. /**
  53098. * Gets the skybox created by the helper.
  53099. */
  53100. get skybox(): Nullable<Mesh>;
  53101. private _skyboxTexture;
  53102. /**
  53103. * Gets the skybox texture created by the helper.
  53104. */
  53105. get skyboxTexture(): Nullable<BaseTexture>;
  53106. private _skyboxMaterial;
  53107. /**
  53108. * Gets the skybox material created by the helper.
  53109. */
  53110. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53111. private _ground;
  53112. /**
  53113. * Gets the ground mesh created by the helper.
  53114. */
  53115. get ground(): Nullable<Mesh>;
  53116. private _groundTexture;
  53117. /**
  53118. * Gets the ground texture created by the helper.
  53119. */
  53120. get groundTexture(): Nullable<BaseTexture>;
  53121. private _groundMirror;
  53122. /**
  53123. * Gets the ground mirror created by the helper.
  53124. */
  53125. get groundMirror(): Nullable<MirrorTexture>;
  53126. /**
  53127. * Gets the ground mirror render list to helps pushing the meshes
  53128. * you wish in the ground reflection.
  53129. */
  53130. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53131. private _groundMaterial;
  53132. /**
  53133. * Gets the ground material created by the helper.
  53134. */
  53135. get groundMaterial(): Nullable<BackgroundMaterial>;
  53136. /**
  53137. * Stores the creation options.
  53138. */
  53139. private readonly _scene;
  53140. private _options;
  53141. /**
  53142. * This observable will be notified with any error during the creation of the environment,
  53143. * mainly texture creation errors.
  53144. */
  53145. onErrorObservable: Observable<{
  53146. message?: string;
  53147. exception?: any;
  53148. }>;
  53149. /**
  53150. * constructor
  53151. * @param options Defines the options we want to customize the helper
  53152. * @param scene The scene to add the material to
  53153. */
  53154. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53155. /**
  53156. * Updates the background according to the new options
  53157. * @param options
  53158. */
  53159. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53160. /**
  53161. * Sets the primary color of all the available elements.
  53162. * @param color the main color to affect to the ground and the background
  53163. */
  53164. setMainColor(color: Color3): void;
  53165. /**
  53166. * Setup the image processing according to the specified options.
  53167. */
  53168. private _setupImageProcessing;
  53169. /**
  53170. * Setup the environment texture according to the specified options.
  53171. */
  53172. private _setupEnvironmentTexture;
  53173. /**
  53174. * Setup the background according to the specified options.
  53175. */
  53176. private _setupBackground;
  53177. /**
  53178. * Get the scene sizes according to the setup.
  53179. */
  53180. private _getSceneSize;
  53181. /**
  53182. * Setup the ground according to the specified options.
  53183. */
  53184. private _setupGround;
  53185. /**
  53186. * Setup the ground material according to the specified options.
  53187. */
  53188. private _setupGroundMaterial;
  53189. /**
  53190. * Setup the ground diffuse texture according to the specified options.
  53191. */
  53192. private _setupGroundDiffuseTexture;
  53193. /**
  53194. * Setup the ground mirror texture according to the specified options.
  53195. */
  53196. private _setupGroundMirrorTexture;
  53197. /**
  53198. * Setup the ground to receive the mirror texture.
  53199. */
  53200. private _setupMirrorInGroundMaterial;
  53201. /**
  53202. * Setup the skybox according to the specified options.
  53203. */
  53204. private _setupSkybox;
  53205. /**
  53206. * Setup the skybox material according to the specified options.
  53207. */
  53208. private _setupSkyboxMaterial;
  53209. /**
  53210. * Setup the skybox reflection texture according to the specified options.
  53211. */
  53212. private _setupSkyboxReflectionTexture;
  53213. private _errorHandler;
  53214. /**
  53215. * Dispose all the elements created by the Helper.
  53216. */
  53217. dispose(): void;
  53218. }
  53219. }
  53220. declare module BABYLON {
  53221. /**
  53222. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53223. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53224. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53225. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53226. */
  53227. export class PhotoDome extends TransformNode {
  53228. /**
  53229. * Define the image as a Monoscopic panoramic 360 image.
  53230. */
  53231. static readonly MODE_MONOSCOPIC: number;
  53232. /**
  53233. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53234. */
  53235. static readonly MODE_TOPBOTTOM: number;
  53236. /**
  53237. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53238. */
  53239. static readonly MODE_SIDEBYSIDE: number;
  53240. private _useDirectMapping;
  53241. /**
  53242. * The texture being displayed on the sphere
  53243. */
  53244. protected _photoTexture: Texture;
  53245. /**
  53246. * Gets or sets the texture being displayed on the sphere
  53247. */
  53248. get photoTexture(): Texture;
  53249. set photoTexture(value: Texture);
  53250. /**
  53251. * Observable raised when an error occured while loading the 360 image
  53252. */
  53253. onLoadErrorObservable: Observable<string>;
  53254. /**
  53255. * The skybox material
  53256. */
  53257. protected _material: BackgroundMaterial;
  53258. /**
  53259. * The surface used for the skybox
  53260. */
  53261. protected _mesh: Mesh;
  53262. /**
  53263. * Gets the mesh used for the skybox.
  53264. */
  53265. get mesh(): Mesh;
  53266. /**
  53267. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53268. * Also see the options.resolution property.
  53269. */
  53270. get fovMultiplier(): number;
  53271. set fovMultiplier(value: number);
  53272. private _imageMode;
  53273. /**
  53274. * Gets or set the current video mode for the video. It can be:
  53275. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53276. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53277. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53278. */
  53279. get imageMode(): number;
  53280. set imageMode(value: number);
  53281. /**
  53282. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53283. * @param name Element's name, child elements will append suffixes for their own names.
  53284. * @param urlsOfPhoto defines the url of the photo to display
  53285. * @param options defines an object containing optional or exposed sub element properties
  53286. * @param onError defines a callback called when an error occured while loading the texture
  53287. */
  53288. constructor(name: string, urlOfPhoto: string, options: {
  53289. resolution?: number;
  53290. size?: number;
  53291. useDirectMapping?: boolean;
  53292. faceForward?: boolean;
  53293. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53294. private _onBeforeCameraRenderObserver;
  53295. private _changeImageMode;
  53296. /**
  53297. * Releases resources associated with this node.
  53298. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53299. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53300. */
  53301. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53302. }
  53303. }
  53304. declare module BABYLON {
  53305. /**
  53306. * Class used to host RGBD texture specific utilities
  53307. */
  53308. export class RGBDTextureTools {
  53309. /**
  53310. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53311. * @param texture the texture to expand.
  53312. */
  53313. static ExpandRGBDTexture(texture: Texture): void;
  53314. }
  53315. }
  53316. declare module BABYLON {
  53317. /**
  53318. * Class used to host texture specific utilities
  53319. */
  53320. export class BRDFTextureTools {
  53321. /**
  53322. * Prevents texture cache collision
  53323. */
  53324. private static _instanceNumber;
  53325. /**
  53326. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53327. * @param scene defines the hosting scene
  53328. * @returns the environment BRDF texture
  53329. */
  53330. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53331. private static _environmentBRDFBase64Texture;
  53332. }
  53333. }
  53334. declare module BABYLON {
  53335. /**
  53336. * @hidden
  53337. */
  53338. export interface IMaterialClearCoatDefines {
  53339. CLEARCOAT: boolean;
  53340. CLEARCOAT_DEFAULTIOR: boolean;
  53341. CLEARCOAT_TEXTURE: boolean;
  53342. CLEARCOAT_TEXTUREDIRECTUV: number;
  53343. CLEARCOAT_BUMP: boolean;
  53344. CLEARCOAT_BUMPDIRECTUV: number;
  53345. CLEARCOAT_TINT: boolean;
  53346. CLEARCOAT_TINT_TEXTURE: boolean;
  53347. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53348. /** @hidden */
  53349. _areTexturesDirty: boolean;
  53350. }
  53351. /**
  53352. * Define the code related to the clear coat parameters of the pbr material.
  53353. */
  53354. export class PBRClearCoatConfiguration {
  53355. /**
  53356. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53357. * The default fits with a polyurethane material.
  53358. */
  53359. private static readonly _DefaultIndexOfRefraction;
  53360. private _isEnabled;
  53361. /**
  53362. * Defines if the clear coat is enabled in the material.
  53363. */
  53364. isEnabled: boolean;
  53365. /**
  53366. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53367. */
  53368. intensity: number;
  53369. /**
  53370. * Defines the clear coat layer roughness.
  53371. */
  53372. roughness: number;
  53373. private _indexOfRefraction;
  53374. /**
  53375. * Defines the index of refraction of the clear coat.
  53376. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53377. * The default fits with a polyurethane material.
  53378. * Changing the default value is more performance intensive.
  53379. */
  53380. indexOfRefraction: number;
  53381. private _texture;
  53382. /**
  53383. * Stores the clear coat values in a texture.
  53384. */
  53385. texture: Nullable<BaseTexture>;
  53386. private _bumpTexture;
  53387. /**
  53388. * Define the clear coat specific bump texture.
  53389. */
  53390. bumpTexture: Nullable<BaseTexture>;
  53391. private _isTintEnabled;
  53392. /**
  53393. * Defines if the clear coat tint is enabled in the material.
  53394. */
  53395. isTintEnabled: boolean;
  53396. /**
  53397. * Defines the clear coat tint of the material.
  53398. * This is only use if tint is enabled
  53399. */
  53400. tintColor: Color3;
  53401. /**
  53402. * Defines the distance at which the tint color should be found in the
  53403. * clear coat media.
  53404. * This is only use if tint is enabled
  53405. */
  53406. tintColorAtDistance: number;
  53407. /**
  53408. * Defines the clear coat layer thickness.
  53409. * This is only use if tint is enabled
  53410. */
  53411. tintThickness: number;
  53412. private _tintTexture;
  53413. /**
  53414. * Stores the clear tint values in a texture.
  53415. * rgb is tint
  53416. * a is a thickness factor
  53417. */
  53418. tintTexture: Nullable<BaseTexture>;
  53419. /** @hidden */
  53420. private _internalMarkAllSubMeshesAsTexturesDirty;
  53421. /** @hidden */
  53422. _markAllSubMeshesAsTexturesDirty(): void;
  53423. /**
  53424. * Instantiate a new istance of clear coat configuration.
  53425. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53426. */
  53427. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53428. /**
  53429. * Gets wehter the submesh is ready to be used or not.
  53430. * @param defines the list of "defines" to update.
  53431. * @param scene defines the scene the material belongs to.
  53432. * @param engine defines the engine the material belongs to.
  53433. * @param disableBumpMap defines wether the material disables bump or not.
  53434. * @returns - boolean indicating that the submesh is ready or not.
  53435. */
  53436. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53437. /**
  53438. * Checks to see if a texture is used in the material.
  53439. * @param defines the list of "defines" to update.
  53440. * @param scene defines the scene to the material belongs to.
  53441. */
  53442. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53443. /**
  53444. * Binds the material data.
  53445. * @param uniformBuffer defines the Uniform buffer to fill in.
  53446. * @param scene defines the scene the material belongs to.
  53447. * @param engine defines the engine the material belongs to.
  53448. * @param disableBumpMap defines wether the material disables bump or not.
  53449. * @param isFrozen defines wether the material is frozen or not.
  53450. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53451. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53452. */
  53453. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53454. /**
  53455. * Checks to see if a texture is used in the material.
  53456. * @param texture - Base texture to use.
  53457. * @returns - Boolean specifying if a texture is used in the material.
  53458. */
  53459. hasTexture(texture: BaseTexture): boolean;
  53460. /**
  53461. * Returns an array of the actively used textures.
  53462. * @param activeTextures Array of BaseTextures
  53463. */
  53464. getActiveTextures(activeTextures: BaseTexture[]): void;
  53465. /**
  53466. * Returns the animatable textures.
  53467. * @param animatables Array of animatable textures.
  53468. */
  53469. getAnimatables(animatables: IAnimatable[]): void;
  53470. /**
  53471. * Disposes the resources of the material.
  53472. * @param forceDisposeTextures - Forces the disposal of all textures.
  53473. */
  53474. dispose(forceDisposeTextures?: boolean): void;
  53475. /**
  53476. * Get the current class name of the texture useful for serialization or dynamic coding.
  53477. * @returns "PBRClearCoatConfiguration"
  53478. */
  53479. getClassName(): string;
  53480. /**
  53481. * Add fallbacks to the effect fallbacks list.
  53482. * @param defines defines the Base texture to use.
  53483. * @param fallbacks defines the current fallback list.
  53484. * @param currentRank defines the current fallback rank.
  53485. * @returns the new fallback rank.
  53486. */
  53487. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53488. /**
  53489. * Add the required uniforms to the current list.
  53490. * @param uniforms defines the current uniform list.
  53491. */
  53492. static AddUniforms(uniforms: string[]): void;
  53493. /**
  53494. * Add the required samplers to the current list.
  53495. * @param samplers defines the current sampler list.
  53496. */
  53497. static AddSamplers(samplers: string[]): void;
  53498. /**
  53499. * Add the required uniforms to the current buffer.
  53500. * @param uniformBuffer defines the current uniform buffer.
  53501. */
  53502. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53503. /**
  53504. * Makes a duplicate of the current configuration into another one.
  53505. * @param clearCoatConfiguration define the config where to copy the info
  53506. */
  53507. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53508. /**
  53509. * Serializes this clear coat configuration.
  53510. * @returns - An object with the serialized config.
  53511. */
  53512. serialize(): any;
  53513. /**
  53514. * Parses a anisotropy Configuration from a serialized object.
  53515. * @param source - Serialized object.
  53516. * @param scene Defines the scene we are parsing for
  53517. * @param rootUrl Defines the rootUrl to load from
  53518. */
  53519. parse(source: any, scene: Scene, rootUrl: string): void;
  53520. }
  53521. }
  53522. declare module BABYLON {
  53523. /**
  53524. * @hidden
  53525. */
  53526. export interface IMaterialAnisotropicDefines {
  53527. ANISOTROPIC: boolean;
  53528. ANISOTROPIC_TEXTURE: boolean;
  53529. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53530. MAINUV1: boolean;
  53531. _areTexturesDirty: boolean;
  53532. _needUVs: boolean;
  53533. }
  53534. /**
  53535. * Define the code related to the anisotropic parameters of the pbr material.
  53536. */
  53537. export class PBRAnisotropicConfiguration {
  53538. private _isEnabled;
  53539. /**
  53540. * Defines if the anisotropy is enabled in the material.
  53541. */
  53542. isEnabled: boolean;
  53543. /**
  53544. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53545. */
  53546. intensity: number;
  53547. /**
  53548. * Defines if the effect is along the tangents, bitangents or in between.
  53549. * By default, the effect is "strectching" the highlights along the tangents.
  53550. */
  53551. direction: Vector2;
  53552. private _texture;
  53553. /**
  53554. * Stores the anisotropy values in a texture.
  53555. * rg is direction (like normal from -1 to 1)
  53556. * b is a intensity
  53557. */
  53558. texture: Nullable<BaseTexture>;
  53559. /** @hidden */
  53560. private _internalMarkAllSubMeshesAsTexturesDirty;
  53561. /** @hidden */
  53562. _markAllSubMeshesAsTexturesDirty(): void;
  53563. /**
  53564. * Instantiate a new istance of anisotropy configuration.
  53565. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53566. */
  53567. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53568. /**
  53569. * Specifies that the submesh is ready to be used.
  53570. * @param defines the list of "defines" to update.
  53571. * @param scene defines the scene the material belongs to.
  53572. * @returns - boolean indicating that the submesh is ready or not.
  53573. */
  53574. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53575. /**
  53576. * Checks to see if a texture is used in the material.
  53577. * @param defines the list of "defines" to update.
  53578. * @param mesh the mesh we are preparing the defines for.
  53579. * @param scene defines the scene the material belongs to.
  53580. */
  53581. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53582. /**
  53583. * Binds the material data.
  53584. * @param uniformBuffer defines the Uniform buffer to fill in.
  53585. * @param scene defines the scene the material belongs to.
  53586. * @param isFrozen defines wether the material is frozen or not.
  53587. */
  53588. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53589. /**
  53590. * Checks to see if a texture is used in the material.
  53591. * @param texture - Base texture to use.
  53592. * @returns - Boolean specifying if a texture is used in the material.
  53593. */
  53594. hasTexture(texture: BaseTexture): boolean;
  53595. /**
  53596. * Returns an array of the actively used textures.
  53597. * @param activeTextures Array of BaseTextures
  53598. */
  53599. getActiveTextures(activeTextures: BaseTexture[]): void;
  53600. /**
  53601. * Returns the animatable textures.
  53602. * @param animatables Array of animatable textures.
  53603. */
  53604. getAnimatables(animatables: IAnimatable[]): void;
  53605. /**
  53606. * Disposes the resources of the material.
  53607. * @param forceDisposeTextures - Forces the disposal of all textures.
  53608. */
  53609. dispose(forceDisposeTextures?: boolean): void;
  53610. /**
  53611. * Get the current class name of the texture useful for serialization or dynamic coding.
  53612. * @returns "PBRAnisotropicConfiguration"
  53613. */
  53614. getClassName(): string;
  53615. /**
  53616. * Add fallbacks to the effect fallbacks list.
  53617. * @param defines defines the Base texture to use.
  53618. * @param fallbacks defines the current fallback list.
  53619. * @param currentRank defines the current fallback rank.
  53620. * @returns the new fallback rank.
  53621. */
  53622. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53623. /**
  53624. * Add the required uniforms to the current list.
  53625. * @param uniforms defines the current uniform list.
  53626. */
  53627. static AddUniforms(uniforms: string[]): void;
  53628. /**
  53629. * Add the required uniforms to the current buffer.
  53630. * @param uniformBuffer defines the current uniform buffer.
  53631. */
  53632. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53633. /**
  53634. * Add the required samplers to the current list.
  53635. * @param samplers defines the current sampler list.
  53636. */
  53637. static AddSamplers(samplers: string[]): void;
  53638. /**
  53639. * Makes a duplicate of the current configuration into another one.
  53640. * @param anisotropicConfiguration define the config where to copy the info
  53641. */
  53642. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53643. /**
  53644. * Serializes this anisotropy configuration.
  53645. * @returns - An object with the serialized config.
  53646. */
  53647. serialize(): any;
  53648. /**
  53649. * Parses a anisotropy Configuration from a serialized object.
  53650. * @param source - Serialized object.
  53651. * @param scene Defines the scene we are parsing for
  53652. * @param rootUrl Defines the rootUrl to load from
  53653. */
  53654. parse(source: any, scene: Scene, rootUrl: string): void;
  53655. }
  53656. }
  53657. declare module BABYLON {
  53658. /**
  53659. * @hidden
  53660. */
  53661. export interface IMaterialBRDFDefines {
  53662. BRDF_V_HEIGHT_CORRELATED: boolean;
  53663. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53664. SPHERICAL_HARMONICS: boolean;
  53665. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53666. /** @hidden */
  53667. _areMiscDirty: boolean;
  53668. }
  53669. /**
  53670. * Define the code related to the BRDF parameters of the pbr material.
  53671. */
  53672. export class PBRBRDFConfiguration {
  53673. /**
  53674. * Default value used for the energy conservation.
  53675. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53676. */
  53677. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53678. /**
  53679. * Default value used for the Smith Visibility Height Correlated mode.
  53680. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53681. */
  53682. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53683. /**
  53684. * Default value used for the IBL diffuse part.
  53685. * This can help switching back to the polynomials mode globally which is a tiny bit
  53686. * less GPU intensive at the drawback of a lower quality.
  53687. */
  53688. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53689. /**
  53690. * Default value used for activating energy conservation for the specular workflow.
  53691. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53692. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53693. */
  53694. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53695. private _useEnergyConservation;
  53696. /**
  53697. * Defines if the material uses energy conservation.
  53698. */
  53699. useEnergyConservation: boolean;
  53700. private _useSmithVisibilityHeightCorrelated;
  53701. /**
  53702. * LEGACY Mode set to false
  53703. * Defines if the material uses height smith correlated visibility term.
  53704. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53705. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53706. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53707. * Not relying on height correlated will also disable energy conservation.
  53708. */
  53709. useSmithVisibilityHeightCorrelated: boolean;
  53710. private _useSphericalHarmonics;
  53711. /**
  53712. * LEGACY Mode set to false
  53713. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53714. * diffuse part of the IBL.
  53715. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53716. * to the ground truth.
  53717. */
  53718. useSphericalHarmonics: boolean;
  53719. private _useSpecularGlossinessInputEnergyConservation;
  53720. /**
  53721. * Defines if the material uses energy conservation, when the specular workflow is active.
  53722. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53723. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53724. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53725. */
  53726. useSpecularGlossinessInputEnergyConservation: boolean;
  53727. /** @hidden */
  53728. private _internalMarkAllSubMeshesAsMiscDirty;
  53729. /** @hidden */
  53730. _markAllSubMeshesAsMiscDirty(): void;
  53731. /**
  53732. * Instantiate a new istance of clear coat configuration.
  53733. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53734. */
  53735. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53736. /**
  53737. * Checks to see if a texture is used in the material.
  53738. * @param defines the list of "defines" to update.
  53739. */
  53740. prepareDefines(defines: IMaterialBRDFDefines): void;
  53741. /**
  53742. * Get the current class name of the texture useful for serialization or dynamic coding.
  53743. * @returns "PBRClearCoatConfiguration"
  53744. */
  53745. getClassName(): string;
  53746. /**
  53747. * Makes a duplicate of the current configuration into another one.
  53748. * @param brdfConfiguration define the config where to copy the info
  53749. */
  53750. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53751. /**
  53752. * Serializes this BRDF configuration.
  53753. * @returns - An object with the serialized config.
  53754. */
  53755. serialize(): any;
  53756. /**
  53757. * Parses a anisotropy Configuration from a serialized object.
  53758. * @param source - Serialized object.
  53759. * @param scene Defines the scene we are parsing for
  53760. * @param rootUrl Defines the rootUrl to load from
  53761. */
  53762. parse(source: any, scene: Scene, rootUrl: string): void;
  53763. }
  53764. }
  53765. declare module BABYLON {
  53766. /**
  53767. * @hidden
  53768. */
  53769. export interface IMaterialSheenDefines {
  53770. SHEEN: boolean;
  53771. SHEEN_TEXTURE: boolean;
  53772. SHEEN_TEXTUREDIRECTUV: number;
  53773. SHEEN_LINKWITHALBEDO: boolean;
  53774. SHEEN_ROUGHNESS: boolean;
  53775. SHEEN_ALBEDOSCALING: boolean;
  53776. /** @hidden */
  53777. _areTexturesDirty: boolean;
  53778. }
  53779. /**
  53780. * Define the code related to the Sheen parameters of the pbr material.
  53781. */
  53782. export class PBRSheenConfiguration {
  53783. private _isEnabled;
  53784. /**
  53785. * Defines if the material uses sheen.
  53786. */
  53787. isEnabled: boolean;
  53788. private _linkSheenWithAlbedo;
  53789. /**
  53790. * Defines if the sheen is linked to the sheen color.
  53791. */
  53792. linkSheenWithAlbedo: boolean;
  53793. /**
  53794. * Defines the sheen intensity.
  53795. */
  53796. intensity: number;
  53797. /**
  53798. * Defines the sheen color.
  53799. */
  53800. color: Color3;
  53801. private _texture;
  53802. /**
  53803. * Stores the sheen tint values in a texture.
  53804. * rgb is tint
  53805. * a is a intensity
  53806. */
  53807. texture: Nullable<BaseTexture>;
  53808. private _roughness;
  53809. /**
  53810. * Defines the sheen roughness.
  53811. * It is not taken into account if linkSheenWithAlbedo is true.
  53812. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53813. */
  53814. roughness: Nullable<number>;
  53815. private _albedoScaling;
  53816. /**
  53817. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53818. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53819. * making it easier to setup and tweak the effect
  53820. */
  53821. albedoScaling: boolean;
  53822. /** @hidden */
  53823. private _internalMarkAllSubMeshesAsTexturesDirty;
  53824. /** @hidden */
  53825. _markAllSubMeshesAsTexturesDirty(): void;
  53826. /**
  53827. * Instantiate a new istance of clear coat configuration.
  53828. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53829. */
  53830. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53831. /**
  53832. * Specifies that the submesh is ready to be used.
  53833. * @param defines the list of "defines" to update.
  53834. * @param scene defines the scene the material belongs to.
  53835. * @returns - boolean indicating that the submesh is ready or not.
  53836. */
  53837. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53838. /**
  53839. * Checks to see if a texture is used in the material.
  53840. * @param defines the list of "defines" to update.
  53841. * @param scene defines the scene the material belongs to.
  53842. */
  53843. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53844. /**
  53845. * Binds the material data.
  53846. * @param uniformBuffer defines the Uniform buffer to fill in.
  53847. * @param scene defines the scene the material belongs to.
  53848. * @param isFrozen defines wether the material is frozen or not.
  53849. */
  53850. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53851. /**
  53852. * Checks to see if a texture is used in the material.
  53853. * @param texture - Base texture to use.
  53854. * @returns - Boolean specifying if a texture is used in the material.
  53855. */
  53856. hasTexture(texture: BaseTexture): boolean;
  53857. /**
  53858. * Returns an array of the actively used textures.
  53859. * @param activeTextures Array of BaseTextures
  53860. */
  53861. getActiveTextures(activeTextures: BaseTexture[]): void;
  53862. /**
  53863. * Returns the animatable textures.
  53864. * @param animatables Array of animatable textures.
  53865. */
  53866. getAnimatables(animatables: IAnimatable[]): void;
  53867. /**
  53868. * Disposes the resources of the material.
  53869. * @param forceDisposeTextures - Forces the disposal of all textures.
  53870. */
  53871. dispose(forceDisposeTextures?: boolean): void;
  53872. /**
  53873. * Get the current class name of the texture useful for serialization or dynamic coding.
  53874. * @returns "PBRSheenConfiguration"
  53875. */
  53876. getClassName(): string;
  53877. /**
  53878. * Add fallbacks to the effect fallbacks list.
  53879. * @param defines defines the Base texture to use.
  53880. * @param fallbacks defines the current fallback list.
  53881. * @param currentRank defines the current fallback rank.
  53882. * @returns the new fallback rank.
  53883. */
  53884. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53885. /**
  53886. * Add the required uniforms to the current list.
  53887. * @param uniforms defines the current uniform list.
  53888. */
  53889. static AddUniforms(uniforms: string[]): void;
  53890. /**
  53891. * Add the required uniforms to the current buffer.
  53892. * @param uniformBuffer defines the current uniform buffer.
  53893. */
  53894. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53895. /**
  53896. * Add the required samplers to the current list.
  53897. * @param samplers defines the current sampler list.
  53898. */
  53899. static AddSamplers(samplers: string[]): void;
  53900. /**
  53901. * Makes a duplicate of the current configuration into another one.
  53902. * @param sheenConfiguration define the config where to copy the info
  53903. */
  53904. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53905. /**
  53906. * Serializes this BRDF configuration.
  53907. * @returns - An object with the serialized config.
  53908. */
  53909. serialize(): any;
  53910. /**
  53911. * Parses a anisotropy Configuration from a serialized object.
  53912. * @param source - Serialized object.
  53913. * @param scene Defines the scene we are parsing for
  53914. * @param rootUrl Defines the rootUrl to load from
  53915. */
  53916. parse(source: any, scene: Scene, rootUrl: string): void;
  53917. }
  53918. }
  53919. declare module BABYLON {
  53920. /**
  53921. * @hidden
  53922. */
  53923. export interface IMaterialSubSurfaceDefines {
  53924. SUBSURFACE: boolean;
  53925. SS_REFRACTION: boolean;
  53926. SS_TRANSLUCENCY: boolean;
  53927. SS_SCATERRING: boolean;
  53928. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53929. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53930. SS_REFRACTIONMAP_3D: boolean;
  53931. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53932. SS_LODINREFRACTIONALPHA: boolean;
  53933. SS_GAMMAREFRACTION: boolean;
  53934. SS_RGBDREFRACTION: boolean;
  53935. SS_LINEARSPECULARREFRACTION: boolean;
  53936. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53937. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53938. /** @hidden */
  53939. _areTexturesDirty: boolean;
  53940. }
  53941. /**
  53942. * Define the code related to the sub surface parameters of the pbr material.
  53943. */
  53944. export class PBRSubSurfaceConfiguration {
  53945. private _isRefractionEnabled;
  53946. /**
  53947. * Defines if the refraction is enabled in the material.
  53948. */
  53949. isRefractionEnabled: boolean;
  53950. private _isTranslucencyEnabled;
  53951. /**
  53952. * Defines if the translucency is enabled in the material.
  53953. */
  53954. isTranslucencyEnabled: boolean;
  53955. private _isScatteringEnabled;
  53956. /**
  53957. * Defines the refraction intensity of the material.
  53958. * The refraction when enabled replaces the Diffuse part of the material.
  53959. * The intensity helps transitionning between diffuse and refraction.
  53960. */
  53961. refractionIntensity: number;
  53962. /**
  53963. * Defines the translucency intensity of the material.
  53964. * When translucency has been enabled, this defines how much of the "translucency"
  53965. * is addded to the diffuse part of the material.
  53966. */
  53967. translucencyIntensity: number;
  53968. /**
  53969. * Defines the scattering intensity of the material.
  53970. * When scattering has been enabled, this defines how much of the "scattered light"
  53971. * is addded to the diffuse part of the material.
  53972. */
  53973. scatteringIntensity: number;
  53974. private _thicknessTexture;
  53975. /**
  53976. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53977. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53978. * 0 would mean minimumThickness
  53979. * 1 would mean maximumThickness
  53980. * The other channels might be use as a mask to vary the different effects intensity.
  53981. */
  53982. thicknessTexture: Nullable<BaseTexture>;
  53983. private _refractionTexture;
  53984. /**
  53985. * Defines the texture to use for refraction.
  53986. */
  53987. refractionTexture: Nullable<BaseTexture>;
  53988. private _indexOfRefraction;
  53989. /**
  53990. * Index of refraction of the material base layer.
  53991. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53992. *
  53993. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  53994. *
  53995. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  53996. */
  53997. indexOfRefraction: number;
  53998. private _invertRefractionY;
  53999. /**
  54000. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54001. */
  54002. invertRefractionY: boolean;
  54003. private _linkRefractionWithTransparency;
  54004. /**
  54005. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54006. * Materials half opaque for instance using refraction could benefit from this control.
  54007. */
  54008. linkRefractionWithTransparency: boolean;
  54009. /**
  54010. * Defines the minimum thickness stored in the thickness map.
  54011. * If no thickness map is defined, this value will be used to simulate thickness.
  54012. */
  54013. minimumThickness: number;
  54014. /**
  54015. * Defines the maximum thickness stored in the thickness map.
  54016. */
  54017. maximumThickness: number;
  54018. /**
  54019. * Defines the volume tint of the material.
  54020. * This is used for both translucency and scattering.
  54021. */
  54022. tintColor: Color3;
  54023. /**
  54024. * Defines the distance at which the tint color should be found in the media.
  54025. * This is used for refraction only.
  54026. */
  54027. tintColorAtDistance: number;
  54028. /**
  54029. * Defines how far each channel transmit through the media.
  54030. * It is defined as a color to simplify it selection.
  54031. */
  54032. diffusionDistance: Color3;
  54033. private _useMaskFromThicknessTexture;
  54034. /**
  54035. * Stores the intensity of the different subsurface effects in the thickness texture.
  54036. * * the green channel is the translucency intensity.
  54037. * * the blue channel is the scattering intensity.
  54038. * * the alpha channel is the refraction intensity.
  54039. */
  54040. useMaskFromThicknessTexture: boolean;
  54041. /** @hidden */
  54042. private _internalMarkAllSubMeshesAsTexturesDirty;
  54043. /** @hidden */
  54044. _markAllSubMeshesAsTexturesDirty(): void;
  54045. /**
  54046. * Instantiate a new istance of sub surface configuration.
  54047. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54048. */
  54049. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54050. /**
  54051. * Gets wehter the submesh is ready to be used or not.
  54052. * @param defines the list of "defines" to update.
  54053. * @param scene defines the scene the material belongs to.
  54054. * @returns - boolean indicating that the submesh is ready or not.
  54055. */
  54056. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54057. /**
  54058. * Checks to see if a texture is used in the material.
  54059. * @param defines the list of "defines" to update.
  54060. * @param scene defines the scene to the material belongs to.
  54061. */
  54062. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54063. /**
  54064. * Binds the material data.
  54065. * @param uniformBuffer defines the Uniform buffer to fill in.
  54066. * @param scene defines the scene the material belongs to.
  54067. * @param engine defines the engine the material belongs to.
  54068. * @param isFrozen defines whether the material is frozen or not.
  54069. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54070. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54071. */
  54072. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54073. /**
  54074. * Unbinds the material from the mesh.
  54075. * @param activeEffect defines the effect that should be unbound from.
  54076. * @returns true if unbound, otherwise false
  54077. */
  54078. unbind(activeEffect: Effect): boolean;
  54079. /**
  54080. * Returns the texture used for refraction or null if none is used.
  54081. * @param scene defines the scene the material belongs to.
  54082. * @returns - Refraction texture if present. If no refraction texture and refraction
  54083. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54084. */
  54085. private _getRefractionTexture;
  54086. /**
  54087. * Returns true if alpha blending should be disabled.
  54088. */
  54089. get disableAlphaBlending(): boolean;
  54090. /**
  54091. * Fills the list of render target textures.
  54092. * @param renderTargets the list of render targets to update
  54093. */
  54094. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54095. /**
  54096. * Checks to see if a texture is used in the material.
  54097. * @param texture - Base texture to use.
  54098. * @returns - Boolean specifying if a texture is used in the material.
  54099. */
  54100. hasTexture(texture: BaseTexture): boolean;
  54101. /**
  54102. * Gets a boolean indicating that current material needs to register RTT
  54103. * @returns true if this uses a render target otherwise false.
  54104. */
  54105. hasRenderTargetTextures(): boolean;
  54106. /**
  54107. * Returns an array of the actively used textures.
  54108. * @param activeTextures Array of BaseTextures
  54109. */
  54110. getActiveTextures(activeTextures: BaseTexture[]): void;
  54111. /**
  54112. * Returns the animatable textures.
  54113. * @param animatables Array of animatable textures.
  54114. */
  54115. getAnimatables(animatables: IAnimatable[]): void;
  54116. /**
  54117. * Disposes the resources of the material.
  54118. * @param forceDisposeTextures - Forces the disposal of all textures.
  54119. */
  54120. dispose(forceDisposeTextures?: boolean): void;
  54121. /**
  54122. * Get the current class name of the texture useful for serialization or dynamic coding.
  54123. * @returns "PBRSubSurfaceConfiguration"
  54124. */
  54125. getClassName(): string;
  54126. /**
  54127. * Add fallbacks to the effect fallbacks list.
  54128. * @param defines defines the Base texture to use.
  54129. * @param fallbacks defines the current fallback list.
  54130. * @param currentRank defines the current fallback rank.
  54131. * @returns the new fallback rank.
  54132. */
  54133. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54134. /**
  54135. * Add the required uniforms to the current list.
  54136. * @param uniforms defines the current uniform list.
  54137. */
  54138. static AddUniforms(uniforms: string[]): void;
  54139. /**
  54140. * Add the required samplers to the current list.
  54141. * @param samplers defines the current sampler list.
  54142. */
  54143. static AddSamplers(samplers: string[]): void;
  54144. /**
  54145. * Add the required uniforms to the current buffer.
  54146. * @param uniformBuffer defines the current uniform buffer.
  54147. */
  54148. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54149. /**
  54150. * Makes a duplicate of the current configuration into another one.
  54151. * @param configuration define the config where to copy the info
  54152. */
  54153. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54154. /**
  54155. * Serializes this Sub Surface configuration.
  54156. * @returns - An object with the serialized config.
  54157. */
  54158. serialize(): any;
  54159. /**
  54160. * Parses a anisotropy Configuration from a serialized object.
  54161. * @param source - Serialized object.
  54162. * @param scene Defines the scene we are parsing for
  54163. * @param rootUrl Defines the rootUrl to load from
  54164. */
  54165. parse(source: any, scene: Scene, rootUrl: string): void;
  54166. }
  54167. }
  54168. declare module BABYLON {
  54169. /** @hidden */
  54170. export var pbrFragmentDeclaration: {
  54171. name: string;
  54172. shader: string;
  54173. };
  54174. }
  54175. declare module BABYLON {
  54176. /** @hidden */
  54177. export var pbrUboDeclaration: {
  54178. name: string;
  54179. shader: string;
  54180. };
  54181. }
  54182. declare module BABYLON {
  54183. /** @hidden */
  54184. export var pbrFragmentExtraDeclaration: {
  54185. name: string;
  54186. shader: string;
  54187. };
  54188. }
  54189. declare module BABYLON {
  54190. /** @hidden */
  54191. export var pbrFragmentSamplersDeclaration: {
  54192. name: string;
  54193. shader: string;
  54194. };
  54195. }
  54196. declare module BABYLON {
  54197. /** @hidden */
  54198. export var importanceSampling: {
  54199. name: string;
  54200. shader: string;
  54201. };
  54202. }
  54203. declare module BABYLON {
  54204. /** @hidden */
  54205. export var pbrHelperFunctions: {
  54206. name: string;
  54207. shader: string;
  54208. };
  54209. }
  54210. declare module BABYLON {
  54211. /** @hidden */
  54212. export var harmonicsFunctions: {
  54213. name: string;
  54214. shader: string;
  54215. };
  54216. }
  54217. declare module BABYLON {
  54218. /** @hidden */
  54219. export var pbrDirectLightingSetupFunctions: {
  54220. name: string;
  54221. shader: string;
  54222. };
  54223. }
  54224. declare module BABYLON {
  54225. /** @hidden */
  54226. export var pbrDirectLightingFalloffFunctions: {
  54227. name: string;
  54228. shader: string;
  54229. };
  54230. }
  54231. declare module BABYLON {
  54232. /** @hidden */
  54233. export var pbrBRDFFunctions: {
  54234. name: string;
  54235. shader: string;
  54236. };
  54237. }
  54238. declare module BABYLON {
  54239. /** @hidden */
  54240. export var hdrFilteringFunctions: {
  54241. name: string;
  54242. shader: string;
  54243. };
  54244. }
  54245. declare module BABYLON {
  54246. /** @hidden */
  54247. export var pbrDirectLightingFunctions: {
  54248. name: string;
  54249. shader: string;
  54250. };
  54251. }
  54252. declare module BABYLON {
  54253. /** @hidden */
  54254. export var pbrIBLFunctions: {
  54255. name: string;
  54256. shader: string;
  54257. };
  54258. }
  54259. declare module BABYLON {
  54260. /** @hidden */
  54261. export var pbrBlockAlbedoOpacity: {
  54262. name: string;
  54263. shader: string;
  54264. };
  54265. }
  54266. declare module BABYLON {
  54267. /** @hidden */
  54268. export var pbrBlockReflectivity: {
  54269. name: string;
  54270. shader: string;
  54271. };
  54272. }
  54273. declare module BABYLON {
  54274. /** @hidden */
  54275. export var pbrBlockAmbientOcclusion: {
  54276. name: string;
  54277. shader: string;
  54278. };
  54279. }
  54280. declare module BABYLON {
  54281. /** @hidden */
  54282. export var pbrBlockAlphaFresnel: {
  54283. name: string;
  54284. shader: string;
  54285. };
  54286. }
  54287. declare module BABYLON {
  54288. /** @hidden */
  54289. export var pbrBlockAnisotropic: {
  54290. name: string;
  54291. shader: string;
  54292. };
  54293. }
  54294. declare module BABYLON {
  54295. /** @hidden */
  54296. export var pbrBlockReflection: {
  54297. name: string;
  54298. shader: string;
  54299. };
  54300. }
  54301. declare module BABYLON {
  54302. /** @hidden */
  54303. export var pbrBlockSheen: {
  54304. name: string;
  54305. shader: string;
  54306. };
  54307. }
  54308. declare module BABYLON {
  54309. /** @hidden */
  54310. export var pbrBlockClearcoat: {
  54311. name: string;
  54312. shader: string;
  54313. };
  54314. }
  54315. declare module BABYLON {
  54316. /** @hidden */
  54317. export var pbrBlockSubSurface: {
  54318. name: string;
  54319. shader: string;
  54320. };
  54321. }
  54322. declare module BABYLON {
  54323. /** @hidden */
  54324. export var pbrBlockNormalGeometric: {
  54325. name: string;
  54326. shader: string;
  54327. };
  54328. }
  54329. declare module BABYLON {
  54330. /** @hidden */
  54331. export var pbrBlockNormalFinal: {
  54332. name: string;
  54333. shader: string;
  54334. };
  54335. }
  54336. declare module BABYLON {
  54337. /** @hidden */
  54338. export var pbrBlockGeometryInfo: {
  54339. name: string;
  54340. shader: string;
  54341. };
  54342. }
  54343. declare module BABYLON {
  54344. /** @hidden */
  54345. export var pbrBlockReflectance0: {
  54346. name: string;
  54347. shader: string;
  54348. };
  54349. }
  54350. declare module BABYLON {
  54351. /** @hidden */
  54352. export var pbrBlockReflectance: {
  54353. name: string;
  54354. shader: string;
  54355. };
  54356. }
  54357. declare module BABYLON {
  54358. /** @hidden */
  54359. export var pbrBlockDirectLighting: {
  54360. name: string;
  54361. shader: string;
  54362. };
  54363. }
  54364. declare module BABYLON {
  54365. /** @hidden */
  54366. export var pbrBlockFinalLitComponents: {
  54367. name: string;
  54368. shader: string;
  54369. };
  54370. }
  54371. declare module BABYLON {
  54372. /** @hidden */
  54373. export var pbrBlockFinalUnlitComponents: {
  54374. name: string;
  54375. shader: string;
  54376. };
  54377. }
  54378. declare module BABYLON {
  54379. /** @hidden */
  54380. export var pbrBlockFinalColorComposition: {
  54381. name: string;
  54382. shader: string;
  54383. };
  54384. }
  54385. declare module BABYLON {
  54386. /** @hidden */
  54387. export var pbrBlockImageProcessing: {
  54388. name: string;
  54389. shader: string;
  54390. };
  54391. }
  54392. declare module BABYLON {
  54393. /** @hidden */
  54394. export var pbrDebug: {
  54395. name: string;
  54396. shader: string;
  54397. };
  54398. }
  54399. declare module BABYLON {
  54400. /** @hidden */
  54401. export var pbrPixelShader: {
  54402. name: string;
  54403. shader: string;
  54404. };
  54405. }
  54406. declare module BABYLON {
  54407. /** @hidden */
  54408. export var pbrVertexDeclaration: {
  54409. name: string;
  54410. shader: string;
  54411. };
  54412. }
  54413. declare module BABYLON {
  54414. /** @hidden */
  54415. export var pbrVertexShader: {
  54416. name: string;
  54417. shader: string;
  54418. };
  54419. }
  54420. declare module BABYLON {
  54421. /**
  54422. * Manages the defines for the PBR Material.
  54423. * @hidden
  54424. */
  54425. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54426. PBR: boolean;
  54427. NUM_SAMPLES: string;
  54428. REALTIME_FILTERING: boolean;
  54429. MAINUV1: boolean;
  54430. MAINUV2: boolean;
  54431. UV1: boolean;
  54432. UV2: boolean;
  54433. ALBEDO: boolean;
  54434. GAMMAALBEDO: boolean;
  54435. ALBEDODIRECTUV: number;
  54436. VERTEXCOLOR: boolean;
  54437. AMBIENT: boolean;
  54438. AMBIENTDIRECTUV: number;
  54439. AMBIENTINGRAYSCALE: boolean;
  54440. OPACITY: boolean;
  54441. VERTEXALPHA: boolean;
  54442. OPACITYDIRECTUV: number;
  54443. OPACITYRGB: boolean;
  54444. ALPHATEST: boolean;
  54445. DEPTHPREPASS: boolean;
  54446. ALPHABLEND: boolean;
  54447. ALPHAFROMALBEDO: boolean;
  54448. ALPHATESTVALUE: string;
  54449. SPECULAROVERALPHA: boolean;
  54450. RADIANCEOVERALPHA: boolean;
  54451. ALPHAFRESNEL: boolean;
  54452. LINEARALPHAFRESNEL: boolean;
  54453. PREMULTIPLYALPHA: boolean;
  54454. EMISSIVE: boolean;
  54455. EMISSIVEDIRECTUV: number;
  54456. REFLECTIVITY: boolean;
  54457. REFLECTIVITYDIRECTUV: number;
  54458. SPECULARTERM: boolean;
  54459. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54460. MICROSURFACEAUTOMATIC: boolean;
  54461. LODBASEDMICROSFURACE: boolean;
  54462. MICROSURFACEMAP: boolean;
  54463. MICROSURFACEMAPDIRECTUV: number;
  54464. METALLICWORKFLOW: boolean;
  54465. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54466. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54467. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54468. AOSTOREINMETALMAPRED: boolean;
  54469. METALLIC_REFLECTANCE: boolean;
  54470. METALLIC_REFLECTANCEDIRECTUV: number;
  54471. ENVIRONMENTBRDF: boolean;
  54472. ENVIRONMENTBRDF_RGBD: boolean;
  54473. NORMAL: boolean;
  54474. TANGENT: boolean;
  54475. BUMP: boolean;
  54476. BUMPDIRECTUV: number;
  54477. OBJECTSPACE_NORMALMAP: boolean;
  54478. PARALLAX: boolean;
  54479. PARALLAXOCCLUSION: boolean;
  54480. NORMALXYSCALE: boolean;
  54481. LIGHTMAP: boolean;
  54482. LIGHTMAPDIRECTUV: number;
  54483. USELIGHTMAPASSHADOWMAP: boolean;
  54484. GAMMALIGHTMAP: boolean;
  54485. RGBDLIGHTMAP: boolean;
  54486. REFLECTION: boolean;
  54487. REFLECTIONMAP_3D: boolean;
  54488. REFLECTIONMAP_SPHERICAL: boolean;
  54489. REFLECTIONMAP_PLANAR: boolean;
  54490. REFLECTIONMAP_CUBIC: boolean;
  54491. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54492. REFLECTIONMAP_PROJECTION: boolean;
  54493. REFLECTIONMAP_SKYBOX: boolean;
  54494. REFLECTIONMAP_EXPLICIT: boolean;
  54495. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54496. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54497. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54498. INVERTCUBICMAP: boolean;
  54499. USESPHERICALFROMREFLECTIONMAP: boolean;
  54500. USEIRRADIANCEMAP: boolean;
  54501. SPHERICAL_HARMONICS: boolean;
  54502. USESPHERICALINVERTEX: boolean;
  54503. REFLECTIONMAP_OPPOSITEZ: boolean;
  54504. LODINREFLECTIONALPHA: boolean;
  54505. GAMMAREFLECTION: boolean;
  54506. RGBDREFLECTION: boolean;
  54507. LINEARSPECULARREFLECTION: boolean;
  54508. RADIANCEOCCLUSION: boolean;
  54509. HORIZONOCCLUSION: boolean;
  54510. INSTANCES: boolean;
  54511. NUM_BONE_INFLUENCERS: number;
  54512. BonesPerMesh: number;
  54513. BONETEXTURE: boolean;
  54514. NONUNIFORMSCALING: boolean;
  54515. MORPHTARGETS: boolean;
  54516. MORPHTARGETS_NORMAL: boolean;
  54517. MORPHTARGETS_TANGENT: boolean;
  54518. MORPHTARGETS_UV: boolean;
  54519. NUM_MORPH_INFLUENCERS: number;
  54520. IMAGEPROCESSING: boolean;
  54521. VIGNETTE: boolean;
  54522. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54523. VIGNETTEBLENDMODEOPAQUE: boolean;
  54524. TONEMAPPING: boolean;
  54525. TONEMAPPING_ACES: boolean;
  54526. CONTRAST: boolean;
  54527. COLORCURVES: boolean;
  54528. COLORGRADING: boolean;
  54529. COLORGRADING3D: boolean;
  54530. SAMPLER3DGREENDEPTH: boolean;
  54531. SAMPLER3DBGRMAP: boolean;
  54532. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54533. EXPOSURE: boolean;
  54534. MULTIVIEW: boolean;
  54535. USEPHYSICALLIGHTFALLOFF: boolean;
  54536. USEGLTFLIGHTFALLOFF: boolean;
  54537. TWOSIDEDLIGHTING: boolean;
  54538. SHADOWFLOAT: boolean;
  54539. CLIPPLANE: boolean;
  54540. CLIPPLANE2: boolean;
  54541. CLIPPLANE3: boolean;
  54542. CLIPPLANE4: boolean;
  54543. CLIPPLANE5: boolean;
  54544. CLIPPLANE6: boolean;
  54545. POINTSIZE: boolean;
  54546. FOG: boolean;
  54547. LOGARITHMICDEPTH: boolean;
  54548. FORCENORMALFORWARD: boolean;
  54549. SPECULARAA: boolean;
  54550. CLEARCOAT: boolean;
  54551. CLEARCOAT_DEFAULTIOR: boolean;
  54552. CLEARCOAT_TEXTURE: boolean;
  54553. CLEARCOAT_TEXTUREDIRECTUV: number;
  54554. CLEARCOAT_BUMP: boolean;
  54555. CLEARCOAT_BUMPDIRECTUV: number;
  54556. CLEARCOAT_TINT: boolean;
  54557. CLEARCOAT_TINT_TEXTURE: boolean;
  54558. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54559. ANISOTROPIC: boolean;
  54560. ANISOTROPIC_TEXTURE: boolean;
  54561. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54562. BRDF_V_HEIGHT_CORRELATED: boolean;
  54563. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54564. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54565. SHEEN: boolean;
  54566. SHEEN_TEXTURE: boolean;
  54567. SHEEN_TEXTUREDIRECTUV: number;
  54568. SHEEN_LINKWITHALBEDO: boolean;
  54569. SHEEN_ROUGHNESS: boolean;
  54570. SHEEN_ALBEDOSCALING: boolean;
  54571. SUBSURFACE: boolean;
  54572. SS_REFRACTION: boolean;
  54573. SS_TRANSLUCENCY: boolean;
  54574. SS_SCATERRING: boolean;
  54575. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54576. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54577. SS_REFRACTIONMAP_3D: boolean;
  54578. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54579. SS_LODINREFRACTIONALPHA: boolean;
  54580. SS_GAMMAREFRACTION: boolean;
  54581. SS_RGBDREFRACTION: boolean;
  54582. SS_LINEARSPECULARREFRACTION: boolean;
  54583. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54584. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54585. UNLIT: boolean;
  54586. DEBUGMODE: number;
  54587. /**
  54588. * Initializes the PBR Material defines.
  54589. */
  54590. constructor();
  54591. /**
  54592. * Resets the PBR Material defines.
  54593. */
  54594. reset(): void;
  54595. }
  54596. /**
  54597. * The Physically based material base class of BJS.
  54598. *
  54599. * This offers the main features of a standard PBR material.
  54600. * For more information, please refer to the documentation :
  54601. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54602. */
  54603. export abstract class PBRBaseMaterial extends PushMaterial {
  54604. /**
  54605. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54606. */
  54607. static readonly PBRMATERIAL_OPAQUE: number;
  54608. /**
  54609. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54610. */
  54611. static readonly PBRMATERIAL_ALPHATEST: number;
  54612. /**
  54613. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54614. */
  54615. static readonly PBRMATERIAL_ALPHABLEND: number;
  54616. /**
  54617. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54618. * They are also discarded below the alpha cutoff threshold to improve performances.
  54619. */
  54620. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54621. /**
  54622. * Defines the default value of how much AO map is occluding the analytical lights
  54623. * (point spot...).
  54624. */
  54625. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54626. /**
  54627. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54628. */
  54629. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54630. /**
  54631. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54632. * to enhance interoperability with other engines.
  54633. */
  54634. static readonly LIGHTFALLOFF_GLTF: number;
  54635. /**
  54636. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54637. * to enhance interoperability with other materials.
  54638. */
  54639. static readonly LIGHTFALLOFF_STANDARD: number;
  54640. /**
  54641. * Intensity of the direct lights e.g. the four lights available in your scene.
  54642. * This impacts both the direct diffuse and specular highlights.
  54643. */
  54644. protected _directIntensity: number;
  54645. /**
  54646. * Intensity of the emissive part of the material.
  54647. * This helps controlling the emissive effect without modifying the emissive color.
  54648. */
  54649. protected _emissiveIntensity: number;
  54650. /**
  54651. * Intensity of the environment e.g. how much the environment will light the object
  54652. * either through harmonics for rough material or through the refelction for shiny ones.
  54653. */
  54654. protected _environmentIntensity: number;
  54655. /**
  54656. * This is a special control allowing the reduction of the specular highlights coming from the
  54657. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54658. */
  54659. protected _specularIntensity: number;
  54660. /**
  54661. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54662. */
  54663. private _lightingInfos;
  54664. /**
  54665. * Debug Control allowing disabling the bump map on this material.
  54666. */
  54667. protected _disableBumpMap: boolean;
  54668. /**
  54669. * AKA Diffuse Texture in standard nomenclature.
  54670. */
  54671. protected _albedoTexture: Nullable<BaseTexture>;
  54672. /**
  54673. * AKA Occlusion Texture in other nomenclature.
  54674. */
  54675. protected _ambientTexture: Nullable<BaseTexture>;
  54676. /**
  54677. * AKA Occlusion Texture Intensity in other nomenclature.
  54678. */
  54679. protected _ambientTextureStrength: number;
  54680. /**
  54681. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54682. * 1 means it completely occludes it
  54683. * 0 mean it has no impact
  54684. */
  54685. protected _ambientTextureImpactOnAnalyticalLights: number;
  54686. /**
  54687. * Stores the alpha values in a texture.
  54688. */
  54689. protected _opacityTexture: Nullable<BaseTexture>;
  54690. /**
  54691. * Stores the reflection values in a texture.
  54692. */
  54693. protected _reflectionTexture: Nullable<BaseTexture>;
  54694. /**
  54695. * Stores the emissive values in a texture.
  54696. */
  54697. protected _emissiveTexture: Nullable<BaseTexture>;
  54698. /**
  54699. * AKA Specular texture in other nomenclature.
  54700. */
  54701. protected _reflectivityTexture: Nullable<BaseTexture>;
  54702. /**
  54703. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54704. */
  54705. protected _metallicTexture: Nullable<BaseTexture>;
  54706. /**
  54707. * Specifies the metallic scalar of the metallic/roughness workflow.
  54708. * Can also be used to scale the metalness values of the metallic texture.
  54709. */
  54710. protected _metallic: Nullable<number>;
  54711. /**
  54712. * Specifies the roughness scalar of the metallic/roughness workflow.
  54713. * Can also be used to scale the roughness values of the metallic texture.
  54714. */
  54715. protected _roughness: Nullable<number>;
  54716. /**
  54717. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54718. * By default the indexOfrefraction is used to compute F0;
  54719. *
  54720. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54721. *
  54722. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54723. * F90 = metallicReflectanceColor;
  54724. */
  54725. protected _metallicF0Factor: number;
  54726. /**
  54727. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54728. * By default the F90 is always 1;
  54729. *
  54730. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54731. *
  54732. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54733. * F90 = metallicReflectanceColor;
  54734. */
  54735. protected _metallicReflectanceColor: Color3;
  54736. /**
  54737. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54738. * This is multiply against the scalar values defined in the material.
  54739. */
  54740. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54741. /**
  54742. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54743. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54744. */
  54745. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54746. /**
  54747. * Stores surface normal data used to displace a mesh in a texture.
  54748. */
  54749. protected _bumpTexture: Nullable<BaseTexture>;
  54750. /**
  54751. * Stores the pre-calculated light information of a mesh in a texture.
  54752. */
  54753. protected _lightmapTexture: Nullable<BaseTexture>;
  54754. /**
  54755. * The color of a material in ambient lighting.
  54756. */
  54757. protected _ambientColor: Color3;
  54758. /**
  54759. * AKA Diffuse Color in other nomenclature.
  54760. */
  54761. protected _albedoColor: Color3;
  54762. /**
  54763. * AKA Specular Color in other nomenclature.
  54764. */
  54765. protected _reflectivityColor: Color3;
  54766. /**
  54767. * The color applied when light is reflected from a material.
  54768. */
  54769. protected _reflectionColor: Color3;
  54770. /**
  54771. * The color applied when light is emitted from a material.
  54772. */
  54773. protected _emissiveColor: Color3;
  54774. /**
  54775. * AKA Glossiness in other nomenclature.
  54776. */
  54777. protected _microSurface: number;
  54778. /**
  54779. * Specifies that the material will use the light map as a show map.
  54780. */
  54781. protected _useLightmapAsShadowmap: boolean;
  54782. /**
  54783. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54784. * makes the reflect vector face the model (under horizon).
  54785. */
  54786. protected _useHorizonOcclusion: boolean;
  54787. /**
  54788. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54789. * too much the area relying on ambient texture to define their ambient occlusion.
  54790. */
  54791. protected _useRadianceOcclusion: boolean;
  54792. /**
  54793. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54794. */
  54795. protected _useAlphaFromAlbedoTexture: boolean;
  54796. /**
  54797. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54798. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54799. */
  54800. protected _useSpecularOverAlpha: boolean;
  54801. /**
  54802. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54803. */
  54804. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54805. /**
  54806. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54807. */
  54808. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54809. /**
  54810. * Specifies if the metallic texture contains the roughness information in its green channel.
  54811. */
  54812. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54813. /**
  54814. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54815. */
  54816. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54817. /**
  54818. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54819. */
  54820. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54821. /**
  54822. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54823. */
  54824. protected _useAmbientInGrayScale: boolean;
  54825. /**
  54826. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54827. * The material will try to infer what glossiness each pixel should be.
  54828. */
  54829. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54830. /**
  54831. * Defines the falloff type used in this material.
  54832. * It by default is Physical.
  54833. */
  54834. protected _lightFalloff: number;
  54835. /**
  54836. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54837. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54838. */
  54839. protected _useRadianceOverAlpha: boolean;
  54840. /**
  54841. * Allows using an object space normal map (instead of tangent space).
  54842. */
  54843. protected _useObjectSpaceNormalMap: boolean;
  54844. /**
  54845. * Allows using the bump map in parallax mode.
  54846. */
  54847. protected _useParallax: boolean;
  54848. /**
  54849. * Allows using the bump map in parallax occlusion mode.
  54850. */
  54851. protected _useParallaxOcclusion: boolean;
  54852. /**
  54853. * Controls the scale bias of the parallax mode.
  54854. */
  54855. protected _parallaxScaleBias: number;
  54856. /**
  54857. * If sets to true, disables all the lights affecting the material.
  54858. */
  54859. protected _disableLighting: boolean;
  54860. /**
  54861. * Number of Simultaneous lights allowed on the material.
  54862. */
  54863. protected _maxSimultaneousLights: number;
  54864. /**
  54865. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54866. */
  54867. protected _invertNormalMapX: boolean;
  54868. /**
  54869. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54870. */
  54871. protected _invertNormalMapY: boolean;
  54872. /**
  54873. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54874. */
  54875. protected _twoSidedLighting: boolean;
  54876. /**
  54877. * Defines the alpha limits in alpha test mode.
  54878. */
  54879. protected _alphaCutOff: number;
  54880. /**
  54881. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54882. */
  54883. protected _forceAlphaTest: boolean;
  54884. /**
  54885. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54886. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54887. */
  54888. protected _useAlphaFresnel: boolean;
  54889. /**
  54890. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54891. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54892. */
  54893. protected _useLinearAlphaFresnel: boolean;
  54894. /**
  54895. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54896. * from cos thetav and roughness:
  54897. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54898. */
  54899. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54900. /**
  54901. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54902. */
  54903. protected _forceIrradianceInFragment: boolean;
  54904. private _realTimeFiltering;
  54905. /**
  54906. * Enables realtime filtering on the texture.
  54907. */
  54908. get realTimeFiltering(): boolean;
  54909. set realTimeFiltering(b: boolean);
  54910. private _realTimeFilteringQuality;
  54911. /**
  54912. * Quality switch for realtime filtering
  54913. */
  54914. get realTimeFilteringQuality(): number;
  54915. set realTimeFilteringQuality(n: number);
  54916. /**
  54917. * Force normal to face away from face.
  54918. */
  54919. protected _forceNormalForward: boolean;
  54920. /**
  54921. * Enables specular anti aliasing in the PBR shader.
  54922. * It will both interacts on the Geometry for analytical and IBL lighting.
  54923. * It also prefilter the roughness map based on the bump values.
  54924. */
  54925. protected _enableSpecularAntiAliasing: boolean;
  54926. /**
  54927. * Default configuration related to image processing available in the PBR Material.
  54928. */
  54929. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54930. /**
  54931. * Keep track of the image processing observer to allow dispose and replace.
  54932. */
  54933. private _imageProcessingObserver;
  54934. /**
  54935. * Attaches a new image processing configuration to the PBR Material.
  54936. * @param configuration
  54937. */
  54938. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54939. /**
  54940. * Stores the available render targets.
  54941. */
  54942. private _renderTargets;
  54943. /**
  54944. * Sets the global ambient color for the material used in lighting calculations.
  54945. */
  54946. private _globalAmbientColor;
  54947. /**
  54948. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54949. */
  54950. private _useLogarithmicDepth;
  54951. /**
  54952. * If set to true, no lighting calculations will be applied.
  54953. */
  54954. private _unlit;
  54955. private _debugMode;
  54956. /**
  54957. * @hidden
  54958. * This is reserved for the inspector.
  54959. * Defines the material debug mode.
  54960. * It helps seeing only some components of the material while troubleshooting.
  54961. */
  54962. debugMode: number;
  54963. /**
  54964. * @hidden
  54965. * This is reserved for the inspector.
  54966. * Specify from where on screen the debug mode should start.
  54967. * The value goes from -1 (full screen) to 1 (not visible)
  54968. * It helps with side by side comparison against the final render
  54969. * This defaults to -1
  54970. */
  54971. private debugLimit;
  54972. /**
  54973. * @hidden
  54974. * This is reserved for the inspector.
  54975. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54976. * You can use the factor to better multiply the final value.
  54977. */
  54978. private debugFactor;
  54979. /**
  54980. * Defines the clear coat layer parameters for the material.
  54981. */
  54982. readonly clearCoat: PBRClearCoatConfiguration;
  54983. /**
  54984. * Defines the anisotropic parameters for the material.
  54985. */
  54986. readonly anisotropy: PBRAnisotropicConfiguration;
  54987. /**
  54988. * Defines the BRDF parameters for the material.
  54989. */
  54990. readonly brdf: PBRBRDFConfiguration;
  54991. /**
  54992. * Defines the Sheen parameters for the material.
  54993. */
  54994. readonly sheen: PBRSheenConfiguration;
  54995. /**
  54996. * Defines the SubSurface parameters for the material.
  54997. */
  54998. readonly subSurface: PBRSubSurfaceConfiguration;
  54999. protected _rebuildInParallel: boolean;
  55000. /**
  55001. * Instantiates a new PBRMaterial instance.
  55002. *
  55003. * @param name The material name
  55004. * @param scene The scene the material will be use in.
  55005. */
  55006. constructor(name: string, scene: Scene);
  55007. /**
  55008. * Gets a boolean indicating that current material needs to register RTT
  55009. */
  55010. get hasRenderTargetTextures(): boolean;
  55011. /**
  55012. * Gets the name of the material class.
  55013. */
  55014. getClassName(): string;
  55015. /**
  55016. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55017. */
  55018. get useLogarithmicDepth(): boolean;
  55019. /**
  55020. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55021. */
  55022. set useLogarithmicDepth(value: boolean);
  55023. /**
  55024. * Returns true if alpha blending should be disabled.
  55025. */
  55026. protected get _disableAlphaBlending(): boolean;
  55027. /**
  55028. * Specifies whether or not this material should be rendered in alpha blend mode.
  55029. */
  55030. needAlphaBlending(): boolean;
  55031. /**
  55032. * Specifies whether or not this material should be rendered in alpha test mode.
  55033. */
  55034. needAlphaTesting(): boolean;
  55035. /**
  55036. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55037. */
  55038. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55039. /**
  55040. * Gets the texture used for the alpha test.
  55041. */
  55042. getAlphaTestTexture(): Nullable<BaseTexture>;
  55043. /**
  55044. * Specifies that the submesh is ready to be used.
  55045. * @param mesh - BJS mesh.
  55046. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55047. * @param useInstances - Specifies that instances should be used.
  55048. * @returns - boolean indicating that the submesh is ready or not.
  55049. */
  55050. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55051. /**
  55052. * Specifies if the material uses metallic roughness workflow.
  55053. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55054. */
  55055. isMetallicWorkflow(): boolean;
  55056. private _prepareEffect;
  55057. private _prepareDefines;
  55058. /**
  55059. * Force shader compilation
  55060. */
  55061. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55062. /**
  55063. * Initializes the uniform buffer layout for the shader.
  55064. */
  55065. buildUniformLayout(): void;
  55066. /**
  55067. * Unbinds the material from the mesh
  55068. */
  55069. unbind(): void;
  55070. /**
  55071. * Binds the submesh data.
  55072. * @param world - The world matrix.
  55073. * @param mesh - The BJS mesh.
  55074. * @param subMesh - A submesh of the BJS mesh.
  55075. */
  55076. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55077. /**
  55078. * Returns the animatable textures.
  55079. * @returns - Array of animatable textures.
  55080. */
  55081. getAnimatables(): IAnimatable[];
  55082. /**
  55083. * Returns the texture used for reflections.
  55084. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55085. */
  55086. private _getReflectionTexture;
  55087. /**
  55088. * Returns an array of the actively used textures.
  55089. * @returns - Array of BaseTextures
  55090. */
  55091. getActiveTextures(): BaseTexture[];
  55092. /**
  55093. * Checks to see if a texture is used in the material.
  55094. * @param texture - Base texture to use.
  55095. * @returns - Boolean specifying if a texture is used in the material.
  55096. */
  55097. hasTexture(texture: BaseTexture): boolean;
  55098. /**
  55099. * Disposes the resources of the material.
  55100. * @param forceDisposeEffect - Forces the disposal of effects.
  55101. * @param forceDisposeTextures - Forces the disposal of all textures.
  55102. */
  55103. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55104. }
  55105. }
  55106. declare module BABYLON {
  55107. /**
  55108. * The Physically based material of BJS.
  55109. *
  55110. * This offers the main features of a standard PBR material.
  55111. * For more information, please refer to the documentation :
  55112. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55113. */
  55114. export class PBRMaterial extends PBRBaseMaterial {
  55115. /**
  55116. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55117. */
  55118. static readonly PBRMATERIAL_OPAQUE: number;
  55119. /**
  55120. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55121. */
  55122. static readonly PBRMATERIAL_ALPHATEST: number;
  55123. /**
  55124. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55125. */
  55126. static readonly PBRMATERIAL_ALPHABLEND: number;
  55127. /**
  55128. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55129. * They are also discarded below the alpha cutoff threshold to improve performances.
  55130. */
  55131. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55132. /**
  55133. * Defines the default value of how much AO map is occluding the analytical lights
  55134. * (point spot...).
  55135. */
  55136. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55137. /**
  55138. * Intensity of the direct lights e.g. the four lights available in your scene.
  55139. * This impacts both the direct diffuse and specular highlights.
  55140. */
  55141. directIntensity: number;
  55142. /**
  55143. * Intensity of the emissive part of the material.
  55144. * This helps controlling the emissive effect without modifying the emissive color.
  55145. */
  55146. emissiveIntensity: number;
  55147. /**
  55148. * Intensity of the environment e.g. how much the environment will light the object
  55149. * either through harmonics for rough material or through the refelction for shiny ones.
  55150. */
  55151. environmentIntensity: number;
  55152. /**
  55153. * This is a special control allowing the reduction of the specular highlights coming from the
  55154. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55155. */
  55156. specularIntensity: number;
  55157. /**
  55158. * Debug Control allowing disabling the bump map on this material.
  55159. */
  55160. disableBumpMap: boolean;
  55161. /**
  55162. * AKA Diffuse Texture in standard nomenclature.
  55163. */
  55164. albedoTexture: BaseTexture;
  55165. /**
  55166. * AKA Occlusion Texture in other nomenclature.
  55167. */
  55168. ambientTexture: BaseTexture;
  55169. /**
  55170. * AKA Occlusion Texture Intensity in other nomenclature.
  55171. */
  55172. ambientTextureStrength: number;
  55173. /**
  55174. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55175. * 1 means it completely occludes it
  55176. * 0 mean it has no impact
  55177. */
  55178. ambientTextureImpactOnAnalyticalLights: number;
  55179. /**
  55180. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55181. */
  55182. opacityTexture: BaseTexture;
  55183. /**
  55184. * Stores the reflection values in a texture.
  55185. */
  55186. reflectionTexture: Nullable<BaseTexture>;
  55187. /**
  55188. * Stores the emissive values in a texture.
  55189. */
  55190. emissiveTexture: BaseTexture;
  55191. /**
  55192. * AKA Specular texture in other nomenclature.
  55193. */
  55194. reflectivityTexture: BaseTexture;
  55195. /**
  55196. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55197. */
  55198. metallicTexture: BaseTexture;
  55199. /**
  55200. * Specifies the metallic scalar of the metallic/roughness workflow.
  55201. * Can also be used to scale the metalness values of the metallic texture.
  55202. */
  55203. metallic: Nullable<number>;
  55204. /**
  55205. * Specifies the roughness scalar of the metallic/roughness workflow.
  55206. * Can also be used to scale the roughness values of the metallic texture.
  55207. */
  55208. roughness: Nullable<number>;
  55209. /**
  55210. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55211. * By default the indexOfrefraction is used to compute F0;
  55212. *
  55213. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55214. *
  55215. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55216. * F90 = metallicReflectanceColor;
  55217. */
  55218. metallicF0Factor: number;
  55219. /**
  55220. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55221. * By default the F90 is always 1;
  55222. *
  55223. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55224. *
  55225. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55226. * F90 = metallicReflectanceColor;
  55227. */
  55228. metallicReflectanceColor: Color3;
  55229. /**
  55230. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55231. * This is multiply against the scalar values defined in the material.
  55232. */
  55233. metallicReflectanceTexture: Nullable<BaseTexture>;
  55234. /**
  55235. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55236. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55237. */
  55238. microSurfaceTexture: BaseTexture;
  55239. /**
  55240. * Stores surface normal data used to displace a mesh in a texture.
  55241. */
  55242. bumpTexture: BaseTexture;
  55243. /**
  55244. * Stores the pre-calculated light information of a mesh in a texture.
  55245. */
  55246. lightmapTexture: BaseTexture;
  55247. /**
  55248. * Stores the refracted light information in a texture.
  55249. */
  55250. get refractionTexture(): Nullable<BaseTexture>;
  55251. set refractionTexture(value: Nullable<BaseTexture>);
  55252. /**
  55253. * The color of a material in ambient lighting.
  55254. */
  55255. ambientColor: Color3;
  55256. /**
  55257. * AKA Diffuse Color in other nomenclature.
  55258. */
  55259. albedoColor: Color3;
  55260. /**
  55261. * AKA Specular Color in other nomenclature.
  55262. */
  55263. reflectivityColor: Color3;
  55264. /**
  55265. * The color reflected from the material.
  55266. */
  55267. reflectionColor: Color3;
  55268. /**
  55269. * The color emitted from the material.
  55270. */
  55271. emissiveColor: Color3;
  55272. /**
  55273. * AKA Glossiness in other nomenclature.
  55274. */
  55275. microSurface: number;
  55276. /**
  55277. * Index of refraction of the material base layer.
  55278. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55279. *
  55280. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55281. *
  55282. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55283. */
  55284. get indexOfRefraction(): number;
  55285. set indexOfRefraction(value: number);
  55286. /**
  55287. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55288. */
  55289. get invertRefractionY(): boolean;
  55290. set invertRefractionY(value: boolean);
  55291. /**
  55292. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55293. * Materials half opaque for instance using refraction could benefit from this control.
  55294. */
  55295. get linkRefractionWithTransparency(): boolean;
  55296. set linkRefractionWithTransparency(value: boolean);
  55297. /**
  55298. * If true, the light map contains occlusion information instead of lighting info.
  55299. */
  55300. useLightmapAsShadowmap: boolean;
  55301. /**
  55302. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55303. */
  55304. useAlphaFromAlbedoTexture: boolean;
  55305. /**
  55306. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55307. */
  55308. forceAlphaTest: boolean;
  55309. /**
  55310. * Defines the alpha limits in alpha test mode.
  55311. */
  55312. alphaCutOff: number;
  55313. /**
  55314. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55315. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55316. */
  55317. useSpecularOverAlpha: boolean;
  55318. /**
  55319. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55320. */
  55321. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55322. /**
  55323. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55324. */
  55325. useRoughnessFromMetallicTextureAlpha: boolean;
  55326. /**
  55327. * Specifies if the metallic texture contains the roughness information in its green channel.
  55328. */
  55329. useRoughnessFromMetallicTextureGreen: boolean;
  55330. /**
  55331. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55332. */
  55333. useMetallnessFromMetallicTextureBlue: boolean;
  55334. /**
  55335. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55336. */
  55337. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55338. /**
  55339. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55340. */
  55341. useAmbientInGrayScale: boolean;
  55342. /**
  55343. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55344. * The material will try to infer what glossiness each pixel should be.
  55345. */
  55346. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55347. /**
  55348. * BJS is using an harcoded light falloff based on a manually sets up range.
  55349. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55350. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55351. */
  55352. get usePhysicalLightFalloff(): boolean;
  55353. /**
  55354. * BJS is using an harcoded light falloff based on a manually sets up range.
  55355. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55356. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55357. */
  55358. set usePhysicalLightFalloff(value: boolean);
  55359. /**
  55360. * In order to support the falloff compatibility with gltf, a special mode has been added
  55361. * to reproduce the gltf light falloff.
  55362. */
  55363. get useGLTFLightFalloff(): boolean;
  55364. /**
  55365. * In order to support the falloff compatibility with gltf, a special mode has been added
  55366. * to reproduce the gltf light falloff.
  55367. */
  55368. set useGLTFLightFalloff(value: boolean);
  55369. /**
  55370. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55371. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55372. */
  55373. useRadianceOverAlpha: boolean;
  55374. /**
  55375. * Allows using an object space normal map (instead of tangent space).
  55376. */
  55377. useObjectSpaceNormalMap: boolean;
  55378. /**
  55379. * Allows using the bump map in parallax mode.
  55380. */
  55381. useParallax: boolean;
  55382. /**
  55383. * Allows using the bump map in parallax occlusion mode.
  55384. */
  55385. useParallaxOcclusion: boolean;
  55386. /**
  55387. * Controls the scale bias of the parallax mode.
  55388. */
  55389. parallaxScaleBias: number;
  55390. /**
  55391. * If sets to true, disables all the lights affecting the material.
  55392. */
  55393. disableLighting: boolean;
  55394. /**
  55395. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55396. */
  55397. forceIrradianceInFragment: boolean;
  55398. /**
  55399. * Number of Simultaneous lights allowed on the material.
  55400. */
  55401. maxSimultaneousLights: number;
  55402. /**
  55403. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55404. */
  55405. invertNormalMapX: boolean;
  55406. /**
  55407. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55408. */
  55409. invertNormalMapY: boolean;
  55410. /**
  55411. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55412. */
  55413. twoSidedLighting: boolean;
  55414. /**
  55415. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55416. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55417. */
  55418. useAlphaFresnel: boolean;
  55419. /**
  55420. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55421. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55422. */
  55423. useLinearAlphaFresnel: boolean;
  55424. /**
  55425. * Let user defines the brdf lookup texture used for IBL.
  55426. * A default 8bit version is embedded but you could point at :
  55427. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55428. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55429. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55430. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55431. */
  55432. environmentBRDFTexture: Nullable<BaseTexture>;
  55433. /**
  55434. * Force normal to face away from face.
  55435. */
  55436. forceNormalForward: boolean;
  55437. /**
  55438. * Enables specular anti aliasing in the PBR shader.
  55439. * It will both interacts on the Geometry for analytical and IBL lighting.
  55440. * It also prefilter the roughness map based on the bump values.
  55441. */
  55442. enableSpecularAntiAliasing: boolean;
  55443. /**
  55444. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55445. * makes the reflect vector face the model (under horizon).
  55446. */
  55447. useHorizonOcclusion: boolean;
  55448. /**
  55449. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55450. * too much the area relying on ambient texture to define their ambient occlusion.
  55451. */
  55452. useRadianceOcclusion: boolean;
  55453. /**
  55454. * If set to true, no lighting calculations will be applied.
  55455. */
  55456. unlit: boolean;
  55457. /**
  55458. * Gets the image processing configuration used either in this material.
  55459. */
  55460. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55461. /**
  55462. * Sets the Default image processing configuration used either in the this material.
  55463. *
  55464. * If sets to null, the scene one is in use.
  55465. */
  55466. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55467. /**
  55468. * Gets wether the color curves effect is enabled.
  55469. */
  55470. get cameraColorCurvesEnabled(): boolean;
  55471. /**
  55472. * Sets wether the color curves effect is enabled.
  55473. */
  55474. set cameraColorCurvesEnabled(value: boolean);
  55475. /**
  55476. * Gets wether the color grading effect is enabled.
  55477. */
  55478. get cameraColorGradingEnabled(): boolean;
  55479. /**
  55480. * Gets wether the color grading effect is enabled.
  55481. */
  55482. set cameraColorGradingEnabled(value: boolean);
  55483. /**
  55484. * Gets wether tonemapping is enabled or not.
  55485. */
  55486. get cameraToneMappingEnabled(): boolean;
  55487. /**
  55488. * Sets wether tonemapping is enabled or not
  55489. */
  55490. set cameraToneMappingEnabled(value: boolean);
  55491. /**
  55492. * The camera exposure used on this material.
  55493. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55494. * This corresponds to a photographic exposure.
  55495. */
  55496. get cameraExposure(): number;
  55497. /**
  55498. * The camera exposure used on this material.
  55499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55500. * This corresponds to a photographic exposure.
  55501. */
  55502. set cameraExposure(value: number);
  55503. /**
  55504. * Gets The camera contrast used on this material.
  55505. */
  55506. get cameraContrast(): number;
  55507. /**
  55508. * Sets The camera contrast used on this material.
  55509. */
  55510. set cameraContrast(value: number);
  55511. /**
  55512. * Gets the Color Grading 2D Lookup Texture.
  55513. */
  55514. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55515. /**
  55516. * Sets the Color Grading 2D Lookup Texture.
  55517. */
  55518. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55519. /**
  55520. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55521. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55522. * 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;
  55523. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55524. */
  55525. get cameraColorCurves(): Nullable<ColorCurves>;
  55526. /**
  55527. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55528. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55529. * 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;
  55530. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55531. */
  55532. set cameraColorCurves(value: Nullable<ColorCurves>);
  55533. /**
  55534. * Instantiates a new PBRMaterial instance.
  55535. *
  55536. * @param name The material name
  55537. * @param scene The scene the material will be use in.
  55538. */
  55539. constructor(name: string, scene: Scene);
  55540. /**
  55541. * Returns the name of this material class.
  55542. */
  55543. getClassName(): string;
  55544. /**
  55545. * Makes a duplicate of the current material.
  55546. * @param name - name to use for the new material.
  55547. */
  55548. clone(name: string): PBRMaterial;
  55549. /**
  55550. * Serializes this PBR Material.
  55551. * @returns - An object with the serialized material.
  55552. */
  55553. serialize(): any;
  55554. /**
  55555. * Parses a PBR Material from a serialized object.
  55556. * @param source - Serialized object.
  55557. * @param scene - BJS scene instance.
  55558. * @param rootUrl - url for the scene object
  55559. * @returns - PBRMaterial
  55560. */
  55561. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55562. }
  55563. }
  55564. declare module BABYLON {
  55565. /**
  55566. * Direct draw surface info
  55567. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55568. */
  55569. export interface DDSInfo {
  55570. /**
  55571. * Width of the texture
  55572. */
  55573. width: number;
  55574. /**
  55575. * Width of the texture
  55576. */
  55577. height: number;
  55578. /**
  55579. * Number of Mipmaps for the texture
  55580. * @see https://en.wikipedia.org/wiki/Mipmap
  55581. */
  55582. mipmapCount: number;
  55583. /**
  55584. * If the textures format is a known fourCC format
  55585. * @see https://www.fourcc.org/
  55586. */
  55587. isFourCC: boolean;
  55588. /**
  55589. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55590. */
  55591. isRGB: boolean;
  55592. /**
  55593. * If the texture is a lumincance format
  55594. */
  55595. isLuminance: boolean;
  55596. /**
  55597. * If this is a cube texture
  55598. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55599. */
  55600. isCube: boolean;
  55601. /**
  55602. * If the texture is a compressed format eg. FOURCC_DXT1
  55603. */
  55604. isCompressed: boolean;
  55605. /**
  55606. * The dxgiFormat of the texture
  55607. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55608. */
  55609. dxgiFormat: number;
  55610. /**
  55611. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55612. */
  55613. textureType: number;
  55614. /**
  55615. * Sphericle polynomial created for the dds texture
  55616. */
  55617. sphericalPolynomial?: SphericalPolynomial;
  55618. }
  55619. /**
  55620. * Class used to provide DDS decompression tools
  55621. */
  55622. export class DDSTools {
  55623. /**
  55624. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55625. */
  55626. static StoreLODInAlphaChannel: boolean;
  55627. /**
  55628. * Gets DDS information from an array buffer
  55629. * @param data defines the array buffer view to read data from
  55630. * @returns the DDS information
  55631. */
  55632. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55633. private static _FloatView;
  55634. private static _Int32View;
  55635. private static _ToHalfFloat;
  55636. private static _FromHalfFloat;
  55637. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55638. private static _GetHalfFloatRGBAArrayBuffer;
  55639. private static _GetFloatRGBAArrayBuffer;
  55640. private static _GetFloatAsUIntRGBAArrayBuffer;
  55641. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55642. private static _GetRGBAArrayBuffer;
  55643. private static _ExtractLongWordOrder;
  55644. private static _GetRGBArrayBuffer;
  55645. private static _GetLuminanceArrayBuffer;
  55646. /**
  55647. * Uploads DDS Levels to a Babylon Texture
  55648. * @hidden
  55649. */
  55650. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55651. }
  55652. interface ThinEngine {
  55653. /**
  55654. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55655. * @param rootUrl defines the url where the file to load is located
  55656. * @param scene defines the current scene
  55657. * @param lodScale defines scale to apply to the mip map selection
  55658. * @param lodOffset defines offset to apply to the mip map selection
  55659. * @param onLoad defines an optional callback raised when the texture is loaded
  55660. * @param onError defines an optional callback raised if there is an issue to load the texture
  55661. * @param format defines the format of the data
  55662. * @param forcedExtension defines the extension to use to pick the right loader
  55663. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55664. * @returns the cube texture as an InternalTexture
  55665. */
  55666. 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;
  55667. }
  55668. }
  55669. declare module BABYLON {
  55670. /**
  55671. * Implementation of the DDS Texture Loader.
  55672. * @hidden
  55673. */
  55674. export class _DDSTextureLoader implements IInternalTextureLoader {
  55675. /**
  55676. * Defines wether the loader supports cascade loading the different faces.
  55677. */
  55678. readonly supportCascades: boolean;
  55679. /**
  55680. * This returns if the loader support the current file information.
  55681. * @param extension defines the file extension of the file being loaded
  55682. * @returns true if the loader can load the specified file
  55683. */
  55684. canLoad(extension: string): boolean;
  55685. /**
  55686. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55687. * @param data contains the texture data
  55688. * @param texture defines the BabylonJS internal texture
  55689. * @param createPolynomials will be true if polynomials have been requested
  55690. * @param onLoad defines the callback to trigger once the texture is ready
  55691. * @param onError defines the callback to trigger in case of error
  55692. */
  55693. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55694. /**
  55695. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55696. * @param data contains the texture data
  55697. * @param texture defines the BabylonJS internal texture
  55698. * @param callback defines the method to call once ready to upload
  55699. */
  55700. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55701. }
  55702. }
  55703. declare module BABYLON {
  55704. /**
  55705. * Implementation of the ENV Texture Loader.
  55706. * @hidden
  55707. */
  55708. export class _ENVTextureLoader implements IInternalTextureLoader {
  55709. /**
  55710. * Defines wether the loader supports cascade loading the different faces.
  55711. */
  55712. readonly supportCascades: boolean;
  55713. /**
  55714. * This returns if the loader support the current file information.
  55715. * @param extension defines the file extension of the file being loaded
  55716. * @returns true if the loader can load the specified file
  55717. */
  55718. canLoad(extension: string): boolean;
  55719. /**
  55720. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55721. * @param data contains the texture data
  55722. * @param texture defines the BabylonJS internal texture
  55723. * @param createPolynomials will be true if polynomials have been requested
  55724. * @param onLoad defines the callback to trigger once the texture is ready
  55725. * @param onError defines the callback to trigger in case of error
  55726. */
  55727. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55728. /**
  55729. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55730. * @param data contains the texture data
  55731. * @param texture defines the BabylonJS internal texture
  55732. * @param callback defines the method to call once ready to upload
  55733. */
  55734. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55735. }
  55736. }
  55737. declare module BABYLON {
  55738. /**
  55739. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55740. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55741. */
  55742. export class KhronosTextureContainer {
  55743. /** contents of the KTX container file */
  55744. data: ArrayBufferView;
  55745. private static HEADER_LEN;
  55746. private static COMPRESSED_2D;
  55747. private static COMPRESSED_3D;
  55748. private static TEX_2D;
  55749. private static TEX_3D;
  55750. /**
  55751. * Gets the openGL type
  55752. */
  55753. glType: number;
  55754. /**
  55755. * Gets the openGL type size
  55756. */
  55757. glTypeSize: number;
  55758. /**
  55759. * Gets the openGL format
  55760. */
  55761. glFormat: number;
  55762. /**
  55763. * Gets the openGL internal format
  55764. */
  55765. glInternalFormat: number;
  55766. /**
  55767. * Gets the base internal format
  55768. */
  55769. glBaseInternalFormat: number;
  55770. /**
  55771. * Gets image width in pixel
  55772. */
  55773. pixelWidth: number;
  55774. /**
  55775. * Gets image height in pixel
  55776. */
  55777. pixelHeight: number;
  55778. /**
  55779. * Gets image depth in pixels
  55780. */
  55781. pixelDepth: number;
  55782. /**
  55783. * Gets the number of array elements
  55784. */
  55785. numberOfArrayElements: number;
  55786. /**
  55787. * Gets the number of faces
  55788. */
  55789. numberOfFaces: number;
  55790. /**
  55791. * Gets the number of mipmap levels
  55792. */
  55793. numberOfMipmapLevels: number;
  55794. /**
  55795. * Gets the bytes of key value data
  55796. */
  55797. bytesOfKeyValueData: number;
  55798. /**
  55799. * Gets the load type
  55800. */
  55801. loadType: number;
  55802. /**
  55803. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55804. */
  55805. isInvalid: boolean;
  55806. /**
  55807. * Creates a new KhronosTextureContainer
  55808. * @param data contents of the KTX container file
  55809. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55810. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55811. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55812. */
  55813. constructor(
  55814. /** contents of the KTX container file */
  55815. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55816. /**
  55817. * Uploads KTX content to a Babylon Texture.
  55818. * It is assumed that the texture has already been created & is currently bound
  55819. * @hidden
  55820. */
  55821. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55822. private _upload2DCompressedLevels;
  55823. /**
  55824. * Checks if the given data starts with a KTX file identifier.
  55825. * @param data the data to check
  55826. * @returns true if the data is a KTX file or false otherwise
  55827. */
  55828. static IsValid(data: ArrayBufferView): boolean;
  55829. }
  55830. }
  55831. declare module BABYLON {
  55832. /**
  55833. * Class for loading KTX2 files
  55834. * !!! Experimental Extension Subject to Changes !!!
  55835. * @hidden
  55836. */
  55837. export class KhronosTextureContainer2 {
  55838. private static _ModulePromise;
  55839. private static _TranscodeFormat;
  55840. constructor(engine: ThinEngine);
  55841. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55842. private _determineTranscodeFormat;
  55843. /**
  55844. * Checks if the given data starts with a KTX2 file identifier.
  55845. * @param data the data to check
  55846. * @returns true if the data is a KTX2 file or false otherwise
  55847. */
  55848. static IsValid(data: ArrayBufferView): boolean;
  55849. }
  55850. }
  55851. declare module BABYLON {
  55852. /**
  55853. * Implementation of the KTX Texture Loader.
  55854. * @hidden
  55855. */
  55856. export class _KTXTextureLoader implements IInternalTextureLoader {
  55857. /**
  55858. * Defines wether the loader supports cascade loading the different faces.
  55859. */
  55860. readonly supportCascades: boolean;
  55861. /**
  55862. * This returns if the loader support the current file information.
  55863. * @param extension defines the file extension of the file being loaded
  55864. * @returns true if the loader can load the specified file
  55865. */
  55866. canLoad(extension: string): boolean;
  55867. /**
  55868. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55869. * @param data contains the texture data
  55870. * @param texture defines the BabylonJS internal texture
  55871. * @param createPolynomials will be true if polynomials have been requested
  55872. * @param onLoad defines the callback to trigger once the texture is ready
  55873. * @param onError defines the callback to trigger in case of error
  55874. */
  55875. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55876. /**
  55877. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55878. * @param data contains the texture data
  55879. * @param texture defines the BabylonJS internal texture
  55880. * @param callback defines the method to call once ready to upload
  55881. */
  55882. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55883. }
  55884. }
  55885. declare module BABYLON {
  55886. /** @hidden */
  55887. export var _forceSceneHelpersToBundle: boolean;
  55888. interface Scene {
  55889. /**
  55890. * Creates a default light for the scene.
  55891. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55892. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55893. */
  55894. createDefaultLight(replace?: boolean): void;
  55895. /**
  55896. * Creates a default camera for the scene.
  55897. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55898. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55899. * @param replace has default false, when true replaces the active camera in the scene
  55900. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55901. */
  55902. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55903. /**
  55904. * Creates a default camera and a default light.
  55905. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55906. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55907. * @param replace has the default false, when true replaces the active camera/light in the scene
  55908. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55909. */
  55910. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55911. /**
  55912. * Creates a new sky box
  55913. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55914. * @param environmentTexture defines the texture to use as environment texture
  55915. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55916. * @param scale defines the overall scale of the skybox
  55917. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55918. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55919. * @returns a new mesh holding the sky box
  55920. */
  55921. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55922. /**
  55923. * Creates a new environment
  55924. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55925. * @param options defines the options you can use to configure the environment
  55926. * @returns the new EnvironmentHelper
  55927. */
  55928. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55929. /**
  55930. * Creates a new VREXperienceHelper
  55931. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55932. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55933. * @returns a new VREXperienceHelper
  55934. */
  55935. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55936. /**
  55937. * Creates a new WebXRDefaultExperience
  55938. * @see http://doc.babylonjs.com/how_to/webxr
  55939. * @param options experience options
  55940. * @returns a promise for a new WebXRDefaultExperience
  55941. */
  55942. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55943. }
  55944. }
  55945. declare module BABYLON {
  55946. /**
  55947. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55948. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55949. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55950. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55951. */
  55952. export class VideoDome extends TransformNode {
  55953. /**
  55954. * Define the video source as a Monoscopic panoramic 360 video.
  55955. */
  55956. static readonly MODE_MONOSCOPIC: number;
  55957. /**
  55958. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55959. */
  55960. static readonly MODE_TOPBOTTOM: number;
  55961. /**
  55962. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55963. */
  55964. static readonly MODE_SIDEBYSIDE: number;
  55965. private _halfDome;
  55966. private _useDirectMapping;
  55967. /**
  55968. * The video texture being displayed on the sphere
  55969. */
  55970. protected _videoTexture: VideoTexture;
  55971. /**
  55972. * Gets the video texture being displayed on the sphere
  55973. */
  55974. get videoTexture(): VideoTexture;
  55975. /**
  55976. * The skybox material
  55977. */
  55978. protected _material: BackgroundMaterial;
  55979. /**
  55980. * The surface used for the skybox
  55981. */
  55982. protected _mesh: Mesh;
  55983. /**
  55984. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55985. */
  55986. private _halfDomeMask;
  55987. /**
  55988. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55989. * Also see the options.resolution property.
  55990. */
  55991. get fovMultiplier(): number;
  55992. set fovMultiplier(value: number);
  55993. private _videoMode;
  55994. /**
  55995. * Gets or set the current video mode for the video. It can be:
  55996. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55997. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55998. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55999. */
  56000. get videoMode(): number;
  56001. set videoMode(value: number);
  56002. /**
  56003. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56004. *
  56005. */
  56006. get halfDome(): boolean;
  56007. /**
  56008. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56009. */
  56010. set halfDome(enabled: boolean);
  56011. /**
  56012. * Oberserver used in Stereoscopic VR Mode.
  56013. */
  56014. private _onBeforeCameraRenderObserver;
  56015. /**
  56016. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56017. * @param name Element's name, child elements will append suffixes for their own names.
  56018. * @param urlsOrVideo defines the url(s) or the video element to use
  56019. * @param options An object containing optional or exposed sub element properties
  56020. */
  56021. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56022. resolution?: number;
  56023. clickToPlay?: boolean;
  56024. autoPlay?: boolean;
  56025. loop?: boolean;
  56026. size?: number;
  56027. poster?: string;
  56028. faceForward?: boolean;
  56029. useDirectMapping?: boolean;
  56030. halfDomeMode?: boolean;
  56031. }, scene: Scene);
  56032. private _changeVideoMode;
  56033. /**
  56034. * Releases resources associated with this node.
  56035. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56036. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56037. */
  56038. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56039. }
  56040. }
  56041. declare module BABYLON {
  56042. /**
  56043. * This class can be used to get instrumentation data from a Babylon engine
  56044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56045. */
  56046. export class EngineInstrumentation implements IDisposable {
  56047. /**
  56048. * Define the instrumented engine.
  56049. */
  56050. engine: Engine;
  56051. private _captureGPUFrameTime;
  56052. private _gpuFrameTimeToken;
  56053. private _gpuFrameTime;
  56054. private _captureShaderCompilationTime;
  56055. private _shaderCompilationTime;
  56056. private _onBeginFrameObserver;
  56057. private _onEndFrameObserver;
  56058. private _onBeforeShaderCompilationObserver;
  56059. private _onAfterShaderCompilationObserver;
  56060. /**
  56061. * Gets the perf counter used for GPU frame time
  56062. */
  56063. get gpuFrameTimeCounter(): PerfCounter;
  56064. /**
  56065. * Gets the GPU frame time capture status
  56066. */
  56067. get captureGPUFrameTime(): boolean;
  56068. /**
  56069. * Enable or disable the GPU frame time capture
  56070. */
  56071. set captureGPUFrameTime(value: boolean);
  56072. /**
  56073. * Gets the perf counter used for shader compilation time
  56074. */
  56075. get shaderCompilationTimeCounter(): PerfCounter;
  56076. /**
  56077. * Gets the shader compilation time capture status
  56078. */
  56079. get captureShaderCompilationTime(): boolean;
  56080. /**
  56081. * Enable or disable the shader compilation time capture
  56082. */
  56083. set captureShaderCompilationTime(value: boolean);
  56084. /**
  56085. * Instantiates a new engine instrumentation.
  56086. * This class can be used to get instrumentation data from a Babylon engine
  56087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56088. * @param engine Defines the engine to instrument
  56089. */
  56090. constructor(
  56091. /**
  56092. * Define the instrumented engine.
  56093. */
  56094. engine: Engine);
  56095. /**
  56096. * Dispose and release associated resources.
  56097. */
  56098. dispose(): void;
  56099. }
  56100. }
  56101. declare module BABYLON {
  56102. /**
  56103. * This class can be used to get instrumentation data from a Babylon engine
  56104. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56105. */
  56106. export class SceneInstrumentation implements IDisposable {
  56107. /**
  56108. * Defines the scene to instrument
  56109. */
  56110. scene: Scene;
  56111. private _captureActiveMeshesEvaluationTime;
  56112. private _activeMeshesEvaluationTime;
  56113. private _captureRenderTargetsRenderTime;
  56114. private _renderTargetsRenderTime;
  56115. private _captureFrameTime;
  56116. private _frameTime;
  56117. private _captureRenderTime;
  56118. private _renderTime;
  56119. private _captureInterFrameTime;
  56120. private _interFrameTime;
  56121. private _captureParticlesRenderTime;
  56122. private _particlesRenderTime;
  56123. private _captureSpritesRenderTime;
  56124. private _spritesRenderTime;
  56125. private _capturePhysicsTime;
  56126. private _physicsTime;
  56127. private _captureAnimationsTime;
  56128. private _animationsTime;
  56129. private _captureCameraRenderTime;
  56130. private _cameraRenderTime;
  56131. private _onBeforeActiveMeshesEvaluationObserver;
  56132. private _onAfterActiveMeshesEvaluationObserver;
  56133. private _onBeforeRenderTargetsRenderObserver;
  56134. private _onAfterRenderTargetsRenderObserver;
  56135. private _onAfterRenderObserver;
  56136. private _onBeforeDrawPhaseObserver;
  56137. private _onAfterDrawPhaseObserver;
  56138. private _onBeforeAnimationsObserver;
  56139. private _onBeforeParticlesRenderingObserver;
  56140. private _onAfterParticlesRenderingObserver;
  56141. private _onBeforeSpritesRenderingObserver;
  56142. private _onAfterSpritesRenderingObserver;
  56143. private _onBeforePhysicsObserver;
  56144. private _onAfterPhysicsObserver;
  56145. private _onAfterAnimationsObserver;
  56146. private _onBeforeCameraRenderObserver;
  56147. private _onAfterCameraRenderObserver;
  56148. /**
  56149. * Gets the perf counter used for active meshes evaluation time
  56150. */
  56151. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56152. /**
  56153. * Gets the active meshes evaluation time capture status
  56154. */
  56155. get captureActiveMeshesEvaluationTime(): boolean;
  56156. /**
  56157. * Enable or disable the active meshes evaluation time capture
  56158. */
  56159. set captureActiveMeshesEvaluationTime(value: boolean);
  56160. /**
  56161. * Gets the perf counter used for render targets render time
  56162. */
  56163. get renderTargetsRenderTimeCounter(): PerfCounter;
  56164. /**
  56165. * Gets the render targets render time capture status
  56166. */
  56167. get captureRenderTargetsRenderTime(): boolean;
  56168. /**
  56169. * Enable or disable the render targets render time capture
  56170. */
  56171. set captureRenderTargetsRenderTime(value: boolean);
  56172. /**
  56173. * Gets the perf counter used for particles render time
  56174. */
  56175. get particlesRenderTimeCounter(): PerfCounter;
  56176. /**
  56177. * Gets the particles render time capture status
  56178. */
  56179. get captureParticlesRenderTime(): boolean;
  56180. /**
  56181. * Enable or disable the particles render time capture
  56182. */
  56183. set captureParticlesRenderTime(value: boolean);
  56184. /**
  56185. * Gets the perf counter used for sprites render time
  56186. */
  56187. get spritesRenderTimeCounter(): PerfCounter;
  56188. /**
  56189. * Gets the sprites render time capture status
  56190. */
  56191. get captureSpritesRenderTime(): boolean;
  56192. /**
  56193. * Enable or disable the sprites render time capture
  56194. */
  56195. set captureSpritesRenderTime(value: boolean);
  56196. /**
  56197. * Gets the perf counter used for physics time
  56198. */
  56199. get physicsTimeCounter(): PerfCounter;
  56200. /**
  56201. * Gets the physics time capture status
  56202. */
  56203. get capturePhysicsTime(): boolean;
  56204. /**
  56205. * Enable or disable the physics time capture
  56206. */
  56207. set capturePhysicsTime(value: boolean);
  56208. /**
  56209. * Gets the perf counter used for animations time
  56210. */
  56211. get animationsTimeCounter(): PerfCounter;
  56212. /**
  56213. * Gets the animations time capture status
  56214. */
  56215. get captureAnimationsTime(): boolean;
  56216. /**
  56217. * Enable or disable the animations time capture
  56218. */
  56219. set captureAnimationsTime(value: boolean);
  56220. /**
  56221. * Gets the perf counter used for frame time capture
  56222. */
  56223. get frameTimeCounter(): PerfCounter;
  56224. /**
  56225. * Gets the frame time capture status
  56226. */
  56227. get captureFrameTime(): boolean;
  56228. /**
  56229. * Enable or disable the frame time capture
  56230. */
  56231. set captureFrameTime(value: boolean);
  56232. /**
  56233. * Gets the perf counter used for inter-frames time capture
  56234. */
  56235. get interFrameTimeCounter(): PerfCounter;
  56236. /**
  56237. * Gets the inter-frames time capture status
  56238. */
  56239. get captureInterFrameTime(): boolean;
  56240. /**
  56241. * Enable or disable the inter-frames time capture
  56242. */
  56243. set captureInterFrameTime(value: boolean);
  56244. /**
  56245. * Gets the perf counter used for render time capture
  56246. */
  56247. get renderTimeCounter(): PerfCounter;
  56248. /**
  56249. * Gets the render time capture status
  56250. */
  56251. get captureRenderTime(): boolean;
  56252. /**
  56253. * Enable or disable the render time capture
  56254. */
  56255. set captureRenderTime(value: boolean);
  56256. /**
  56257. * Gets the perf counter used for camera render time capture
  56258. */
  56259. get cameraRenderTimeCounter(): PerfCounter;
  56260. /**
  56261. * Gets the camera render time capture status
  56262. */
  56263. get captureCameraRenderTime(): boolean;
  56264. /**
  56265. * Enable or disable the camera render time capture
  56266. */
  56267. set captureCameraRenderTime(value: boolean);
  56268. /**
  56269. * Gets the perf counter used for draw calls
  56270. */
  56271. get drawCallsCounter(): PerfCounter;
  56272. /**
  56273. * Instantiates a new scene instrumentation.
  56274. * This class can be used to get instrumentation data from a Babylon engine
  56275. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56276. * @param scene Defines the scene to instrument
  56277. */
  56278. constructor(
  56279. /**
  56280. * Defines the scene to instrument
  56281. */
  56282. scene: Scene);
  56283. /**
  56284. * Dispose and release associated resources.
  56285. */
  56286. dispose(): void;
  56287. }
  56288. }
  56289. declare module BABYLON {
  56290. /** @hidden */
  56291. export var glowMapGenerationPixelShader: {
  56292. name: string;
  56293. shader: string;
  56294. };
  56295. }
  56296. declare module BABYLON {
  56297. /** @hidden */
  56298. export var glowMapGenerationVertexShader: {
  56299. name: string;
  56300. shader: string;
  56301. };
  56302. }
  56303. declare module BABYLON {
  56304. /**
  56305. * Effect layer options. This helps customizing the behaviour
  56306. * of the effect layer.
  56307. */
  56308. export interface IEffectLayerOptions {
  56309. /**
  56310. * Multiplication factor apply to the canvas size to compute the render target size
  56311. * used to generated the objects (the smaller the faster).
  56312. */
  56313. mainTextureRatio: number;
  56314. /**
  56315. * Enforces a fixed size texture to ensure effect stability across devices.
  56316. */
  56317. mainTextureFixedSize?: number;
  56318. /**
  56319. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56320. */
  56321. alphaBlendingMode: number;
  56322. /**
  56323. * The camera attached to the layer.
  56324. */
  56325. camera: Nullable<Camera>;
  56326. /**
  56327. * The rendering group to draw the layer in.
  56328. */
  56329. renderingGroupId: number;
  56330. }
  56331. /**
  56332. * The effect layer Helps adding post process effect blended with the main pass.
  56333. *
  56334. * This can be for instance use to generate glow or higlight effects on the scene.
  56335. *
  56336. * The effect layer class can not be used directly and is intented to inherited from to be
  56337. * customized per effects.
  56338. */
  56339. export abstract class EffectLayer {
  56340. private _vertexBuffers;
  56341. private _indexBuffer;
  56342. private _cachedDefines;
  56343. private _effectLayerMapGenerationEffect;
  56344. private _effectLayerOptions;
  56345. private _mergeEffect;
  56346. protected _scene: Scene;
  56347. protected _engine: Engine;
  56348. protected _maxSize: number;
  56349. protected _mainTextureDesiredSize: ISize;
  56350. protected _mainTexture: RenderTargetTexture;
  56351. protected _shouldRender: boolean;
  56352. protected _postProcesses: PostProcess[];
  56353. protected _textures: BaseTexture[];
  56354. protected _emissiveTextureAndColor: {
  56355. texture: Nullable<BaseTexture>;
  56356. color: Color4;
  56357. };
  56358. /**
  56359. * The name of the layer
  56360. */
  56361. name: string;
  56362. /**
  56363. * The clear color of the texture used to generate the glow map.
  56364. */
  56365. neutralColor: Color4;
  56366. /**
  56367. * Specifies whether the highlight layer is enabled or not.
  56368. */
  56369. isEnabled: boolean;
  56370. /**
  56371. * Gets the camera attached to the layer.
  56372. */
  56373. get camera(): Nullable<Camera>;
  56374. /**
  56375. * Gets the rendering group id the layer should render in.
  56376. */
  56377. get renderingGroupId(): number;
  56378. set renderingGroupId(renderingGroupId: number);
  56379. /**
  56380. * An event triggered when the effect layer has been disposed.
  56381. */
  56382. onDisposeObservable: Observable<EffectLayer>;
  56383. /**
  56384. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56385. */
  56386. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56387. /**
  56388. * An event triggered when the generated texture is being merged in the scene.
  56389. */
  56390. onBeforeComposeObservable: Observable<EffectLayer>;
  56391. /**
  56392. * An event triggered when the mesh is rendered into the effect render target.
  56393. */
  56394. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56395. /**
  56396. * An event triggered after the mesh has been rendered into the effect render target.
  56397. */
  56398. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56399. /**
  56400. * An event triggered when the generated texture has been merged in the scene.
  56401. */
  56402. onAfterComposeObservable: Observable<EffectLayer>;
  56403. /**
  56404. * An event triggered when the efffect layer changes its size.
  56405. */
  56406. onSizeChangedObservable: Observable<EffectLayer>;
  56407. /** @hidden */
  56408. static _SceneComponentInitialization: (scene: Scene) => void;
  56409. /**
  56410. * Instantiates a new effect Layer and references it in the scene.
  56411. * @param name The name of the layer
  56412. * @param scene The scene to use the layer in
  56413. */
  56414. constructor(
  56415. /** The Friendly of the effect in the scene */
  56416. name: string, scene: Scene);
  56417. /**
  56418. * Get the effect name of the layer.
  56419. * @return The effect name
  56420. */
  56421. abstract getEffectName(): string;
  56422. /**
  56423. * Checks for the readiness of the element composing the layer.
  56424. * @param subMesh the mesh to check for
  56425. * @param useInstances specify whether or not to use instances to render the mesh
  56426. * @return true if ready otherwise, false
  56427. */
  56428. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56429. /**
  56430. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56431. * @returns true if the effect requires stencil during the main canvas render pass.
  56432. */
  56433. abstract needStencil(): boolean;
  56434. /**
  56435. * Create the merge effect. This is the shader use to blit the information back
  56436. * to the main canvas at the end of the scene rendering.
  56437. * @returns The effect containing the shader used to merge the effect on the main canvas
  56438. */
  56439. protected abstract _createMergeEffect(): Effect;
  56440. /**
  56441. * Creates the render target textures and post processes used in the effect layer.
  56442. */
  56443. protected abstract _createTextureAndPostProcesses(): void;
  56444. /**
  56445. * Implementation specific of rendering the generating effect on the main canvas.
  56446. * @param effect The effect used to render through
  56447. */
  56448. protected abstract _internalRender(effect: Effect): void;
  56449. /**
  56450. * Sets the required values for both the emissive texture and and the main color.
  56451. */
  56452. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56453. /**
  56454. * Free any resources and references associated to a mesh.
  56455. * Internal use
  56456. * @param mesh The mesh to free.
  56457. */
  56458. abstract _disposeMesh(mesh: Mesh): void;
  56459. /**
  56460. * Serializes this layer (Glow or Highlight for example)
  56461. * @returns a serialized layer object
  56462. */
  56463. abstract serialize?(): any;
  56464. /**
  56465. * Initializes the effect layer with the required options.
  56466. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56467. */
  56468. protected _init(options: Partial<IEffectLayerOptions>): void;
  56469. /**
  56470. * Generates the index buffer of the full screen quad blending to the main canvas.
  56471. */
  56472. private _generateIndexBuffer;
  56473. /**
  56474. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56475. */
  56476. private _generateVertexBuffer;
  56477. /**
  56478. * Sets the main texture desired size which is the closest power of two
  56479. * of the engine canvas size.
  56480. */
  56481. private _setMainTextureSize;
  56482. /**
  56483. * Creates the main texture for the effect layer.
  56484. */
  56485. protected _createMainTexture(): void;
  56486. /**
  56487. * Adds specific effects defines.
  56488. * @param defines The defines to add specifics to.
  56489. */
  56490. protected _addCustomEffectDefines(defines: string[]): void;
  56491. /**
  56492. * Checks for the readiness of the element composing the layer.
  56493. * @param subMesh the mesh to check for
  56494. * @param useInstances specify whether or not to use instances to render the mesh
  56495. * @param emissiveTexture the associated emissive texture used to generate the glow
  56496. * @return true if ready otherwise, false
  56497. */
  56498. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56499. /**
  56500. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56501. */
  56502. render(): void;
  56503. /**
  56504. * Determine if a given mesh will be used in the current effect.
  56505. * @param mesh mesh to test
  56506. * @returns true if the mesh will be used
  56507. */
  56508. hasMesh(mesh: AbstractMesh): boolean;
  56509. /**
  56510. * Returns true if the layer contains information to display, otherwise false.
  56511. * @returns true if the glow layer should be rendered
  56512. */
  56513. shouldRender(): boolean;
  56514. /**
  56515. * Returns true if the mesh should render, otherwise false.
  56516. * @param mesh The mesh to render
  56517. * @returns true if it should render otherwise false
  56518. */
  56519. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56520. /**
  56521. * Returns true if the mesh can be rendered, otherwise false.
  56522. * @param mesh The mesh to render
  56523. * @param material The material used on the mesh
  56524. * @returns true if it can be rendered otherwise false
  56525. */
  56526. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56527. /**
  56528. * Returns true if the mesh should render, otherwise false.
  56529. * @param mesh The mesh to render
  56530. * @returns true if it should render otherwise false
  56531. */
  56532. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56533. /**
  56534. * Renders the submesh passed in parameter to the generation map.
  56535. */
  56536. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56537. /**
  56538. * Defines whether the current material of the mesh should be use to render the effect.
  56539. * @param mesh defines the current mesh to render
  56540. */
  56541. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56542. /**
  56543. * Rebuild the required buffers.
  56544. * @hidden Internal use only.
  56545. */
  56546. _rebuild(): void;
  56547. /**
  56548. * Dispose only the render target textures and post process.
  56549. */
  56550. private _disposeTextureAndPostProcesses;
  56551. /**
  56552. * Dispose the highlight layer and free resources.
  56553. */
  56554. dispose(): void;
  56555. /**
  56556. * Gets the class name of the effect layer
  56557. * @returns the string with the class name of the effect layer
  56558. */
  56559. getClassName(): string;
  56560. /**
  56561. * Creates an effect layer from parsed effect layer data
  56562. * @param parsedEffectLayer defines effect layer data
  56563. * @param scene defines the current scene
  56564. * @param rootUrl defines the root URL containing the effect layer information
  56565. * @returns a parsed effect Layer
  56566. */
  56567. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56568. }
  56569. }
  56570. declare module BABYLON {
  56571. interface AbstractScene {
  56572. /**
  56573. * The list of effect layers (highlights/glow) added to the scene
  56574. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56575. * @see http://doc.babylonjs.com/how_to/glow_layer
  56576. */
  56577. effectLayers: Array<EffectLayer>;
  56578. /**
  56579. * Removes the given effect layer from this scene.
  56580. * @param toRemove defines the effect layer to remove
  56581. * @returns the index of the removed effect layer
  56582. */
  56583. removeEffectLayer(toRemove: EffectLayer): number;
  56584. /**
  56585. * Adds the given effect layer to this scene
  56586. * @param newEffectLayer defines the effect layer to add
  56587. */
  56588. addEffectLayer(newEffectLayer: EffectLayer): void;
  56589. }
  56590. /**
  56591. * Defines the layer scene component responsible to manage any effect layers
  56592. * in a given scene.
  56593. */
  56594. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56595. /**
  56596. * The component name helpfull to identify the component in the list of scene components.
  56597. */
  56598. readonly name: string;
  56599. /**
  56600. * The scene the component belongs to.
  56601. */
  56602. scene: Scene;
  56603. private _engine;
  56604. private _renderEffects;
  56605. private _needStencil;
  56606. private _previousStencilState;
  56607. /**
  56608. * Creates a new instance of the component for the given scene
  56609. * @param scene Defines the scene to register the component in
  56610. */
  56611. constructor(scene: Scene);
  56612. /**
  56613. * Registers the component in a given scene
  56614. */
  56615. register(): void;
  56616. /**
  56617. * Rebuilds the elements related to this component in case of
  56618. * context lost for instance.
  56619. */
  56620. rebuild(): void;
  56621. /**
  56622. * Serializes the component data to the specified json object
  56623. * @param serializationObject The object to serialize to
  56624. */
  56625. serialize(serializationObject: any): void;
  56626. /**
  56627. * Adds all the elements from the container to the scene
  56628. * @param container the container holding the elements
  56629. */
  56630. addFromContainer(container: AbstractScene): void;
  56631. /**
  56632. * Removes all the elements in the container from the scene
  56633. * @param container contains the elements to remove
  56634. * @param dispose if the removed element should be disposed (default: false)
  56635. */
  56636. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56637. /**
  56638. * Disposes the component and the associated ressources.
  56639. */
  56640. dispose(): void;
  56641. private _isReadyForMesh;
  56642. private _renderMainTexture;
  56643. private _setStencil;
  56644. private _setStencilBack;
  56645. private _draw;
  56646. private _drawCamera;
  56647. private _drawRenderingGroup;
  56648. }
  56649. }
  56650. declare module BABYLON {
  56651. /** @hidden */
  56652. export var glowMapMergePixelShader: {
  56653. name: string;
  56654. shader: string;
  56655. };
  56656. }
  56657. declare module BABYLON {
  56658. /** @hidden */
  56659. export var glowMapMergeVertexShader: {
  56660. name: string;
  56661. shader: string;
  56662. };
  56663. }
  56664. declare module BABYLON {
  56665. interface AbstractScene {
  56666. /**
  56667. * Return a the first highlight layer of the scene with a given name.
  56668. * @param name The name of the highlight layer to look for.
  56669. * @return The highlight layer if found otherwise null.
  56670. */
  56671. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56672. }
  56673. /**
  56674. * Glow layer options. This helps customizing the behaviour
  56675. * of the glow layer.
  56676. */
  56677. export interface IGlowLayerOptions {
  56678. /**
  56679. * Multiplication factor apply to the canvas size to compute the render target size
  56680. * used to generated the glowing objects (the smaller the faster).
  56681. */
  56682. mainTextureRatio: number;
  56683. /**
  56684. * Enforces a fixed size texture to ensure resize independant blur.
  56685. */
  56686. mainTextureFixedSize?: number;
  56687. /**
  56688. * How big is the kernel of the blur texture.
  56689. */
  56690. blurKernelSize: number;
  56691. /**
  56692. * The camera attached to the layer.
  56693. */
  56694. camera: Nullable<Camera>;
  56695. /**
  56696. * Enable MSAA by chosing the number of samples.
  56697. */
  56698. mainTextureSamples?: number;
  56699. /**
  56700. * The rendering group to draw the layer in.
  56701. */
  56702. renderingGroupId: number;
  56703. }
  56704. /**
  56705. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56706. *
  56707. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56708. *
  56709. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56710. */
  56711. export class GlowLayer extends EffectLayer {
  56712. /**
  56713. * Effect Name of the layer.
  56714. */
  56715. static readonly EffectName: string;
  56716. /**
  56717. * The default blur kernel size used for the glow.
  56718. */
  56719. static DefaultBlurKernelSize: number;
  56720. /**
  56721. * The default texture size ratio used for the glow.
  56722. */
  56723. static DefaultTextureRatio: number;
  56724. /**
  56725. * Sets the kernel size of the blur.
  56726. */
  56727. set blurKernelSize(value: number);
  56728. /**
  56729. * Gets the kernel size of the blur.
  56730. */
  56731. get blurKernelSize(): number;
  56732. /**
  56733. * Sets the glow intensity.
  56734. */
  56735. set intensity(value: number);
  56736. /**
  56737. * Gets the glow intensity.
  56738. */
  56739. get intensity(): number;
  56740. private _options;
  56741. private _intensity;
  56742. private _horizontalBlurPostprocess1;
  56743. private _verticalBlurPostprocess1;
  56744. private _horizontalBlurPostprocess2;
  56745. private _verticalBlurPostprocess2;
  56746. private _blurTexture1;
  56747. private _blurTexture2;
  56748. private _postProcesses1;
  56749. private _postProcesses2;
  56750. private _includedOnlyMeshes;
  56751. private _excludedMeshes;
  56752. private _meshesUsingTheirOwnMaterials;
  56753. /**
  56754. * Callback used to let the user override the color selection on a per mesh basis
  56755. */
  56756. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56757. /**
  56758. * Callback used to let the user override the texture selection on a per mesh basis
  56759. */
  56760. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56761. /**
  56762. * Instantiates a new glow Layer and references it to the scene.
  56763. * @param name The name of the layer
  56764. * @param scene The scene to use the layer in
  56765. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56766. */
  56767. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56768. /**
  56769. * Get the effect name of the layer.
  56770. * @return The effect name
  56771. */
  56772. getEffectName(): string;
  56773. /**
  56774. * Create the merge effect. This is the shader use to blit the information back
  56775. * to the main canvas at the end of the scene rendering.
  56776. */
  56777. protected _createMergeEffect(): Effect;
  56778. /**
  56779. * Creates the render target textures and post processes used in the glow layer.
  56780. */
  56781. protected _createTextureAndPostProcesses(): void;
  56782. /**
  56783. * Checks for the readiness of the element composing the layer.
  56784. * @param subMesh the mesh to check for
  56785. * @param useInstances specify wether or not to use instances to render the mesh
  56786. * @param emissiveTexture the associated emissive texture used to generate the glow
  56787. * @return true if ready otherwise, false
  56788. */
  56789. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56790. /**
  56791. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56792. */
  56793. needStencil(): boolean;
  56794. /**
  56795. * Returns true if the mesh can be rendered, otherwise false.
  56796. * @param mesh The mesh to render
  56797. * @param material The material used on the mesh
  56798. * @returns true if it can be rendered otherwise false
  56799. */
  56800. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56801. /**
  56802. * Implementation specific of rendering the generating effect on the main canvas.
  56803. * @param effect The effect used to render through
  56804. */
  56805. protected _internalRender(effect: Effect): void;
  56806. /**
  56807. * Sets the required values for both the emissive texture and and the main color.
  56808. */
  56809. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56810. /**
  56811. * Returns true if the mesh should render, otherwise false.
  56812. * @param mesh The mesh to render
  56813. * @returns true if it should render otherwise false
  56814. */
  56815. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56816. /**
  56817. * Adds specific effects defines.
  56818. * @param defines The defines to add specifics to.
  56819. */
  56820. protected _addCustomEffectDefines(defines: string[]): void;
  56821. /**
  56822. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56823. * @param mesh The mesh to exclude from the glow layer
  56824. */
  56825. addExcludedMesh(mesh: Mesh): void;
  56826. /**
  56827. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56828. * @param mesh The mesh to remove
  56829. */
  56830. removeExcludedMesh(mesh: Mesh): void;
  56831. /**
  56832. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56833. * @param mesh The mesh to include in the glow layer
  56834. */
  56835. addIncludedOnlyMesh(mesh: Mesh): void;
  56836. /**
  56837. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56838. * @param mesh The mesh to remove
  56839. */
  56840. removeIncludedOnlyMesh(mesh: Mesh): void;
  56841. /**
  56842. * Determine if a given mesh will be used in the glow layer
  56843. * @param mesh The mesh to test
  56844. * @returns true if the mesh will be highlighted by the current glow layer
  56845. */
  56846. hasMesh(mesh: AbstractMesh): boolean;
  56847. /**
  56848. * Defines whether the current material of the mesh should be use to render the effect.
  56849. * @param mesh defines the current mesh to render
  56850. */
  56851. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56852. /**
  56853. * Add a mesh to be rendered through its own material and not with emissive only.
  56854. * @param mesh The mesh for which we need to use its material
  56855. */
  56856. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56857. /**
  56858. * Remove a mesh from being rendered through its own material and not with emissive only.
  56859. * @param mesh The mesh for which we need to not use its material
  56860. */
  56861. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56862. /**
  56863. * Free any resources and references associated to a mesh.
  56864. * Internal use
  56865. * @param mesh The mesh to free.
  56866. * @hidden
  56867. */
  56868. _disposeMesh(mesh: Mesh): void;
  56869. /**
  56870. * Gets the class name of the effect layer
  56871. * @returns the string with the class name of the effect layer
  56872. */
  56873. getClassName(): string;
  56874. /**
  56875. * Serializes this glow layer
  56876. * @returns a serialized glow layer object
  56877. */
  56878. serialize(): any;
  56879. /**
  56880. * Creates a Glow Layer from parsed glow layer data
  56881. * @param parsedGlowLayer defines glow layer data
  56882. * @param scene defines the current scene
  56883. * @param rootUrl defines the root URL containing the glow layer information
  56884. * @returns a parsed Glow Layer
  56885. */
  56886. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56887. }
  56888. }
  56889. declare module BABYLON {
  56890. /** @hidden */
  56891. export var glowBlurPostProcessPixelShader: {
  56892. name: string;
  56893. shader: string;
  56894. };
  56895. }
  56896. declare module BABYLON {
  56897. interface AbstractScene {
  56898. /**
  56899. * Return a the first highlight layer of the scene with a given name.
  56900. * @param name The name of the highlight layer to look for.
  56901. * @return The highlight layer if found otherwise null.
  56902. */
  56903. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56904. }
  56905. /**
  56906. * Highlight layer options. This helps customizing the behaviour
  56907. * of the highlight layer.
  56908. */
  56909. export interface IHighlightLayerOptions {
  56910. /**
  56911. * Multiplication factor apply to the canvas size to compute the render target size
  56912. * used to generated the glowing objects (the smaller the faster).
  56913. */
  56914. mainTextureRatio: number;
  56915. /**
  56916. * Enforces a fixed size texture to ensure resize independant blur.
  56917. */
  56918. mainTextureFixedSize?: number;
  56919. /**
  56920. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56921. * of the picture to blur (the smaller the faster).
  56922. */
  56923. blurTextureSizeRatio: number;
  56924. /**
  56925. * How big in texel of the blur texture is the vertical blur.
  56926. */
  56927. blurVerticalSize: number;
  56928. /**
  56929. * How big in texel of the blur texture is the horizontal blur.
  56930. */
  56931. blurHorizontalSize: number;
  56932. /**
  56933. * Alpha blending mode used to apply the blur. Default is combine.
  56934. */
  56935. alphaBlendingMode: number;
  56936. /**
  56937. * The camera attached to the layer.
  56938. */
  56939. camera: Nullable<Camera>;
  56940. /**
  56941. * Should we display highlight as a solid stroke?
  56942. */
  56943. isStroke?: boolean;
  56944. /**
  56945. * The rendering group to draw the layer in.
  56946. */
  56947. renderingGroupId: number;
  56948. }
  56949. /**
  56950. * The highlight layer Helps adding a glow effect around a mesh.
  56951. *
  56952. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56953. * glowy meshes to your scene.
  56954. *
  56955. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56956. */
  56957. export class HighlightLayer extends EffectLayer {
  56958. name: string;
  56959. /**
  56960. * Effect Name of the highlight layer.
  56961. */
  56962. static readonly EffectName: string;
  56963. /**
  56964. * The neutral color used during the preparation of the glow effect.
  56965. * This is black by default as the blend operation is a blend operation.
  56966. */
  56967. static NeutralColor: Color4;
  56968. /**
  56969. * Stencil value used for glowing meshes.
  56970. */
  56971. static GlowingMeshStencilReference: number;
  56972. /**
  56973. * Stencil value used for the other meshes in the scene.
  56974. */
  56975. static NormalMeshStencilReference: number;
  56976. /**
  56977. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56978. */
  56979. innerGlow: boolean;
  56980. /**
  56981. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56982. */
  56983. outerGlow: boolean;
  56984. /**
  56985. * Specifies the horizontal size of the blur.
  56986. */
  56987. set blurHorizontalSize(value: number);
  56988. /**
  56989. * Specifies the vertical size of the blur.
  56990. */
  56991. set blurVerticalSize(value: number);
  56992. /**
  56993. * Gets the horizontal size of the blur.
  56994. */
  56995. get blurHorizontalSize(): number;
  56996. /**
  56997. * Gets the vertical size of the blur.
  56998. */
  56999. get blurVerticalSize(): number;
  57000. /**
  57001. * An event triggered when the highlight layer is being blurred.
  57002. */
  57003. onBeforeBlurObservable: Observable<HighlightLayer>;
  57004. /**
  57005. * An event triggered when the highlight layer has been blurred.
  57006. */
  57007. onAfterBlurObservable: Observable<HighlightLayer>;
  57008. private _instanceGlowingMeshStencilReference;
  57009. private _options;
  57010. private _downSamplePostprocess;
  57011. private _horizontalBlurPostprocess;
  57012. private _verticalBlurPostprocess;
  57013. private _blurTexture;
  57014. private _meshes;
  57015. private _excludedMeshes;
  57016. /**
  57017. * Instantiates a new highlight Layer and references it to the scene..
  57018. * @param name The name of the layer
  57019. * @param scene The scene to use the layer in
  57020. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57021. */
  57022. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57023. /**
  57024. * Get the effect name of the layer.
  57025. * @return The effect name
  57026. */
  57027. getEffectName(): string;
  57028. /**
  57029. * Create the merge effect. This is the shader use to blit the information back
  57030. * to the main canvas at the end of the scene rendering.
  57031. */
  57032. protected _createMergeEffect(): Effect;
  57033. /**
  57034. * Creates the render target textures and post processes used in the highlight layer.
  57035. */
  57036. protected _createTextureAndPostProcesses(): void;
  57037. /**
  57038. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57039. */
  57040. needStencil(): boolean;
  57041. /**
  57042. * Checks for the readiness of the element composing the layer.
  57043. * @param subMesh the mesh to check for
  57044. * @param useInstances specify wether or not to use instances to render the mesh
  57045. * @param emissiveTexture the associated emissive texture used to generate the glow
  57046. * @return true if ready otherwise, false
  57047. */
  57048. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57049. /**
  57050. * Implementation specific of rendering the generating effect on the main canvas.
  57051. * @param effect The effect used to render through
  57052. */
  57053. protected _internalRender(effect: Effect): void;
  57054. /**
  57055. * Returns true if the layer contains information to display, otherwise false.
  57056. */
  57057. shouldRender(): boolean;
  57058. /**
  57059. * Returns true if the mesh should render, otherwise false.
  57060. * @param mesh The mesh to render
  57061. * @returns true if it should render otherwise false
  57062. */
  57063. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57064. /**
  57065. * Adds specific effects defines.
  57066. * @param defines The defines to add specifics to.
  57067. */
  57068. protected _addCustomEffectDefines(defines: string[]): void;
  57069. /**
  57070. * Sets the required values for both the emissive texture and and the main color.
  57071. */
  57072. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57073. /**
  57074. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57075. * @param mesh The mesh to exclude from the highlight layer
  57076. */
  57077. addExcludedMesh(mesh: Mesh): void;
  57078. /**
  57079. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57080. * @param mesh The mesh to highlight
  57081. */
  57082. removeExcludedMesh(mesh: Mesh): void;
  57083. /**
  57084. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57085. * @param mesh mesh to test
  57086. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57087. */
  57088. hasMesh(mesh: AbstractMesh): boolean;
  57089. /**
  57090. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57091. * @param mesh The mesh to highlight
  57092. * @param color The color of the highlight
  57093. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57094. */
  57095. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57096. /**
  57097. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57098. * @param mesh The mesh to highlight
  57099. */
  57100. removeMesh(mesh: Mesh): void;
  57101. /**
  57102. * Remove all the meshes currently referenced in the highlight layer
  57103. */
  57104. removeAllMeshes(): void;
  57105. /**
  57106. * Force the stencil to the normal expected value for none glowing parts
  57107. */
  57108. private _defaultStencilReference;
  57109. /**
  57110. * Free any resources and references associated to a mesh.
  57111. * Internal use
  57112. * @param mesh The mesh to free.
  57113. * @hidden
  57114. */
  57115. _disposeMesh(mesh: Mesh): void;
  57116. /**
  57117. * Dispose the highlight layer and free resources.
  57118. */
  57119. dispose(): void;
  57120. /**
  57121. * Gets the class name of the effect layer
  57122. * @returns the string with the class name of the effect layer
  57123. */
  57124. getClassName(): string;
  57125. /**
  57126. * Serializes this Highlight layer
  57127. * @returns a serialized Highlight layer object
  57128. */
  57129. serialize(): any;
  57130. /**
  57131. * Creates a Highlight layer from parsed Highlight layer data
  57132. * @param parsedHightlightLayer defines the Highlight layer data
  57133. * @param scene defines the current scene
  57134. * @param rootUrl defines the root URL containing the Highlight layer information
  57135. * @returns a parsed Highlight layer
  57136. */
  57137. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57138. }
  57139. }
  57140. declare module BABYLON {
  57141. interface AbstractScene {
  57142. /**
  57143. * The list of layers (background and foreground) of the scene
  57144. */
  57145. layers: Array<Layer>;
  57146. }
  57147. /**
  57148. * Defines the layer scene component responsible to manage any layers
  57149. * in a given scene.
  57150. */
  57151. export class LayerSceneComponent implements ISceneComponent {
  57152. /**
  57153. * The component name helpfull to identify the component in the list of scene components.
  57154. */
  57155. readonly name: string;
  57156. /**
  57157. * The scene the component belongs to.
  57158. */
  57159. scene: Scene;
  57160. private _engine;
  57161. /**
  57162. * Creates a new instance of the component for the given scene
  57163. * @param scene Defines the scene to register the component in
  57164. */
  57165. constructor(scene: Scene);
  57166. /**
  57167. * Registers the component in a given scene
  57168. */
  57169. register(): void;
  57170. /**
  57171. * Rebuilds the elements related to this component in case of
  57172. * context lost for instance.
  57173. */
  57174. rebuild(): void;
  57175. /**
  57176. * Disposes the component and the associated ressources.
  57177. */
  57178. dispose(): void;
  57179. private _draw;
  57180. private _drawCameraPredicate;
  57181. private _drawCameraBackground;
  57182. private _drawCameraForeground;
  57183. private _drawRenderTargetPredicate;
  57184. private _drawRenderTargetBackground;
  57185. private _drawRenderTargetForeground;
  57186. /**
  57187. * Adds all the elements from the container to the scene
  57188. * @param container the container holding the elements
  57189. */
  57190. addFromContainer(container: AbstractScene): void;
  57191. /**
  57192. * Removes all the elements in the container from the scene
  57193. * @param container contains the elements to remove
  57194. * @param dispose if the removed element should be disposed (default: false)
  57195. */
  57196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57197. }
  57198. }
  57199. declare module BABYLON {
  57200. /** @hidden */
  57201. export var layerPixelShader: {
  57202. name: string;
  57203. shader: string;
  57204. };
  57205. }
  57206. declare module BABYLON {
  57207. /** @hidden */
  57208. export var layerVertexShader: {
  57209. name: string;
  57210. shader: string;
  57211. };
  57212. }
  57213. declare module BABYLON {
  57214. /**
  57215. * This represents a full screen 2d layer.
  57216. * This can be useful to display a picture in the background of your scene for instance.
  57217. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57218. */
  57219. export class Layer {
  57220. /**
  57221. * Define the name of the layer.
  57222. */
  57223. name: string;
  57224. /**
  57225. * Define the texture the layer should display.
  57226. */
  57227. texture: Nullable<Texture>;
  57228. /**
  57229. * Is the layer in background or foreground.
  57230. */
  57231. isBackground: boolean;
  57232. /**
  57233. * Define the color of the layer (instead of texture).
  57234. */
  57235. color: Color4;
  57236. /**
  57237. * Define the scale of the layer in order to zoom in out of the texture.
  57238. */
  57239. scale: Vector2;
  57240. /**
  57241. * Define an offset for the layer in order to shift the texture.
  57242. */
  57243. offset: Vector2;
  57244. /**
  57245. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57246. */
  57247. alphaBlendingMode: number;
  57248. /**
  57249. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57250. * Alpha test will not mix with the background color in case of transparency.
  57251. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57252. */
  57253. alphaTest: boolean;
  57254. /**
  57255. * Define a mask to restrict the layer to only some of the scene cameras.
  57256. */
  57257. layerMask: number;
  57258. /**
  57259. * Define the list of render target the layer is visible into.
  57260. */
  57261. renderTargetTextures: RenderTargetTexture[];
  57262. /**
  57263. * Define if the layer is only used in renderTarget or if it also
  57264. * renders in the main frame buffer of the canvas.
  57265. */
  57266. renderOnlyInRenderTargetTextures: boolean;
  57267. private _scene;
  57268. private _vertexBuffers;
  57269. private _indexBuffer;
  57270. private _effect;
  57271. private _previousDefines;
  57272. /**
  57273. * An event triggered when the layer is disposed.
  57274. */
  57275. onDisposeObservable: Observable<Layer>;
  57276. private _onDisposeObserver;
  57277. /**
  57278. * Back compatibility with callback before the onDisposeObservable existed.
  57279. * The set callback will be triggered when the layer has been disposed.
  57280. */
  57281. set onDispose(callback: () => void);
  57282. /**
  57283. * An event triggered before rendering the scene
  57284. */
  57285. onBeforeRenderObservable: Observable<Layer>;
  57286. private _onBeforeRenderObserver;
  57287. /**
  57288. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57289. * The set callback will be triggered just before rendering the layer.
  57290. */
  57291. set onBeforeRender(callback: () => void);
  57292. /**
  57293. * An event triggered after rendering the scene
  57294. */
  57295. onAfterRenderObservable: Observable<Layer>;
  57296. private _onAfterRenderObserver;
  57297. /**
  57298. * Back compatibility with callback before the onAfterRenderObservable existed.
  57299. * The set callback will be triggered just after rendering the layer.
  57300. */
  57301. set onAfterRender(callback: () => void);
  57302. /**
  57303. * Instantiates a new layer.
  57304. * This represents a full screen 2d layer.
  57305. * This can be useful to display a picture in the background of your scene for instance.
  57306. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57307. * @param name Define the name of the layer in the scene
  57308. * @param imgUrl Define the url of the texture to display in the layer
  57309. * @param scene Define the scene the layer belongs to
  57310. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57311. * @param color Defines a color for the layer
  57312. */
  57313. constructor(
  57314. /**
  57315. * Define the name of the layer.
  57316. */
  57317. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57318. private _createIndexBuffer;
  57319. /** @hidden */
  57320. _rebuild(): void;
  57321. /**
  57322. * Renders the layer in the scene.
  57323. */
  57324. render(): void;
  57325. /**
  57326. * Disposes and releases the associated ressources.
  57327. */
  57328. dispose(): void;
  57329. }
  57330. }
  57331. declare module BABYLON {
  57332. /** @hidden */
  57333. export var lensFlarePixelShader: {
  57334. name: string;
  57335. shader: string;
  57336. };
  57337. }
  57338. declare module BABYLON {
  57339. /** @hidden */
  57340. export var lensFlareVertexShader: {
  57341. name: string;
  57342. shader: string;
  57343. };
  57344. }
  57345. declare module BABYLON {
  57346. /**
  57347. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57348. * It is usually composed of several `lensFlare`.
  57349. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57350. */
  57351. export class LensFlareSystem {
  57352. /**
  57353. * Define the name of the lens flare system
  57354. */
  57355. name: string;
  57356. /**
  57357. * List of lens flares used in this system.
  57358. */
  57359. lensFlares: LensFlare[];
  57360. /**
  57361. * Define a limit from the border the lens flare can be visible.
  57362. */
  57363. borderLimit: number;
  57364. /**
  57365. * Define a viewport border we do not want to see the lens flare in.
  57366. */
  57367. viewportBorder: number;
  57368. /**
  57369. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57370. */
  57371. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57372. /**
  57373. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57374. */
  57375. layerMask: number;
  57376. /**
  57377. * Define the id of the lens flare system in the scene.
  57378. * (equal to name by default)
  57379. */
  57380. id: string;
  57381. private _scene;
  57382. private _emitter;
  57383. private _vertexBuffers;
  57384. private _indexBuffer;
  57385. private _effect;
  57386. private _positionX;
  57387. private _positionY;
  57388. private _isEnabled;
  57389. /** @hidden */
  57390. static _SceneComponentInitialization: (scene: Scene) => void;
  57391. /**
  57392. * Instantiates a lens flare system.
  57393. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57394. * It is usually composed of several `lensFlare`.
  57395. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57396. * @param name Define the name of the lens flare system in the scene
  57397. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57398. * @param scene Define the scene the lens flare system belongs to
  57399. */
  57400. constructor(
  57401. /**
  57402. * Define the name of the lens flare system
  57403. */
  57404. name: string, emitter: any, scene: Scene);
  57405. /**
  57406. * Define if the lens flare system is enabled.
  57407. */
  57408. get isEnabled(): boolean;
  57409. set isEnabled(value: boolean);
  57410. /**
  57411. * Get the scene the effects belongs to.
  57412. * @returns the scene holding the lens flare system
  57413. */
  57414. getScene(): Scene;
  57415. /**
  57416. * Get the emitter of the lens flare system.
  57417. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57418. * @returns the emitter of the lens flare system
  57419. */
  57420. getEmitter(): any;
  57421. /**
  57422. * Set the emitter of the lens flare system.
  57423. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57424. * @param newEmitter Define the new emitter of the system
  57425. */
  57426. setEmitter(newEmitter: any): void;
  57427. /**
  57428. * Get the lens flare system emitter position.
  57429. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57430. * @returns the position
  57431. */
  57432. getEmitterPosition(): Vector3;
  57433. /**
  57434. * @hidden
  57435. */
  57436. computeEffectivePosition(globalViewport: Viewport): boolean;
  57437. /** @hidden */
  57438. _isVisible(): boolean;
  57439. /**
  57440. * @hidden
  57441. */
  57442. render(): boolean;
  57443. /**
  57444. * Dispose and release the lens flare with its associated resources.
  57445. */
  57446. dispose(): void;
  57447. /**
  57448. * Parse a lens flare system from a JSON repressentation
  57449. * @param parsedLensFlareSystem Define the JSON to parse
  57450. * @param scene Define the scene the parsed system should be instantiated in
  57451. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57452. * @returns the parsed system
  57453. */
  57454. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57455. /**
  57456. * Serialize the current Lens Flare System into a JSON representation.
  57457. * @returns the serialized JSON
  57458. */
  57459. serialize(): any;
  57460. }
  57461. }
  57462. declare module BABYLON {
  57463. /**
  57464. * This represents one of the lens effect in a `lensFlareSystem`.
  57465. * It controls one of the indiviual texture used in the effect.
  57466. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57467. */
  57468. export class LensFlare {
  57469. /**
  57470. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57471. */
  57472. size: number;
  57473. /**
  57474. * 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.
  57475. */
  57476. position: number;
  57477. /**
  57478. * Define the lens color.
  57479. */
  57480. color: Color3;
  57481. /**
  57482. * Define the lens texture.
  57483. */
  57484. texture: Nullable<Texture>;
  57485. /**
  57486. * Define the alpha mode to render this particular lens.
  57487. */
  57488. alphaMode: number;
  57489. private _system;
  57490. /**
  57491. * Creates a new Lens Flare.
  57492. * This represents one of the lens effect in a `lensFlareSystem`.
  57493. * It controls one of the indiviual texture used in the effect.
  57494. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57495. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57496. * @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.
  57497. * @param color Define the lens color
  57498. * @param imgUrl Define the lens texture url
  57499. * @param system Define the `lensFlareSystem` this flare is part of
  57500. * @returns The newly created Lens Flare
  57501. */
  57502. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57503. /**
  57504. * Instantiates a new Lens Flare.
  57505. * This represents one of the lens effect in a `lensFlareSystem`.
  57506. * It controls one of the indiviual texture used in the effect.
  57507. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57508. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57509. * @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.
  57510. * @param color Define the lens color
  57511. * @param imgUrl Define the lens texture url
  57512. * @param system Define the `lensFlareSystem` this flare is part of
  57513. */
  57514. constructor(
  57515. /**
  57516. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57517. */
  57518. size: number,
  57519. /**
  57520. * 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.
  57521. */
  57522. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57523. /**
  57524. * Dispose and release the lens flare with its associated resources.
  57525. */
  57526. dispose(): void;
  57527. }
  57528. }
  57529. declare module BABYLON {
  57530. interface AbstractScene {
  57531. /**
  57532. * The list of lens flare system added to the scene
  57533. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57534. */
  57535. lensFlareSystems: Array<LensFlareSystem>;
  57536. /**
  57537. * Removes the given lens flare system from this scene.
  57538. * @param toRemove The lens flare system to remove
  57539. * @returns The index of the removed lens flare system
  57540. */
  57541. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57542. /**
  57543. * Adds the given lens flare system to this scene
  57544. * @param newLensFlareSystem The lens flare system to add
  57545. */
  57546. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57547. /**
  57548. * Gets a lens flare system using its name
  57549. * @param name defines the name to look for
  57550. * @returns the lens flare system or null if not found
  57551. */
  57552. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57553. /**
  57554. * Gets a lens flare system using its id
  57555. * @param id defines the id to look for
  57556. * @returns the lens flare system or null if not found
  57557. */
  57558. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57559. }
  57560. /**
  57561. * Defines the lens flare scene component responsible to manage any lens flares
  57562. * in a given scene.
  57563. */
  57564. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57565. /**
  57566. * The component name helpfull to identify the component in the list of scene components.
  57567. */
  57568. readonly name: string;
  57569. /**
  57570. * The scene the component belongs to.
  57571. */
  57572. scene: Scene;
  57573. /**
  57574. * Creates a new instance of the component for the given scene
  57575. * @param scene Defines the scene to register the component in
  57576. */
  57577. constructor(scene: Scene);
  57578. /**
  57579. * Registers the component in a given scene
  57580. */
  57581. register(): void;
  57582. /**
  57583. * Rebuilds the elements related to this component in case of
  57584. * context lost for instance.
  57585. */
  57586. rebuild(): void;
  57587. /**
  57588. * Adds all the elements from the container to the scene
  57589. * @param container the container holding the elements
  57590. */
  57591. addFromContainer(container: AbstractScene): void;
  57592. /**
  57593. * Removes all the elements in the container from the scene
  57594. * @param container contains the elements to remove
  57595. * @param dispose if the removed element should be disposed (default: false)
  57596. */
  57597. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57598. /**
  57599. * Serializes the component data to the specified json object
  57600. * @param serializationObject The object to serialize to
  57601. */
  57602. serialize(serializationObject: any): void;
  57603. /**
  57604. * Disposes the component and the associated ressources.
  57605. */
  57606. dispose(): void;
  57607. private _draw;
  57608. }
  57609. }
  57610. declare module BABYLON {
  57611. /** @hidden */
  57612. export var depthPixelShader: {
  57613. name: string;
  57614. shader: string;
  57615. };
  57616. }
  57617. declare module BABYLON {
  57618. /** @hidden */
  57619. export var depthVertexShader: {
  57620. name: string;
  57621. shader: string;
  57622. };
  57623. }
  57624. declare module BABYLON {
  57625. /**
  57626. * This represents a depth renderer in Babylon.
  57627. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57628. */
  57629. export class DepthRenderer {
  57630. private _scene;
  57631. private _depthMap;
  57632. private _effect;
  57633. private readonly _storeNonLinearDepth;
  57634. private readonly _clearColor;
  57635. /** Get if the depth renderer is using packed depth or not */
  57636. readonly isPacked: boolean;
  57637. private _cachedDefines;
  57638. private _camera;
  57639. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57640. enabled: boolean;
  57641. /**
  57642. * Specifiess that the depth renderer will only be used within
  57643. * the camera it is created for.
  57644. * This can help forcing its rendering during the camera processing.
  57645. */
  57646. useOnlyInActiveCamera: boolean;
  57647. /** @hidden */
  57648. static _SceneComponentInitialization: (scene: Scene) => void;
  57649. /**
  57650. * Instantiates a depth renderer
  57651. * @param scene The scene the renderer belongs to
  57652. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57653. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57654. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57655. */
  57656. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57657. /**
  57658. * Creates the depth rendering effect and checks if the effect is ready.
  57659. * @param subMesh The submesh to be used to render the depth map of
  57660. * @param useInstances If multiple world instances should be used
  57661. * @returns if the depth renderer is ready to render the depth map
  57662. */
  57663. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57664. /**
  57665. * Gets the texture which the depth map will be written to.
  57666. * @returns The depth map texture
  57667. */
  57668. getDepthMap(): RenderTargetTexture;
  57669. /**
  57670. * Disposes of the depth renderer.
  57671. */
  57672. dispose(): void;
  57673. }
  57674. }
  57675. declare module BABYLON {
  57676. /** @hidden */
  57677. export var minmaxReduxPixelShader: {
  57678. name: string;
  57679. shader: string;
  57680. };
  57681. }
  57682. declare module BABYLON {
  57683. /**
  57684. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57685. * and maximum values from all values of the texture.
  57686. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57687. * The source values are read from the red channel of the texture.
  57688. */
  57689. export class MinMaxReducer {
  57690. /**
  57691. * Observable triggered when the computation has been performed
  57692. */
  57693. onAfterReductionPerformed: Observable<{
  57694. min: number;
  57695. max: number;
  57696. }>;
  57697. protected _camera: Camera;
  57698. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57699. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57700. protected _postProcessManager: PostProcessManager;
  57701. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57702. protected _forceFullscreenViewport: boolean;
  57703. /**
  57704. * Creates a min/max reducer
  57705. * @param camera The camera to use for the post processes
  57706. */
  57707. constructor(camera: Camera);
  57708. /**
  57709. * Gets the texture used to read the values from.
  57710. */
  57711. get sourceTexture(): Nullable<RenderTargetTexture>;
  57712. /**
  57713. * Sets the source texture to read the values from.
  57714. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57715. * because in such textures '1' value must not be taken into account to compute the maximum
  57716. * as this value is used to clear the texture.
  57717. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57718. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57719. * @param depthRedux Indicates if the texture is a depth texture or not
  57720. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57721. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57722. */
  57723. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57724. /**
  57725. * Defines the refresh rate of the computation.
  57726. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57727. */
  57728. get refreshRate(): number;
  57729. set refreshRate(value: number);
  57730. protected _activated: boolean;
  57731. /**
  57732. * Gets the activation status of the reducer
  57733. */
  57734. get activated(): boolean;
  57735. /**
  57736. * Activates the reduction computation.
  57737. * When activated, the observers registered in onAfterReductionPerformed are
  57738. * called after the compuation is performed
  57739. */
  57740. activate(): void;
  57741. /**
  57742. * Deactivates the reduction computation.
  57743. */
  57744. deactivate(): void;
  57745. /**
  57746. * Disposes the min/max reducer
  57747. * @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.
  57748. */
  57749. dispose(disposeAll?: boolean): void;
  57750. }
  57751. }
  57752. declare module BABYLON {
  57753. /**
  57754. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57755. */
  57756. export class DepthReducer extends MinMaxReducer {
  57757. private _depthRenderer;
  57758. private _depthRendererId;
  57759. /**
  57760. * Gets the depth renderer used for the computation.
  57761. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57762. */
  57763. get depthRenderer(): Nullable<DepthRenderer>;
  57764. /**
  57765. * Creates a depth reducer
  57766. * @param camera The camera used to render the depth texture
  57767. */
  57768. constructor(camera: Camera);
  57769. /**
  57770. * Sets the depth renderer to use to generate the depth map
  57771. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57772. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57773. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57774. */
  57775. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57776. /** @hidden */
  57777. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57778. /**
  57779. * Activates the reduction computation.
  57780. * When activated, the observers registered in onAfterReductionPerformed are
  57781. * called after the compuation is performed
  57782. */
  57783. activate(): void;
  57784. /**
  57785. * Deactivates the reduction computation.
  57786. */
  57787. deactivate(): void;
  57788. /**
  57789. * Disposes the depth reducer
  57790. * @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.
  57791. */
  57792. dispose(disposeAll?: boolean): void;
  57793. }
  57794. }
  57795. declare module BABYLON {
  57796. /**
  57797. * A CSM implementation allowing casting shadows on large scenes.
  57798. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57799. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57800. */
  57801. export class CascadedShadowGenerator extends ShadowGenerator {
  57802. private static readonly frustumCornersNDCSpace;
  57803. /**
  57804. * Name of the CSM class
  57805. */
  57806. static CLASSNAME: string;
  57807. /**
  57808. * Defines the default number of cascades used by the CSM.
  57809. */
  57810. static readonly DEFAULT_CASCADES_COUNT: number;
  57811. /**
  57812. * Defines the minimum number of cascades used by the CSM.
  57813. */
  57814. static readonly MIN_CASCADES_COUNT: number;
  57815. /**
  57816. * Defines the maximum number of cascades used by the CSM.
  57817. */
  57818. static readonly MAX_CASCADES_COUNT: number;
  57819. protected _validateFilter(filter: number): number;
  57820. /**
  57821. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57822. */
  57823. penumbraDarkness: number;
  57824. private _numCascades;
  57825. /**
  57826. * Gets or set the number of cascades used by the CSM.
  57827. */
  57828. get numCascades(): number;
  57829. set numCascades(value: number);
  57830. /**
  57831. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57832. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57833. */
  57834. stabilizeCascades: boolean;
  57835. private _freezeShadowCastersBoundingInfo;
  57836. private _freezeShadowCastersBoundingInfoObservable;
  57837. /**
  57838. * Enables or disables the shadow casters bounding info computation.
  57839. * If your shadow casters don't move, you can disable this feature.
  57840. * If it is enabled, the bounding box computation is done every frame.
  57841. */
  57842. get freezeShadowCastersBoundingInfo(): boolean;
  57843. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57844. private _scbiMin;
  57845. private _scbiMax;
  57846. protected _computeShadowCastersBoundingInfo(): void;
  57847. protected _shadowCastersBoundingInfo: BoundingInfo;
  57848. /**
  57849. * Gets or sets the shadow casters bounding info.
  57850. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57851. * so that the system won't overwrite the bounds you provide
  57852. */
  57853. get shadowCastersBoundingInfo(): BoundingInfo;
  57854. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57855. protected _breaksAreDirty: boolean;
  57856. protected _minDistance: number;
  57857. protected _maxDistance: number;
  57858. /**
  57859. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57860. *
  57861. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57862. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57863. * @param min minimal distance for the breaks (default to 0.)
  57864. * @param max maximal distance for the breaks (default to 1.)
  57865. */
  57866. setMinMaxDistance(min: number, max: number): void;
  57867. /** Gets the minimal distance used in the cascade break computation */
  57868. get minDistance(): number;
  57869. /** Gets the maximal distance used in the cascade break computation */
  57870. get maxDistance(): number;
  57871. /**
  57872. * Gets the class name of that object
  57873. * @returns "CascadedShadowGenerator"
  57874. */
  57875. getClassName(): string;
  57876. private _cascadeMinExtents;
  57877. private _cascadeMaxExtents;
  57878. /**
  57879. * Gets a cascade minimum extents
  57880. * @param cascadeIndex index of the cascade
  57881. * @returns the minimum cascade extents
  57882. */
  57883. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57884. /**
  57885. * Gets a cascade maximum extents
  57886. * @param cascadeIndex index of the cascade
  57887. * @returns the maximum cascade extents
  57888. */
  57889. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57890. private _cascades;
  57891. private _currentLayer;
  57892. private _viewSpaceFrustumsZ;
  57893. private _viewMatrices;
  57894. private _projectionMatrices;
  57895. private _transformMatrices;
  57896. private _transformMatricesAsArray;
  57897. private _frustumLengths;
  57898. private _lightSizeUVCorrection;
  57899. private _depthCorrection;
  57900. private _frustumCornersWorldSpace;
  57901. private _frustumCenter;
  57902. private _shadowCameraPos;
  57903. private _shadowMaxZ;
  57904. /**
  57905. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57906. * It defaults to camera.maxZ
  57907. */
  57908. get shadowMaxZ(): number;
  57909. /**
  57910. * Sets the shadow max z distance.
  57911. */
  57912. set shadowMaxZ(value: number);
  57913. protected _debug: boolean;
  57914. /**
  57915. * Gets or sets the debug flag.
  57916. * When enabled, the cascades are materialized by different colors on the screen.
  57917. */
  57918. get debug(): boolean;
  57919. set debug(dbg: boolean);
  57920. private _depthClamp;
  57921. /**
  57922. * Gets or sets the depth clamping value.
  57923. *
  57924. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57925. * to account for the shadow casters far away.
  57926. *
  57927. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57928. */
  57929. get depthClamp(): boolean;
  57930. set depthClamp(value: boolean);
  57931. private _cascadeBlendPercentage;
  57932. /**
  57933. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57934. * It defaults to 0.1 (10% blending).
  57935. */
  57936. get cascadeBlendPercentage(): number;
  57937. set cascadeBlendPercentage(value: number);
  57938. private _lambda;
  57939. /**
  57940. * Gets or set the lambda parameter.
  57941. * This parameter is used to split the camera frustum and create the cascades.
  57942. * 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.
  57943. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57944. */
  57945. get lambda(): number;
  57946. set lambda(value: number);
  57947. /**
  57948. * Gets the view matrix corresponding to a given cascade
  57949. * @param cascadeNum cascade to retrieve the view matrix from
  57950. * @returns the cascade view matrix
  57951. */
  57952. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57953. /**
  57954. * Gets the projection matrix corresponding to a given cascade
  57955. * @param cascadeNum cascade to retrieve the projection matrix from
  57956. * @returns the cascade projection matrix
  57957. */
  57958. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57959. /**
  57960. * Gets the transformation matrix corresponding to a given cascade
  57961. * @param cascadeNum cascade to retrieve the transformation matrix from
  57962. * @returns the cascade transformation matrix
  57963. */
  57964. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57965. private _depthRenderer;
  57966. /**
  57967. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57968. *
  57969. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57970. *
  57971. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57972. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57973. * @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
  57974. */
  57975. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57976. private _depthReducer;
  57977. private _autoCalcDepthBounds;
  57978. /**
  57979. * Gets or sets the autoCalcDepthBounds property.
  57980. *
  57981. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57982. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57983. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57984. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57985. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57986. */
  57987. get autoCalcDepthBounds(): boolean;
  57988. set autoCalcDepthBounds(value: boolean);
  57989. /**
  57990. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57991. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57992. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57993. * for setting the refresh rate on the renderer yourself!
  57994. */
  57995. get autoCalcDepthBoundsRefreshRate(): number;
  57996. set autoCalcDepthBoundsRefreshRate(value: number);
  57997. /**
  57998. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57999. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58000. * you change the camera near/far planes!
  58001. */
  58002. splitFrustum(): void;
  58003. private _splitFrustum;
  58004. private _computeMatrices;
  58005. private _computeFrustumInWorldSpace;
  58006. private _computeCascadeFrustum;
  58007. /**
  58008. * Support test.
  58009. */
  58010. static get IsSupported(): boolean;
  58011. /** @hidden */
  58012. static _SceneComponentInitialization: (scene: Scene) => void;
  58013. /**
  58014. * Creates a Cascaded Shadow Generator object.
  58015. * A ShadowGenerator is the required tool to use the shadows.
  58016. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58017. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58018. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58019. * @param light The directional light object generating the shadows.
  58020. * @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.
  58021. */
  58022. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58023. protected _initializeGenerator(): void;
  58024. protected _createTargetRenderTexture(): void;
  58025. protected _initializeShadowMap(): void;
  58026. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58027. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58028. /**
  58029. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58030. * @param defines Defines of the material we want to update
  58031. * @param lightIndex Index of the light in the enabled light list of the material
  58032. */
  58033. prepareDefines(defines: any, lightIndex: number): void;
  58034. /**
  58035. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58036. * defined in the generator but impacting the effect).
  58037. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58038. * @param effect The effect we are binfing the information for
  58039. */
  58040. bindShadowLight(lightIndex: string, effect: Effect): void;
  58041. /**
  58042. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58043. * (eq to view projection * shadow projection matrices)
  58044. * @returns The transform matrix used to create the shadow map
  58045. */
  58046. getTransformMatrix(): Matrix;
  58047. /**
  58048. * Disposes the ShadowGenerator.
  58049. * Returns nothing.
  58050. */
  58051. dispose(): void;
  58052. /**
  58053. * Serializes the shadow generator setup to a json object.
  58054. * @returns The serialized JSON object
  58055. */
  58056. serialize(): any;
  58057. /**
  58058. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58059. * @param parsedShadowGenerator The JSON object to parse
  58060. * @param scene The scene to create the shadow map for
  58061. * @returns The parsed shadow generator
  58062. */
  58063. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58064. }
  58065. }
  58066. declare module BABYLON {
  58067. /**
  58068. * Defines the shadow generator component responsible to manage any shadow generators
  58069. * in a given scene.
  58070. */
  58071. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58072. /**
  58073. * The component name helpfull to identify the component in the list of scene components.
  58074. */
  58075. readonly name: string;
  58076. /**
  58077. * The scene the component belongs to.
  58078. */
  58079. scene: Scene;
  58080. /**
  58081. * Creates a new instance of the component for the given scene
  58082. * @param scene Defines the scene to register the component in
  58083. */
  58084. constructor(scene: Scene);
  58085. /**
  58086. * Registers the component in a given scene
  58087. */
  58088. register(): void;
  58089. /**
  58090. * Rebuilds the elements related to this component in case of
  58091. * context lost for instance.
  58092. */
  58093. rebuild(): void;
  58094. /**
  58095. * Serializes the component data to the specified json object
  58096. * @param serializationObject The object to serialize to
  58097. */
  58098. serialize(serializationObject: any): void;
  58099. /**
  58100. * Adds all the elements from the container to the scene
  58101. * @param container the container holding the elements
  58102. */
  58103. addFromContainer(container: AbstractScene): void;
  58104. /**
  58105. * Removes all the elements in the container from the scene
  58106. * @param container contains the elements to remove
  58107. * @param dispose if the removed element should be disposed (default: false)
  58108. */
  58109. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58110. /**
  58111. * Rebuilds the elements related to this component in case of
  58112. * context lost for instance.
  58113. */
  58114. dispose(): void;
  58115. private _gatherRenderTargets;
  58116. }
  58117. }
  58118. declare module BABYLON {
  58119. /**
  58120. * A point light is a light defined by an unique point in world space.
  58121. * The light is emitted in every direction from this point.
  58122. * A good example of a point light is a standard light bulb.
  58123. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58124. */
  58125. export class PointLight extends ShadowLight {
  58126. private _shadowAngle;
  58127. /**
  58128. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58129. * This specifies what angle the shadow will use to be created.
  58130. *
  58131. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58132. */
  58133. get shadowAngle(): number;
  58134. /**
  58135. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58136. * This specifies what angle the shadow will use to be created.
  58137. *
  58138. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58139. */
  58140. set shadowAngle(value: number);
  58141. /**
  58142. * Gets the direction if it has been set.
  58143. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58144. */
  58145. get direction(): Vector3;
  58146. /**
  58147. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58148. */
  58149. set direction(value: Vector3);
  58150. /**
  58151. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58152. * A PointLight emits the light in every direction.
  58153. * It can cast shadows.
  58154. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58155. * ```javascript
  58156. * var pointLight = new PointLight("pl", camera.position, scene);
  58157. * ```
  58158. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58159. * @param name The light friendly name
  58160. * @param position The position of the point light in the scene
  58161. * @param scene The scene the lights belongs to
  58162. */
  58163. constructor(name: string, position: Vector3, scene: Scene);
  58164. /**
  58165. * Returns the string "PointLight"
  58166. * @returns the class name
  58167. */
  58168. getClassName(): string;
  58169. /**
  58170. * Returns the integer 0.
  58171. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58172. */
  58173. getTypeID(): number;
  58174. /**
  58175. * Specifies wether or not the shadowmap should be a cube texture.
  58176. * @returns true if the shadowmap needs to be a cube texture.
  58177. */
  58178. needCube(): boolean;
  58179. /**
  58180. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58181. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58182. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58183. */
  58184. getShadowDirection(faceIndex?: number): Vector3;
  58185. /**
  58186. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58187. * - fov = PI / 2
  58188. * - aspect ratio : 1.0
  58189. * - z-near and far equal to the active camera minZ and maxZ.
  58190. * Returns the PointLight.
  58191. */
  58192. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58193. protected _buildUniformLayout(): void;
  58194. /**
  58195. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58196. * @param effect The effect to update
  58197. * @param lightIndex The index of the light in the effect to update
  58198. * @returns The point light
  58199. */
  58200. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58201. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58202. /**
  58203. * Prepares the list of defines specific to the light type.
  58204. * @param defines the list of defines
  58205. * @param lightIndex defines the index of the light for the effect
  58206. */
  58207. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58208. }
  58209. }
  58210. declare module BABYLON {
  58211. /**
  58212. * Header information of HDR texture files.
  58213. */
  58214. export interface HDRInfo {
  58215. /**
  58216. * The height of the texture in pixels.
  58217. */
  58218. height: number;
  58219. /**
  58220. * The width of the texture in pixels.
  58221. */
  58222. width: number;
  58223. /**
  58224. * The index of the beginning of the data in the binary file.
  58225. */
  58226. dataPosition: number;
  58227. }
  58228. /**
  58229. * This groups tools to convert HDR texture to native colors array.
  58230. */
  58231. export class HDRTools {
  58232. private static Ldexp;
  58233. private static Rgbe2float;
  58234. private static readStringLine;
  58235. /**
  58236. * Reads header information from an RGBE texture stored in a native array.
  58237. * More information on this format are available here:
  58238. * https://en.wikipedia.org/wiki/RGBE_image_format
  58239. *
  58240. * @param uint8array The binary file stored in native array.
  58241. * @return The header information.
  58242. */
  58243. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58244. /**
  58245. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58246. * This RGBE texture needs to store the information as a panorama.
  58247. *
  58248. * More information on this format are available here:
  58249. * https://en.wikipedia.org/wiki/RGBE_image_format
  58250. *
  58251. * @param buffer The binary file stored in an array buffer.
  58252. * @param size The expected size of the extracted cubemap.
  58253. * @return The Cube Map information.
  58254. */
  58255. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58256. /**
  58257. * Returns the pixels data extracted from an RGBE texture.
  58258. * This pixels will be stored left to right up to down in the R G B order in one array.
  58259. *
  58260. * More information on this format are available here:
  58261. * https://en.wikipedia.org/wiki/RGBE_image_format
  58262. *
  58263. * @param uint8array The binary file stored in an array buffer.
  58264. * @param hdrInfo The header information of the file.
  58265. * @return The pixels data in RGB right to left up to down order.
  58266. */
  58267. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58268. private static RGBE_ReadPixels_RLE;
  58269. }
  58270. }
  58271. declare module BABYLON {
  58272. /**
  58273. * Effect Render Options
  58274. */
  58275. export interface IEffectRendererOptions {
  58276. /**
  58277. * Defines the vertices positions.
  58278. */
  58279. positions?: number[];
  58280. /**
  58281. * Defines the indices.
  58282. */
  58283. indices?: number[];
  58284. }
  58285. /**
  58286. * Helper class to render one or more effects.
  58287. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58288. */
  58289. export class EffectRenderer {
  58290. private engine;
  58291. private static _DefaultOptions;
  58292. private _vertexBuffers;
  58293. private _indexBuffer;
  58294. private _fullscreenViewport;
  58295. /**
  58296. * Creates an effect renderer
  58297. * @param engine the engine to use for rendering
  58298. * @param options defines the options of the effect renderer
  58299. */
  58300. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58301. /**
  58302. * Sets the current viewport in normalized coordinates 0-1
  58303. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58304. */
  58305. setViewport(viewport?: Viewport): void;
  58306. /**
  58307. * Binds the embedded attributes buffer to the effect.
  58308. * @param effect Defines the effect to bind the attributes for
  58309. */
  58310. bindBuffers(effect: Effect): void;
  58311. /**
  58312. * Sets the current effect wrapper to use during draw.
  58313. * The effect needs to be ready before calling this api.
  58314. * This also sets the default full screen position attribute.
  58315. * @param effectWrapper Defines the effect to draw with
  58316. */
  58317. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58318. /**
  58319. * Restores engine states
  58320. */
  58321. restoreStates(): void;
  58322. /**
  58323. * Draws a full screen quad.
  58324. */
  58325. draw(): void;
  58326. private isRenderTargetTexture;
  58327. /**
  58328. * renders one or more effects to a specified texture
  58329. * @param effectWrapper the effect to renderer
  58330. * @param outputTexture texture to draw to, if null it will render to the screen.
  58331. */
  58332. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58333. /**
  58334. * Disposes of the effect renderer
  58335. */
  58336. dispose(): void;
  58337. }
  58338. /**
  58339. * Options to create an EffectWrapper
  58340. */
  58341. interface EffectWrapperCreationOptions {
  58342. /**
  58343. * Engine to use to create the effect
  58344. */
  58345. engine: ThinEngine;
  58346. /**
  58347. * Fragment shader for the effect
  58348. */
  58349. fragmentShader: string;
  58350. /**
  58351. * Use the shader store instead of direct source code
  58352. */
  58353. useShaderStore?: boolean;
  58354. /**
  58355. * Vertex shader for the effect
  58356. */
  58357. vertexShader?: string;
  58358. /**
  58359. * Attributes to use in the shader
  58360. */
  58361. attributeNames?: Array<string>;
  58362. /**
  58363. * Uniforms to use in the shader
  58364. */
  58365. uniformNames?: Array<string>;
  58366. /**
  58367. * Texture sampler names to use in the shader
  58368. */
  58369. samplerNames?: Array<string>;
  58370. /**
  58371. * Defines to use in the shader
  58372. */
  58373. defines?: Array<string>;
  58374. /**
  58375. * Callback when effect is compiled
  58376. */
  58377. onCompiled?: Nullable<(effect: Effect) => void>;
  58378. /**
  58379. * The friendly name of the effect displayed in Spector.
  58380. */
  58381. name?: string;
  58382. }
  58383. /**
  58384. * Wraps an effect to be used for rendering
  58385. */
  58386. export class EffectWrapper {
  58387. /**
  58388. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58389. */
  58390. onApplyObservable: Observable<{}>;
  58391. /**
  58392. * The underlying effect
  58393. */
  58394. effect: Effect;
  58395. /**
  58396. * Creates an effect to be renderer
  58397. * @param creationOptions options to create the effect
  58398. */
  58399. constructor(creationOptions: EffectWrapperCreationOptions);
  58400. /**
  58401. * Disposes of the effect wrapper
  58402. */
  58403. dispose(): void;
  58404. }
  58405. }
  58406. declare module BABYLON {
  58407. /** @hidden */
  58408. export var hdrFilteringVertexShader: {
  58409. name: string;
  58410. shader: string;
  58411. };
  58412. }
  58413. declare module BABYLON {
  58414. /** @hidden */
  58415. export var hdrFilteringPixelShader: {
  58416. name: string;
  58417. shader: string;
  58418. };
  58419. }
  58420. declare module BABYLON {
  58421. /**
  58422. * Options for texture filtering
  58423. */
  58424. interface IHDRFilteringOptions {
  58425. /**
  58426. * Scales pixel intensity for the input HDR map.
  58427. */
  58428. hdrScale?: number;
  58429. /**
  58430. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58431. */
  58432. quality?: number;
  58433. }
  58434. /**
  58435. * Filters HDR maps to get correct renderings of PBR reflections
  58436. */
  58437. export class HDRFiltering {
  58438. private _engine;
  58439. private _effectRenderer;
  58440. private _effectWrapper;
  58441. private _lodGenerationOffset;
  58442. private _lodGenerationScale;
  58443. /**
  58444. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58445. * you care about baking speed.
  58446. */
  58447. quality: number;
  58448. /**
  58449. * Scales pixel intensity for the input HDR map.
  58450. */
  58451. hdrScale: number;
  58452. /**
  58453. * Instantiates HDR filter for reflection maps
  58454. *
  58455. * @param engine Thin engine
  58456. * @param options Options
  58457. */
  58458. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58459. private _createRenderTarget;
  58460. private _prefilterInternal;
  58461. private _createEffect;
  58462. /**
  58463. * Get a value indicating if the filter is ready to be used
  58464. * @param texture Texture to filter
  58465. * @returns true if the filter is ready
  58466. */
  58467. isReady(texture: BaseTexture): boolean;
  58468. /**
  58469. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58470. * Prefiltering will be invoked at the end of next rendering pass.
  58471. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58472. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58473. * @param texture Texture to filter
  58474. * @param onFinished Callback when filtering is done
  58475. * @return Promise called when prefiltering is done
  58476. */
  58477. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58478. }
  58479. }
  58480. declare module BABYLON {
  58481. /**
  58482. * This represents a texture coming from an HDR input.
  58483. *
  58484. * The only supported format is currently panorama picture stored in RGBE format.
  58485. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58486. */
  58487. export class HDRCubeTexture extends BaseTexture {
  58488. private static _facesMapping;
  58489. private _generateHarmonics;
  58490. private _noMipmap;
  58491. private _prefilterOnLoad;
  58492. private _textureMatrix;
  58493. private _size;
  58494. private _onLoad;
  58495. private _onError;
  58496. /**
  58497. * The texture URL.
  58498. */
  58499. url: string;
  58500. /**
  58501. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58502. */
  58503. coordinatesMode: number;
  58504. protected _isBlocking: boolean;
  58505. /**
  58506. * Sets wether or not the texture is blocking during loading.
  58507. */
  58508. set isBlocking(value: boolean);
  58509. /**
  58510. * Gets wether or not the texture is blocking during loading.
  58511. */
  58512. get isBlocking(): boolean;
  58513. protected _rotationY: number;
  58514. /**
  58515. * Sets texture matrix rotation angle around Y axis in radians.
  58516. */
  58517. set rotationY(value: number);
  58518. /**
  58519. * Gets texture matrix rotation angle around Y axis radians.
  58520. */
  58521. get rotationY(): number;
  58522. /**
  58523. * Gets or sets the center of the bounding box associated with the cube texture
  58524. * It must define where the camera used to render the texture was set
  58525. */
  58526. boundingBoxPosition: Vector3;
  58527. private _boundingBoxSize;
  58528. /**
  58529. * Gets or sets the size of the bounding box associated with the cube texture
  58530. * When defined, the cubemap will switch to local mode
  58531. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58532. * @example https://www.babylonjs-playground.com/#RNASML
  58533. */
  58534. set boundingBoxSize(value: Vector3);
  58535. get boundingBoxSize(): Vector3;
  58536. /**
  58537. * Instantiates an HDRTexture from the following parameters.
  58538. *
  58539. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58540. * @param sceneOrEngine The scene or engine the texture will be used in
  58541. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58542. * @param noMipmap Forces to not generate the mipmap if true
  58543. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58544. * @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)
  58545. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58546. */
  58547. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58548. /**
  58549. * Get the current class name of the texture useful for serialization or dynamic coding.
  58550. * @returns "HDRCubeTexture"
  58551. */
  58552. getClassName(): string;
  58553. /**
  58554. * Occurs when the file is raw .hdr file.
  58555. */
  58556. private loadTexture;
  58557. clone(): HDRCubeTexture;
  58558. delayLoad(): void;
  58559. /**
  58560. * Get the texture reflection matrix used to rotate/transform the reflection.
  58561. * @returns the reflection matrix
  58562. */
  58563. getReflectionTextureMatrix(): Matrix;
  58564. /**
  58565. * Set the texture reflection matrix used to rotate/transform the reflection.
  58566. * @param value Define the reflection matrix to set
  58567. */
  58568. setReflectionTextureMatrix(value: Matrix): void;
  58569. /**
  58570. * Parses a JSON representation of an HDR Texture in order to create the texture
  58571. * @param parsedTexture Define the JSON representation
  58572. * @param scene Define the scene the texture should be created in
  58573. * @param rootUrl Define the root url in case we need to load relative dependencies
  58574. * @returns the newly created texture after parsing
  58575. */
  58576. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58577. serialize(): any;
  58578. }
  58579. }
  58580. declare module BABYLON {
  58581. /**
  58582. * Class used to control physics engine
  58583. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58584. */
  58585. export class PhysicsEngine implements IPhysicsEngine {
  58586. private _physicsPlugin;
  58587. /**
  58588. * Global value used to control the smallest number supported by the simulation
  58589. */
  58590. static Epsilon: number;
  58591. private _impostors;
  58592. private _joints;
  58593. private _subTimeStep;
  58594. /**
  58595. * Gets the gravity vector used by the simulation
  58596. */
  58597. gravity: Vector3;
  58598. /**
  58599. * Factory used to create the default physics plugin.
  58600. * @returns The default physics plugin
  58601. */
  58602. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58603. /**
  58604. * Creates a new Physics Engine
  58605. * @param gravity defines the gravity vector used by the simulation
  58606. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58607. */
  58608. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58609. /**
  58610. * Sets the gravity vector used by the simulation
  58611. * @param gravity defines the gravity vector to use
  58612. */
  58613. setGravity(gravity: Vector3): void;
  58614. /**
  58615. * Set the time step of the physics engine.
  58616. * Default is 1/60.
  58617. * To slow it down, enter 1/600 for example.
  58618. * To speed it up, 1/30
  58619. * @param newTimeStep defines the new timestep to apply to this world.
  58620. */
  58621. setTimeStep(newTimeStep?: number): void;
  58622. /**
  58623. * Get the time step of the physics engine.
  58624. * @returns the current time step
  58625. */
  58626. getTimeStep(): number;
  58627. /**
  58628. * Set the sub time step of the physics engine.
  58629. * Default is 0 meaning there is no sub steps
  58630. * To increase physics resolution precision, set a small value (like 1 ms)
  58631. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58632. */
  58633. setSubTimeStep(subTimeStep?: number): void;
  58634. /**
  58635. * Get the sub time step of the physics engine.
  58636. * @returns the current sub time step
  58637. */
  58638. getSubTimeStep(): number;
  58639. /**
  58640. * Release all resources
  58641. */
  58642. dispose(): void;
  58643. /**
  58644. * Gets the name of the current physics plugin
  58645. * @returns the name of the plugin
  58646. */
  58647. getPhysicsPluginName(): string;
  58648. /**
  58649. * Adding a new impostor for the impostor tracking.
  58650. * This will be done by the impostor itself.
  58651. * @param impostor the impostor to add
  58652. */
  58653. addImpostor(impostor: PhysicsImpostor): void;
  58654. /**
  58655. * Remove an impostor from the engine.
  58656. * This impostor and its mesh will not longer be updated by the physics engine.
  58657. * @param impostor the impostor to remove
  58658. */
  58659. removeImpostor(impostor: PhysicsImpostor): void;
  58660. /**
  58661. * Add a joint to the physics engine
  58662. * @param mainImpostor defines the main impostor to which the joint is added.
  58663. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58664. * @param joint defines the joint that will connect both impostors.
  58665. */
  58666. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58667. /**
  58668. * Removes a joint from the simulation
  58669. * @param mainImpostor defines the impostor used with the joint
  58670. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58671. * @param joint defines the joint to remove
  58672. */
  58673. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58674. /**
  58675. * Called by the scene. No need to call it.
  58676. * @param delta defines the timespam between frames
  58677. */
  58678. _step(delta: number): void;
  58679. /**
  58680. * Gets the current plugin used to run the simulation
  58681. * @returns current plugin
  58682. */
  58683. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58684. /**
  58685. * Gets the list of physic impostors
  58686. * @returns an array of PhysicsImpostor
  58687. */
  58688. getImpostors(): Array<PhysicsImpostor>;
  58689. /**
  58690. * Gets the impostor for a physics enabled object
  58691. * @param object defines the object impersonated by the impostor
  58692. * @returns the PhysicsImpostor or null if not found
  58693. */
  58694. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58695. /**
  58696. * Gets the impostor for a physics body object
  58697. * @param body defines physics body used by the impostor
  58698. * @returns the PhysicsImpostor or null if not found
  58699. */
  58700. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58701. /**
  58702. * Does a raycast in the physics world
  58703. * @param from when should the ray start?
  58704. * @param to when should the ray end?
  58705. * @returns PhysicsRaycastResult
  58706. */
  58707. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58708. }
  58709. }
  58710. declare module BABYLON {
  58711. /** @hidden */
  58712. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58713. private _useDeltaForWorldStep;
  58714. world: any;
  58715. name: string;
  58716. private _physicsMaterials;
  58717. private _fixedTimeStep;
  58718. private _cannonRaycastResult;
  58719. private _raycastResult;
  58720. private _physicsBodysToRemoveAfterStep;
  58721. BJSCANNON: any;
  58722. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58723. setGravity(gravity: Vector3): void;
  58724. setTimeStep(timeStep: number): void;
  58725. getTimeStep(): number;
  58726. executeStep(delta: number): void;
  58727. private _removeMarkedPhysicsBodiesFromWorld;
  58728. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58729. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58730. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58731. private _processChildMeshes;
  58732. removePhysicsBody(impostor: PhysicsImpostor): void;
  58733. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58734. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58735. private _addMaterial;
  58736. private _checkWithEpsilon;
  58737. private _createShape;
  58738. private _createHeightmap;
  58739. private _minus90X;
  58740. private _plus90X;
  58741. private _tmpPosition;
  58742. private _tmpDeltaPosition;
  58743. private _tmpUnityRotation;
  58744. private _updatePhysicsBodyTransformation;
  58745. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58746. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58747. isSupported(): boolean;
  58748. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58749. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58750. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58751. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58752. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58753. getBodyMass(impostor: PhysicsImpostor): number;
  58754. getBodyFriction(impostor: PhysicsImpostor): number;
  58755. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58756. getBodyRestitution(impostor: PhysicsImpostor): number;
  58757. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58758. sleepBody(impostor: PhysicsImpostor): void;
  58759. wakeUpBody(impostor: PhysicsImpostor): void;
  58760. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58761. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58762. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58763. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58764. getRadius(impostor: PhysicsImpostor): number;
  58765. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58766. dispose(): void;
  58767. private _extendNamespace;
  58768. /**
  58769. * Does a raycast in the physics world
  58770. * @param from when should the ray start?
  58771. * @param to when should the ray end?
  58772. * @returns PhysicsRaycastResult
  58773. */
  58774. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58775. }
  58776. }
  58777. declare module BABYLON {
  58778. /** @hidden */
  58779. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58780. private _useDeltaForWorldStep;
  58781. world: any;
  58782. name: string;
  58783. BJSOIMO: any;
  58784. private _raycastResult;
  58785. private _fixedTimeStep;
  58786. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58787. setGravity(gravity: Vector3): void;
  58788. setTimeStep(timeStep: number): void;
  58789. getTimeStep(): number;
  58790. private _tmpImpostorsArray;
  58791. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58792. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58793. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58794. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58795. private _tmpPositionVector;
  58796. removePhysicsBody(impostor: PhysicsImpostor): void;
  58797. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58798. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58799. isSupported(): boolean;
  58800. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58801. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58802. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58803. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58804. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58805. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58806. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58807. getBodyMass(impostor: PhysicsImpostor): number;
  58808. getBodyFriction(impostor: PhysicsImpostor): number;
  58809. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58810. getBodyRestitution(impostor: PhysicsImpostor): number;
  58811. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58812. sleepBody(impostor: PhysicsImpostor): void;
  58813. wakeUpBody(impostor: PhysicsImpostor): void;
  58814. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58815. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58816. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58817. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58818. getRadius(impostor: PhysicsImpostor): number;
  58819. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58820. dispose(): void;
  58821. /**
  58822. * Does a raycast in the physics world
  58823. * @param from when should the ray start?
  58824. * @param to when should the ray end?
  58825. * @returns PhysicsRaycastResult
  58826. */
  58827. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58828. }
  58829. }
  58830. declare module BABYLON {
  58831. /**
  58832. * Class containing static functions to help procedurally build meshes
  58833. */
  58834. export class RibbonBuilder {
  58835. /**
  58836. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58837. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58838. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58839. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58840. * * 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
  58841. * * 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
  58842. * * 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
  58843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58844. * * 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
  58845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58846. * * 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
  58847. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58848. * * 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
  58849. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58851. * @param name defines the name of the mesh
  58852. * @param options defines the options used to create the mesh
  58853. * @param scene defines the hosting scene
  58854. * @returns the ribbon mesh
  58855. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58856. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58857. */
  58858. static CreateRibbon(name: string, options: {
  58859. pathArray: Vector3[][];
  58860. closeArray?: boolean;
  58861. closePath?: boolean;
  58862. offset?: number;
  58863. updatable?: boolean;
  58864. sideOrientation?: number;
  58865. frontUVs?: Vector4;
  58866. backUVs?: Vector4;
  58867. instance?: Mesh;
  58868. invertUV?: boolean;
  58869. uvs?: Vector2[];
  58870. colors?: Color4[];
  58871. }, scene?: Nullable<Scene>): Mesh;
  58872. }
  58873. }
  58874. declare module BABYLON {
  58875. /**
  58876. * Class containing static functions to help procedurally build meshes
  58877. */
  58878. export class ShapeBuilder {
  58879. /**
  58880. * 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.
  58881. * * 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.
  58882. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58883. * * 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.
  58884. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58885. * * 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
  58886. * * 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
  58887. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58889. * * 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
  58890. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58892. * @param name defines the name of the mesh
  58893. * @param options defines the options used to create the mesh
  58894. * @param scene defines the hosting scene
  58895. * @returns the extruded shape mesh
  58896. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58898. */
  58899. static ExtrudeShape(name: string, options: {
  58900. shape: Vector3[];
  58901. path: Vector3[];
  58902. scale?: number;
  58903. rotation?: number;
  58904. cap?: number;
  58905. updatable?: boolean;
  58906. sideOrientation?: number;
  58907. frontUVs?: Vector4;
  58908. backUVs?: Vector4;
  58909. instance?: Mesh;
  58910. invertUV?: boolean;
  58911. }, scene?: Nullable<Scene>): Mesh;
  58912. /**
  58913. * Creates an custom extruded shape mesh.
  58914. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58915. * * 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.
  58916. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58917. * * 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
  58918. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58919. * * 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
  58920. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58921. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58922. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58923. * * 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
  58924. * * 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
  58925. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58927. * * 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
  58928. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58930. * @param name defines the name of the mesh
  58931. * @param options defines the options used to create the mesh
  58932. * @param scene defines the hosting scene
  58933. * @returns the custom extruded shape mesh
  58934. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58935. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58937. */
  58938. static ExtrudeShapeCustom(name: string, options: {
  58939. shape: Vector3[];
  58940. path: Vector3[];
  58941. scaleFunction?: any;
  58942. rotationFunction?: any;
  58943. ribbonCloseArray?: boolean;
  58944. ribbonClosePath?: boolean;
  58945. cap?: number;
  58946. updatable?: boolean;
  58947. sideOrientation?: number;
  58948. frontUVs?: Vector4;
  58949. backUVs?: Vector4;
  58950. instance?: Mesh;
  58951. invertUV?: boolean;
  58952. }, scene?: Nullable<Scene>): Mesh;
  58953. private static _ExtrudeShapeGeneric;
  58954. }
  58955. }
  58956. declare module BABYLON {
  58957. /**
  58958. * AmmoJS Physics plugin
  58959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58960. * @see https://github.com/kripken/ammo.js/
  58961. */
  58962. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58963. private _useDeltaForWorldStep;
  58964. /**
  58965. * Reference to the Ammo library
  58966. */
  58967. bjsAMMO: any;
  58968. /**
  58969. * Created ammoJS world which physics bodies are added to
  58970. */
  58971. world: any;
  58972. /**
  58973. * Name of the plugin
  58974. */
  58975. name: string;
  58976. private _timeStep;
  58977. private _fixedTimeStep;
  58978. private _maxSteps;
  58979. private _tmpQuaternion;
  58980. private _tmpAmmoTransform;
  58981. private _tmpAmmoQuaternion;
  58982. private _tmpAmmoConcreteContactResultCallback;
  58983. private _collisionConfiguration;
  58984. private _dispatcher;
  58985. private _overlappingPairCache;
  58986. private _solver;
  58987. private _softBodySolver;
  58988. private _tmpAmmoVectorA;
  58989. private _tmpAmmoVectorB;
  58990. private _tmpAmmoVectorC;
  58991. private _tmpAmmoVectorD;
  58992. private _tmpContactCallbackResult;
  58993. private _tmpAmmoVectorRCA;
  58994. private _tmpAmmoVectorRCB;
  58995. private _raycastResult;
  58996. private static readonly DISABLE_COLLISION_FLAG;
  58997. private static readonly KINEMATIC_FLAG;
  58998. private static readonly DISABLE_DEACTIVATION_FLAG;
  58999. /**
  59000. * Initializes the ammoJS plugin
  59001. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59002. * @param ammoInjection can be used to inject your own ammo reference
  59003. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59004. */
  59005. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59006. /**
  59007. * Sets the gravity of the physics world (m/(s^2))
  59008. * @param gravity Gravity to set
  59009. */
  59010. setGravity(gravity: Vector3): void;
  59011. /**
  59012. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59013. * @param timeStep timestep to use in seconds
  59014. */
  59015. setTimeStep(timeStep: number): void;
  59016. /**
  59017. * 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)
  59018. * @param fixedTimeStep fixedTimeStep to use in seconds
  59019. */
  59020. setFixedTimeStep(fixedTimeStep: number): void;
  59021. /**
  59022. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59023. * @param maxSteps the maximum number of steps by the physics engine per frame
  59024. */
  59025. setMaxSteps(maxSteps: number): void;
  59026. /**
  59027. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59028. * @returns the current timestep in seconds
  59029. */
  59030. getTimeStep(): number;
  59031. /**
  59032. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59033. */
  59034. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59035. private _isImpostorInContact;
  59036. private _isImpostorPairInContact;
  59037. private _stepSimulation;
  59038. /**
  59039. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59040. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59041. * After the step the babylon meshes are set to the position of the physics imposters
  59042. * @param delta amount of time to step forward
  59043. * @param impostors array of imposters to update before/after the step
  59044. */
  59045. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59046. /**
  59047. * Update babylon mesh to match physics world object
  59048. * @param impostor imposter to match
  59049. */
  59050. private _afterSoftStep;
  59051. /**
  59052. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59053. * @param impostor imposter to match
  59054. */
  59055. private _ropeStep;
  59056. /**
  59057. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59058. * @param impostor imposter to match
  59059. */
  59060. private _softbodyOrClothStep;
  59061. private _tmpMatrix;
  59062. /**
  59063. * Applies an impulse on the imposter
  59064. * @param impostor imposter to apply impulse to
  59065. * @param force amount of force to be applied to the imposter
  59066. * @param contactPoint the location to apply the impulse on the imposter
  59067. */
  59068. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59069. /**
  59070. * Applies a force on the imposter
  59071. * @param impostor imposter to apply force
  59072. * @param force amount of force to be applied to the imposter
  59073. * @param contactPoint the location to apply the force on the imposter
  59074. */
  59075. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59076. /**
  59077. * Creates a physics body using the plugin
  59078. * @param impostor the imposter to create the physics body on
  59079. */
  59080. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59081. /**
  59082. * Removes the physics body from the imposter and disposes of the body's memory
  59083. * @param impostor imposter to remove the physics body from
  59084. */
  59085. removePhysicsBody(impostor: PhysicsImpostor): void;
  59086. /**
  59087. * Generates a joint
  59088. * @param impostorJoint the imposter joint to create the joint with
  59089. */
  59090. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59091. /**
  59092. * Removes a joint
  59093. * @param impostorJoint the imposter joint to remove the joint from
  59094. */
  59095. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59096. private _addMeshVerts;
  59097. /**
  59098. * Initialise the soft body vertices to match its object's (mesh) vertices
  59099. * Softbody vertices (nodes) are in world space and to match this
  59100. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59101. * @param impostor to create the softbody for
  59102. */
  59103. private _softVertexData;
  59104. /**
  59105. * Create an impostor's soft body
  59106. * @param impostor to create the softbody for
  59107. */
  59108. private _createSoftbody;
  59109. /**
  59110. * Create cloth for an impostor
  59111. * @param impostor to create the softbody for
  59112. */
  59113. private _createCloth;
  59114. /**
  59115. * Create rope for an impostor
  59116. * @param impostor to create the softbody for
  59117. */
  59118. private _createRope;
  59119. /**
  59120. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59121. * @param impostor to create the custom physics shape for
  59122. */
  59123. private _createCustom;
  59124. private _addHullVerts;
  59125. private _createShape;
  59126. /**
  59127. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59128. * @param impostor imposter containing the physics body and babylon object
  59129. */
  59130. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59131. /**
  59132. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59133. * @param impostor imposter containing the physics body and babylon object
  59134. * @param newPosition new position
  59135. * @param newRotation new rotation
  59136. */
  59137. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59138. /**
  59139. * If this plugin is supported
  59140. * @returns true if its supported
  59141. */
  59142. isSupported(): boolean;
  59143. /**
  59144. * Sets the linear velocity of the physics body
  59145. * @param impostor imposter to set the velocity on
  59146. * @param velocity velocity to set
  59147. */
  59148. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59149. /**
  59150. * Sets the angular velocity of the physics body
  59151. * @param impostor imposter to set the velocity on
  59152. * @param velocity velocity to set
  59153. */
  59154. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59155. /**
  59156. * gets the linear velocity
  59157. * @param impostor imposter to get linear velocity from
  59158. * @returns linear velocity
  59159. */
  59160. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59161. /**
  59162. * gets the angular velocity
  59163. * @param impostor imposter to get angular velocity from
  59164. * @returns angular velocity
  59165. */
  59166. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59167. /**
  59168. * Sets the mass of physics body
  59169. * @param impostor imposter to set the mass on
  59170. * @param mass mass to set
  59171. */
  59172. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59173. /**
  59174. * Gets the mass of the physics body
  59175. * @param impostor imposter to get the mass from
  59176. * @returns mass
  59177. */
  59178. getBodyMass(impostor: PhysicsImpostor): number;
  59179. /**
  59180. * Gets friction of the impostor
  59181. * @param impostor impostor to get friction from
  59182. * @returns friction value
  59183. */
  59184. getBodyFriction(impostor: PhysicsImpostor): number;
  59185. /**
  59186. * Sets friction of the impostor
  59187. * @param impostor impostor to set friction on
  59188. * @param friction friction value
  59189. */
  59190. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59191. /**
  59192. * Gets restitution of the impostor
  59193. * @param impostor impostor to get restitution from
  59194. * @returns restitution value
  59195. */
  59196. getBodyRestitution(impostor: PhysicsImpostor): number;
  59197. /**
  59198. * Sets resitution of the impostor
  59199. * @param impostor impostor to set resitution on
  59200. * @param restitution resitution value
  59201. */
  59202. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59203. /**
  59204. * Gets pressure inside the impostor
  59205. * @param impostor impostor to get pressure from
  59206. * @returns pressure value
  59207. */
  59208. getBodyPressure(impostor: PhysicsImpostor): number;
  59209. /**
  59210. * Sets pressure inside a soft body impostor
  59211. * Cloth and rope must remain 0 pressure
  59212. * @param impostor impostor to set pressure on
  59213. * @param pressure pressure value
  59214. */
  59215. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59216. /**
  59217. * Gets stiffness of the impostor
  59218. * @param impostor impostor to get stiffness from
  59219. * @returns pressure value
  59220. */
  59221. getBodyStiffness(impostor: PhysicsImpostor): number;
  59222. /**
  59223. * Sets stiffness of the impostor
  59224. * @param impostor impostor to set stiffness on
  59225. * @param stiffness stiffness value from 0 to 1
  59226. */
  59227. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59228. /**
  59229. * Gets velocityIterations of the impostor
  59230. * @param impostor impostor to get velocity iterations from
  59231. * @returns velocityIterations value
  59232. */
  59233. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59234. /**
  59235. * Sets velocityIterations of the impostor
  59236. * @param impostor impostor to set velocity iterations on
  59237. * @param velocityIterations velocityIterations value
  59238. */
  59239. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59240. /**
  59241. * Gets positionIterations of the impostor
  59242. * @param impostor impostor to get position iterations from
  59243. * @returns positionIterations value
  59244. */
  59245. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59246. /**
  59247. * Sets positionIterations of the impostor
  59248. * @param impostor impostor to set position on
  59249. * @param positionIterations positionIterations value
  59250. */
  59251. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59252. /**
  59253. * Append an anchor to a cloth object
  59254. * @param impostor is the cloth impostor to add anchor to
  59255. * @param otherImpostor is the rigid impostor to anchor to
  59256. * @param width ratio across width from 0 to 1
  59257. * @param height ratio up height from 0 to 1
  59258. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59259. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59260. */
  59261. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59262. /**
  59263. * Append an hook to a rope object
  59264. * @param impostor is the rope impostor to add hook to
  59265. * @param otherImpostor is the rigid impostor to hook to
  59266. * @param length ratio along the rope from 0 to 1
  59267. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59268. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59269. */
  59270. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59271. /**
  59272. * Sleeps the physics body and stops it from being active
  59273. * @param impostor impostor to sleep
  59274. */
  59275. sleepBody(impostor: PhysicsImpostor): void;
  59276. /**
  59277. * Activates the physics body
  59278. * @param impostor impostor to activate
  59279. */
  59280. wakeUpBody(impostor: PhysicsImpostor): void;
  59281. /**
  59282. * Updates the distance parameters of the joint
  59283. * @param joint joint to update
  59284. * @param maxDistance maximum distance of the joint
  59285. * @param minDistance minimum distance of the joint
  59286. */
  59287. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59288. /**
  59289. * Sets a motor on the joint
  59290. * @param joint joint to set motor on
  59291. * @param speed speed of the motor
  59292. * @param maxForce maximum force of the motor
  59293. * @param motorIndex index of the motor
  59294. */
  59295. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59296. /**
  59297. * Sets the motors limit
  59298. * @param joint joint to set limit on
  59299. * @param upperLimit upper limit
  59300. * @param lowerLimit lower limit
  59301. */
  59302. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59303. /**
  59304. * Syncs the position and rotation of a mesh with the impostor
  59305. * @param mesh mesh to sync
  59306. * @param impostor impostor to update the mesh with
  59307. */
  59308. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59309. /**
  59310. * Gets the radius of the impostor
  59311. * @param impostor impostor to get radius from
  59312. * @returns the radius
  59313. */
  59314. getRadius(impostor: PhysicsImpostor): number;
  59315. /**
  59316. * Gets the box size of the impostor
  59317. * @param impostor impostor to get box size from
  59318. * @param result the resulting box size
  59319. */
  59320. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59321. /**
  59322. * Disposes of the impostor
  59323. */
  59324. dispose(): void;
  59325. /**
  59326. * Does a raycast in the physics world
  59327. * @param from when should the ray start?
  59328. * @param to when should the ray end?
  59329. * @returns PhysicsRaycastResult
  59330. */
  59331. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59332. }
  59333. }
  59334. declare module BABYLON {
  59335. interface AbstractScene {
  59336. /**
  59337. * The list of reflection probes added to the scene
  59338. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59339. */
  59340. reflectionProbes: Array<ReflectionProbe>;
  59341. /**
  59342. * Removes the given reflection probe from this scene.
  59343. * @param toRemove The reflection probe to remove
  59344. * @returns The index of the removed reflection probe
  59345. */
  59346. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59347. /**
  59348. * Adds the given reflection probe to this scene.
  59349. * @param newReflectionProbe The reflection probe to add
  59350. */
  59351. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59352. }
  59353. /**
  59354. * Class used to generate realtime reflection / refraction cube textures
  59355. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59356. */
  59357. export class ReflectionProbe {
  59358. /** defines the name of the probe */
  59359. name: string;
  59360. private _scene;
  59361. private _renderTargetTexture;
  59362. private _projectionMatrix;
  59363. private _viewMatrix;
  59364. private _target;
  59365. private _add;
  59366. private _attachedMesh;
  59367. private _invertYAxis;
  59368. /** Gets or sets probe position (center of the cube map) */
  59369. position: Vector3;
  59370. /**
  59371. * Creates a new reflection probe
  59372. * @param name defines the name of the probe
  59373. * @param size defines the texture resolution (for each face)
  59374. * @param scene defines the hosting scene
  59375. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59376. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59377. */
  59378. constructor(
  59379. /** defines the name of the probe */
  59380. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59381. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59382. get samples(): number;
  59383. set samples(value: number);
  59384. /** Gets or sets the refresh rate to use (on every frame by default) */
  59385. get refreshRate(): number;
  59386. set refreshRate(value: number);
  59387. /**
  59388. * Gets the hosting scene
  59389. * @returns a Scene
  59390. */
  59391. getScene(): Scene;
  59392. /** Gets the internal CubeTexture used to render to */
  59393. get cubeTexture(): RenderTargetTexture;
  59394. /** Gets the list of meshes to render */
  59395. get renderList(): Nullable<AbstractMesh[]>;
  59396. /**
  59397. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59398. * @param mesh defines the mesh to attach to
  59399. */
  59400. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59401. /**
  59402. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59403. * @param renderingGroupId The rendering group id corresponding to its index
  59404. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59405. */
  59406. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59407. /**
  59408. * Clean all associated resources
  59409. */
  59410. dispose(): void;
  59411. /**
  59412. * Converts the reflection probe information to a readable string for debug purpose.
  59413. * @param fullDetails Supports for multiple levels of logging within scene loading
  59414. * @returns the human readable reflection probe info
  59415. */
  59416. toString(fullDetails?: boolean): string;
  59417. /**
  59418. * Get the class name of the relfection probe.
  59419. * @returns "ReflectionProbe"
  59420. */
  59421. getClassName(): string;
  59422. /**
  59423. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59424. * @returns The JSON representation of the texture
  59425. */
  59426. serialize(): any;
  59427. /**
  59428. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59429. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59430. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59431. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59432. * @returns The parsed reflection probe if successful
  59433. */
  59434. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59435. }
  59436. }
  59437. declare module BABYLON {
  59438. /** @hidden */
  59439. export var _BabylonLoaderRegistered: boolean;
  59440. /**
  59441. * Helps setting up some configuration for the babylon file loader.
  59442. */
  59443. export class BabylonFileLoaderConfiguration {
  59444. /**
  59445. * The loader does not allow injecting custom physix engine into the plugins.
  59446. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59447. * So you could set this variable to your engine import to make it work.
  59448. */
  59449. static LoaderInjectedPhysicsEngine: any;
  59450. }
  59451. }
  59452. declare module BABYLON {
  59453. /**
  59454. * The Physically based simple base material of BJS.
  59455. *
  59456. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59457. * It is used as the base class for both the specGloss and metalRough conventions.
  59458. */
  59459. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59460. /**
  59461. * Number of Simultaneous lights allowed on the material.
  59462. */
  59463. maxSimultaneousLights: number;
  59464. /**
  59465. * If sets to true, disables all the lights affecting the material.
  59466. */
  59467. disableLighting: boolean;
  59468. /**
  59469. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59470. */
  59471. environmentTexture: BaseTexture;
  59472. /**
  59473. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59474. */
  59475. invertNormalMapX: boolean;
  59476. /**
  59477. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59478. */
  59479. invertNormalMapY: boolean;
  59480. /**
  59481. * Normal map used in the model.
  59482. */
  59483. normalTexture: BaseTexture;
  59484. /**
  59485. * Emissivie color used to self-illuminate the model.
  59486. */
  59487. emissiveColor: Color3;
  59488. /**
  59489. * Emissivie texture used to self-illuminate the model.
  59490. */
  59491. emissiveTexture: BaseTexture;
  59492. /**
  59493. * Occlusion Channel Strenght.
  59494. */
  59495. occlusionStrength: number;
  59496. /**
  59497. * Occlusion Texture of the material (adding extra occlusion effects).
  59498. */
  59499. occlusionTexture: BaseTexture;
  59500. /**
  59501. * Defines the alpha limits in alpha test mode.
  59502. */
  59503. alphaCutOff: number;
  59504. /**
  59505. * Gets the current double sided mode.
  59506. */
  59507. get doubleSided(): boolean;
  59508. /**
  59509. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59510. */
  59511. set doubleSided(value: boolean);
  59512. /**
  59513. * Stores the pre-calculated light information of a mesh in a texture.
  59514. */
  59515. lightmapTexture: BaseTexture;
  59516. /**
  59517. * If true, the light map contains occlusion information instead of lighting info.
  59518. */
  59519. useLightmapAsShadowmap: boolean;
  59520. /**
  59521. * Instantiates a new PBRMaterial instance.
  59522. *
  59523. * @param name The material name
  59524. * @param scene The scene the material will be use in.
  59525. */
  59526. constructor(name: string, scene: Scene);
  59527. getClassName(): string;
  59528. }
  59529. }
  59530. declare module BABYLON {
  59531. /**
  59532. * The PBR material of BJS following the metal roughness convention.
  59533. *
  59534. * This fits to the PBR convention in the GLTF definition:
  59535. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59536. */
  59537. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59538. /**
  59539. * The base color has two different interpretations depending on the value of metalness.
  59540. * When the material is a metal, the base color is the specific measured reflectance value
  59541. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59542. * of the material.
  59543. */
  59544. baseColor: Color3;
  59545. /**
  59546. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59547. * well as opacity information in the alpha channel.
  59548. */
  59549. baseTexture: BaseTexture;
  59550. /**
  59551. * Specifies the metallic scalar value of the material.
  59552. * Can also be used to scale the metalness values of the metallic texture.
  59553. */
  59554. metallic: number;
  59555. /**
  59556. * Specifies the roughness scalar value of the material.
  59557. * Can also be used to scale the roughness values of the metallic texture.
  59558. */
  59559. roughness: number;
  59560. /**
  59561. * Texture containing both the metallic value in the B channel and the
  59562. * roughness value in the G channel to keep better precision.
  59563. */
  59564. metallicRoughnessTexture: BaseTexture;
  59565. /**
  59566. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59567. *
  59568. * @param name The material name
  59569. * @param scene The scene the material will be use in.
  59570. */
  59571. constructor(name: string, scene: Scene);
  59572. /**
  59573. * Return the currrent class name of the material.
  59574. */
  59575. getClassName(): string;
  59576. /**
  59577. * Makes a duplicate of the current material.
  59578. * @param name - name to use for the new material.
  59579. */
  59580. clone(name: string): PBRMetallicRoughnessMaterial;
  59581. /**
  59582. * Serialize the material to a parsable JSON object.
  59583. */
  59584. serialize(): any;
  59585. /**
  59586. * Parses a JSON object correponding to the serialize function.
  59587. */
  59588. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59589. }
  59590. }
  59591. declare module BABYLON {
  59592. /**
  59593. * The PBR material of BJS following the specular glossiness convention.
  59594. *
  59595. * This fits to the PBR convention in the GLTF definition:
  59596. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59597. */
  59598. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59599. /**
  59600. * Specifies the diffuse color of the material.
  59601. */
  59602. diffuseColor: Color3;
  59603. /**
  59604. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59605. * channel.
  59606. */
  59607. diffuseTexture: BaseTexture;
  59608. /**
  59609. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59610. */
  59611. specularColor: Color3;
  59612. /**
  59613. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59614. */
  59615. glossiness: number;
  59616. /**
  59617. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59618. */
  59619. specularGlossinessTexture: BaseTexture;
  59620. /**
  59621. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59622. *
  59623. * @param name The material name
  59624. * @param scene The scene the material will be use in.
  59625. */
  59626. constructor(name: string, scene: Scene);
  59627. /**
  59628. * Return the currrent class name of the material.
  59629. */
  59630. getClassName(): string;
  59631. /**
  59632. * Makes a duplicate of the current material.
  59633. * @param name - name to use for the new material.
  59634. */
  59635. clone(name: string): PBRSpecularGlossinessMaterial;
  59636. /**
  59637. * Serialize the material to a parsable JSON object.
  59638. */
  59639. serialize(): any;
  59640. /**
  59641. * Parses a JSON object correponding to the serialize function.
  59642. */
  59643. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59644. }
  59645. }
  59646. declare module BABYLON {
  59647. /**
  59648. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59649. * It can help converting any input color in a desired output one. This can then be used to create effects
  59650. * from sepia, black and white to sixties or futuristic rendering...
  59651. *
  59652. * The only supported format is currently 3dl.
  59653. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59654. */
  59655. export class ColorGradingTexture extends BaseTexture {
  59656. /**
  59657. * The texture URL.
  59658. */
  59659. url: string;
  59660. /**
  59661. * Empty line regex stored for GC.
  59662. */
  59663. private static _noneEmptyLineRegex;
  59664. private _textureMatrix;
  59665. private _onLoad;
  59666. /**
  59667. * Instantiates a ColorGradingTexture from the following parameters.
  59668. *
  59669. * @param url The location of the color gradind data (currently only supporting 3dl)
  59670. * @param sceneOrEngine The scene or engine the texture will be used in
  59671. * @param onLoad defines a callback triggered when the texture has been loaded
  59672. */
  59673. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59674. /**
  59675. * Fires the onload event from the constructor if requested.
  59676. */
  59677. private _triggerOnLoad;
  59678. /**
  59679. * Returns the texture matrix used in most of the material.
  59680. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59681. */
  59682. getTextureMatrix(): Matrix;
  59683. /**
  59684. * Occurs when the file being loaded is a .3dl LUT file.
  59685. */
  59686. private load3dlTexture;
  59687. /**
  59688. * Starts the loading process of the texture.
  59689. */
  59690. private loadTexture;
  59691. /**
  59692. * Clones the color gradind texture.
  59693. */
  59694. clone(): ColorGradingTexture;
  59695. /**
  59696. * Called during delayed load for textures.
  59697. */
  59698. delayLoad(): void;
  59699. /**
  59700. * Parses a color grading texture serialized by Babylon.
  59701. * @param parsedTexture The texture information being parsedTexture
  59702. * @param scene The scene to load the texture in
  59703. * @param rootUrl The root url of the data assets to load
  59704. * @return A color gradind texture
  59705. */
  59706. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59707. /**
  59708. * Serializes the LUT texture to json format.
  59709. */
  59710. serialize(): any;
  59711. }
  59712. }
  59713. declare module BABYLON {
  59714. /**
  59715. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59716. */
  59717. export class EquiRectangularCubeTexture extends BaseTexture {
  59718. /** The six faces of the cube. */
  59719. private static _FacesMapping;
  59720. private _noMipmap;
  59721. private _onLoad;
  59722. private _onError;
  59723. /** The size of the cubemap. */
  59724. private _size;
  59725. /** The buffer of the image. */
  59726. private _buffer;
  59727. /** The width of the input image. */
  59728. private _width;
  59729. /** The height of the input image. */
  59730. private _height;
  59731. /** The URL to the image. */
  59732. url: string;
  59733. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59734. coordinatesMode: number;
  59735. /**
  59736. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59737. * @param url The location of the image
  59738. * @param scene The scene the texture will be used in
  59739. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59740. * @param noMipmap Forces to not generate the mipmap if true
  59741. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59742. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59743. * @param onLoad — defines a callback called when texture is loaded
  59744. * @param onError — defines a callback called if there is an error
  59745. */
  59746. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59747. /**
  59748. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59749. */
  59750. private loadImage;
  59751. /**
  59752. * Convert the image buffer into a cubemap and create a CubeTexture.
  59753. */
  59754. private loadTexture;
  59755. /**
  59756. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59757. * @param buffer The ArrayBuffer that should be converted.
  59758. * @returns The buffer as Float32Array.
  59759. */
  59760. private getFloat32ArrayFromArrayBuffer;
  59761. /**
  59762. * Get the current class name of the texture useful for serialization or dynamic coding.
  59763. * @returns "EquiRectangularCubeTexture"
  59764. */
  59765. getClassName(): string;
  59766. /**
  59767. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59768. * @returns A clone of the current EquiRectangularCubeTexture.
  59769. */
  59770. clone(): EquiRectangularCubeTexture;
  59771. }
  59772. }
  59773. declare module BABYLON {
  59774. /**
  59775. * Defines the options related to the creation of an HtmlElementTexture
  59776. */
  59777. export interface IHtmlElementTextureOptions {
  59778. /**
  59779. * Defines wether mip maps should be created or not.
  59780. */
  59781. generateMipMaps?: boolean;
  59782. /**
  59783. * Defines the sampling mode of the texture.
  59784. */
  59785. samplingMode?: number;
  59786. /**
  59787. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59788. */
  59789. engine: Nullable<ThinEngine>;
  59790. /**
  59791. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59792. */
  59793. scene: Nullable<Scene>;
  59794. }
  59795. /**
  59796. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59797. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59798. * is automatically managed.
  59799. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59800. * in your application.
  59801. *
  59802. * As the update is not automatic, you need to call them manually.
  59803. */
  59804. export class HtmlElementTexture extends BaseTexture {
  59805. /**
  59806. * The texture URL.
  59807. */
  59808. element: HTMLVideoElement | HTMLCanvasElement;
  59809. private static readonly DefaultOptions;
  59810. private _textureMatrix;
  59811. private _isVideo;
  59812. private _generateMipMaps;
  59813. private _samplingMode;
  59814. /**
  59815. * Instantiates a HtmlElementTexture from the following parameters.
  59816. *
  59817. * @param name Defines the name of the texture
  59818. * @param element Defines the video or canvas the texture is filled with
  59819. * @param options Defines the other none mandatory texture creation options
  59820. */
  59821. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59822. private _createInternalTexture;
  59823. /**
  59824. * Returns the texture matrix used in most of the material.
  59825. */
  59826. getTextureMatrix(): Matrix;
  59827. /**
  59828. * Updates the content of the texture.
  59829. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59830. */
  59831. update(invertY?: Nullable<boolean>): void;
  59832. }
  59833. }
  59834. declare module BABYLON {
  59835. /**
  59836. * Based on jsTGALoader - Javascript loader for TGA file
  59837. * By Vincent Thibault
  59838. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59839. */
  59840. export class TGATools {
  59841. private static _TYPE_INDEXED;
  59842. private static _TYPE_RGB;
  59843. private static _TYPE_GREY;
  59844. private static _TYPE_RLE_INDEXED;
  59845. private static _TYPE_RLE_RGB;
  59846. private static _TYPE_RLE_GREY;
  59847. private static _ORIGIN_MASK;
  59848. private static _ORIGIN_SHIFT;
  59849. private static _ORIGIN_BL;
  59850. private static _ORIGIN_BR;
  59851. private static _ORIGIN_UL;
  59852. private static _ORIGIN_UR;
  59853. /**
  59854. * Gets the header of a TGA file
  59855. * @param data defines the TGA data
  59856. * @returns the header
  59857. */
  59858. static GetTGAHeader(data: Uint8Array): any;
  59859. /**
  59860. * Uploads TGA content to a Babylon Texture
  59861. * @hidden
  59862. */
  59863. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59864. /** @hidden */
  59865. 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;
  59866. /** @hidden */
  59867. 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;
  59868. /** @hidden */
  59869. 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;
  59870. /** @hidden */
  59871. 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;
  59872. /** @hidden */
  59873. 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;
  59874. /** @hidden */
  59875. 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;
  59876. }
  59877. }
  59878. declare module BABYLON {
  59879. /**
  59880. * Implementation of the TGA Texture Loader.
  59881. * @hidden
  59882. */
  59883. export class _TGATextureLoader implements IInternalTextureLoader {
  59884. /**
  59885. * Defines wether the loader supports cascade loading the different faces.
  59886. */
  59887. readonly supportCascades: boolean;
  59888. /**
  59889. * This returns if the loader support the current file information.
  59890. * @param extension defines the file extension of the file being loaded
  59891. * @returns true if the loader can load the specified file
  59892. */
  59893. canLoad(extension: string): boolean;
  59894. /**
  59895. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59896. * @param data contains the texture data
  59897. * @param texture defines the BabylonJS internal texture
  59898. * @param createPolynomials will be true if polynomials have been requested
  59899. * @param onLoad defines the callback to trigger once the texture is ready
  59900. * @param onError defines the callback to trigger in case of error
  59901. */
  59902. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59903. /**
  59904. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59905. * @param data contains the texture data
  59906. * @param texture defines the BabylonJS internal texture
  59907. * @param callback defines the method to call once ready to upload
  59908. */
  59909. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59910. }
  59911. }
  59912. declare module BABYLON {
  59913. /**
  59914. * Info about the .basis files
  59915. */
  59916. class BasisFileInfo {
  59917. /**
  59918. * If the file has alpha
  59919. */
  59920. hasAlpha: boolean;
  59921. /**
  59922. * Info about each image of the basis file
  59923. */
  59924. images: Array<{
  59925. levels: Array<{
  59926. width: number;
  59927. height: number;
  59928. transcodedPixels: ArrayBufferView;
  59929. }>;
  59930. }>;
  59931. }
  59932. /**
  59933. * Result of transcoding a basis file
  59934. */
  59935. class TranscodeResult {
  59936. /**
  59937. * Info about the .basis file
  59938. */
  59939. fileInfo: BasisFileInfo;
  59940. /**
  59941. * Format to use when loading the file
  59942. */
  59943. format: number;
  59944. }
  59945. /**
  59946. * Configuration options for the Basis transcoder
  59947. */
  59948. export class BasisTranscodeConfiguration {
  59949. /**
  59950. * Supported compression formats used to determine the supported output format of the transcoder
  59951. */
  59952. supportedCompressionFormats?: {
  59953. /**
  59954. * etc1 compression format
  59955. */
  59956. etc1?: boolean;
  59957. /**
  59958. * s3tc compression format
  59959. */
  59960. s3tc?: boolean;
  59961. /**
  59962. * pvrtc compression format
  59963. */
  59964. pvrtc?: boolean;
  59965. /**
  59966. * etc2 compression format
  59967. */
  59968. etc2?: boolean;
  59969. };
  59970. /**
  59971. * If mipmap levels should be loaded for transcoded images (Default: true)
  59972. */
  59973. loadMipmapLevels?: boolean;
  59974. /**
  59975. * Index of a single image to load (Default: all images)
  59976. */
  59977. loadSingleImage?: number;
  59978. }
  59979. /**
  59980. * Used to load .Basis files
  59981. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59982. */
  59983. export class BasisTools {
  59984. private static _IgnoreSupportedFormats;
  59985. /**
  59986. * URL to use when loading the basis transcoder
  59987. */
  59988. static JSModuleURL: string;
  59989. /**
  59990. * URL to use when loading the wasm module for the transcoder
  59991. */
  59992. static WasmModuleURL: string;
  59993. /**
  59994. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59995. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59996. * @returns internal format corresponding to the Basis format
  59997. */
  59998. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59999. private static _WorkerPromise;
  60000. private static _Worker;
  60001. private static _actionId;
  60002. private static _CreateWorkerAsync;
  60003. /**
  60004. * Transcodes a loaded image file to compressed pixel data
  60005. * @param data image data to transcode
  60006. * @param config configuration options for the transcoding
  60007. * @returns a promise resulting in the transcoded image
  60008. */
  60009. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60010. /**
  60011. * Loads a texture from the transcode result
  60012. * @param texture texture load to
  60013. * @param transcodeResult the result of transcoding the basis file to load from
  60014. */
  60015. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60016. }
  60017. }
  60018. declare module BABYLON {
  60019. /**
  60020. * Loader for .basis file format
  60021. */
  60022. export class _BasisTextureLoader implements IInternalTextureLoader {
  60023. /**
  60024. * Defines whether the loader supports cascade loading the different faces.
  60025. */
  60026. readonly supportCascades: boolean;
  60027. /**
  60028. * This returns if the loader support the current file information.
  60029. * @param extension defines the file extension of the file being loaded
  60030. * @returns true if the loader can load the specified file
  60031. */
  60032. canLoad(extension: string): boolean;
  60033. /**
  60034. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60035. * @param data contains the texture data
  60036. * @param texture defines the BabylonJS internal texture
  60037. * @param createPolynomials will be true if polynomials have been requested
  60038. * @param onLoad defines the callback to trigger once the texture is ready
  60039. * @param onError defines the callback to trigger in case of error
  60040. */
  60041. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60042. /**
  60043. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60044. * @param data contains the texture data
  60045. * @param texture defines the BabylonJS internal texture
  60046. * @param callback defines the method to call once ready to upload
  60047. */
  60048. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60049. }
  60050. }
  60051. declare module BABYLON {
  60052. /**
  60053. * Defines the basic options interface of a TexturePacker Frame
  60054. */
  60055. export interface ITexturePackerFrame {
  60056. /**
  60057. * The frame ID
  60058. */
  60059. id: number;
  60060. /**
  60061. * The frames Scale
  60062. */
  60063. scale: Vector2;
  60064. /**
  60065. * The Frames offset
  60066. */
  60067. offset: Vector2;
  60068. }
  60069. /**
  60070. * This is a support class for frame Data on texture packer sets.
  60071. */
  60072. export class TexturePackerFrame implements ITexturePackerFrame {
  60073. /**
  60074. * The frame ID
  60075. */
  60076. id: number;
  60077. /**
  60078. * The frames Scale
  60079. */
  60080. scale: Vector2;
  60081. /**
  60082. * The Frames offset
  60083. */
  60084. offset: Vector2;
  60085. /**
  60086. * Initializes a texture package frame.
  60087. * @param id The numerical frame identifier
  60088. * @param scale Scalar Vector2 for UV frame
  60089. * @param offset Vector2 for the frame position in UV units.
  60090. * @returns TexturePackerFrame
  60091. */
  60092. constructor(id: number, scale: Vector2, offset: Vector2);
  60093. }
  60094. }
  60095. declare module BABYLON {
  60096. /**
  60097. * Defines the basic options interface of a TexturePacker
  60098. */
  60099. export interface ITexturePackerOptions {
  60100. /**
  60101. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60102. */
  60103. map?: string[];
  60104. /**
  60105. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60106. */
  60107. uvsIn?: string;
  60108. /**
  60109. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60110. */
  60111. uvsOut?: string;
  60112. /**
  60113. * number representing the layout style. Defaults to LAYOUT_STRIP
  60114. */
  60115. layout?: number;
  60116. /**
  60117. * number of columns if using custom column count layout(2). This defaults to 4.
  60118. */
  60119. colnum?: number;
  60120. /**
  60121. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60122. */
  60123. updateInputMeshes?: boolean;
  60124. /**
  60125. * boolean flag to dispose all the source textures. Defaults to true.
  60126. */
  60127. disposeSources?: boolean;
  60128. /**
  60129. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60130. */
  60131. fillBlanks?: boolean;
  60132. /**
  60133. * string value representing the context fill style color. Defaults to 'black'.
  60134. */
  60135. customFillColor?: string;
  60136. /**
  60137. * Width and Height Value of each Frame in the TexturePacker Sets
  60138. */
  60139. frameSize?: number;
  60140. /**
  60141. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60142. */
  60143. paddingRatio?: number;
  60144. /**
  60145. * Number that declares the fill method for the padding gutter.
  60146. */
  60147. paddingMode?: number;
  60148. /**
  60149. * If in SUBUV_COLOR padding mode what color to use.
  60150. */
  60151. paddingColor?: Color3 | Color4;
  60152. }
  60153. /**
  60154. * Defines the basic interface of a TexturePacker JSON File
  60155. */
  60156. export interface ITexturePackerJSON {
  60157. /**
  60158. * The frame ID
  60159. */
  60160. name: string;
  60161. /**
  60162. * The base64 channel data
  60163. */
  60164. sets: any;
  60165. /**
  60166. * The options of the Packer
  60167. */
  60168. options: ITexturePackerOptions;
  60169. /**
  60170. * The frame data of the Packer
  60171. */
  60172. frames: Array<number>;
  60173. }
  60174. /**
  60175. * This is a support class that generates a series of packed texture sets.
  60176. * @see https://doc.babylonjs.com/babylon101/materials
  60177. */
  60178. export class TexturePacker {
  60179. /** Packer Layout Constant 0 */
  60180. static readonly LAYOUT_STRIP: number;
  60181. /** Packer Layout Constant 1 */
  60182. static readonly LAYOUT_POWER2: number;
  60183. /** Packer Layout Constant 2 */
  60184. static readonly LAYOUT_COLNUM: number;
  60185. /** Packer Layout Constant 0 */
  60186. static readonly SUBUV_WRAP: number;
  60187. /** Packer Layout Constant 1 */
  60188. static readonly SUBUV_EXTEND: number;
  60189. /** Packer Layout Constant 2 */
  60190. static readonly SUBUV_COLOR: number;
  60191. /** The Name of the Texture Package */
  60192. name: string;
  60193. /** The scene scope of the TexturePacker */
  60194. scene: Scene;
  60195. /** The Meshes to target */
  60196. meshes: AbstractMesh[];
  60197. /** Arguments passed with the Constructor */
  60198. options: ITexturePackerOptions;
  60199. /** The promise that is started upon initialization */
  60200. promise: Nullable<Promise<TexturePacker | string>>;
  60201. /** The Container object for the channel sets that are generated */
  60202. sets: object;
  60203. /** The Container array for the frames that are generated */
  60204. frames: TexturePackerFrame[];
  60205. /** The expected number of textures the system is parsing. */
  60206. private _expecting;
  60207. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60208. private _paddingValue;
  60209. /**
  60210. * Initializes a texture package series from an array of meshes or a single mesh.
  60211. * @param name The name of the package
  60212. * @param meshes The target meshes to compose the package from
  60213. * @param options The arguments that texture packer should follow while building.
  60214. * @param scene The scene which the textures are scoped to.
  60215. * @returns TexturePacker
  60216. */
  60217. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60218. /**
  60219. * Starts the package process
  60220. * @param resolve The promises resolution function
  60221. * @returns TexturePacker
  60222. */
  60223. private _createFrames;
  60224. /**
  60225. * Calculates the Size of the Channel Sets
  60226. * @returns Vector2
  60227. */
  60228. private _calculateSize;
  60229. /**
  60230. * Calculates the UV data for the frames.
  60231. * @param baseSize the base frameSize
  60232. * @param padding the base frame padding
  60233. * @param dtSize size of the Dynamic Texture for that channel
  60234. * @param dtUnits is 1/dtSize
  60235. * @param update flag to update the input meshes
  60236. */
  60237. private _calculateMeshUVFrames;
  60238. /**
  60239. * Calculates the frames Offset.
  60240. * @param index of the frame
  60241. * @returns Vector2
  60242. */
  60243. private _getFrameOffset;
  60244. /**
  60245. * Updates a Mesh to the frame data
  60246. * @param mesh that is the target
  60247. * @param frameID or the frame index
  60248. */
  60249. private _updateMeshUV;
  60250. /**
  60251. * Updates a Meshes materials to use the texture packer channels
  60252. * @param m is the mesh to target
  60253. * @param force all channels on the packer to be set.
  60254. */
  60255. private _updateTextureReferences;
  60256. /**
  60257. * Public method to set a Mesh to a frame
  60258. * @param m that is the target
  60259. * @param frameID or the frame index
  60260. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60261. */
  60262. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60263. /**
  60264. * Starts the async promise to compile the texture packer.
  60265. * @returns Promise<void>
  60266. */
  60267. processAsync(): Promise<void>;
  60268. /**
  60269. * Disposes all textures associated with this packer
  60270. */
  60271. dispose(): void;
  60272. /**
  60273. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60274. * @param imageType is the image type to use.
  60275. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60276. */
  60277. download(imageType?: string, quality?: number): void;
  60278. /**
  60279. * Public method to load a texturePacker JSON file.
  60280. * @param data of the JSON file in string format.
  60281. */
  60282. updateFromJSON(data: string): void;
  60283. }
  60284. }
  60285. declare module BABYLON {
  60286. /**
  60287. * 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.
  60288. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60289. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60290. */
  60291. export class CustomProceduralTexture extends ProceduralTexture {
  60292. private _animate;
  60293. private _time;
  60294. private _config;
  60295. private _texturePath;
  60296. /**
  60297. * Instantiates a new Custom Procedural Texture.
  60298. * 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.
  60299. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60300. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60301. * @param name Define the name of the texture
  60302. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60303. * @param size Define the size of the texture to create
  60304. * @param scene Define the scene the texture belongs to
  60305. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60306. * @param generateMipMaps Define if the texture should creates mip maps or not
  60307. */
  60308. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60309. private _loadJson;
  60310. /**
  60311. * Is the texture ready to be used ? (rendered at least once)
  60312. * @returns true if ready, otherwise, false.
  60313. */
  60314. isReady(): boolean;
  60315. /**
  60316. * Render the texture to its associated render target.
  60317. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60318. */
  60319. render(useCameraPostProcess?: boolean): void;
  60320. /**
  60321. * Update the list of dependant textures samplers in the shader.
  60322. */
  60323. updateTextures(): void;
  60324. /**
  60325. * Update the uniform values of the procedural texture in the shader.
  60326. */
  60327. updateShaderUniforms(): void;
  60328. /**
  60329. * Define if the texture animates or not.
  60330. */
  60331. get animate(): boolean;
  60332. set animate(value: boolean);
  60333. }
  60334. }
  60335. declare module BABYLON {
  60336. /** @hidden */
  60337. export var noisePixelShader: {
  60338. name: string;
  60339. shader: string;
  60340. };
  60341. }
  60342. declare module BABYLON {
  60343. /**
  60344. * Class used to generate noise procedural textures
  60345. */
  60346. export class NoiseProceduralTexture extends ProceduralTexture {
  60347. private _time;
  60348. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60349. brightness: number;
  60350. /** Defines the number of octaves to process */
  60351. octaves: number;
  60352. /** Defines the level of persistence (0.8 by default) */
  60353. persistence: number;
  60354. /** Gets or sets animation speed factor (default is 1) */
  60355. animationSpeedFactor: number;
  60356. /**
  60357. * Creates a new NoiseProceduralTexture
  60358. * @param name defines the name fo the texture
  60359. * @param size defines the size of the texture (default is 256)
  60360. * @param scene defines the hosting scene
  60361. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60362. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60363. */
  60364. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60365. private _updateShaderUniforms;
  60366. protected _getDefines(): string;
  60367. /** Generate the current state of the procedural texture */
  60368. render(useCameraPostProcess?: boolean): void;
  60369. /**
  60370. * Serializes this noise procedural texture
  60371. * @returns a serialized noise procedural texture object
  60372. */
  60373. serialize(): any;
  60374. /**
  60375. * Clone the texture.
  60376. * @returns the cloned texture
  60377. */
  60378. clone(): NoiseProceduralTexture;
  60379. /**
  60380. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60381. * @param parsedTexture defines parsed texture data
  60382. * @param scene defines the current scene
  60383. * @param rootUrl defines the root URL containing noise procedural texture information
  60384. * @returns a parsed NoiseProceduralTexture
  60385. */
  60386. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60387. }
  60388. }
  60389. declare module BABYLON {
  60390. /**
  60391. * Raw cube texture where the raw buffers are passed in
  60392. */
  60393. export class RawCubeTexture extends CubeTexture {
  60394. /**
  60395. * Creates a cube texture where the raw buffers are passed in.
  60396. * @param scene defines the scene the texture is attached to
  60397. * @param data defines the array of data to use to create each face
  60398. * @param size defines the size of the textures
  60399. * @param format defines the format of the data
  60400. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60401. * @param generateMipMaps defines if the engine should generate the mip levels
  60402. * @param invertY defines if data must be stored with Y axis inverted
  60403. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60404. * @param compression defines the compression used (null by default)
  60405. */
  60406. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60407. /**
  60408. * Updates the raw cube texture.
  60409. * @param data defines the data to store
  60410. * @param format defines the data format
  60411. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60412. * @param invertY defines if data must be stored with Y axis inverted
  60413. * @param compression defines the compression used (null by default)
  60414. * @param level defines which level of the texture to update
  60415. */
  60416. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60417. /**
  60418. * Updates a raw cube texture with RGBD encoded data.
  60419. * @param data defines the array of data [mipmap][face] to use to create each face
  60420. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60421. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60422. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60423. * @returns a promsie that resolves when the operation is complete
  60424. */
  60425. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60426. /**
  60427. * Clones the raw cube texture.
  60428. * @return a new cube texture
  60429. */
  60430. clone(): CubeTexture;
  60431. /** @hidden */
  60432. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60433. }
  60434. }
  60435. declare module BABYLON {
  60436. /**
  60437. * Class used to store 2D array textures containing user data
  60438. */
  60439. export class RawTexture2DArray extends Texture {
  60440. /** Gets or sets the texture format to use */
  60441. format: number;
  60442. /**
  60443. * Create a new RawTexture2DArray
  60444. * @param data defines the data of the texture
  60445. * @param width defines the width of the texture
  60446. * @param height defines the height of the texture
  60447. * @param depth defines the number of layers of the texture
  60448. * @param format defines the texture format to use
  60449. * @param scene defines the hosting scene
  60450. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60451. * @param invertY defines if texture must be stored with Y axis inverted
  60452. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60453. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60454. */
  60455. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60456. /** Gets or sets the texture format to use */
  60457. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60458. /**
  60459. * Update the texture with new data
  60460. * @param data defines the data to store in the texture
  60461. */
  60462. update(data: ArrayBufferView): void;
  60463. }
  60464. }
  60465. declare module BABYLON {
  60466. /**
  60467. * Class used to store 3D textures containing user data
  60468. */
  60469. export class RawTexture3D extends Texture {
  60470. /** Gets or sets the texture format to use */
  60471. format: number;
  60472. /**
  60473. * Create a new RawTexture3D
  60474. * @param data defines the data of the texture
  60475. * @param width defines the width of the texture
  60476. * @param height defines the height of the texture
  60477. * @param depth defines the depth of the texture
  60478. * @param format defines the texture format to use
  60479. * @param scene defines the hosting scene
  60480. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60481. * @param invertY defines if texture must be stored with Y axis inverted
  60482. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60483. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60484. */
  60485. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60486. /** Gets or sets the texture format to use */
  60487. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60488. /**
  60489. * Update the texture with new data
  60490. * @param data defines the data to store in the texture
  60491. */
  60492. update(data: ArrayBufferView): void;
  60493. }
  60494. }
  60495. declare module BABYLON {
  60496. /**
  60497. * Creates a refraction texture used by refraction channel of the standard material.
  60498. * It is like a mirror but to see through a material.
  60499. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60500. */
  60501. export class RefractionTexture extends RenderTargetTexture {
  60502. /**
  60503. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60504. * 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.
  60505. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60506. */
  60507. refractionPlane: Plane;
  60508. /**
  60509. * Define how deep under the surface we should see.
  60510. */
  60511. depth: number;
  60512. /**
  60513. * Creates a refraction texture used by refraction channel of the standard material.
  60514. * It is like a mirror but to see through a material.
  60515. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60516. * @param name Define the texture name
  60517. * @param size Define the size of the underlying texture
  60518. * @param scene Define the scene the refraction belongs to
  60519. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60520. */
  60521. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60522. /**
  60523. * Clone the refraction texture.
  60524. * @returns the cloned texture
  60525. */
  60526. clone(): RefractionTexture;
  60527. /**
  60528. * Serialize the texture to a JSON representation you could use in Parse later on
  60529. * @returns the serialized JSON representation
  60530. */
  60531. serialize(): any;
  60532. }
  60533. }
  60534. declare module BABYLON {
  60535. /**
  60536. * Block used to add support for vertex skinning (bones)
  60537. */
  60538. export class BonesBlock extends NodeMaterialBlock {
  60539. /**
  60540. * Creates a new BonesBlock
  60541. * @param name defines the block name
  60542. */
  60543. constructor(name: string);
  60544. /**
  60545. * Initialize the block and prepare the context for build
  60546. * @param state defines the state that will be used for the build
  60547. */
  60548. initialize(state: NodeMaterialBuildState): void;
  60549. /**
  60550. * Gets the current class name
  60551. * @returns the class name
  60552. */
  60553. getClassName(): string;
  60554. /**
  60555. * Gets the matrix indices input component
  60556. */
  60557. get matricesIndices(): NodeMaterialConnectionPoint;
  60558. /**
  60559. * Gets the matrix weights input component
  60560. */
  60561. get matricesWeights(): NodeMaterialConnectionPoint;
  60562. /**
  60563. * Gets the extra matrix indices input component
  60564. */
  60565. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60566. /**
  60567. * Gets the extra matrix weights input component
  60568. */
  60569. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60570. /**
  60571. * Gets the world input component
  60572. */
  60573. get world(): NodeMaterialConnectionPoint;
  60574. /**
  60575. * Gets the output component
  60576. */
  60577. get output(): NodeMaterialConnectionPoint;
  60578. autoConfigure(material: NodeMaterial): void;
  60579. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60580. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60582. protected _buildBlock(state: NodeMaterialBuildState): this;
  60583. }
  60584. }
  60585. declare module BABYLON {
  60586. /**
  60587. * Block used to add support for instances
  60588. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60589. */
  60590. export class InstancesBlock extends NodeMaterialBlock {
  60591. /**
  60592. * Creates a new InstancesBlock
  60593. * @param name defines the block name
  60594. */
  60595. constructor(name: string);
  60596. /**
  60597. * Gets the current class name
  60598. * @returns the class name
  60599. */
  60600. getClassName(): string;
  60601. /**
  60602. * Gets the first world row input component
  60603. */
  60604. get world0(): NodeMaterialConnectionPoint;
  60605. /**
  60606. * Gets the second world row input component
  60607. */
  60608. get world1(): NodeMaterialConnectionPoint;
  60609. /**
  60610. * Gets the third world row input component
  60611. */
  60612. get world2(): NodeMaterialConnectionPoint;
  60613. /**
  60614. * Gets the forth world row input component
  60615. */
  60616. get world3(): NodeMaterialConnectionPoint;
  60617. /**
  60618. * Gets the world input component
  60619. */
  60620. get world(): NodeMaterialConnectionPoint;
  60621. /**
  60622. * Gets the output component
  60623. */
  60624. get output(): NodeMaterialConnectionPoint;
  60625. /**
  60626. * Gets the isntanceID component
  60627. */
  60628. get instanceID(): NodeMaterialConnectionPoint;
  60629. autoConfigure(material: NodeMaterial): void;
  60630. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60631. protected _buildBlock(state: NodeMaterialBuildState): this;
  60632. }
  60633. }
  60634. declare module BABYLON {
  60635. /**
  60636. * Block used to add morph targets support to vertex shader
  60637. */
  60638. export class MorphTargetsBlock extends NodeMaterialBlock {
  60639. private _repeatableContentAnchor;
  60640. /**
  60641. * Create a new MorphTargetsBlock
  60642. * @param name defines the block name
  60643. */
  60644. constructor(name: string);
  60645. /**
  60646. * Gets the current class name
  60647. * @returns the class name
  60648. */
  60649. getClassName(): string;
  60650. /**
  60651. * Gets the position input component
  60652. */
  60653. get position(): NodeMaterialConnectionPoint;
  60654. /**
  60655. * Gets the normal input component
  60656. */
  60657. get normal(): NodeMaterialConnectionPoint;
  60658. /**
  60659. * Gets the tangent input component
  60660. */
  60661. get tangent(): NodeMaterialConnectionPoint;
  60662. /**
  60663. * Gets the tangent input component
  60664. */
  60665. get uv(): NodeMaterialConnectionPoint;
  60666. /**
  60667. * Gets the position output component
  60668. */
  60669. get positionOutput(): NodeMaterialConnectionPoint;
  60670. /**
  60671. * Gets the normal output component
  60672. */
  60673. get normalOutput(): NodeMaterialConnectionPoint;
  60674. /**
  60675. * Gets the tangent output component
  60676. */
  60677. get tangentOutput(): NodeMaterialConnectionPoint;
  60678. /**
  60679. * Gets the tangent output component
  60680. */
  60681. get uvOutput(): NodeMaterialConnectionPoint;
  60682. initialize(state: NodeMaterialBuildState): void;
  60683. autoConfigure(material: NodeMaterial): void;
  60684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60685. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60686. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60687. protected _buildBlock(state: NodeMaterialBuildState): this;
  60688. }
  60689. }
  60690. declare module BABYLON {
  60691. /**
  60692. * Block used to get data information from a light
  60693. */
  60694. export class LightInformationBlock extends NodeMaterialBlock {
  60695. private _lightDataUniformName;
  60696. private _lightColorUniformName;
  60697. private _lightTypeDefineName;
  60698. /**
  60699. * Gets or sets the light associated with this block
  60700. */
  60701. light: Nullable<Light>;
  60702. /**
  60703. * Creates a new LightInformationBlock
  60704. * @param name defines the block name
  60705. */
  60706. constructor(name: string);
  60707. /**
  60708. * Gets the current class name
  60709. * @returns the class name
  60710. */
  60711. getClassName(): string;
  60712. /**
  60713. * Gets the world position input component
  60714. */
  60715. get worldPosition(): NodeMaterialConnectionPoint;
  60716. /**
  60717. * Gets the direction output component
  60718. */
  60719. get direction(): NodeMaterialConnectionPoint;
  60720. /**
  60721. * Gets the direction output component
  60722. */
  60723. get color(): NodeMaterialConnectionPoint;
  60724. /**
  60725. * Gets the direction output component
  60726. */
  60727. get intensity(): NodeMaterialConnectionPoint;
  60728. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60730. protected _buildBlock(state: NodeMaterialBuildState): this;
  60731. serialize(): any;
  60732. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60733. }
  60734. }
  60735. declare module BABYLON {
  60736. /**
  60737. * Block used to add image processing support to fragment shader
  60738. */
  60739. export class ImageProcessingBlock extends NodeMaterialBlock {
  60740. /**
  60741. * Create a new ImageProcessingBlock
  60742. * @param name defines the block name
  60743. */
  60744. constructor(name: string);
  60745. /**
  60746. * Gets the current class name
  60747. * @returns the class name
  60748. */
  60749. getClassName(): string;
  60750. /**
  60751. * Gets the color input component
  60752. */
  60753. get color(): NodeMaterialConnectionPoint;
  60754. /**
  60755. * Gets the output component
  60756. */
  60757. get output(): NodeMaterialConnectionPoint;
  60758. /**
  60759. * Initialize the block and prepare the context for build
  60760. * @param state defines the state that will be used for the build
  60761. */
  60762. initialize(state: NodeMaterialBuildState): void;
  60763. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60765. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60766. protected _buildBlock(state: NodeMaterialBuildState): this;
  60767. }
  60768. }
  60769. declare module BABYLON {
  60770. /**
  60771. * Block used to pertub normals based on a normal map
  60772. */
  60773. export class PerturbNormalBlock extends NodeMaterialBlock {
  60774. private _tangentSpaceParameterName;
  60775. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60776. invertX: boolean;
  60777. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60778. invertY: boolean;
  60779. /**
  60780. * Create a new PerturbNormalBlock
  60781. * @param name defines the block name
  60782. */
  60783. constructor(name: string);
  60784. /**
  60785. * Gets the current class name
  60786. * @returns the class name
  60787. */
  60788. getClassName(): string;
  60789. /**
  60790. * Gets the world position input component
  60791. */
  60792. get worldPosition(): NodeMaterialConnectionPoint;
  60793. /**
  60794. * Gets the world normal input component
  60795. */
  60796. get worldNormal(): NodeMaterialConnectionPoint;
  60797. /**
  60798. * Gets the world tangent input component
  60799. */
  60800. get worldTangent(): NodeMaterialConnectionPoint;
  60801. /**
  60802. * Gets the uv input component
  60803. */
  60804. get uv(): NodeMaterialConnectionPoint;
  60805. /**
  60806. * Gets the normal map color input component
  60807. */
  60808. get normalMapColor(): NodeMaterialConnectionPoint;
  60809. /**
  60810. * Gets the strength input component
  60811. */
  60812. get strength(): NodeMaterialConnectionPoint;
  60813. /**
  60814. * Gets the output component
  60815. */
  60816. get output(): NodeMaterialConnectionPoint;
  60817. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60818. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60819. autoConfigure(material: NodeMaterial): void;
  60820. protected _buildBlock(state: NodeMaterialBuildState): this;
  60821. protected _dumpPropertiesCode(): string;
  60822. serialize(): any;
  60823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60824. }
  60825. }
  60826. declare module BABYLON {
  60827. /**
  60828. * Block used to discard a pixel if a value is smaller than a cutoff
  60829. */
  60830. export class DiscardBlock extends NodeMaterialBlock {
  60831. /**
  60832. * Create a new DiscardBlock
  60833. * @param name defines the block name
  60834. */
  60835. constructor(name: string);
  60836. /**
  60837. * Gets the current class name
  60838. * @returns the class name
  60839. */
  60840. getClassName(): string;
  60841. /**
  60842. * Gets the color input component
  60843. */
  60844. get value(): NodeMaterialConnectionPoint;
  60845. /**
  60846. * Gets the cutoff input component
  60847. */
  60848. get cutoff(): NodeMaterialConnectionPoint;
  60849. protected _buildBlock(state: NodeMaterialBuildState): this;
  60850. }
  60851. }
  60852. declare module BABYLON {
  60853. /**
  60854. * Block used to test if the fragment shader is front facing
  60855. */
  60856. export class FrontFacingBlock extends NodeMaterialBlock {
  60857. /**
  60858. * Creates a new FrontFacingBlock
  60859. * @param name defines the block name
  60860. */
  60861. constructor(name: string);
  60862. /**
  60863. * Gets the current class name
  60864. * @returns the class name
  60865. */
  60866. getClassName(): string;
  60867. /**
  60868. * Gets the output component
  60869. */
  60870. get output(): NodeMaterialConnectionPoint;
  60871. protected _buildBlock(state: NodeMaterialBuildState): this;
  60872. }
  60873. }
  60874. declare module BABYLON {
  60875. /**
  60876. * Block used to get the derivative value on x and y of a given input
  60877. */
  60878. export class DerivativeBlock extends NodeMaterialBlock {
  60879. /**
  60880. * Create a new DerivativeBlock
  60881. * @param name defines the block name
  60882. */
  60883. constructor(name: string);
  60884. /**
  60885. * Gets the current class name
  60886. * @returns the class name
  60887. */
  60888. getClassName(): string;
  60889. /**
  60890. * Gets the input component
  60891. */
  60892. get input(): NodeMaterialConnectionPoint;
  60893. /**
  60894. * Gets the derivative output on x
  60895. */
  60896. get dx(): NodeMaterialConnectionPoint;
  60897. /**
  60898. * Gets the derivative output on y
  60899. */
  60900. get dy(): NodeMaterialConnectionPoint;
  60901. protected _buildBlock(state: NodeMaterialBuildState): this;
  60902. }
  60903. }
  60904. declare module BABYLON {
  60905. /**
  60906. * Block used to add support for scene fog
  60907. */
  60908. export class FogBlock extends NodeMaterialBlock {
  60909. private _fogDistanceName;
  60910. private _fogParameters;
  60911. /**
  60912. * Create a new FogBlock
  60913. * @param name defines the block name
  60914. */
  60915. constructor(name: string);
  60916. /**
  60917. * Gets the current class name
  60918. * @returns the class name
  60919. */
  60920. getClassName(): string;
  60921. /**
  60922. * Gets the world position input component
  60923. */
  60924. get worldPosition(): NodeMaterialConnectionPoint;
  60925. /**
  60926. * Gets the view input component
  60927. */
  60928. get view(): NodeMaterialConnectionPoint;
  60929. /**
  60930. * Gets the color input component
  60931. */
  60932. get input(): NodeMaterialConnectionPoint;
  60933. /**
  60934. * Gets the fog color input component
  60935. */
  60936. get fogColor(): NodeMaterialConnectionPoint;
  60937. /**
  60938. * Gets the output component
  60939. */
  60940. get output(): NodeMaterialConnectionPoint;
  60941. autoConfigure(material: NodeMaterial): void;
  60942. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60943. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60944. protected _buildBlock(state: NodeMaterialBuildState): this;
  60945. }
  60946. }
  60947. declare module BABYLON {
  60948. /**
  60949. * Block used to add light in the fragment shader
  60950. */
  60951. export class LightBlock extends NodeMaterialBlock {
  60952. private _lightId;
  60953. /**
  60954. * Gets or sets the light associated with this block
  60955. */
  60956. light: Nullable<Light>;
  60957. /**
  60958. * Create a new LightBlock
  60959. * @param name defines the block name
  60960. */
  60961. constructor(name: string);
  60962. /**
  60963. * Gets the current class name
  60964. * @returns the class name
  60965. */
  60966. getClassName(): string;
  60967. /**
  60968. * Gets the world position input component
  60969. */
  60970. get worldPosition(): NodeMaterialConnectionPoint;
  60971. /**
  60972. * Gets the world normal input component
  60973. */
  60974. get worldNormal(): NodeMaterialConnectionPoint;
  60975. /**
  60976. * Gets the camera (or eye) position component
  60977. */
  60978. get cameraPosition(): NodeMaterialConnectionPoint;
  60979. /**
  60980. * Gets the glossiness component
  60981. */
  60982. get glossiness(): NodeMaterialConnectionPoint;
  60983. /**
  60984. * Gets the glossinness power component
  60985. */
  60986. get glossPower(): NodeMaterialConnectionPoint;
  60987. /**
  60988. * Gets the diffuse color component
  60989. */
  60990. get diffuseColor(): NodeMaterialConnectionPoint;
  60991. /**
  60992. * Gets the specular color component
  60993. */
  60994. get specularColor(): NodeMaterialConnectionPoint;
  60995. /**
  60996. * Gets the diffuse output component
  60997. */
  60998. get diffuseOutput(): NodeMaterialConnectionPoint;
  60999. /**
  61000. * Gets the specular output component
  61001. */
  61002. get specularOutput(): NodeMaterialConnectionPoint;
  61003. /**
  61004. * Gets the shadow output component
  61005. */
  61006. get shadow(): NodeMaterialConnectionPoint;
  61007. autoConfigure(material: NodeMaterial): void;
  61008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61009. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61011. private _injectVertexCode;
  61012. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61013. serialize(): any;
  61014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61015. }
  61016. }
  61017. declare module BABYLON {
  61018. /**
  61019. * Block used to read a reflection texture from a sampler
  61020. */
  61021. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61022. /**
  61023. * Create a new ReflectionTextureBlock
  61024. * @param name defines the block name
  61025. */
  61026. constructor(name: string);
  61027. /**
  61028. * Gets the current class name
  61029. * @returns the class name
  61030. */
  61031. getClassName(): string;
  61032. /**
  61033. * Gets the world position input component
  61034. */
  61035. get position(): NodeMaterialConnectionPoint;
  61036. /**
  61037. * Gets the world position input component
  61038. */
  61039. get worldPosition(): NodeMaterialConnectionPoint;
  61040. /**
  61041. * Gets the world normal input component
  61042. */
  61043. get worldNormal(): NodeMaterialConnectionPoint;
  61044. /**
  61045. * Gets the world input component
  61046. */
  61047. get world(): NodeMaterialConnectionPoint;
  61048. /**
  61049. * Gets the camera (or eye) position component
  61050. */
  61051. get cameraPosition(): NodeMaterialConnectionPoint;
  61052. /**
  61053. * Gets the view input component
  61054. */
  61055. get view(): NodeMaterialConnectionPoint;
  61056. /**
  61057. * Gets the rgb output component
  61058. */
  61059. get rgb(): NodeMaterialConnectionPoint;
  61060. /**
  61061. * Gets the r output component
  61062. */
  61063. get r(): NodeMaterialConnectionPoint;
  61064. /**
  61065. * Gets the g output component
  61066. */
  61067. get g(): NodeMaterialConnectionPoint;
  61068. /**
  61069. * Gets the b output component
  61070. */
  61071. get b(): NodeMaterialConnectionPoint;
  61072. autoConfigure(material: NodeMaterial): void;
  61073. protected _buildBlock(state: NodeMaterialBuildState): this;
  61074. }
  61075. }
  61076. declare module BABYLON {
  61077. /**
  61078. * Block used to add 2 vectors
  61079. */
  61080. export class AddBlock extends NodeMaterialBlock {
  61081. /**
  61082. * Creates a new AddBlock
  61083. * @param name defines the block name
  61084. */
  61085. constructor(name: string);
  61086. /**
  61087. * Gets the current class name
  61088. * @returns the class name
  61089. */
  61090. getClassName(): string;
  61091. /**
  61092. * Gets the left operand input component
  61093. */
  61094. get left(): NodeMaterialConnectionPoint;
  61095. /**
  61096. * Gets the right operand input component
  61097. */
  61098. get right(): NodeMaterialConnectionPoint;
  61099. /**
  61100. * Gets the output component
  61101. */
  61102. get output(): NodeMaterialConnectionPoint;
  61103. protected _buildBlock(state: NodeMaterialBuildState): this;
  61104. }
  61105. }
  61106. declare module BABYLON {
  61107. /**
  61108. * Block used to scale a vector by a float
  61109. */
  61110. export class ScaleBlock extends NodeMaterialBlock {
  61111. /**
  61112. * Creates a new ScaleBlock
  61113. * @param name defines the block name
  61114. */
  61115. constructor(name: string);
  61116. /**
  61117. * Gets the current class name
  61118. * @returns the class name
  61119. */
  61120. getClassName(): string;
  61121. /**
  61122. * Gets the input component
  61123. */
  61124. get input(): NodeMaterialConnectionPoint;
  61125. /**
  61126. * Gets the factor input component
  61127. */
  61128. get factor(): NodeMaterialConnectionPoint;
  61129. /**
  61130. * Gets the output component
  61131. */
  61132. get output(): NodeMaterialConnectionPoint;
  61133. protected _buildBlock(state: NodeMaterialBuildState): this;
  61134. }
  61135. }
  61136. declare module BABYLON {
  61137. /**
  61138. * Block used to clamp a float
  61139. */
  61140. export class ClampBlock extends NodeMaterialBlock {
  61141. /** Gets or sets the minimum range */
  61142. minimum: number;
  61143. /** Gets or sets the maximum range */
  61144. maximum: number;
  61145. /**
  61146. * Creates a new ClampBlock
  61147. * @param name defines the block name
  61148. */
  61149. constructor(name: string);
  61150. /**
  61151. * Gets the current class name
  61152. * @returns the class name
  61153. */
  61154. getClassName(): string;
  61155. /**
  61156. * Gets the value input component
  61157. */
  61158. get value(): NodeMaterialConnectionPoint;
  61159. /**
  61160. * Gets the output component
  61161. */
  61162. get output(): NodeMaterialConnectionPoint;
  61163. protected _buildBlock(state: NodeMaterialBuildState): this;
  61164. protected _dumpPropertiesCode(): string;
  61165. serialize(): any;
  61166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61167. }
  61168. }
  61169. declare module BABYLON {
  61170. /**
  61171. * Block used to apply a cross product between 2 vectors
  61172. */
  61173. export class CrossBlock extends NodeMaterialBlock {
  61174. /**
  61175. * Creates a new CrossBlock
  61176. * @param name defines the block name
  61177. */
  61178. constructor(name: string);
  61179. /**
  61180. * Gets the current class name
  61181. * @returns the class name
  61182. */
  61183. getClassName(): string;
  61184. /**
  61185. * Gets the left operand input component
  61186. */
  61187. get left(): NodeMaterialConnectionPoint;
  61188. /**
  61189. * Gets the right operand input component
  61190. */
  61191. get right(): NodeMaterialConnectionPoint;
  61192. /**
  61193. * Gets the output component
  61194. */
  61195. get output(): NodeMaterialConnectionPoint;
  61196. protected _buildBlock(state: NodeMaterialBuildState): this;
  61197. }
  61198. }
  61199. declare module BABYLON {
  61200. /**
  61201. * Block used to apply a dot product between 2 vectors
  61202. */
  61203. export class DotBlock extends NodeMaterialBlock {
  61204. /**
  61205. * Creates a new DotBlock
  61206. * @param name defines the block name
  61207. */
  61208. constructor(name: string);
  61209. /**
  61210. * Gets the current class name
  61211. * @returns the class name
  61212. */
  61213. getClassName(): string;
  61214. /**
  61215. * Gets the left operand input component
  61216. */
  61217. get left(): NodeMaterialConnectionPoint;
  61218. /**
  61219. * Gets the right operand input component
  61220. */
  61221. get right(): NodeMaterialConnectionPoint;
  61222. /**
  61223. * Gets the output component
  61224. */
  61225. get output(): NodeMaterialConnectionPoint;
  61226. protected _buildBlock(state: NodeMaterialBuildState): this;
  61227. }
  61228. }
  61229. declare module BABYLON {
  61230. /**
  61231. * Block used to normalize a vector
  61232. */
  61233. export class NormalizeBlock extends NodeMaterialBlock {
  61234. /**
  61235. * Creates a new NormalizeBlock
  61236. * @param name defines the block name
  61237. */
  61238. constructor(name: string);
  61239. /**
  61240. * Gets the current class name
  61241. * @returns the class name
  61242. */
  61243. getClassName(): string;
  61244. /**
  61245. * Gets the input component
  61246. */
  61247. get input(): NodeMaterialConnectionPoint;
  61248. /**
  61249. * Gets the output component
  61250. */
  61251. get output(): NodeMaterialConnectionPoint;
  61252. protected _buildBlock(state: NodeMaterialBuildState): this;
  61253. }
  61254. }
  61255. declare module BABYLON {
  61256. /**
  61257. * Operations supported by the Trigonometry block
  61258. */
  61259. export enum TrigonometryBlockOperations {
  61260. /** Cos */
  61261. Cos = 0,
  61262. /** Sin */
  61263. Sin = 1,
  61264. /** Abs */
  61265. Abs = 2,
  61266. /** Exp */
  61267. Exp = 3,
  61268. /** Exp2 */
  61269. Exp2 = 4,
  61270. /** Round */
  61271. Round = 5,
  61272. /** Floor */
  61273. Floor = 6,
  61274. /** Ceiling */
  61275. Ceiling = 7,
  61276. /** Square root */
  61277. Sqrt = 8,
  61278. /** Log */
  61279. Log = 9,
  61280. /** Tangent */
  61281. Tan = 10,
  61282. /** Arc tangent */
  61283. ArcTan = 11,
  61284. /** Arc cosinus */
  61285. ArcCos = 12,
  61286. /** Arc sinus */
  61287. ArcSin = 13,
  61288. /** Fraction */
  61289. Fract = 14,
  61290. /** Sign */
  61291. Sign = 15,
  61292. /** To radians (from degrees) */
  61293. Radians = 16,
  61294. /** To degrees (from radians) */
  61295. Degrees = 17
  61296. }
  61297. /**
  61298. * Block used to apply trigonometry operation to floats
  61299. */
  61300. export class TrigonometryBlock extends NodeMaterialBlock {
  61301. /**
  61302. * Gets or sets the operation applied by the block
  61303. */
  61304. operation: TrigonometryBlockOperations;
  61305. /**
  61306. * Creates a new TrigonometryBlock
  61307. * @param name defines the block name
  61308. */
  61309. constructor(name: string);
  61310. /**
  61311. * Gets the current class name
  61312. * @returns the class name
  61313. */
  61314. getClassName(): string;
  61315. /**
  61316. * Gets the input component
  61317. */
  61318. get input(): NodeMaterialConnectionPoint;
  61319. /**
  61320. * Gets the output component
  61321. */
  61322. get output(): NodeMaterialConnectionPoint;
  61323. protected _buildBlock(state: NodeMaterialBuildState): this;
  61324. serialize(): any;
  61325. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61326. protected _dumpPropertiesCode(): string;
  61327. }
  61328. }
  61329. declare module BABYLON {
  61330. /**
  61331. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61332. */
  61333. export class ColorMergerBlock extends NodeMaterialBlock {
  61334. /**
  61335. * Create a new ColorMergerBlock
  61336. * @param name defines the block name
  61337. */
  61338. constructor(name: string);
  61339. /**
  61340. * Gets the current class name
  61341. * @returns the class name
  61342. */
  61343. getClassName(): string;
  61344. /**
  61345. * Gets the rgb component (input)
  61346. */
  61347. get rgbIn(): NodeMaterialConnectionPoint;
  61348. /**
  61349. * Gets the r component (input)
  61350. */
  61351. get r(): NodeMaterialConnectionPoint;
  61352. /**
  61353. * Gets the g component (input)
  61354. */
  61355. get g(): NodeMaterialConnectionPoint;
  61356. /**
  61357. * Gets the b component (input)
  61358. */
  61359. get b(): NodeMaterialConnectionPoint;
  61360. /**
  61361. * Gets the a component (input)
  61362. */
  61363. get a(): NodeMaterialConnectionPoint;
  61364. /**
  61365. * Gets the rgba component (output)
  61366. */
  61367. get rgba(): NodeMaterialConnectionPoint;
  61368. /**
  61369. * Gets the rgb component (output)
  61370. */
  61371. get rgbOut(): NodeMaterialConnectionPoint;
  61372. /**
  61373. * Gets the rgb component (output)
  61374. * @deprecated Please use rgbOut instead.
  61375. */
  61376. get rgb(): NodeMaterialConnectionPoint;
  61377. protected _buildBlock(state: NodeMaterialBuildState): this;
  61378. }
  61379. }
  61380. declare module BABYLON {
  61381. /**
  61382. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61383. */
  61384. export class VectorSplitterBlock extends NodeMaterialBlock {
  61385. /**
  61386. * Create a new VectorSplitterBlock
  61387. * @param name defines the block name
  61388. */
  61389. constructor(name: string);
  61390. /**
  61391. * Gets the current class name
  61392. * @returns the class name
  61393. */
  61394. getClassName(): string;
  61395. /**
  61396. * Gets the xyzw component (input)
  61397. */
  61398. get xyzw(): NodeMaterialConnectionPoint;
  61399. /**
  61400. * Gets the xyz component (input)
  61401. */
  61402. get xyzIn(): NodeMaterialConnectionPoint;
  61403. /**
  61404. * Gets the xy component (input)
  61405. */
  61406. get xyIn(): NodeMaterialConnectionPoint;
  61407. /**
  61408. * Gets the xyz component (output)
  61409. */
  61410. get xyzOut(): NodeMaterialConnectionPoint;
  61411. /**
  61412. * Gets the xy component (output)
  61413. */
  61414. get xyOut(): NodeMaterialConnectionPoint;
  61415. /**
  61416. * Gets the x component (output)
  61417. */
  61418. get x(): NodeMaterialConnectionPoint;
  61419. /**
  61420. * Gets the y component (output)
  61421. */
  61422. get y(): NodeMaterialConnectionPoint;
  61423. /**
  61424. * Gets the z component (output)
  61425. */
  61426. get z(): NodeMaterialConnectionPoint;
  61427. /**
  61428. * Gets the w component (output)
  61429. */
  61430. get w(): NodeMaterialConnectionPoint;
  61431. protected _inputRename(name: string): string;
  61432. protected _outputRename(name: string): string;
  61433. protected _buildBlock(state: NodeMaterialBuildState): this;
  61434. }
  61435. }
  61436. declare module BABYLON {
  61437. /**
  61438. * Block used to lerp between 2 values
  61439. */
  61440. export class LerpBlock extends NodeMaterialBlock {
  61441. /**
  61442. * Creates a new LerpBlock
  61443. * @param name defines the block name
  61444. */
  61445. constructor(name: string);
  61446. /**
  61447. * Gets the current class name
  61448. * @returns the class name
  61449. */
  61450. getClassName(): string;
  61451. /**
  61452. * Gets the left operand input component
  61453. */
  61454. get left(): NodeMaterialConnectionPoint;
  61455. /**
  61456. * Gets the right operand input component
  61457. */
  61458. get right(): NodeMaterialConnectionPoint;
  61459. /**
  61460. * Gets the gradient operand input component
  61461. */
  61462. get gradient(): NodeMaterialConnectionPoint;
  61463. /**
  61464. * Gets the output component
  61465. */
  61466. get output(): NodeMaterialConnectionPoint;
  61467. protected _buildBlock(state: NodeMaterialBuildState): this;
  61468. }
  61469. }
  61470. declare module BABYLON {
  61471. /**
  61472. * Block used to divide 2 vectors
  61473. */
  61474. export class DivideBlock extends NodeMaterialBlock {
  61475. /**
  61476. * Creates a new DivideBlock
  61477. * @param name defines the block name
  61478. */
  61479. constructor(name: string);
  61480. /**
  61481. * Gets the current class name
  61482. * @returns the class name
  61483. */
  61484. getClassName(): string;
  61485. /**
  61486. * Gets the left operand input component
  61487. */
  61488. get left(): NodeMaterialConnectionPoint;
  61489. /**
  61490. * Gets the right operand input component
  61491. */
  61492. get right(): NodeMaterialConnectionPoint;
  61493. /**
  61494. * Gets the output component
  61495. */
  61496. get output(): NodeMaterialConnectionPoint;
  61497. protected _buildBlock(state: NodeMaterialBuildState): this;
  61498. }
  61499. }
  61500. declare module BABYLON {
  61501. /**
  61502. * Block used to subtract 2 vectors
  61503. */
  61504. export class SubtractBlock extends NodeMaterialBlock {
  61505. /**
  61506. * Creates a new SubtractBlock
  61507. * @param name defines the block name
  61508. */
  61509. constructor(name: string);
  61510. /**
  61511. * Gets the current class name
  61512. * @returns the class name
  61513. */
  61514. getClassName(): string;
  61515. /**
  61516. * Gets the left operand input component
  61517. */
  61518. get left(): NodeMaterialConnectionPoint;
  61519. /**
  61520. * Gets the right operand input component
  61521. */
  61522. get right(): NodeMaterialConnectionPoint;
  61523. /**
  61524. * Gets the output component
  61525. */
  61526. get output(): NodeMaterialConnectionPoint;
  61527. protected _buildBlock(state: NodeMaterialBuildState): this;
  61528. }
  61529. }
  61530. declare module BABYLON {
  61531. /**
  61532. * Block used to step a value
  61533. */
  61534. export class StepBlock extends NodeMaterialBlock {
  61535. /**
  61536. * Creates a new StepBlock
  61537. * @param name defines the block name
  61538. */
  61539. constructor(name: string);
  61540. /**
  61541. * Gets the current class name
  61542. * @returns the class name
  61543. */
  61544. getClassName(): string;
  61545. /**
  61546. * Gets the value operand input component
  61547. */
  61548. get value(): NodeMaterialConnectionPoint;
  61549. /**
  61550. * Gets the edge operand input component
  61551. */
  61552. get edge(): NodeMaterialConnectionPoint;
  61553. /**
  61554. * Gets the output component
  61555. */
  61556. get output(): NodeMaterialConnectionPoint;
  61557. protected _buildBlock(state: NodeMaterialBuildState): this;
  61558. }
  61559. }
  61560. declare module BABYLON {
  61561. /**
  61562. * Block used to get the opposite (1 - x) of a value
  61563. */
  61564. export class OneMinusBlock extends NodeMaterialBlock {
  61565. /**
  61566. * Creates a new OneMinusBlock
  61567. * @param name defines the block name
  61568. */
  61569. constructor(name: string);
  61570. /**
  61571. * Gets the current class name
  61572. * @returns the class name
  61573. */
  61574. getClassName(): string;
  61575. /**
  61576. * Gets the input component
  61577. */
  61578. get input(): NodeMaterialConnectionPoint;
  61579. /**
  61580. * Gets the output component
  61581. */
  61582. get output(): NodeMaterialConnectionPoint;
  61583. protected _buildBlock(state: NodeMaterialBuildState): this;
  61584. }
  61585. }
  61586. declare module BABYLON {
  61587. /**
  61588. * Block used to get the view direction
  61589. */
  61590. export class ViewDirectionBlock extends NodeMaterialBlock {
  61591. /**
  61592. * Creates a new ViewDirectionBlock
  61593. * @param name defines the block name
  61594. */
  61595. constructor(name: string);
  61596. /**
  61597. * Gets the current class name
  61598. * @returns the class name
  61599. */
  61600. getClassName(): string;
  61601. /**
  61602. * Gets the world position component
  61603. */
  61604. get worldPosition(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the camera position component
  61607. */
  61608. get cameraPosition(): NodeMaterialConnectionPoint;
  61609. /**
  61610. * Gets the output component
  61611. */
  61612. get output(): NodeMaterialConnectionPoint;
  61613. autoConfigure(material: NodeMaterial): void;
  61614. protected _buildBlock(state: NodeMaterialBuildState): this;
  61615. }
  61616. }
  61617. declare module BABYLON {
  61618. /**
  61619. * Block used to compute fresnel value
  61620. */
  61621. export class FresnelBlock extends NodeMaterialBlock {
  61622. /**
  61623. * Create a new FresnelBlock
  61624. * @param name defines the block name
  61625. */
  61626. constructor(name: string);
  61627. /**
  61628. * Gets the current class name
  61629. * @returns the class name
  61630. */
  61631. getClassName(): string;
  61632. /**
  61633. * Gets the world normal input component
  61634. */
  61635. get worldNormal(): NodeMaterialConnectionPoint;
  61636. /**
  61637. * Gets the view direction input component
  61638. */
  61639. get viewDirection(): NodeMaterialConnectionPoint;
  61640. /**
  61641. * Gets the bias input component
  61642. */
  61643. get bias(): NodeMaterialConnectionPoint;
  61644. /**
  61645. * Gets the camera (or eye) position component
  61646. */
  61647. get power(): NodeMaterialConnectionPoint;
  61648. /**
  61649. * Gets the fresnel output component
  61650. */
  61651. get fresnel(): NodeMaterialConnectionPoint;
  61652. autoConfigure(material: NodeMaterial): void;
  61653. protected _buildBlock(state: NodeMaterialBuildState): this;
  61654. }
  61655. }
  61656. declare module BABYLON {
  61657. /**
  61658. * Block used to get the max of 2 values
  61659. */
  61660. export class MaxBlock extends NodeMaterialBlock {
  61661. /**
  61662. * Creates a new MaxBlock
  61663. * @param name defines the block name
  61664. */
  61665. constructor(name: string);
  61666. /**
  61667. * Gets the current class name
  61668. * @returns the class name
  61669. */
  61670. getClassName(): string;
  61671. /**
  61672. * Gets the left operand input component
  61673. */
  61674. get left(): NodeMaterialConnectionPoint;
  61675. /**
  61676. * Gets the right operand input component
  61677. */
  61678. get right(): NodeMaterialConnectionPoint;
  61679. /**
  61680. * Gets the output component
  61681. */
  61682. get output(): NodeMaterialConnectionPoint;
  61683. protected _buildBlock(state: NodeMaterialBuildState): this;
  61684. }
  61685. }
  61686. declare module BABYLON {
  61687. /**
  61688. * Block used to get the min of 2 values
  61689. */
  61690. export class MinBlock extends NodeMaterialBlock {
  61691. /**
  61692. * Creates a new MinBlock
  61693. * @param name defines the block name
  61694. */
  61695. constructor(name: string);
  61696. /**
  61697. * Gets the current class name
  61698. * @returns the class name
  61699. */
  61700. getClassName(): string;
  61701. /**
  61702. * Gets the left operand input component
  61703. */
  61704. get left(): NodeMaterialConnectionPoint;
  61705. /**
  61706. * Gets the right operand input component
  61707. */
  61708. get right(): NodeMaterialConnectionPoint;
  61709. /**
  61710. * Gets the output component
  61711. */
  61712. get output(): NodeMaterialConnectionPoint;
  61713. protected _buildBlock(state: NodeMaterialBuildState): this;
  61714. }
  61715. }
  61716. declare module BABYLON {
  61717. /**
  61718. * Block used to get the distance between 2 values
  61719. */
  61720. export class DistanceBlock extends NodeMaterialBlock {
  61721. /**
  61722. * Creates a new DistanceBlock
  61723. * @param name defines the block name
  61724. */
  61725. constructor(name: string);
  61726. /**
  61727. * Gets the current class name
  61728. * @returns the class name
  61729. */
  61730. getClassName(): string;
  61731. /**
  61732. * Gets the left operand input component
  61733. */
  61734. get left(): NodeMaterialConnectionPoint;
  61735. /**
  61736. * Gets the right operand input component
  61737. */
  61738. get right(): NodeMaterialConnectionPoint;
  61739. /**
  61740. * Gets the output component
  61741. */
  61742. get output(): NodeMaterialConnectionPoint;
  61743. protected _buildBlock(state: NodeMaterialBuildState): this;
  61744. }
  61745. }
  61746. declare module BABYLON {
  61747. /**
  61748. * Block used to get the length of a vector
  61749. */
  61750. export class LengthBlock extends NodeMaterialBlock {
  61751. /**
  61752. * Creates a new LengthBlock
  61753. * @param name defines the block name
  61754. */
  61755. constructor(name: string);
  61756. /**
  61757. * Gets the current class name
  61758. * @returns the class name
  61759. */
  61760. getClassName(): string;
  61761. /**
  61762. * Gets the value input component
  61763. */
  61764. get value(): NodeMaterialConnectionPoint;
  61765. /**
  61766. * Gets the output component
  61767. */
  61768. get output(): NodeMaterialConnectionPoint;
  61769. protected _buildBlock(state: NodeMaterialBuildState): this;
  61770. }
  61771. }
  61772. declare module BABYLON {
  61773. /**
  61774. * Block used to get negative version of a value (i.e. x * -1)
  61775. */
  61776. export class NegateBlock extends NodeMaterialBlock {
  61777. /**
  61778. * Creates a new NegateBlock
  61779. * @param name defines the block name
  61780. */
  61781. constructor(name: string);
  61782. /**
  61783. * Gets the current class name
  61784. * @returns the class name
  61785. */
  61786. getClassName(): string;
  61787. /**
  61788. * Gets the value input component
  61789. */
  61790. get value(): NodeMaterialConnectionPoint;
  61791. /**
  61792. * Gets the output component
  61793. */
  61794. get output(): NodeMaterialConnectionPoint;
  61795. protected _buildBlock(state: NodeMaterialBuildState): this;
  61796. }
  61797. }
  61798. declare module BABYLON {
  61799. /**
  61800. * Block used to get the value of the first parameter raised to the power of the second
  61801. */
  61802. export class PowBlock extends NodeMaterialBlock {
  61803. /**
  61804. * Creates a new PowBlock
  61805. * @param name defines the block name
  61806. */
  61807. constructor(name: string);
  61808. /**
  61809. * Gets the current class name
  61810. * @returns the class name
  61811. */
  61812. getClassName(): string;
  61813. /**
  61814. * Gets the value operand input component
  61815. */
  61816. get value(): NodeMaterialConnectionPoint;
  61817. /**
  61818. * Gets the power operand input component
  61819. */
  61820. get power(): NodeMaterialConnectionPoint;
  61821. /**
  61822. * Gets the output component
  61823. */
  61824. get output(): NodeMaterialConnectionPoint;
  61825. protected _buildBlock(state: NodeMaterialBuildState): this;
  61826. }
  61827. }
  61828. declare module BABYLON {
  61829. /**
  61830. * Block used to get a random number
  61831. */
  61832. export class RandomNumberBlock extends NodeMaterialBlock {
  61833. /**
  61834. * Creates a new RandomNumberBlock
  61835. * @param name defines the block name
  61836. */
  61837. constructor(name: string);
  61838. /**
  61839. * Gets the current class name
  61840. * @returns the class name
  61841. */
  61842. getClassName(): string;
  61843. /**
  61844. * Gets the seed input component
  61845. */
  61846. get seed(): NodeMaterialConnectionPoint;
  61847. /**
  61848. * Gets the output component
  61849. */
  61850. get output(): NodeMaterialConnectionPoint;
  61851. protected _buildBlock(state: NodeMaterialBuildState): this;
  61852. }
  61853. }
  61854. declare module BABYLON {
  61855. /**
  61856. * Block used to compute arc tangent of 2 values
  61857. */
  61858. export class ArcTan2Block extends NodeMaterialBlock {
  61859. /**
  61860. * Creates a new ArcTan2Block
  61861. * @param name defines the block name
  61862. */
  61863. constructor(name: string);
  61864. /**
  61865. * Gets the current class name
  61866. * @returns the class name
  61867. */
  61868. getClassName(): string;
  61869. /**
  61870. * Gets the x operand input component
  61871. */
  61872. get x(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the y operand input component
  61875. */
  61876. get y(): NodeMaterialConnectionPoint;
  61877. /**
  61878. * Gets the output component
  61879. */
  61880. get output(): NodeMaterialConnectionPoint;
  61881. protected _buildBlock(state: NodeMaterialBuildState): this;
  61882. }
  61883. }
  61884. declare module BABYLON {
  61885. /**
  61886. * Block used to smooth step a value
  61887. */
  61888. export class SmoothStepBlock extends NodeMaterialBlock {
  61889. /**
  61890. * Creates a new SmoothStepBlock
  61891. * @param name defines the block name
  61892. */
  61893. constructor(name: string);
  61894. /**
  61895. * Gets the current class name
  61896. * @returns the class name
  61897. */
  61898. getClassName(): string;
  61899. /**
  61900. * Gets the value operand input component
  61901. */
  61902. get value(): NodeMaterialConnectionPoint;
  61903. /**
  61904. * Gets the first edge operand input component
  61905. */
  61906. get edge0(): NodeMaterialConnectionPoint;
  61907. /**
  61908. * Gets the second edge operand input component
  61909. */
  61910. get edge1(): NodeMaterialConnectionPoint;
  61911. /**
  61912. * Gets the output component
  61913. */
  61914. get output(): NodeMaterialConnectionPoint;
  61915. protected _buildBlock(state: NodeMaterialBuildState): this;
  61916. }
  61917. }
  61918. declare module BABYLON {
  61919. /**
  61920. * Block used to get the reciprocal (1 / x) of a value
  61921. */
  61922. export class ReciprocalBlock extends NodeMaterialBlock {
  61923. /**
  61924. * Creates a new ReciprocalBlock
  61925. * @param name defines the block name
  61926. */
  61927. constructor(name: string);
  61928. /**
  61929. * Gets the current class name
  61930. * @returns the class name
  61931. */
  61932. getClassName(): string;
  61933. /**
  61934. * Gets the input component
  61935. */
  61936. get input(): NodeMaterialConnectionPoint;
  61937. /**
  61938. * Gets the output component
  61939. */
  61940. get output(): NodeMaterialConnectionPoint;
  61941. protected _buildBlock(state: NodeMaterialBuildState): this;
  61942. }
  61943. }
  61944. declare module BABYLON {
  61945. /**
  61946. * Block used to replace a color by another one
  61947. */
  61948. export class ReplaceColorBlock extends NodeMaterialBlock {
  61949. /**
  61950. * Creates a new ReplaceColorBlock
  61951. * @param name defines the block name
  61952. */
  61953. constructor(name: string);
  61954. /**
  61955. * Gets the current class name
  61956. * @returns the class name
  61957. */
  61958. getClassName(): string;
  61959. /**
  61960. * Gets the value input component
  61961. */
  61962. get value(): NodeMaterialConnectionPoint;
  61963. /**
  61964. * Gets the reference input component
  61965. */
  61966. get reference(): NodeMaterialConnectionPoint;
  61967. /**
  61968. * Gets the distance input component
  61969. */
  61970. get distance(): NodeMaterialConnectionPoint;
  61971. /**
  61972. * Gets the replacement input component
  61973. */
  61974. get replacement(): NodeMaterialConnectionPoint;
  61975. /**
  61976. * Gets the output component
  61977. */
  61978. get output(): NodeMaterialConnectionPoint;
  61979. protected _buildBlock(state: NodeMaterialBuildState): this;
  61980. }
  61981. }
  61982. declare module BABYLON {
  61983. /**
  61984. * Block used to posterize a value
  61985. * @see https://en.wikipedia.org/wiki/Posterization
  61986. */
  61987. export class PosterizeBlock extends NodeMaterialBlock {
  61988. /**
  61989. * Creates a new PosterizeBlock
  61990. * @param name defines the block name
  61991. */
  61992. constructor(name: string);
  61993. /**
  61994. * Gets the current class name
  61995. * @returns the class name
  61996. */
  61997. getClassName(): string;
  61998. /**
  61999. * Gets the value input component
  62000. */
  62001. get value(): NodeMaterialConnectionPoint;
  62002. /**
  62003. * Gets the steps input component
  62004. */
  62005. get steps(): NodeMaterialConnectionPoint;
  62006. /**
  62007. * Gets the output component
  62008. */
  62009. get output(): NodeMaterialConnectionPoint;
  62010. protected _buildBlock(state: NodeMaterialBuildState): this;
  62011. }
  62012. }
  62013. declare module BABYLON {
  62014. /**
  62015. * Operations supported by the Wave block
  62016. */
  62017. export enum WaveBlockKind {
  62018. /** SawTooth */
  62019. SawTooth = 0,
  62020. /** Square */
  62021. Square = 1,
  62022. /** Triangle */
  62023. Triangle = 2
  62024. }
  62025. /**
  62026. * Block used to apply wave operation to floats
  62027. */
  62028. export class WaveBlock extends NodeMaterialBlock {
  62029. /**
  62030. * Gets or sets the kibnd of wave to be applied by the block
  62031. */
  62032. kind: WaveBlockKind;
  62033. /**
  62034. * Creates a new WaveBlock
  62035. * @param name defines the block name
  62036. */
  62037. constructor(name: string);
  62038. /**
  62039. * Gets the current class name
  62040. * @returns the class name
  62041. */
  62042. getClassName(): string;
  62043. /**
  62044. * Gets the input component
  62045. */
  62046. get input(): NodeMaterialConnectionPoint;
  62047. /**
  62048. * Gets the output component
  62049. */
  62050. get output(): NodeMaterialConnectionPoint;
  62051. protected _buildBlock(state: NodeMaterialBuildState): this;
  62052. serialize(): any;
  62053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62054. }
  62055. }
  62056. declare module BABYLON {
  62057. /**
  62058. * Class used to store a color step for the GradientBlock
  62059. */
  62060. export class GradientBlockColorStep {
  62061. /**
  62062. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62063. */
  62064. step: number;
  62065. /**
  62066. * Gets or sets the color associated with this step
  62067. */
  62068. color: Color3;
  62069. /**
  62070. * Creates a new GradientBlockColorStep
  62071. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62072. * @param color defines the color associated with this step
  62073. */
  62074. constructor(
  62075. /**
  62076. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62077. */
  62078. step: number,
  62079. /**
  62080. * Gets or sets the color associated with this step
  62081. */
  62082. color: Color3);
  62083. }
  62084. /**
  62085. * Block used to return a color from a gradient based on an input value between 0 and 1
  62086. */
  62087. export class GradientBlock extends NodeMaterialBlock {
  62088. /**
  62089. * Gets or sets the list of color steps
  62090. */
  62091. colorSteps: GradientBlockColorStep[];
  62092. /**
  62093. * Creates a new GradientBlock
  62094. * @param name defines the block name
  62095. */
  62096. constructor(name: string);
  62097. /**
  62098. * Gets the current class name
  62099. * @returns the class name
  62100. */
  62101. getClassName(): string;
  62102. /**
  62103. * Gets the gradient input component
  62104. */
  62105. get gradient(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the output component
  62108. */
  62109. get output(): NodeMaterialConnectionPoint;
  62110. private _writeColorConstant;
  62111. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62112. serialize(): any;
  62113. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62114. protected _dumpPropertiesCode(): string;
  62115. }
  62116. }
  62117. declare module BABYLON {
  62118. /**
  62119. * Block used to normalize lerp between 2 values
  62120. */
  62121. export class NLerpBlock extends NodeMaterialBlock {
  62122. /**
  62123. * Creates a new NLerpBlock
  62124. * @param name defines the block name
  62125. */
  62126. constructor(name: string);
  62127. /**
  62128. * Gets the current class name
  62129. * @returns the class name
  62130. */
  62131. getClassName(): string;
  62132. /**
  62133. * Gets the left operand input component
  62134. */
  62135. get left(): NodeMaterialConnectionPoint;
  62136. /**
  62137. * Gets the right operand input component
  62138. */
  62139. get right(): NodeMaterialConnectionPoint;
  62140. /**
  62141. * Gets the gradient operand input component
  62142. */
  62143. get gradient(): NodeMaterialConnectionPoint;
  62144. /**
  62145. * Gets the output component
  62146. */
  62147. get output(): NodeMaterialConnectionPoint;
  62148. protected _buildBlock(state: NodeMaterialBuildState): this;
  62149. }
  62150. }
  62151. declare module BABYLON {
  62152. /**
  62153. * block used to Generate a Worley Noise 3D Noise Pattern
  62154. */
  62155. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62156. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62157. manhattanDistance: boolean;
  62158. /**
  62159. * Creates a new WorleyNoise3DBlock
  62160. * @param name defines the block name
  62161. */
  62162. constructor(name: string);
  62163. /**
  62164. * Gets the current class name
  62165. * @returns the class name
  62166. */
  62167. getClassName(): string;
  62168. /**
  62169. * Gets the seed input component
  62170. */
  62171. get seed(): NodeMaterialConnectionPoint;
  62172. /**
  62173. * Gets the jitter input component
  62174. */
  62175. get jitter(): NodeMaterialConnectionPoint;
  62176. /**
  62177. * Gets the output component
  62178. */
  62179. get output(): NodeMaterialConnectionPoint;
  62180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62181. /**
  62182. * Exposes the properties to the UI?
  62183. */
  62184. protected _dumpPropertiesCode(): string;
  62185. /**
  62186. * Exposes the properties to the Seralize?
  62187. */
  62188. serialize(): any;
  62189. /**
  62190. * Exposes the properties to the deseralize?
  62191. */
  62192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62193. }
  62194. }
  62195. declare module BABYLON {
  62196. /**
  62197. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62198. */
  62199. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62200. /**
  62201. * Creates a new SimplexPerlin3DBlock
  62202. * @param name defines the block name
  62203. */
  62204. constructor(name: string);
  62205. /**
  62206. * Gets the current class name
  62207. * @returns the class name
  62208. */
  62209. getClassName(): string;
  62210. /**
  62211. * Gets the seed operand input component
  62212. */
  62213. get seed(): NodeMaterialConnectionPoint;
  62214. /**
  62215. * Gets the output component
  62216. */
  62217. get output(): NodeMaterialConnectionPoint;
  62218. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62219. }
  62220. }
  62221. declare module BABYLON {
  62222. /**
  62223. * Block used to blend normals
  62224. */
  62225. export class NormalBlendBlock extends NodeMaterialBlock {
  62226. /**
  62227. * Creates a new NormalBlendBlock
  62228. * @param name defines the block name
  62229. */
  62230. constructor(name: string);
  62231. /**
  62232. * Gets the current class name
  62233. * @returns the class name
  62234. */
  62235. getClassName(): string;
  62236. /**
  62237. * Gets the first input component
  62238. */
  62239. get normalMap0(): NodeMaterialConnectionPoint;
  62240. /**
  62241. * Gets the second input component
  62242. */
  62243. get normalMap1(): NodeMaterialConnectionPoint;
  62244. /**
  62245. * Gets the output component
  62246. */
  62247. get output(): NodeMaterialConnectionPoint;
  62248. protected _buildBlock(state: NodeMaterialBuildState): this;
  62249. }
  62250. }
  62251. declare module BABYLON {
  62252. /**
  62253. * Block used to rotate a 2d vector by a given angle
  62254. */
  62255. export class Rotate2dBlock extends NodeMaterialBlock {
  62256. /**
  62257. * Creates a new Rotate2dBlock
  62258. * @param name defines the block name
  62259. */
  62260. constructor(name: string);
  62261. /**
  62262. * Gets the current class name
  62263. * @returns the class name
  62264. */
  62265. getClassName(): string;
  62266. /**
  62267. * Gets the input vector
  62268. */
  62269. get input(): NodeMaterialConnectionPoint;
  62270. /**
  62271. * Gets the input angle
  62272. */
  62273. get angle(): NodeMaterialConnectionPoint;
  62274. /**
  62275. * Gets the output component
  62276. */
  62277. get output(): NodeMaterialConnectionPoint;
  62278. autoConfigure(material: NodeMaterial): void;
  62279. protected _buildBlock(state: NodeMaterialBuildState): this;
  62280. }
  62281. }
  62282. declare module BABYLON {
  62283. /**
  62284. * Block used to get the reflected vector from a direction and a normal
  62285. */
  62286. export class ReflectBlock extends NodeMaterialBlock {
  62287. /**
  62288. * Creates a new ReflectBlock
  62289. * @param name defines the block name
  62290. */
  62291. constructor(name: string);
  62292. /**
  62293. * Gets the current class name
  62294. * @returns the class name
  62295. */
  62296. getClassName(): string;
  62297. /**
  62298. * Gets the incident component
  62299. */
  62300. get incident(): NodeMaterialConnectionPoint;
  62301. /**
  62302. * Gets the normal component
  62303. */
  62304. get normal(): NodeMaterialConnectionPoint;
  62305. /**
  62306. * Gets the output component
  62307. */
  62308. get output(): NodeMaterialConnectionPoint;
  62309. protected _buildBlock(state: NodeMaterialBuildState): this;
  62310. }
  62311. }
  62312. declare module BABYLON {
  62313. /**
  62314. * Block used to get the refracted vector from a direction and a normal
  62315. */
  62316. export class RefractBlock extends NodeMaterialBlock {
  62317. /**
  62318. * Creates a new RefractBlock
  62319. * @param name defines the block name
  62320. */
  62321. constructor(name: string);
  62322. /**
  62323. * Gets the current class name
  62324. * @returns the class name
  62325. */
  62326. getClassName(): string;
  62327. /**
  62328. * Gets the incident component
  62329. */
  62330. get incident(): NodeMaterialConnectionPoint;
  62331. /**
  62332. * Gets the normal component
  62333. */
  62334. get normal(): NodeMaterialConnectionPoint;
  62335. /**
  62336. * Gets the index of refraction component
  62337. */
  62338. get ior(): NodeMaterialConnectionPoint;
  62339. /**
  62340. * Gets the output component
  62341. */
  62342. get output(): NodeMaterialConnectionPoint;
  62343. protected _buildBlock(state: NodeMaterialBuildState): this;
  62344. }
  62345. }
  62346. declare module BABYLON {
  62347. /**
  62348. * Block used to desaturate a color
  62349. */
  62350. export class DesaturateBlock extends NodeMaterialBlock {
  62351. /**
  62352. * Creates a new DesaturateBlock
  62353. * @param name defines the block name
  62354. */
  62355. constructor(name: string);
  62356. /**
  62357. * Gets the current class name
  62358. * @returns the class name
  62359. */
  62360. getClassName(): string;
  62361. /**
  62362. * Gets the color operand input component
  62363. */
  62364. get color(): NodeMaterialConnectionPoint;
  62365. /**
  62366. * Gets the level operand input component
  62367. */
  62368. get level(): NodeMaterialConnectionPoint;
  62369. /**
  62370. * Gets the output component
  62371. */
  62372. get output(): NodeMaterialConnectionPoint;
  62373. protected _buildBlock(state: NodeMaterialBuildState): this;
  62374. }
  62375. }
  62376. declare module BABYLON {
  62377. /**
  62378. * Block used to implement the ambient occlusion module of the PBR material
  62379. */
  62380. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62381. /**
  62382. * Create a new AmbientOcclusionBlock
  62383. * @param name defines the block name
  62384. */
  62385. constructor(name: string);
  62386. /**
  62387. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62388. */
  62389. useAmbientInGrayScale: boolean;
  62390. /**
  62391. * Initialize the block and prepare the context for build
  62392. * @param state defines the state that will be used for the build
  62393. */
  62394. initialize(state: NodeMaterialBuildState): void;
  62395. /**
  62396. * Gets the current class name
  62397. * @returns the class name
  62398. */
  62399. getClassName(): string;
  62400. /**
  62401. * Gets the texture input component
  62402. */
  62403. get texture(): NodeMaterialConnectionPoint;
  62404. /**
  62405. * Gets the texture intensity component
  62406. */
  62407. get intensity(): NodeMaterialConnectionPoint;
  62408. /**
  62409. * Gets the direct light intensity input component
  62410. */
  62411. get directLightIntensity(): NodeMaterialConnectionPoint;
  62412. /**
  62413. * Gets the ambient occlusion object output component
  62414. */
  62415. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62416. /**
  62417. * Gets the main code of the block (fragment side)
  62418. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62419. * @returns the shader code
  62420. */
  62421. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62422. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62423. protected _buildBlock(state: NodeMaterialBuildState): this;
  62424. protected _dumpPropertiesCode(): string;
  62425. serialize(): any;
  62426. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62427. }
  62428. }
  62429. declare module BABYLON {
  62430. /**
  62431. * Block used to implement the reflection module of the PBR material
  62432. */
  62433. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62434. /** @hidden */
  62435. _defineLODReflectionAlpha: string;
  62436. /** @hidden */
  62437. _defineLinearSpecularReflection: string;
  62438. private _vEnvironmentIrradianceName;
  62439. /** @hidden */
  62440. _vReflectionMicrosurfaceInfosName: string;
  62441. /** @hidden */
  62442. _vReflectionInfosName: string;
  62443. private _scene;
  62444. /**
  62445. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62446. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62447. * It's less burden on the user side in the editor part.
  62448. */
  62449. /** @hidden */
  62450. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62451. /** @hidden */
  62452. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62453. /** @hidden */
  62454. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62455. /**
  62456. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62457. * diffuse part of the IBL.
  62458. */
  62459. useSphericalHarmonics: boolean;
  62460. /**
  62461. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62462. */
  62463. forceIrradianceInFragment: boolean;
  62464. /**
  62465. * Create a new ReflectionBlock
  62466. * @param name defines the block name
  62467. */
  62468. constructor(name: string);
  62469. /**
  62470. * Gets the current class name
  62471. * @returns the class name
  62472. */
  62473. getClassName(): string;
  62474. /**
  62475. * Gets the position input component
  62476. */
  62477. get position(): NodeMaterialConnectionPoint;
  62478. /**
  62479. * Gets the world position input component
  62480. */
  62481. get worldPosition(): NodeMaterialConnectionPoint;
  62482. /**
  62483. * Gets the world normal input component
  62484. */
  62485. get worldNormal(): NodeMaterialConnectionPoint;
  62486. /**
  62487. * Gets the world input component
  62488. */
  62489. get world(): NodeMaterialConnectionPoint;
  62490. /**
  62491. * Gets the camera (or eye) position component
  62492. */
  62493. get cameraPosition(): NodeMaterialConnectionPoint;
  62494. /**
  62495. * Gets the view input component
  62496. */
  62497. get view(): NodeMaterialConnectionPoint;
  62498. /**
  62499. * Gets the color input component
  62500. */
  62501. get color(): NodeMaterialConnectionPoint;
  62502. /**
  62503. * Gets the reflection object output component
  62504. */
  62505. get reflection(): NodeMaterialConnectionPoint;
  62506. /**
  62507. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62508. */
  62509. get hasTexture(): boolean;
  62510. /**
  62511. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62512. */
  62513. get reflectionColor(): string;
  62514. protected _getTexture(): Nullable<BaseTexture>;
  62515. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62516. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62517. /**
  62518. * Gets the code to inject in the vertex shader
  62519. * @param state current state of the node material building
  62520. * @returns the shader code
  62521. */
  62522. handleVertexSide(state: NodeMaterialBuildState): string;
  62523. /**
  62524. * Gets the main code of the block (fragment side)
  62525. * @param state current state of the node material building
  62526. * @param normalVarName name of the existing variable corresponding to the normal
  62527. * @returns the shader code
  62528. */
  62529. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62530. protected _buildBlock(state: NodeMaterialBuildState): this;
  62531. protected _dumpPropertiesCode(): string;
  62532. serialize(): any;
  62533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62534. }
  62535. }
  62536. declare module BABYLON {
  62537. /**
  62538. * Block used to implement the sheen module of the PBR material
  62539. */
  62540. export class SheenBlock extends NodeMaterialBlock {
  62541. /**
  62542. * Create a new SheenBlock
  62543. * @param name defines the block name
  62544. */
  62545. constructor(name: string);
  62546. /**
  62547. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62548. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62549. * making it easier to setup and tweak the effect
  62550. */
  62551. albedoScaling: boolean;
  62552. /**
  62553. * Defines if the sheen is linked to the sheen color.
  62554. */
  62555. linkSheenWithAlbedo: boolean;
  62556. /**
  62557. * Initialize the block and prepare the context for build
  62558. * @param state defines the state that will be used for the build
  62559. */
  62560. initialize(state: NodeMaterialBuildState): void;
  62561. /**
  62562. * Gets the current class name
  62563. * @returns the class name
  62564. */
  62565. getClassName(): string;
  62566. /**
  62567. * Gets the intensity input component
  62568. */
  62569. get intensity(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the color input component
  62572. */
  62573. get color(): NodeMaterialConnectionPoint;
  62574. /**
  62575. * Gets the roughness input component
  62576. */
  62577. get roughness(): NodeMaterialConnectionPoint;
  62578. /**
  62579. * Gets the texture input component
  62580. */
  62581. get texture(): NodeMaterialConnectionPoint;
  62582. /**
  62583. * Gets the sheen object output component
  62584. */
  62585. get sheen(): NodeMaterialConnectionPoint;
  62586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62587. /**
  62588. * Gets the main code of the block (fragment side)
  62589. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62590. * @returns the shader code
  62591. */
  62592. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62593. protected _buildBlock(state: NodeMaterialBuildState): this;
  62594. protected _dumpPropertiesCode(): string;
  62595. serialize(): any;
  62596. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62597. }
  62598. }
  62599. declare module BABYLON {
  62600. /**
  62601. * Block used to implement the reflectivity module of the PBR material
  62602. */
  62603. export class ReflectivityBlock extends NodeMaterialBlock {
  62604. /**
  62605. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62606. */
  62607. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62608. /**
  62609. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62610. */
  62611. useMetallnessFromMetallicTextureBlue: boolean;
  62612. /**
  62613. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62614. */
  62615. useRoughnessFromMetallicTextureAlpha: boolean;
  62616. /**
  62617. * Specifies if the metallic texture contains the roughness information in its green channel.
  62618. */
  62619. useRoughnessFromMetallicTextureGreen: boolean;
  62620. /**
  62621. * Create a new ReflectivityBlock
  62622. * @param name defines the block name
  62623. */
  62624. constructor(name: string);
  62625. /**
  62626. * Initialize the block and prepare the context for build
  62627. * @param state defines the state that will be used for the build
  62628. */
  62629. initialize(state: NodeMaterialBuildState): void;
  62630. /**
  62631. * Gets the current class name
  62632. * @returns the class name
  62633. */
  62634. getClassName(): string;
  62635. /**
  62636. * Gets the metallic input component
  62637. */
  62638. get metallic(): NodeMaterialConnectionPoint;
  62639. /**
  62640. * Gets the roughness input component
  62641. */
  62642. get roughness(): NodeMaterialConnectionPoint;
  62643. /**
  62644. * Gets the texture input component
  62645. */
  62646. get texture(): NodeMaterialConnectionPoint;
  62647. /**
  62648. * Gets the reflectivity object output component
  62649. */
  62650. get reflectivity(): NodeMaterialConnectionPoint;
  62651. /**
  62652. * Gets the main code of the block (fragment side)
  62653. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62654. * @returns the shader code
  62655. */
  62656. getCode(aoIntensityVarName: string): string;
  62657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62658. protected _buildBlock(state: NodeMaterialBuildState): this;
  62659. protected _dumpPropertiesCode(): string;
  62660. serialize(): any;
  62661. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62662. }
  62663. }
  62664. declare module BABYLON {
  62665. /**
  62666. * Block used to implement the anisotropy module of the PBR material
  62667. */
  62668. export class AnisotropyBlock extends NodeMaterialBlock {
  62669. /**
  62670. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62671. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62672. * It's less burden on the user side in the editor part.
  62673. */
  62674. /** @hidden */
  62675. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62676. /** @hidden */
  62677. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62678. /**
  62679. * Create a new AnisotropyBlock
  62680. * @param name defines the block name
  62681. */
  62682. constructor(name: string);
  62683. /**
  62684. * Initialize the block and prepare the context for build
  62685. * @param state defines the state that will be used for the build
  62686. */
  62687. initialize(state: NodeMaterialBuildState): void;
  62688. /**
  62689. * Gets the current class name
  62690. * @returns the class name
  62691. */
  62692. getClassName(): string;
  62693. /**
  62694. * Gets the intensity input component
  62695. */
  62696. get intensity(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the direction input component
  62699. */
  62700. get direction(): NodeMaterialConnectionPoint;
  62701. /**
  62702. * Gets the texture input component
  62703. */
  62704. get texture(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the uv input component
  62707. */
  62708. get uv(): NodeMaterialConnectionPoint;
  62709. /**
  62710. * Gets the worldTangent input component
  62711. */
  62712. get worldTangent(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the anisotropy object output component
  62715. */
  62716. get anisotropy(): NodeMaterialConnectionPoint;
  62717. private _generateTBNSpace;
  62718. /**
  62719. * Gets the main code of the block (fragment side)
  62720. * @param state current state of the node material building
  62721. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62722. * @returns the shader code
  62723. */
  62724. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62726. protected _buildBlock(state: NodeMaterialBuildState): this;
  62727. }
  62728. }
  62729. declare module BABYLON {
  62730. /**
  62731. * Block used to implement the clear coat module of the PBR material
  62732. */
  62733. export class ClearCoatBlock extends NodeMaterialBlock {
  62734. private _scene;
  62735. /**
  62736. * Create a new ClearCoatBlock
  62737. * @param name defines the block name
  62738. */
  62739. constructor(name: string);
  62740. /**
  62741. * Initialize the block and prepare the context for build
  62742. * @param state defines the state that will be used for the build
  62743. */
  62744. initialize(state: NodeMaterialBuildState): void;
  62745. /**
  62746. * Gets the current class name
  62747. * @returns the class name
  62748. */
  62749. getClassName(): string;
  62750. /**
  62751. * Gets the intensity input component
  62752. */
  62753. get intensity(): NodeMaterialConnectionPoint;
  62754. /**
  62755. * Gets the roughness input component
  62756. */
  62757. get roughness(): NodeMaterialConnectionPoint;
  62758. /**
  62759. * Gets the ior input component
  62760. */
  62761. get ior(): NodeMaterialConnectionPoint;
  62762. /**
  62763. * Gets the texture input component
  62764. */
  62765. get texture(): NodeMaterialConnectionPoint;
  62766. /**
  62767. * Gets the bump texture input component
  62768. */
  62769. get bumpTexture(): NodeMaterialConnectionPoint;
  62770. /**
  62771. * Gets the uv input component
  62772. */
  62773. get uv(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the tint color input component
  62776. */
  62777. get tintColor(): NodeMaterialConnectionPoint;
  62778. /**
  62779. * Gets the tint "at distance" input component
  62780. */
  62781. get tintAtDistance(): NodeMaterialConnectionPoint;
  62782. /**
  62783. * Gets the tint thickness input component
  62784. */
  62785. get tintThickness(): NodeMaterialConnectionPoint;
  62786. /**
  62787. * Gets the tint texture input component
  62788. */
  62789. get tintTexture(): NodeMaterialConnectionPoint;
  62790. /**
  62791. * Gets the world tangent input component
  62792. */
  62793. get worldTangent(): NodeMaterialConnectionPoint;
  62794. /**
  62795. * Gets the clear coat object output component
  62796. */
  62797. get clearcoat(): NodeMaterialConnectionPoint;
  62798. autoConfigure(material: NodeMaterial): void;
  62799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62800. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62801. private _generateTBNSpace;
  62802. /**
  62803. * Gets the main code of the block (fragment side)
  62804. * @param state current state of the node material building
  62805. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  62806. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62807. * @param worldPosVarName name of the variable holding the world position
  62808. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62809. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  62810. * @param worldNormalVarName name of the variable holding the world normal
  62811. * @returns the shader code
  62812. */
  62813. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  62814. protected _buildBlock(state: NodeMaterialBuildState): this;
  62815. }
  62816. }
  62817. declare module BABYLON {
  62818. /**
  62819. * Block used to implement the sub surface module of the PBR material
  62820. */
  62821. export class SubSurfaceBlock extends NodeMaterialBlock {
  62822. /**
  62823. * Create a new SubSurfaceBlock
  62824. * @param name defines the block name
  62825. */
  62826. constructor(name: string);
  62827. /**
  62828. * Stores the intensity of the different subsurface effects in the thickness texture.
  62829. * * the green channel is the translucency intensity.
  62830. * * the blue channel is the scattering intensity.
  62831. * * the alpha channel is the refraction intensity.
  62832. */
  62833. useMaskFromThicknessTexture: boolean;
  62834. /**
  62835. * Initialize the block and prepare the context for build
  62836. * @param state defines the state that will be used for the build
  62837. */
  62838. initialize(state: NodeMaterialBuildState): void;
  62839. /**
  62840. * Gets the current class name
  62841. * @returns the class name
  62842. */
  62843. getClassName(): string;
  62844. /**
  62845. * Gets the min thickness input component
  62846. */
  62847. get minThickness(): NodeMaterialConnectionPoint;
  62848. /**
  62849. * Gets the max thickness input component
  62850. */
  62851. get maxThickness(): NodeMaterialConnectionPoint;
  62852. /**
  62853. * Gets the thickness texture component
  62854. */
  62855. get thicknessTexture(): NodeMaterialConnectionPoint;
  62856. /**
  62857. * Gets the tint color input component
  62858. */
  62859. get tintColor(): NodeMaterialConnectionPoint;
  62860. /**
  62861. * Gets the translucency intensity input component
  62862. */
  62863. get translucencyIntensity(): NodeMaterialConnectionPoint;
  62864. /**
  62865. * Gets the translucency diffusion distance input component
  62866. */
  62867. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  62868. /**
  62869. * Gets the refraction object parameters
  62870. */
  62871. get refraction(): NodeMaterialConnectionPoint;
  62872. /**
  62873. * Gets the sub surface object output component
  62874. */
  62875. get subsurface(): NodeMaterialConnectionPoint;
  62876. autoConfigure(material: NodeMaterial): void;
  62877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62878. /**
  62879. * Gets the main code of the block (fragment side)
  62880. * @param state current state of the node material building
  62881. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  62882. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62883. * @param worldPosVarName name of the variable holding the world position
  62884. * @returns the shader code
  62885. */
  62886. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  62887. protected _buildBlock(state: NodeMaterialBuildState): this;
  62888. }
  62889. }
  62890. declare module BABYLON {
  62891. /**
  62892. * Block used to implement the PBR metallic/roughness model
  62893. */
  62894. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62895. /**
  62896. * Gets or sets the light associated with this block
  62897. */
  62898. light: Nullable<Light>;
  62899. private _lightId;
  62900. private _scene;
  62901. private _environmentBRDFTexture;
  62902. private _environmentBrdfSamplerName;
  62903. private _vNormalWName;
  62904. private _invertNormalName;
  62905. /**
  62906. * Create a new ReflectionBlock
  62907. * @param name defines the block name
  62908. */
  62909. constructor(name: string);
  62910. /**
  62911. * Intensity of the direct lights e.g. the four lights available in your scene.
  62912. * This impacts both the direct diffuse and specular highlights.
  62913. */
  62914. directIntensity: number;
  62915. /**
  62916. * Intensity of the environment e.g. how much the environment will light the object
  62917. * either through harmonics for rough material or through the refelction for shiny ones.
  62918. */
  62919. environmentIntensity: number;
  62920. /**
  62921. * This is a special control allowing the reduction of the specular highlights coming from the
  62922. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  62923. */
  62924. specularIntensity: number;
  62925. /**
  62926. * Defines the falloff type used in this material.
  62927. * It by default is Physical.
  62928. */
  62929. lightFalloff: number;
  62930. /**
  62931. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  62932. */
  62933. useAlphaFromAlbedoTexture: boolean;
  62934. /**
  62935. * Specifies that alpha test should be used
  62936. */
  62937. useAlphaTest: boolean;
  62938. /**
  62939. * Defines the alpha limits in alpha test mode.
  62940. */
  62941. alphaTestCutoff: number;
  62942. /**
  62943. * Specifies that alpha blending should be used
  62944. */
  62945. useAlphaBlending: boolean;
  62946. /**
  62947. * Defines if the alpha value should be determined via the rgb values.
  62948. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  62949. */
  62950. opacityRGB: boolean;
  62951. /**
  62952. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  62953. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  62954. */
  62955. useRadianceOverAlpha: boolean;
  62956. /**
  62957. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  62958. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  62959. */
  62960. useSpecularOverAlpha: boolean;
  62961. /**
  62962. * Enables specular anti aliasing in the PBR shader.
  62963. * It will both interacts on the Geometry for analytical and IBL lighting.
  62964. * It also prefilter the roughness map based on the bump values.
  62965. */
  62966. enableSpecularAntiAliasing: boolean;
  62967. /**
  62968. * Defines if the material uses energy conservation.
  62969. */
  62970. useEnergyConservation: boolean;
  62971. /**
  62972. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  62973. * too much the area relying on ambient texture to define their ambient occlusion.
  62974. */
  62975. useRadianceOcclusion: boolean;
  62976. /**
  62977. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  62978. * makes the reflect vector face the model (under horizon).
  62979. */
  62980. useHorizonOcclusion: boolean;
  62981. /**
  62982. * If set to true, no lighting calculations will be applied.
  62983. */
  62984. unlit: boolean;
  62985. /**
  62986. * Force normal to face away from face.
  62987. */
  62988. forceNormalForward: boolean;
  62989. /**
  62990. * Defines the material debug mode.
  62991. * It helps seeing only some components of the material while troubleshooting.
  62992. */
  62993. debugMode: number;
  62994. /**
  62995. * Specify from where on screen the debug mode should start.
  62996. * The value goes from -1 (full screen) to 1 (not visible)
  62997. * It helps with side by side comparison against the final render
  62998. * This defaults to 0
  62999. */
  63000. debugLimit: number;
  63001. /**
  63002. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63003. * You can use the factor to better multiply the final value.
  63004. */
  63005. debugFactor: number;
  63006. /**
  63007. * Initialize the block and prepare the context for build
  63008. * @param state defines the state that will be used for the build
  63009. */
  63010. initialize(state: NodeMaterialBuildState): void;
  63011. /**
  63012. * Gets the current class name
  63013. * @returns the class name
  63014. */
  63015. getClassName(): string;
  63016. /**
  63017. * Gets the world position input component
  63018. */
  63019. get worldPosition(): NodeMaterialConnectionPoint;
  63020. /**
  63021. * Gets the world normal input component
  63022. */
  63023. get worldNormal(): NodeMaterialConnectionPoint;
  63024. /**
  63025. * Gets the perturbed normal input component
  63026. */
  63027. get perturbedNormal(): NodeMaterialConnectionPoint;
  63028. /**
  63029. * Gets the camera position input component
  63030. */
  63031. get cameraPosition(): NodeMaterialConnectionPoint;
  63032. /**
  63033. * Gets the base color input component
  63034. */
  63035. get baseColor(): NodeMaterialConnectionPoint;
  63036. /**
  63037. * Gets the base texture input component
  63038. */
  63039. get baseTexture(): NodeMaterialConnectionPoint;
  63040. /**
  63041. * Gets the opacity texture input component
  63042. */
  63043. get opacityTexture(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the ambient color input component
  63046. */
  63047. get ambientColor(): NodeMaterialConnectionPoint;
  63048. /**
  63049. * Gets the reflectivity object parameters
  63050. */
  63051. get reflectivity(): NodeMaterialConnectionPoint;
  63052. /**
  63053. * Gets the ambient occlusion object parameters
  63054. */
  63055. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63056. /**
  63057. * Gets the reflection object parameters
  63058. */
  63059. get reflection(): NodeMaterialConnectionPoint;
  63060. /**
  63061. * Gets the sheen object parameters
  63062. */
  63063. get sheen(): NodeMaterialConnectionPoint;
  63064. /**
  63065. * Gets the clear coat object parameters
  63066. */
  63067. get clearcoat(): NodeMaterialConnectionPoint;
  63068. /**
  63069. * Gets the sub surface object parameters
  63070. */
  63071. get subsurface(): NodeMaterialConnectionPoint;
  63072. /**
  63073. * Gets the anisotropy object parameters
  63074. */
  63075. get anisotropy(): NodeMaterialConnectionPoint;
  63076. /**
  63077. * Gets the ambient output component
  63078. */
  63079. get ambient(): NodeMaterialConnectionPoint;
  63080. /**
  63081. * Gets the diffuse output component
  63082. */
  63083. get diffuse(): NodeMaterialConnectionPoint;
  63084. /**
  63085. * Gets the specular output component
  63086. */
  63087. get specular(): NodeMaterialConnectionPoint;
  63088. /**
  63089. * Gets the sheen output component
  63090. */
  63091. get sheenDir(): NodeMaterialConnectionPoint;
  63092. /**
  63093. * Gets the clear coat output component
  63094. */
  63095. get clearcoatDir(): NodeMaterialConnectionPoint;
  63096. /**
  63097. * Gets the indirect diffuse output component
  63098. */
  63099. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63100. /**
  63101. * Gets the indirect specular output component
  63102. */
  63103. get specularIndirect(): NodeMaterialConnectionPoint;
  63104. /**
  63105. * Gets the indirect sheen output component
  63106. */
  63107. get sheenIndirect(): NodeMaterialConnectionPoint;
  63108. /**
  63109. * Gets the indirect clear coat output component
  63110. */
  63111. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63112. /**
  63113. * Gets the refraction output component
  63114. */
  63115. get refraction(): NodeMaterialConnectionPoint;
  63116. /**
  63117. * Gets the global lighting output component
  63118. */
  63119. get lighting(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the shadow output component
  63122. */
  63123. get shadow(): NodeMaterialConnectionPoint;
  63124. /**
  63125. * Gets the alpha output component
  63126. */
  63127. get alpha(): NodeMaterialConnectionPoint;
  63128. autoConfigure(material: NodeMaterial): void;
  63129. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63130. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63131. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63132. private _injectVertexCode;
  63133. /**
  63134. * Gets the code corresponding to the albedo/opacity module
  63135. * @returns the shader code
  63136. */
  63137. getAlbedoOpacityCode(): string;
  63138. protected _buildBlock(state: NodeMaterialBuildState): this;
  63139. protected _dumpPropertiesCode(): string;
  63140. serialize(): any;
  63141. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63142. }
  63143. }
  63144. declare module BABYLON {
  63145. /**
  63146. * Block used to compute value of one parameter modulo another
  63147. */
  63148. export class ModBlock extends NodeMaterialBlock {
  63149. /**
  63150. * Creates a new ModBlock
  63151. * @param name defines the block name
  63152. */
  63153. constructor(name: string);
  63154. /**
  63155. * Gets the current class name
  63156. * @returns the class name
  63157. */
  63158. getClassName(): string;
  63159. /**
  63160. * Gets the left operand input component
  63161. */
  63162. get left(): NodeMaterialConnectionPoint;
  63163. /**
  63164. * Gets the right operand input component
  63165. */
  63166. get right(): NodeMaterialConnectionPoint;
  63167. /**
  63168. * Gets the output component
  63169. */
  63170. get output(): NodeMaterialConnectionPoint;
  63171. protected _buildBlock(state: NodeMaterialBuildState): this;
  63172. }
  63173. }
  63174. declare module BABYLON {
  63175. /**
  63176. * Helper class to push actions to a pool of workers.
  63177. */
  63178. export class WorkerPool implements IDisposable {
  63179. private _workerInfos;
  63180. private _pendingActions;
  63181. /**
  63182. * Constructor
  63183. * @param workers Array of workers to use for actions
  63184. */
  63185. constructor(workers: Array<Worker>);
  63186. /**
  63187. * Terminates all workers and clears any pending actions.
  63188. */
  63189. dispose(): void;
  63190. /**
  63191. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63192. * pended until a worker has completed its action.
  63193. * @param action The action to perform. Call onComplete when the action is complete.
  63194. */
  63195. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63196. private _execute;
  63197. }
  63198. }
  63199. declare module BABYLON {
  63200. /**
  63201. * Configuration for Draco compression
  63202. */
  63203. export interface IDracoCompressionConfiguration {
  63204. /**
  63205. * Configuration for the decoder.
  63206. */
  63207. decoder: {
  63208. /**
  63209. * The url to the WebAssembly module.
  63210. */
  63211. wasmUrl?: string;
  63212. /**
  63213. * The url to the WebAssembly binary.
  63214. */
  63215. wasmBinaryUrl?: string;
  63216. /**
  63217. * The url to the fallback JavaScript module.
  63218. */
  63219. fallbackUrl?: string;
  63220. };
  63221. }
  63222. /**
  63223. * Draco compression (https://google.github.io/draco/)
  63224. *
  63225. * This class wraps the Draco module.
  63226. *
  63227. * **Encoder**
  63228. *
  63229. * The encoder is not currently implemented.
  63230. *
  63231. * **Decoder**
  63232. *
  63233. * 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.
  63234. *
  63235. * To update the configuration, use the following code:
  63236. * ```javascript
  63237. * DracoCompression.Configuration = {
  63238. * decoder: {
  63239. * wasmUrl: "<url to the WebAssembly library>",
  63240. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63241. * fallbackUrl: "<url to the fallback JavaScript library>",
  63242. * }
  63243. * };
  63244. * ```
  63245. *
  63246. * 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.
  63247. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63248. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63249. *
  63250. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63251. * ```javascript
  63252. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63253. * ```
  63254. *
  63255. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63256. */
  63257. export class DracoCompression implements IDisposable {
  63258. private _workerPoolPromise?;
  63259. private _decoderModulePromise?;
  63260. /**
  63261. * The configuration. Defaults to the following urls:
  63262. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63263. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63264. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63265. */
  63266. static Configuration: IDracoCompressionConfiguration;
  63267. /**
  63268. * Returns true if the decoder configuration is available.
  63269. */
  63270. static get DecoderAvailable(): boolean;
  63271. /**
  63272. * Default number of workers to create when creating the draco compression object.
  63273. */
  63274. static DefaultNumWorkers: number;
  63275. private static GetDefaultNumWorkers;
  63276. private static _Default;
  63277. /**
  63278. * Default instance for the draco compression object.
  63279. */
  63280. static get Default(): DracoCompression;
  63281. /**
  63282. * Constructor
  63283. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63284. */
  63285. constructor(numWorkers?: number);
  63286. /**
  63287. * Stop all async operations and release resources.
  63288. */
  63289. dispose(): void;
  63290. /**
  63291. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63292. * @returns a promise that resolves when ready
  63293. */
  63294. whenReadyAsync(): Promise<void>;
  63295. /**
  63296. * Decode Draco compressed mesh data to vertex data.
  63297. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63298. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63299. * @returns A promise that resolves with the decoded vertex data
  63300. */
  63301. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63302. [kind: string]: number;
  63303. }): Promise<VertexData>;
  63304. }
  63305. }
  63306. declare module BABYLON {
  63307. /**
  63308. * Class for building Constructive Solid Geometry
  63309. */
  63310. export class CSG {
  63311. private polygons;
  63312. /**
  63313. * The world matrix
  63314. */
  63315. matrix: Matrix;
  63316. /**
  63317. * Stores the position
  63318. */
  63319. position: Vector3;
  63320. /**
  63321. * Stores the rotation
  63322. */
  63323. rotation: Vector3;
  63324. /**
  63325. * Stores the rotation quaternion
  63326. */
  63327. rotationQuaternion: Nullable<Quaternion>;
  63328. /**
  63329. * Stores the scaling vector
  63330. */
  63331. scaling: Vector3;
  63332. /**
  63333. * Convert the Mesh to CSG
  63334. * @param mesh The Mesh to convert to CSG
  63335. * @returns A new CSG from the Mesh
  63336. */
  63337. static FromMesh(mesh: Mesh): CSG;
  63338. /**
  63339. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63340. * @param polygons Polygons used to construct a CSG solid
  63341. */
  63342. private static FromPolygons;
  63343. /**
  63344. * Clones, or makes a deep copy, of the CSG
  63345. * @returns A new CSG
  63346. */
  63347. clone(): CSG;
  63348. /**
  63349. * Unions this CSG with another CSG
  63350. * @param csg The CSG to union against this CSG
  63351. * @returns The unioned CSG
  63352. */
  63353. union(csg: CSG): CSG;
  63354. /**
  63355. * Unions this CSG with another CSG in place
  63356. * @param csg The CSG to union against this CSG
  63357. */
  63358. unionInPlace(csg: CSG): void;
  63359. /**
  63360. * Subtracts this CSG with another CSG
  63361. * @param csg The CSG to subtract against this CSG
  63362. * @returns A new CSG
  63363. */
  63364. subtract(csg: CSG): CSG;
  63365. /**
  63366. * Subtracts this CSG with another CSG in place
  63367. * @param csg The CSG to subtact against this CSG
  63368. */
  63369. subtractInPlace(csg: CSG): void;
  63370. /**
  63371. * Intersect this CSG with another CSG
  63372. * @param csg The CSG to intersect against this CSG
  63373. * @returns A new CSG
  63374. */
  63375. intersect(csg: CSG): CSG;
  63376. /**
  63377. * Intersects this CSG with another CSG in place
  63378. * @param csg The CSG to intersect against this CSG
  63379. */
  63380. intersectInPlace(csg: CSG): void;
  63381. /**
  63382. * Return a new CSG solid with solid and empty space switched. This solid is
  63383. * not modified.
  63384. * @returns A new CSG solid with solid and empty space switched
  63385. */
  63386. inverse(): CSG;
  63387. /**
  63388. * Inverses the CSG in place
  63389. */
  63390. inverseInPlace(): void;
  63391. /**
  63392. * This is used to keep meshes transformations so they can be restored
  63393. * when we build back a Babylon Mesh
  63394. * NB : All CSG operations are performed in world coordinates
  63395. * @param csg The CSG to copy the transform attributes from
  63396. * @returns This CSG
  63397. */
  63398. copyTransformAttributes(csg: CSG): CSG;
  63399. /**
  63400. * Build Raw mesh from CSG
  63401. * Coordinates here are in world space
  63402. * @param name The name of the mesh geometry
  63403. * @param scene The Scene
  63404. * @param keepSubMeshes Specifies if the submeshes should be kept
  63405. * @returns A new Mesh
  63406. */
  63407. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63408. /**
  63409. * Build Mesh from CSG taking material and transforms into account
  63410. * @param name The name of the Mesh
  63411. * @param material The material of the Mesh
  63412. * @param scene The Scene
  63413. * @param keepSubMeshes Specifies if submeshes should be kept
  63414. * @returns The new Mesh
  63415. */
  63416. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63417. }
  63418. }
  63419. declare module BABYLON {
  63420. /**
  63421. * Class used to create a trail following a mesh
  63422. */
  63423. export class TrailMesh extends Mesh {
  63424. private _generator;
  63425. private _autoStart;
  63426. private _running;
  63427. private _diameter;
  63428. private _length;
  63429. private _sectionPolygonPointsCount;
  63430. private _sectionVectors;
  63431. private _sectionNormalVectors;
  63432. private _beforeRenderObserver;
  63433. /**
  63434. * @constructor
  63435. * @param name The value used by scene.getMeshByName() to do a lookup.
  63436. * @param generator The mesh or transform node to generate a trail.
  63437. * @param scene The scene to add this mesh to.
  63438. * @param diameter Diameter of trailing mesh. Default is 1.
  63439. * @param length Length of trailing mesh. Default is 60.
  63440. * @param autoStart Automatically start trailing mesh. Default true.
  63441. */
  63442. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63443. /**
  63444. * "TrailMesh"
  63445. * @returns "TrailMesh"
  63446. */
  63447. getClassName(): string;
  63448. private _createMesh;
  63449. /**
  63450. * Start trailing mesh.
  63451. */
  63452. start(): void;
  63453. /**
  63454. * Stop trailing mesh.
  63455. */
  63456. stop(): void;
  63457. /**
  63458. * Update trailing mesh geometry.
  63459. */
  63460. update(): void;
  63461. /**
  63462. * Returns a new TrailMesh object.
  63463. * @param name is a string, the name given to the new mesh
  63464. * @param newGenerator use new generator object for cloned trail mesh
  63465. * @returns a new mesh
  63466. */
  63467. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63468. /**
  63469. * Serializes this trail mesh
  63470. * @param serializationObject object to write serialization to
  63471. */
  63472. serialize(serializationObject: any): void;
  63473. /**
  63474. * Parses a serialized trail mesh
  63475. * @param parsedMesh the serialized mesh
  63476. * @param scene the scene to create the trail mesh in
  63477. * @returns the created trail mesh
  63478. */
  63479. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63480. }
  63481. }
  63482. declare module BABYLON {
  63483. /**
  63484. * Class containing static functions to help procedurally build meshes
  63485. */
  63486. export class TiledBoxBuilder {
  63487. /**
  63488. * Creates a box mesh
  63489. * 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)
  63490. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63492. * * 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
  63493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63494. * @param name defines the name of the mesh
  63495. * @param options defines the options used to create the mesh
  63496. * @param scene defines the hosting scene
  63497. * @returns the box mesh
  63498. */
  63499. static CreateTiledBox(name: string, options: {
  63500. pattern?: number;
  63501. width?: number;
  63502. height?: number;
  63503. depth?: number;
  63504. tileSize?: number;
  63505. tileWidth?: number;
  63506. tileHeight?: number;
  63507. alignHorizontal?: number;
  63508. alignVertical?: number;
  63509. faceUV?: Vector4[];
  63510. faceColors?: Color4[];
  63511. sideOrientation?: number;
  63512. updatable?: boolean;
  63513. }, scene?: Nullable<Scene>): Mesh;
  63514. }
  63515. }
  63516. declare module BABYLON {
  63517. /**
  63518. * Class containing static functions to help procedurally build meshes
  63519. */
  63520. export class TorusKnotBuilder {
  63521. /**
  63522. * Creates a torus knot mesh
  63523. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63524. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63525. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63526. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63528. * * 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
  63529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63530. * @param name defines the name of the mesh
  63531. * @param options defines the options used to create the mesh
  63532. * @param scene defines the hosting scene
  63533. * @returns the torus knot mesh
  63534. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63535. */
  63536. static CreateTorusKnot(name: string, options: {
  63537. radius?: number;
  63538. tube?: number;
  63539. radialSegments?: number;
  63540. tubularSegments?: number;
  63541. p?: number;
  63542. q?: number;
  63543. updatable?: boolean;
  63544. sideOrientation?: number;
  63545. frontUVs?: Vector4;
  63546. backUVs?: Vector4;
  63547. }, scene: any): Mesh;
  63548. }
  63549. }
  63550. declare module BABYLON {
  63551. /**
  63552. * Polygon
  63553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63554. */
  63555. export class Polygon {
  63556. /**
  63557. * Creates a rectangle
  63558. * @param xmin bottom X coord
  63559. * @param ymin bottom Y coord
  63560. * @param xmax top X coord
  63561. * @param ymax top Y coord
  63562. * @returns points that make the resulting rectation
  63563. */
  63564. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63565. /**
  63566. * Creates a circle
  63567. * @param radius radius of circle
  63568. * @param cx scale in x
  63569. * @param cy scale in y
  63570. * @param numberOfSides number of sides that make up the circle
  63571. * @returns points that make the resulting circle
  63572. */
  63573. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63574. /**
  63575. * Creates a polygon from input string
  63576. * @param input Input polygon data
  63577. * @returns the parsed points
  63578. */
  63579. static Parse(input: string): Vector2[];
  63580. /**
  63581. * Starts building a polygon from x and y coordinates
  63582. * @param x x coordinate
  63583. * @param y y coordinate
  63584. * @returns the started path2
  63585. */
  63586. static StartingAt(x: number, y: number): Path2;
  63587. }
  63588. /**
  63589. * Builds a polygon
  63590. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63591. */
  63592. export class PolygonMeshBuilder {
  63593. private _points;
  63594. private _outlinepoints;
  63595. private _holes;
  63596. private _name;
  63597. private _scene;
  63598. private _epoints;
  63599. private _eholes;
  63600. private _addToepoint;
  63601. /**
  63602. * Babylon reference to the earcut plugin.
  63603. */
  63604. bjsEarcut: any;
  63605. /**
  63606. * Creates a PolygonMeshBuilder
  63607. * @param name name of the builder
  63608. * @param contours Path of the polygon
  63609. * @param scene scene to add to when creating the mesh
  63610. * @param earcutInjection can be used to inject your own earcut reference
  63611. */
  63612. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63613. /**
  63614. * Adds a whole within the polygon
  63615. * @param hole Array of points defining the hole
  63616. * @returns this
  63617. */
  63618. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63619. /**
  63620. * Creates the polygon
  63621. * @param updatable If the mesh should be updatable
  63622. * @param depth The depth of the mesh created
  63623. * @returns the created mesh
  63624. */
  63625. build(updatable?: boolean, depth?: number): Mesh;
  63626. /**
  63627. * Creates the polygon
  63628. * @param depth The depth of the mesh created
  63629. * @returns the created VertexData
  63630. */
  63631. buildVertexData(depth?: number): VertexData;
  63632. /**
  63633. * Adds a side to the polygon
  63634. * @param positions points that make the polygon
  63635. * @param normals normals of the polygon
  63636. * @param uvs uvs of the polygon
  63637. * @param indices indices of the polygon
  63638. * @param bounds bounds of the polygon
  63639. * @param points points of the polygon
  63640. * @param depth depth of the polygon
  63641. * @param flip flip of the polygon
  63642. */
  63643. private addSide;
  63644. }
  63645. }
  63646. declare module BABYLON {
  63647. /**
  63648. * Class containing static functions to help procedurally build meshes
  63649. */
  63650. export class PolygonBuilder {
  63651. /**
  63652. * Creates a polygon mesh
  63653. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63654. * * 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
  63655. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63657. * * 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)
  63658. * * Remember you can only change the shape positions, not their number when updating a polygon
  63659. * @param name defines the name of the mesh
  63660. * @param options defines the options used to create the mesh
  63661. * @param scene defines the hosting scene
  63662. * @param earcutInjection can be used to inject your own earcut reference
  63663. * @returns the polygon mesh
  63664. */
  63665. static CreatePolygon(name: string, options: {
  63666. shape: Vector3[];
  63667. holes?: Vector3[][];
  63668. depth?: number;
  63669. faceUV?: Vector4[];
  63670. faceColors?: Color4[];
  63671. updatable?: boolean;
  63672. sideOrientation?: number;
  63673. frontUVs?: Vector4;
  63674. backUVs?: Vector4;
  63675. wrap?: boolean;
  63676. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63677. /**
  63678. * Creates an extruded polygon mesh, with depth in the Y direction.
  63679. * * 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)
  63680. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63681. * @param name defines the name of the mesh
  63682. * @param options defines the options used to create the mesh
  63683. * @param scene defines the hosting scene
  63684. * @param earcutInjection can be used to inject your own earcut reference
  63685. * @returns the polygon mesh
  63686. */
  63687. static ExtrudePolygon(name: string, options: {
  63688. shape: Vector3[];
  63689. holes?: Vector3[][];
  63690. depth?: number;
  63691. faceUV?: Vector4[];
  63692. faceColors?: Color4[];
  63693. updatable?: boolean;
  63694. sideOrientation?: number;
  63695. frontUVs?: Vector4;
  63696. backUVs?: Vector4;
  63697. wrap?: boolean;
  63698. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63699. }
  63700. }
  63701. declare module BABYLON {
  63702. /**
  63703. * Class containing static functions to help procedurally build meshes
  63704. */
  63705. export class LatheBuilder {
  63706. /**
  63707. * Creates lathe mesh.
  63708. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63709. * * 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
  63710. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63711. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63712. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63713. * * 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
  63714. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63715. * * 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
  63716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63717. * * 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
  63718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63720. * @param name defines the name of the mesh
  63721. * @param options defines the options used to create the mesh
  63722. * @param scene defines the hosting scene
  63723. * @returns the lathe mesh
  63724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63725. */
  63726. static CreateLathe(name: string, options: {
  63727. shape: Vector3[];
  63728. radius?: number;
  63729. tessellation?: number;
  63730. clip?: number;
  63731. arc?: number;
  63732. closed?: boolean;
  63733. updatable?: boolean;
  63734. sideOrientation?: number;
  63735. frontUVs?: Vector4;
  63736. backUVs?: Vector4;
  63737. cap?: number;
  63738. invertUV?: boolean;
  63739. }, scene?: Nullable<Scene>): Mesh;
  63740. }
  63741. }
  63742. declare module BABYLON {
  63743. /**
  63744. * Class containing static functions to help procedurally build meshes
  63745. */
  63746. export class TiledPlaneBuilder {
  63747. /**
  63748. * Creates a tiled plane mesh
  63749. * * The parameter `pattern` will, depending on value, do nothing or
  63750. * * * flip (reflect about central vertical) alternate tiles across and up
  63751. * * * flip every tile on alternate rows
  63752. * * * rotate (180 degs) alternate tiles across and up
  63753. * * * rotate every tile on alternate rows
  63754. * * * flip and rotate alternate tiles across and up
  63755. * * * flip and rotate every tile on alternate rows
  63756. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63757. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63758. * * 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
  63759. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63760. * * 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)
  63761. * * 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)
  63762. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63763. * @param name defines the name of the mesh
  63764. * @param options defines the options used to create the mesh
  63765. * @param scene defines the hosting scene
  63766. * @returns the box mesh
  63767. */
  63768. static CreateTiledPlane(name: string, options: {
  63769. pattern?: number;
  63770. tileSize?: number;
  63771. tileWidth?: number;
  63772. tileHeight?: number;
  63773. size?: number;
  63774. width?: number;
  63775. height?: number;
  63776. alignHorizontal?: number;
  63777. alignVertical?: number;
  63778. sideOrientation?: number;
  63779. frontUVs?: Vector4;
  63780. backUVs?: Vector4;
  63781. updatable?: boolean;
  63782. }, scene?: Nullable<Scene>): Mesh;
  63783. }
  63784. }
  63785. declare module BABYLON {
  63786. /**
  63787. * Class containing static functions to help procedurally build meshes
  63788. */
  63789. export class TubeBuilder {
  63790. /**
  63791. * Creates a tube mesh.
  63792. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63793. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63794. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63795. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63796. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63797. * * 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)
  63798. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63799. * * 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
  63800. * * 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
  63801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63802. * * 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
  63803. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63805. * @param name defines the name of the mesh
  63806. * @param options defines the options used to create the mesh
  63807. * @param scene defines the hosting scene
  63808. * @returns the tube mesh
  63809. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63810. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63811. */
  63812. static CreateTube(name: string, options: {
  63813. path: Vector3[];
  63814. radius?: number;
  63815. tessellation?: number;
  63816. radiusFunction?: {
  63817. (i: number, distance: number): number;
  63818. };
  63819. cap?: number;
  63820. arc?: number;
  63821. updatable?: boolean;
  63822. sideOrientation?: number;
  63823. frontUVs?: Vector4;
  63824. backUVs?: Vector4;
  63825. instance?: Mesh;
  63826. invertUV?: boolean;
  63827. }, scene?: Nullable<Scene>): Mesh;
  63828. }
  63829. }
  63830. declare module BABYLON {
  63831. /**
  63832. * Class containing static functions to help procedurally build meshes
  63833. */
  63834. export class IcoSphereBuilder {
  63835. /**
  63836. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63837. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63838. * * 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`)
  63839. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63840. * * 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
  63841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63842. * * 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
  63843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63844. * @param name defines the name of the mesh
  63845. * @param options defines the options used to create the mesh
  63846. * @param scene defines the hosting scene
  63847. * @returns the icosahedron mesh
  63848. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63849. */
  63850. static CreateIcoSphere(name: string, options: {
  63851. radius?: number;
  63852. radiusX?: number;
  63853. radiusY?: number;
  63854. radiusZ?: number;
  63855. flat?: boolean;
  63856. subdivisions?: number;
  63857. sideOrientation?: number;
  63858. frontUVs?: Vector4;
  63859. backUVs?: Vector4;
  63860. updatable?: boolean;
  63861. }, scene?: Nullable<Scene>): Mesh;
  63862. }
  63863. }
  63864. declare module BABYLON {
  63865. /**
  63866. * Class containing static functions to help procedurally build meshes
  63867. */
  63868. export class DecalBuilder {
  63869. /**
  63870. * Creates a decal mesh.
  63871. * 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
  63872. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63873. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63874. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63875. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63876. * @param name defines the name of the mesh
  63877. * @param sourceMesh defines the mesh where the decal must be applied
  63878. * @param options defines the options used to create the mesh
  63879. * @param scene defines the hosting scene
  63880. * @returns the decal mesh
  63881. * @see https://doc.babylonjs.com/how_to/decals
  63882. */
  63883. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63884. position?: Vector3;
  63885. normal?: Vector3;
  63886. size?: Vector3;
  63887. angle?: number;
  63888. }): Mesh;
  63889. }
  63890. }
  63891. declare module BABYLON {
  63892. /**
  63893. * Class containing static functions to help procedurally build meshes
  63894. */
  63895. export class MeshBuilder {
  63896. /**
  63897. * Creates a box mesh
  63898. * * The parameter `size` sets the size (float) of each box side (default 1)
  63899. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63900. * * 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)
  63901. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63903. * * 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
  63904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63905. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63906. * @param name defines the name of the mesh
  63907. * @param options defines the options used to create the mesh
  63908. * @param scene defines the hosting scene
  63909. * @returns the box mesh
  63910. */
  63911. static CreateBox(name: string, options: {
  63912. size?: number;
  63913. width?: number;
  63914. height?: number;
  63915. depth?: number;
  63916. faceUV?: Vector4[];
  63917. faceColors?: Color4[];
  63918. sideOrientation?: number;
  63919. frontUVs?: Vector4;
  63920. backUVs?: Vector4;
  63921. wrap?: boolean;
  63922. topBaseAt?: number;
  63923. bottomBaseAt?: number;
  63924. updatable?: boolean;
  63925. }, scene?: Nullable<Scene>): Mesh;
  63926. /**
  63927. * Creates a tiled box mesh
  63928. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63930. * @param name defines the name of the mesh
  63931. * @param options defines the options used to create the mesh
  63932. * @param scene defines the hosting scene
  63933. * @returns the tiled box mesh
  63934. */
  63935. static CreateTiledBox(name: string, options: {
  63936. pattern?: number;
  63937. size?: number;
  63938. width?: number;
  63939. height?: number;
  63940. depth: number;
  63941. tileSize?: number;
  63942. tileWidth?: number;
  63943. tileHeight?: number;
  63944. faceUV?: Vector4[];
  63945. faceColors?: Color4[];
  63946. alignHorizontal?: number;
  63947. alignVertical?: number;
  63948. sideOrientation?: number;
  63949. updatable?: boolean;
  63950. }, scene?: Nullable<Scene>): Mesh;
  63951. /**
  63952. * Creates a sphere mesh
  63953. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63954. * * 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`)
  63955. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63956. * * 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
  63957. * * 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)
  63958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63959. * * 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
  63960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63961. * @param name defines the name of the mesh
  63962. * @param options defines the options used to create the mesh
  63963. * @param scene defines the hosting scene
  63964. * @returns the sphere mesh
  63965. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63966. */
  63967. static CreateSphere(name: string, options: {
  63968. segments?: number;
  63969. diameter?: number;
  63970. diameterX?: number;
  63971. diameterY?: number;
  63972. diameterZ?: number;
  63973. arc?: number;
  63974. slice?: number;
  63975. sideOrientation?: number;
  63976. frontUVs?: Vector4;
  63977. backUVs?: Vector4;
  63978. updatable?: boolean;
  63979. }, scene?: Nullable<Scene>): Mesh;
  63980. /**
  63981. * Creates a plane polygonal mesh. By default, this is a disc
  63982. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63983. * * 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
  63984. * * 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
  63985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63986. * * 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
  63987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63988. * @param name defines the name of the mesh
  63989. * @param options defines the options used to create the mesh
  63990. * @param scene defines the hosting scene
  63991. * @returns the plane polygonal mesh
  63992. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63993. */
  63994. static CreateDisc(name: string, options: {
  63995. radius?: number;
  63996. tessellation?: number;
  63997. arc?: number;
  63998. updatable?: boolean;
  63999. sideOrientation?: number;
  64000. frontUVs?: Vector4;
  64001. backUVs?: Vector4;
  64002. }, scene?: Nullable<Scene>): Mesh;
  64003. /**
  64004. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64005. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64006. * * 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`)
  64007. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64008. * * 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
  64009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64010. * * 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
  64011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64012. * @param name defines the name of the mesh
  64013. * @param options defines the options used to create the mesh
  64014. * @param scene defines the hosting scene
  64015. * @returns the icosahedron mesh
  64016. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64017. */
  64018. static CreateIcoSphere(name: string, options: {
  64019. radius?: number;
  64020. radiusX?: number;
  64021. radiusY?: number;
  64022. radiusZ?: number;
  64023. flat?: boolean;
  64024. subdivisions?: number;
  64025. sideOrientation?: number;
  64026. frontUVs?: Vector4;
  64027. backUVs?: Vector4;
  64028. updatable?: boolean;
  64029. }, scene?: Nullable<Scene>): Mesh;
  64030. /**
  64031. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64032. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64033. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64034. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64035. * * 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
  64036. * * 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
  64037. * * 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
  64038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64039. * * 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
  64040. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64041. * * 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
  64042. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64043. * * 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
  64044. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64046. * @param name defines the name of the mesh
  64047. * @param options defines the options used to create the mesh
  64048. * @param scene defines the hosting scene
  64049. * @returns the ribbon mesh
  64050. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64051. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64052. */
  64053. static CreateRibbon(name: string, options: {
  64054. pathArray: Vector3[][];
  64055. closeArray?: boolean;
  64056. closePath?: boolean;
  64057. offset?: number;
  64058. updatable?: boolean;
  64059. sideOrientation?: number;
  64060. frontUVs?: Vector4;
  64061. backUVs?: Vector4;
  64062. instance?: Mesh;
  64063. invertUV?: boolean;
  64064. uvs?: Vector2[];
  64065. colors?: Color4[];
  64066. }, scene?: Nullable<Scene>): Mesh;
  64067. /**
  64068. * Creates a cylinder or a cone mesh
  64069. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64070. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64071. * * 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.
  64072. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64073. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64074. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64075. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64076. * * 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).
  64077. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64078. * * 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).
  64079. * * 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
  64080. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64081. * * 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
  64082. * * 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.
  64083. * * If `enclose` is false, a ring surface is one element.
  64084. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64085. * * 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
  64086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64087. * * 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
  64088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64089. * @param name defines the name of the mesh
  64090. * @param options defines the options used to create the mesh
  64091. * @param scene defines the hosting scene
  64092. * @returns the cylinder mesh
  64093. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64094. */
  64095. static CreateCylinder(name: string, options: {
  64096. height?: number;
  64097. diameterTop?: number;
  64098. diameterBottom?: number;
  64099. diameter?: number;
  64100. tessellation?: number;
  64101. subdivisions?: number;
  64102. arc?: number;
  64103. faceColors?: Color4[];
  64104. faceUV?: Vector4[];
  64105. updatable?: boolean;
  64106. hasRings?: boolean;
  64107. enclose?: boolean;
  64108. cap?: number;
  64109. sideOrientation?: number;
  64110. frontUVs?: Vector4;
  64111. backUVs?: Vector4;
  64112. }, scene?: Nullable<Scene>): Mesh;
  64113. /**
  64114. * Creates a torus mesh
  64115. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64116. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64117. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64119. * * 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
  64120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64121. * @param name defines the name of the mesh
  64122. * @param options defines the options used to create the mesh
  64123. * @param scene defines the hosting scene
  64124. * @returns the torus mesh
  64125. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64126. */
  64127. static CreateTorus(name: string, options: {
  64128. diameter?: number;
  64129. thickness?: number;
  64130. tessellation?: number;
  64131. updatable?: boolean;
  64132. sideOrientation?: number;
  64133. frontUVs?: Vector4;
  64134. backUVs?: Vector4;
  64135. }, scene?: Nullable<Scene>): Mesh;
  64136. /**
  64137. * Creates a torus knot mesh
  64138. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64139. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64140. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64141. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64143. * * 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
  64144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64145. * @param name defines the name of the mesh
  64146. * @param options defines the options used to create the mesh
  64147. * @param scene defines the hosting scene
  64148. * @returns the torus knot mesh
  64149. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64150. */
  64151. static CreateTorusKnot(name: string, options: {
  64152. radius?: number;
  64153. tube?: number;
  64154. radialSegments?: number;
  64155. tubularSegments?: number;
  64156. p?: number;
  64157. q?: number;
  64158. updatable?: boolean;
  64159. sideOrientation?: number;
  64160. frontUVs?: Vector4;
  64161. backUVs?: Vector4;
  64162. }, scene?: Nullable<Scene>): Mesh;
  64163. /**
  64164. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64165. * * 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
  64166. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64167. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64168. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64169. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64170. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64171. * * 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
  64172. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64175. * @param name defines the name of the new line system
  64176. * @param options defines the options used to create the line system
  64177. * @param scene defines the hosting scene
  64178. * @returns a new line system mesh
  64179. */
  64180. static CreateLineSystem(name: string, options: {
  64181. lines: Vector3[][];
  64182. updatable?: boolean;
  64183. instance?: Nullable<LinesMesh>;
  64184. colors?: Nullable<Color4[][]>;
  64185. useVertexAlpha?: boolean;
  64186. }, scene: Nullable<Scene>): LinesMesh;
  64187. /**
  64188. * Creates a line mesh
  64189. * 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
  64190. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64191. * * The parameter `points` is an array successive Vector3
  64192. * * 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
  64193. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64194. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64195. * * When updating an instance, remember that only point positions can change, not the number of points
  64196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64198. * @param name defines the name of the new line system
  64199. * @param options defines the options used to create the line system
  64200. * @param scene defines the hosting scene
  64201. * @returns a new line mesh
  64202. */
  64203. static CreateLines(name: string, options: {
  64204. points: Vector3[];
  64205. updatable?: boolean;
  64206. instance?: Nullable<LinesMesh>;
  64207. colors?: Color4[];
  64208. useVertexAlpha?: boolean;
  64209. }, scene?: Nullable<Scene>): LinesMesh;
  64210. /**
  64211. * Creates a dashed line mesh
  64212. * * 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
  64213. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64214. * * The parameter `points` is an array successive Vector3
  64215. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64216. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64217. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64218. * * 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
  64219. * * When updating an instance, remember that only point positions can change, not the number of points
  64220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64221. * @param name defines the name of the mesh
  64222. * @param options defines the options used to create the mesh
  64223. * @param scene defines the hosting scene
  64224. * @returns the dashed line mesh
  64225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64226. */
  64227. static CreateDashedLines(name: string, options: {
  64228. points: Vector3[];
  64229. dashSize?: number;
  64230. gapSize?: number;
  64231. dashNb?: number;
  64232. updatable?: boolean;
  64233. instance?: LinesMesh;
  64234. }, scene?: Nullable<Scene>): LinesMesh;
  64235. /**
  64236. * 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.
  64237. * * 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.
  64238. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64239. * * 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.
  64240. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64241. * * 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
  64242. * * 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
  64243. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64245. * * 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
  64246. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64248. * @param name defines the name of the mesh
  64249. * @param options defines the options used to create the mesh
  64250. * @param scene defines the hosting scene
  64251. * @returns the extruded shape mesh
  64252. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64254. */
  64255. static ExtrudeShape(name: string, options: {
  64256. shape: Vector3[];
  64257. path: Vector3[];
  64258. scale?: number;
  64259. rotation?: number;
  64260. cap?: number;
  64261. updatable?: boolean;
  64262. sideOrientation?: number;
  64263. frontUVs?: Vector4;
  64264. backUVs?: Vector4;
  64265. instance?: Mesh;
  64266. invertUV?: boolean;
  64267. }, scene?: Nullable<Scene>): Mesh;
  64268. /**
  64269. * Creates an custom extruded shape mesh.
  64270. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64271. * * 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.
  64272. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64273. * * 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
  64274. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64275. * * 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
  64276. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64277. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64278. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64279. * * 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
  64280. * * 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
  64281. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64283. * * 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
  64284. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64286. * @param name defines the name of the mesh
  64287. * @param options defines the options used to create the mesh
  64288. * @param scene defines the hosting scene
  64289. * @returns the custom extruded shape mesh
  64290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64291. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64293. */
  64294. static ExtrudeShapeCustom(name: string, options: {
  64295. shape: Vector3[];
  64296. path: Vector3[];
  64297. scaleFunction?: any;
  64298. rotationFunction?: any;
  64299. ribbonCloseArray?: boolean;
  64300. ribbonClosePath?: boolean;
  64301. cap?: number;
  64302. updatable?: boolean;
  64303. sideOrientation?: number;
  64304. frontUVs?: Vector4;
  64305. backUVs?: Vector4;
  64306. instance?: Mesh;
  64307. invertUV?: boolean;
  64308. }, scene?: Nullable<Scene>): Mesh;
  64309. /**
  64310. * Creates lathe mesh.
  64311. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64312. * * 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
  64313. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64314. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64315. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64316. * * 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
  64317. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64318. * * 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
  64319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64320. * * 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
  64321. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64323. * @param name defines the name of the mesh
  64324. * @param options defines the options used to create the mesh
  64325. * @param scene defines the hosting scene
  64326. * @returns the lathe mesh
  64327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64328. */
  64329. static CreateLathe(name: string, options: {
  64330. shape: Vector3[];
  64331. radius?: number;
  64332. tessellation?: number;
  64333. clip?: number;
  64334. arc?: number;
  64335. closed?: boolean;
  64336. updatable?: boolean;
  64337. sideOrientation?: number;
  64338. frontUVs?: Vector4;
  64339. backUVs?: Vector4;
  64340. cap?: number;
  64341. invertUV?: boolean;
  64342. }, scene?: Nullable<Scene>): Mesh;
  64343. /**
  64344. * Creates a tiled plane mesh
  64345. * * You can set a limited pattern arrangement with the tiles
  64346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64347. * * 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
  64348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64349. * @param name defines the name of the mesh
  64350. * @param options defines the options used to create the mesh
  64351. * @param scene defines the hosting scene
  64352. * @returns the plane mesh
  64353. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64354. */
  64355. static CreateTiledPlane(name: string, options: {
  64356. pattern?: number;
  64357. tileSize?: number;
  64358. tileWidth?: number;
  64359. tileHeight?: number;
  64360. size?: number;
  64361. width?: number;
  64362. height?: number;
  64363. alignHorizontal?: number;
  64364. alignVertical?: number;
  64365. sideOrientation?: number;
  64366. frontUVs?: Vector4;
  64367. backUVs?: Vector4;
  64368. updatable?: boolean;
  64369. }, scene?: Nullable<Scene>): Mesh;
  64370. /**
  64371. * Creates a plane mesh
  64372. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64373. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64374. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64376. * * 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
  64377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64378. * @param name defines the name of the mesh
  64379. * @param options defines the options used to create the mesh
  64380. * @param scene defines the hosting scene
  64381. * @returns the plane mesh
  64382. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64383. */
  64384. static CreatePlane(name: string, options: {
  64385. size?: number;
  64386. width?: number;
  64387. height?: number;
  64388. sideOrientation?: number;
  64389. frontUVs?: Vector4;
  64390. backUVs?: Vector4;
  64391. updatable?: boolean;
  64392. sourcePlane?: Plane;
  64393. }, scene?: Nullable<Scene>): Mesh;
  64394. /**
  64395. * Creates a ground mesh
  64396. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64397. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64399. * @param name defines the name of the mesh
  64400. * @param options defines the options used to create the mesh
  64401. * @param scene defines the hosting scene
  64402. * @returns the ground mesh
  64403. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64404. */
  64405. static CreateGround(name: string, options: {
  64406. width?: number;
  64407. height?: number;
  64408. subdivisions?: number;
  64409. subdivisionsX?: number;
  64410. subdivisionsY?: number;
  64411. updatable?: boolean;
  64412. }, scene?: Nullable<Scene>): Mesh;
  64413. /**
  64414. * Creates a tiled ground mesh
  64415. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64416. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64417. * * 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
  64418. * * 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
  64419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64420. * @param name defines the name of the mesh
  64421. * @param options defines the options used to create the mesh
  64422. * @param scene defines the hosting scene
  64423. * @returns the tiled ground mesh
  64424. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64425. */
  64426. static CreateTiledGround(name: string, options: {
  64427. xmin: number;
  64428. zmin: number;
  64429. xmax: number;
  64430. zmax: number;
  64431. subdivisions?: {
  64432. w: number;
  64433. h: number;
  64434. };
  64435. precision?: {
  64436. w: number;
  64437. h: number;
  64438. };
  64439. updatable?: boolean;
  64440. }, scene?: Nullable<Scene>): Mesh;
  64441. /**
  64442. * Creates a ground mesh from a height map
  64443. * * The parameter `url` sets the URL of the height map image resource.
  64444. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64445. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64446. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64447. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64448. * * 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.
  64449. * * 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).
  64450. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64452. * @param name defines the name of the mesh
  64453. * @param url defines the url to the height map
  64454. * @param options defines the options used to create the mesh
  64455. * @param scene defines the hosting scene
  64456. * @returns the ground mesh
  64457. * @see https://doc.babylonjs.com/babylon101/height_map
  64458. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64459. */
  64460. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64461. width?: number;
  64462. height?: number;
  64463. subdivisions?: number;
  64464. minHeight?: number;
  64465. maxHeight?: number;
  64466. colorFilter?: Color3;
  64467. alphaFilter?: number;
  64468. updatable?: boolean;
  64469. onReady?: (mesh: GroundMesh) => void;
  64470. }, scene?: Nullable<Scene>): GroundMesh;
  64471. /**
  64472. * Creates a polygon mesh
  64473. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64474. * * 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
  64475. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64477. * * 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)
  64478. * * Remember you can only change the shape positions, not their number when updating a polygon
  64479. * @param name defines the name of the mesh
  64480. * @param options defines the options used to create the mesh
  64481. * @param scene defines the hosting scene
  64482. * @param earcutInjection can be used to inject your own earcut reference
  64483. * @returns the polygon mesh
  64484. */
  64485. static CreatePolygon(name: string, options: {
  64486. shape: Vector3[];
  64487. holes?: Vector3[][];
  64488. depth?: number;
  64489. faceUV?: Vector4[];
  64490. faceColors?: Color4[];
  64491. updatable?: boolean;
  64492. sideOrientation?: number;
  64493. frontUVs?: Vector4;
  64494. backUVs?: Vector4;
  64495. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64496. /**
  64497. * Creates an extruded polygon mesh, with depth in the Y direction.
  64498. * * 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)
  64499. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64500. * @param name defines the name of the mesh
  64501. * @param options defines the options used to create the mesh
  64502. * @param scene defines the hosting scene
  64503. * @param earcutInjection can be used to inject your own earcut reference
  64504. * @returns the polygon mesh
  64505. */
  64506. static ExtrudePolygon(name: string, options: {
  64507. shape: Vector3[];
  64508. holes?: Vector3[][];
  64509. depth?: number;
  64510. faceUV?: Vector4[];
  64511. faceColors?: Color4[];
  64512. updatable?: boolean;
  64513. sideOrientation?: number;
  64514. frontUVs?: Vector4;
  64515. backUVs?: Vector4;
  64516. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64517. /**
  64518. * Creates a tube mesh.
  64519. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64520. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64521. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64522. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64523. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64524. * * 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)
  64525. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64526. * * 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
  64527. * * 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
  64528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64529. * * 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
  64530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64532. * @param name defines the name of the mesh
  64533. * @param options defines the options used to create the mesh
  64534. * @param scene defines the hosting scene
  64535. * @returns the tube mesh
  64536. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64537. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64538. */
  64539. static CreateTube(name: string, options: {
  64540. path: Vector3[];
  64541. radius?: number;
  64542. tessellation?: number;
  64543. radiusFunction?: {
  64544. (i: number, distance: number): number;
  64545. };
  64546. cap?: number;
  64547. arc?: number;
  64548. updatable?: boolean;
  64549. sideOrientation?: number;
  64550. frontUVs?: Vector4;
  64551. backUVs?: Vector4;
  64552. instance?: Mesh;
  64553. invertUV?: boolean;
  64554. }, scene?: Nullable<Scene>): Mesh;
  64555. /**
  64556. * Creates a polyhedron mesh
  64557. * * 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
  64558. * * The parameter `size` (positive float, default 1) sets the polygon size
  64559. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64560. * * 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`
  64561. * * 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
  64562. * * 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)`)
  64563. * * 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
  64564. * * 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
  64565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64566. * * 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
  64567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64568. * @param name defines the name of the mesh
  64569. * @param options defines the options used to create the mesh
  64570. * @param scene defines the hosting scene
  64571. * @returns the polyhedron mesh
  64572. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64573. */
  64574. static CreatePolyhedron(name: string, options: {
  64575. type?: number;
  64576. size?: number;
  64577. sizeX?: number;
  64578. sizeY?: number;
  64579. sizeZ?: number;
  64580. custom?: any;
  64581. faceUV?: Vector4[];
  64582. faceColors?: Color4[];
  64583. flat?: boolean;
  64584. updatable?: boolean;
  64585. sideOrientation?: number;
  64586. frontUVs?: Vector4;
  64587. backUVs?: Vector4;
  64588. }, scene?: Nullable<Scene>): Mesh;
  64589. /**
  64590. * Creates a decal mesh.
  64591. * 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
  64592. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64593. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64594. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64595. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64596. * @param name defines the name of the mesh
  64597. * @param sourceMesh defines the mesh where the decal must be applied
  64598. * @param options defines the options used to create the mesh
  64599. * @param scene defines the hosting scene
  64600. * @returns the decal mesh
  64601. * @see https://doc.babylonjs.com/how_to/decals
  64602. */
  64603. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64604. position?: Vector3;
  64605. normal?: Vector3;
  64606. size?: Vector3;
  64607. angle?: number;
  64608. }): Mesh;
  64609. }
  64610. }
  64611. declare module BABYLON {
  64612. /**
  64613. * A simplifier interface for future simplification implementations
  64614. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64615. */
  64616. export interface ISimplifier {
  64617. /**
  64618. * Simplification of a given mesh according to the given settings.
  64619. * Since this requires computation, it is assumed that the function runs async.
  64620. * @param settings The settings of the simplification, including quality and distance
  64621. * @param successCallback A callback that will be called after the mesh was simplified.
  64622. * @param errorCallback in case of an error, this callback will be called. optional.
  64623. */
  64624. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64625. }
  64626. /**
  64627. * Expected simplification settings.
  64628. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64629. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64630. */
  64631. export interface ISimplificationSettings {
  64632. /**
  64633. * Gets or sets the expected quality
  64634. */
  64635. quality: number;
  64636. /**
  64637. * Gets or sets the distance when this optimized version should be used
  64638. */
  64639. distance: number;
  64640. /**
  64641. * Gets an already optimized mesh
  64642. */
  64643. optimizeMesh?: boolean;
  64644. }
  64645. /**
  64646. * Class used to specify simplification options
  64647. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64648. */
  64649. export class SimplificationSettings implements ISimplificationSettings {
  64650. /** expected quality */
  64651. quality: number;
  64652. /** distance when this optimized version should be used */
  64653. distance: number;
  64654. /** already optimized mesh */
  64655. optimizeMesh?: boolean | undefined;
  64656. /**
  64657. * Creates a SimplificationSettings
  64658. * @param quality expected quality
  64659. * @param distance distance when this optimized version should be used
  64660. * @param optimizeMesh already optimized mesh
  64661. */
  64662. constructor(
  64663. /** expected quality */
  64664. quality: number,
  64665. /** distance when this optimized version should be used */
  64666. distance: number,
  64667. /** already optimized mesh */
  64668. optimizeMesh?: boolean | undefined);
  64669. }
  64670. /**
  64671. * Interface used to define a simplification task
  64672. */
  64673. export interface ISimplificationTask {
  64674. /**
  64675. * Array of settings
  64676. */
  64677. settings: Array<ISimplificationSettings>;
  64678. /**
  64679. * Simplification type
  64680. */
  64681. simplificationType: SimplificationType;
  64682. /**
  64683. * Mesh to simplify
  64684. */
  64685. mesh: Mesh;
  64686. /**
  64687. * Callback called on success
  64688. */
  64689. successCallback?: () => void;
  64690. /**
  64691. * Defines if parallel processing can be used
  64692. */
  64693. parallelProcessing: boolean;
  64694. }
  64695. /**
  64696. * Queue used to order the simplification tasks
  64697. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64698. */
  64699. export class SimplificationQueue {
  64700. private _simplificationArray;
  64701. /**
  64702. * Gets a boolean indicating that the process is still running
  64703. */
  64704. running: boolean;
  64705. /**
  64706. * Creates a new queue
  64707. */
  64708. constructor();
  64709. /**
  64710. * Adds a new simplification task
  64711. * @param task defines a task to add
  64712. */
  64713. addTask(task: ISimplificationTask): void;
  64714. /**
  64715. * Execute next task
  64716. */
  64717. executeNext(): void;
  64718. /**
  64719. * Execute a simplification task
  64720. * @param task defines the task to run
  64721. */
  64722. runSimplification(task: ISimplificationTask): void;
  64723. private getSimplifier;
  64724. }
  64725. /**
  64726. * The implemented types of simplification
  64727. * At the moment only Quadratic Error Decimation is implemented
  64728. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64729. */
  64730. export enum SimplificationType {
  64731. /** Quadratic error decimation */
  64732. QUADRATIC = 0
  64733. }
  64734. /**
  64735. * An implementation of the Quadratic Error simplification algorithm.
  64736. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64737. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64738. * @author RaananW
  64739. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64740. */
  64741. export class QuadraticErrorSimplification implements ISimplifier {
  64742. private _mesh;
  64743. private triangles;
  64744. private vertices;
  64745. private references;
  64746. private _reconstructedMesh;
  64747. /** Gets or sets the number pf sync interations */
  64748. syncIterations: number;
  64749. /** Gets or sets the aggressiveness of the simplifier */
  64750. aggressiveness: number;
  64751. /** Gets or sets the number of allowed iterations for decimation */
  64752. decimationIterations: number;
  64753. /** Gets or sets the espilon to use for bounding box computation */
  64754. boundingBoxEpsilon: number;
  64755. /**
  64756. * Creates a new QuadraticErrorSimplification
  64757. * @param _mesh defines the target mesh
  64758. */
  64759. constructor(_mesh: Mesh);
  64760. /**
  64761. * Simplification of a given mesh according to the given settings.
  64762. * Since this requires computation, it is assumed that the function runs async.
  64763. * @param settings The settings of the simplification, including quality and distance
  64764. * @param successCallback A callback that will be called after the mesh was simplified.
  64765. */
  64766. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64767. private runDecimation;
  64768. private initWithMesh;
  64769. private init;
  64770. private reconstructMesh;
  64771. private initDecimatedMesh;
  64772. private isFlipped;
  64773. private updateTriangles;
  64774. private identifyBorder;
  64775. private updateMesh;
  64776. private vertexError;
  64777. private calculateError;
  64778. }
  64779. }
  64780. declare module BABYLON {
  64781. interface Scene {
  64782. /** @hidden (Backing field) */
  64783. _simplificationQueue: SimplificationQueue;
  64784. /**
  64785. * Gets or sets the simplification queue attached to the scene
  64786. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64787. */
  64788. simplificationQueue: SimplificationQueue;
  64789. }
  64790. interface Mesh {
  64791. /**
  64792. * Simplify the mesh according to the given array of settings.
  64793. * Function will return immediately and will simplify async
  64794. * @param settings a collection of simplification settings
  64795. * @param parallelProcessing should all levels calculate parallel or one after the other
  64796. * @param simplificationType the type of simplification to run
  64797. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64798. * @returns the current mesh
  64799. */
  64800. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64801. }
  64802. /**
  64803. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64804. * created in a scene
  64805. */
  64806. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64807. /**
  64808. * The component name helpfull to identify the component in the list of scene components.
  64809. */
  64810. readonly name: string;
  64811. /**
  64812. * The scene the component belongs to.
  64813. */
  64814. scene: Scene;
  64815. /**
  64816. * Creates a new instance of the component for the given scene
  64817. * @param scene Defines the scene to register the component in
  64818. */
  64819. constructor(scene: Scene);
  64820. /**
  64821. * Registers the component in a given scene
  64822. */
  64823. register(): void;
  64824. /**
  64825. * Rebuilds the elements related to this component in case of
  64826. * context lost for instance.
  64827. */
  64828. rebuild(): void;
  64829. /**
  64830. * Disposes the component and the associated ressources
  64831. */
  64832. dispose(): void;
  64833. private _beforeCameraUpdate;
  64834. }
  64835. }
  64836. declare module BABYLON {
  64837. /**
  64838. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64839. */
  64840. export interface INavigationEnginePlugin {
  64841. /**
  64842. * plugin name
  64843. */
  64844. name: string;
  64845. /**
  64846. * Creates a navigation mesh
  64847. * @param meshes array of all the geometry used to compute the navigatio mesh
  64848. * @param parameters bunch of parameters used to filter geometry
  64849. */
  64850. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64851. /**
  64852. * Create a navigation mesh debug mesh
  64853. * @param scene is where the mesh will be added
  64854. * @returns debug display mesh
  64855. */
  64856. createDebugNavMesh(scene: Scene): Mesh;
  64857. /**
  64858. * Get a navigation mesh constrained position, closest to the parameter position
  64859. * @param position world position
  64860. * @returns the closest point to position constrained by the navigation mesh
  64861. */
  64862. getClosestPoint(position: Vector3): Vector3;
  64863. /**
  64864. * Get a navigation mesh constrained position, closest to the parameter position
  64865. * @param position world position
  64866. * @param result output the closest point to position constrained by the navigation mesh
  64867. */
  64868. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64869. /**
  64870. * Get a navigation mesh constrained position, within a particular radius
  64871. * @param position world position
  64872. * @param maxRadius the maximum distance to the constrained world position
  64873. * @returns the closest point to position constrained by the navigation mesh
  64874. */
  64875. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64876. /**
  64877. * Get a navigation mesh constrained position, within a particular radius
  64878. * @param position world position
  64879. * @param maxRadius the maximum distance to the constrained world position
  64880. * @param result output the closest point to position constrained by the navigation mesh
  64881. */
  64882. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64883. /**
  64884. * Compute the final position from a segment made of destination-position
  64885. * @param position world position
  64886. * @param destination world position
  64887. * @returns the resulting point along the navmesh
  64888. */
  64889. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64890. /**
  64891. * Compute the final position from a segment made of destination-position
  64892. * @param position world position
  64893. * @param destination world position
  64894. * @param result output the resulting point along the navmesh
  64895. */
  64896. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64897. /**
  64898. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64899. * @param start world position
  64900. * @param end world position
  64901. * @returns array containing world position composing the path
  64902. */
  64903. computePath(start: Vector3, end: Vector3): Vector3[];
  64904. /**
  64905. * If this plugin is supported
  64906. * @returns true if plugin is supported
  64907. */
  64908. isSupported(): boolean;
  64909. /**
  64910. * Create a new Crowd so you can add agents
  64911. * @param maxAgents the maximum agent count in the crowd
  64912. * @param maxAgentRadius the maximum radius an agent can have
  64913. * @param scene to attach the crowd to
  64914. * @returns the crowd you can add agents to
  64915. */
  64916. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64917. /**
  64918. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64919. * The queries will try to find a solution within those bounds
  64920. * default is (1,1,1)
  64921. * @param extent x,y,z value that define the extent around the queries point of reference
  64922. */
  64923. setDefaultQueryExtent(extent: Vector3): void;
  64924. /**
  64925. * Get the Bounding box extent specified by setDefaultQueryExtent
  64926. * @returns the box extent values
  64927. */
  64928. getDefaultQueryExtent(): Vector3;
  64929. /**
  64930. * build the navmesh from a previously saved state using getNavmeshData
  64931. * @param data the Uint8Array returned by getNavmeshData
  64932. */
  64933. buildFromNavmeshData(data: Uint8Array): void;
  64934. /**
  64935. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64936. * @returns data the Uint8Array that can be saved and reused
  64937. */
  64938. getNavmeshData(): Uint8Array;
  64939. /**
  64940. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64941. * @param result output the box extent values
  64942. */
  64943. getDefaultQueryExtentToRef(result: Vector3): void;
  64944. /**
  64945. * Release all resources
  64946. */
  64947. dispose(): void;
  64948. }
  64949. /**
  64950. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64951. */
  64952. export interface ICrowd {
  64953. /**
  64954. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64955. * You can attach anything to that node. The node position is updated in the scene update tick.
  64956. * @param pos world position that will be constrained by the navigation mesh
  64957. * @param parameters agent parameters
  64958. * @param transform hooked to the agent that will be update by the scene
  64959. * @returns agent index
  64960. */
  64961. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64962. /**
  64963. * Returns the agent position in world space
  64964. * @param index agent index returned by addAgent
  64965. * @returns world space position
  64966. */
  64967. getAgentPosition(index: number): Vector3;
  64968. /**
  64969. * Gets the agent position result in world space
  64970. * @param index agent index returned by addAgent
  64971. * @param result output world space position
  64972. */
  64973. getAgentPositionToRef(index: number, result: Vector3): void;
  64974. /**
  64975. * Gets the agent velocity in world space
  64976. * @param index agent index returned by addAgent
  64977. * @returns world space velocity
  64978. */
  64979. getAgentVelocity(index: number): Vector3;
  64980. /**
  64981. * Gets the agent velocity result in world space
  64982. * @param index agent index returned by addAgent
  64983. * @param result output world space velocity
  64984. */
  64985. getAgentVelocityToRef(index: number, result: Vector3): void;
  64986. /**
  64987. * remove a particular agent previously created
  64988. * @param index agent index returned by addAgent
  64989. */
  64990. removeAgent(index: number): void;
  64991. /**
  64992. * get the list of all agents attached to this crowd
  64993. * @returns list of agent indices
  64994. */
  64995. getAgents(): number[];
  64996. /**
  64997. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64998. * @param deltaTime in seconds
  64999. */
  65000. update(deltaTime: number): void;
  65001. /**
  65002. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65003. * @param index agent index returned by addAgent
  65004. * @param destination targeted world position
  65005. */
  65006. agentGoto(index: number, destination: Vector3): void;
  65007. /**
  65008. * Teleport the agent to a new position
  65009. * @param index agent index returned by addAgent
  65010. * @param destination targeted world position
  65011. */
  65012. agentTeleport(index: number, destination: Vector3): void;
  65013. /**
  65014. * Update agent parameters
  65015. * @param index agent index returned by addAgent
  65016. * @param parameters agent parameters
  65017. */
  65018. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65019. /**
  65020. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65021. * The queries will try to find a solution within those bounds
  65022. * default is (1,1,1)
  65023. * @param extent x,y,z value that define the extent around the queries point of reference
  65024. */
  65025. setDefaultQueryExtent(extent: Vector3): void;
  65026. /**
  65027. * Get the Bounding box extent specified by setDefaultQueryExtent
  65028. * @returns the box extent values
  65029. */
  65030. getDefaultQueryExtent(): Vector3;
  65031. /**
  65032. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65033. * @param result output the box extent values
  65034. */
  65035. getDefaultQueryExtentToRef(result: Vector3): void;
  65036. /**
  65037. * Release all resources
  65038. */
  65039. dispose(): void;
  65040. }
  65041. /**
  65042. * Configures an agent
  65043. */
  65044. export interface IAgentParameters {
  65045. /**
  65046. * Agent radius. [Limit: >= 0]
  65047. */
  65048. radius: number;
  65049. /**
  65050. * Agent height. [Limit: > 0]
  65051. */
  65052. height: number;
  65053. /**
  65054. * Maximum allowed acceleration. [Limit: >= 0]
  65055. */
  65056. maxAcceleration: number;
  65057. /**
  65058. * Maximum allowed speed. [Limit: >= 0]
  65059. */
  65060. maxSpeed: number;
  65061. /**
  65062. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65063. */
  65064. collisionQueryRange: number;
  65065. /**
  65066. * The path visibility optimization range. [Limit: > 0]
  65067. */
  65068. pathOptimizationRange: number;
  65069. /**
  65070. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65071. */
  65072. separationWeight: number;
  65073. }
  65074. /**
  65075. * Configures the navigation mesh creation
  65076. */
  65077. export interface INavMeshParameters {
  65078. /**
  65079. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65080. */
  65081. cs: number;
  65082. /**
  65083. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65084. */
  65085. ch: number;
  65086. /**
  65087. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65088. */
  65089. walkableSlopeAngle: number;
  65090. /**
  65091. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65092. * be considered walkable. [Limit: >= 3] [Units: vx]
  65093. */
  65094. walkableHeight: number;
  65095. /**
  65096. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65097. */
  65098. walkableClimb: number;
  65099. /**
  65100. * The distance to erode/shrink the walkable area of the heightfield away from
  65101. * obstructions. [Limit: >=0] [Units: vx]
  65102. */
  65103. walkableRadius: number;
  65104. /**
  65105. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65106. */
  65107. maxEdgeLen: number;
  65108. /**
  65109. * The maximum distance a simplfied contour's border edges should deviate
  65110. * the original raw contour. [Limit: >=0] [Units: vx]
  65111. */
  65112. maxSimplificationError: number;
  65113. /**
  65114. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65115. */
  65116. minRegionArea: number;
  65117. /**
  65118. * Any regions with a span count smaller than this value will, if possible,
  65119. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65120. */
  65121. mergeRegionArea: number;
  65122. /**
  65123. * The maximum number of vertices allowed for polygons generated during the
  65124. * contour to polygon conversion process. [Limit: >= 3]
  65125. */
  65126. maxVertsPerPoly: number;
  65127. /**
  65128. * Sets the sampling distance to use when generating the detail mesh.
  65129. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65130. */
  65131. detailSampleDist: number;
  65132. /**
  65133. * The maximum distance the detail mesh surface should deviate from heightfield
  65134. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65135. */
  65136. detailSampleMaxError: number;
  65137. }
  65138. }
  65139. declare module BABYLON {
  65140. /**
  65141. * RecastJS navigation plugin
  65142. */
  65143. export class RecastJSPlugin implements INavigationEnginePlugin {
  65144. /**
  65145. * Reference to the Recast library
  65146. */
  65147. bjsRECAST: any;
  65148. /**
  65149. * plugin name
  65150. */
  65151. name: string;
  65152. /**
  65153. * the first navmesh created. We might extend this to support multiple navmeshes
  65154. */
  65155. navMesh: any;
  65156. /**
  65157. * Initializes the recastJS plugin
  65158. * @param recastInjection can be used to inject your own recast reference
  65159. */
  65160. constructor(recastInjection?: any);
  65161. /**
  65162. * Creates a navigation mesh
  65163. * @param meshes array of all the geometry used to compute the navigatio mesh
  65164. * @param parameters bunch of parameters used to filter geometry
  65165. */
  65166. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65167. /**
  65168. * Create a navigation mesh debug mesh
  65169. * @param scene is where the mesh will be added
  65170. * @returns debug display mesh
  65171. */
  65172. createDebugNavMesh(scene: Scene): Mesh;
  65173. /**
  65174. * Get a navigation mesh constrained position, closest to the parameter position
  65175. * @param position world position
  65176. * @returns the closest point to position constrained by the navigation mesh
  65177. */
  65178. getClosestPoint(position: Vector3): Vector3;
  65179. /**
  65180. * Get a navigation mesh constrained position, closest to the parameter position
  65181. * @param position world position
  65182. * @param result output the closest point to position constrained by the navigation mesh
  65183. */
  65184. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65185. /**
  65186. * Get a navigation mesh constrained position, within a particular radius
  65187. * @param position world position
  65188. * @param maxRadius the maximum distance to the constrained world position
  65189. * @returns the closest point to position constrained by the navigation mesh
  65190. */
  65191. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65192. /**
  65193. * Get a navigation mesh constrained position, within a particular radius
  65194. * @param position world position
  65195. * @param maxRadius the maximum distance to the constrained world position
  65196. * @param result output the closest point to position constrained by the navigation mesh
  65197. */
  65198. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65199. /**
  65200. * Compute the final position from a segment made of destination-position
  65201. * @param position world position
  65202. * @param destination world position
  65203. * @returns the resulting point along the navmesh
  65204. */
  65205. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65206. /**
  65207. * Compute the final position from a segment made of destination-position
  65208. * @param position world position
  65209. * @param destination world position
  65210. * @param result output the resulting point along the navmesh
  65211. */
  65212. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65213. /**
  65214. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65215. * @param start world position
  65216. * @param end world position
  65217. * @returns array containing world position composing the path
  65218. */
  65219. computePath(start: Vector3, end: Vector3): Vector3[];
  65220. /**
  65221. * Create a new Crowd so you can add agents
  65222. * @param maxAgents the maximum agent count in the crowd
  65223. * @param maxAgentRadius the maximum radius an agent can have
  65224. * @param scene to attach the crowd to
  65225. * @returns the crowd you can add agents to
  65226. */
  65227. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65228. /**
  65229. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65230. * The queries will try to find a solution within those bounds
  65231. * default is (1,1,1)
  65232. * @param extent x,y,z value that define the extent around the queries point of reference
  65233. */
  65234. setDefaultQueryExtent(extent: Vector3): void;
  65235. /**
  65236. * Get the Bounding box extent specified by setDefaultQueryExtent
  65237. * @returns the box extent values
  65238. */
  65239. getDefaultQueryExtent(): Vector3;
  65240. /**
  65241. * build the navmesh from a previously saved state using getNavmeshData
  65242. * @param data the Uint8Array returned by getNavmeshData
  65243. */
  65244. buildFromNavmeshData(data: Uint8Array): void;
  65245. /**
  65246. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65247. * @returns data the Uint8Array that can be saved and reused
  65248. */
  65249. getNavmeshData(): Uint8Array;
  65250. /**
  65251. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65252. * @param result output the box extent values
  65253. */
  65254. getDefaultQueryExtentToRef(result: Vector3): void;
  65255. /**
  65256. * Disposes
  65257. */
  65258. dispose(): void;
  65259. /**
  65260. * If this plugin is supported
  65261. * @returns true if plugin is supported
  65262. */
  65263. isSupported(): boolean;
  65264. }
  65265. /**
  65266. * Recast detour crowd implementation
  65267. */
  65268. export class RecastJSCrowd implements ICrowd {
  65269. /**
  65270. * Recast/detour plugin
  65271. */
  65272. bjsRECASTPlugin: RecastJSPlugin;
  65273. /**
  65274. * Link to the detour crowd
  65275. */
  65276. recastCrowd: any;
  65277. /**
  65278. * One transform per agent
  65279. */
  65280. transforms: TransformNode[];
  65281. /**
  65282. * All agents created
  65283. */
  65284. agents: number[];
  65285. /**
  65286. * Link to the scene is kept to unregister the crowd from the scene
  65287. */
  65288. private _scene;
  65289. /**
  65290. * Observer for crowd updates
  65291. */
  65292. private _onBeforeAnimationsObserver;
  65293. /**
  65294. * Constructor
  65295. * @param plugin recastJS plugin
  65296. * @param maxAgents the maximum agent count in the crowd
  65297. * @param maxAgentRadius the maximum radius an agent can have
  65298. * @param scene to attach the crowd to
  65299. * @returns the crowd you can add agents to
  65300. */
  65301. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65302. /**
  65303. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65304. * You can attach anything to that node. The node position is updated in the scene update tick.
  65305. * @param pos world position that will be constrained by the navigation mesh
  65306. * @param parameters agent parameters
  65307. * @param transform hooked to the agent that will be update by the scene
  65308. * @returns agent index
  65309. */
  65310. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65311. /**
  65312. * Returns the agent position in world space
  65313. * @param index agent index returned by addAgent
  65314. * @returns world space position
  65315. */
  65316. getAgentPosition(index: number): Vector3;
  65317. /**
  65318. * Returns the agent position result in world space
  65319. * @param index agent index returned by addAgent
  65320. * @param result output world space position
  65321. */
  65322. getAgentPositionToRef(index: number, result: Vector3): void;
  65323. /**
  65324. * Returns the agent velocity in world space
  65325. * @param index agent index returned by addAgent
  65326. * @returns world space velocity
  65327. */
  65328. getAgentVelocity(index: number): Vector3;
  65329. /**
  65330. * Returns the agent velocity result in world space
  65331. * @param index agent index returned by addAgent
  65332. * @param result output world space velocity
  65333. */
  65334. getAgentVelocityToRef(index: number, result: Vector3): void;
  65335. /**
  65336. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65337. * @param index agent index returned by addAgent
  65338. * @param destination targeted world position
  65339. */
  65340. agentGoto(index: number, destination: Vector3): void;
  65341. /**
  65342. * Teleport the agent to a new position
  65343. * @param index agent index returned by addAgent
  65344. * @param destination targeted world position
  65345. */
  65346. agentTeleport(index: number, destination: Vector3): void;
  65347. /**
  65348. * Update agent parameters
  65349. * @param index agent index returned by addAgent
  65350. * @param parameters agent parameters
  65351. */
  65352. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65353. /**
  65354. * remove a particular agent previously created
  65355. * @param index agent index returned by addAgent
  65356. */
  65357. removeAgent(index: number): void;
  65358. /**
  65359. * get the list of all agents attached to this crowd
  65360. * @returns list of agent indices
  65361. */
  65362. getAgents(): number[];
  65363. /**
  65364. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65365. * @param deltaTime in seconds
  65366. */
  65367. update(deltaTime: number): void;
  65368. /**
  65369. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65370. * The queries will try to find a solution within those bounds
  65371. * default is (1,1,1)
  65372. * @param extent x,y,z value that define the extent around the queries point of reference
  65373. */
  65374. setDefaultQueryExtent(extent: Vector3): void;
  65375. /**
  65376. * Get the Bounding box extent specified by setDefaultQueryExtent
  65377. * @returns the box extent values
  65378. */
  65379. getDefaultQueryExtent(): Vector3;
  65380. /**
  65381. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65382. * @param result output the box extent values
  65383. */
  65384. getDefaultQueryExtentToRef(result: Vector3): void;
  65385. /**
  65386. * Release all resources
  65387. */
  65388. dispose(): void;
  65389. }
  65390. }
  65391. declare module BABYLON {
  65392. /**
  65393. * Class used to enable access to IndexedDB
  65394. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65395. */
  65396. export class Database implements IOfflineProvider {
  65397. private _callbackManifestChecked;
  65398. private _currentSceneUrl;
  65399. private _db;
  65400. private _enableSceneOffline;
  65401. private _enableTexturesOffline;
  65402. private _manifestVersionFound;
  65403. private _mustUpdateRessources;
  65404. private _hasReachedQuota;
  65405. private _isSupported;
  65406. private _idbFactory;
  65407. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65408. private static IsUASupportingBlobStorage;
  65409. /**
  65410. * Gets a boolean indicating if Database storate is enabled (off by default)
  65411. */
  65412. static IDBStorageEnabled: boolean;
  65413. /**
  65414. * Gets a boolean indicating if scene must be saved in the database
  65415. */
  65416. get enableSceneOffline(): boolean;
  65417. /**
  65418. * Gets a boolean indicating if textures must be saved in the database
  65419. */
  65420. get enableTexturesOffline(): boolean;
  65421. /**
  65422. * Creates a new Database
  65423. * @param urlToScene defines the url to load the scene
  65424. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65425. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65426. */
  65427. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65428. private static _ParseURL;
  65429. private static _ReturnFullUrlLocation;
  65430. private _checkManifestFile;
  65431. /**
  65432. * Open the database and make it available
  65433. * @param successCallback defines the callback to call on success
  65434. * @param errorCallback defines the callback to call on error
  65435. */
  65436. open(successCallback: () => void, errorCallback: () => void): void;
  65437. /**
  65438. * Loads an image from the database
  65439. * @param url defines the url to load from
  65440. * @param image defines the target DOM image
  65441. */
  65442. loadImage(url: string, image: HTMLImageElement): void;
  65443. private _loadImageFromDBAsync;
  65444. private _saveImageIntoDBAsync;
  65445. private _checkVersionFromDB;
  65446. private _loadVersionFromDBAsync;
  65447. private _saveVersionIntoDBAsync;
  65448. /**
  65449. * Loads a file from database
  65450. * @param url defines the URL to load from
  65451. * @param sceneLoaded defines a callback to call on success
  65452. * @param progressCallBack defines a callback to call when progress changed
  65453. * @param errorCallback defines a callback to call on error
  65454. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65455. */
  65456. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65457. private _loadFileAsync;
  65458. private _saveFileAsync;
  65459. /**
  65460. * Validates if xhr data is correct
  65461. * @param xhr defines the request to validate
  65462. * @param dataType defines the expected data type
  65463. * @returns true if data is correct
  65464. */
  65465. private static _ValidateXHRData;
  65466. }
  65467. }
  65468. declare module BABYLON {
  65469. /** @hidden */
  65470. export var gpuUpdateParticlesPixelShader: {
  65471. name: string;
  65472. shader: string;
  65473. };
  65474. }
  65475. declare module BABYLON {
  65476. /** @hidden */
  65477. export var gpuUpdateParticlesVertexShader: {
  65478. name: string;
  65479. shader: string;
  65480. };
  65481. }
  65482. declare module BABYLON {
  65483. /** @hidden */
  65484. export var clipPlaneFragmentDeclaration2: {
  65485. name: string;
  65486. shader: string;
  65487. };
  65488. }
  65489. declare module BABYLON {
  65490. /** @hidden */
  65491. export var gpuRenderParticlesPixelShader: {
  65492. name: string;
  65493. shader: string;
  65494. };
  65495. }
  65496. declare module BABYLON {
  65497. /** @hidden */
  65498. export var clipPlaneVertexDeclaration2: {
  65499. name: string;
  65500. shader: string;
  65501. };
  65502. }
  65503. declare module BABYLON {
  65504. /** @hidden */
  65505. export var gpuRenderParticlesVertexShader: {
  65506. name: string;
  65507. shader: string;
  65508. };
  65509. }
  65510. declare module BABYLON {
  65511. /**
  65512. * This represents a GPU particle system in Babylon
  65513. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65514. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65515. */
  65516. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65517. /**
  65518. * The layer mask we are rendering the particles through.
  65519. */
  65520. layerMask: number;
  65521. private _capacity;
  65522. private _activeCount;
  65523. private _currentActiveCount;
  65524. private _accumulatedCount;
  65525. private _renderEffect;
  65526. private _updateEffect;
  65527. private _buffer0;
  65528. private _buffer1;
  65529. private _spriteBuffer;
  65530. private _updateVAO;
  65531. private _renderVAO;
  65532. private _targetIndex;
  65533. private _sourceBuffer;
  65534. private _targetBuffer;
  65535. private _engine;
  65536. private _currentRenderId;
  65537. private _started;
  65538. private _stopped;
  65539. private _timeDelta;
  65540. private _randomTexture;
  65541. private _randomTexture2;
  65542. private _attributesStrideSize;
  65543. private _updateEffectOptions;
  65544. private _randomTextureSize;
  65545. private _actualFrame;
  65546. private _customEffect;
  65547. private readonly _rawTextureWidth;
  65548. /**
  65549. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65550. */
  65551. static get IsSupported(): boolean;
  65552. /**
  65553. * An event triggered when the system is disposed.
  65554. */
  65555. onDisposeObservable: Observable<IParticleSystem>;
  65556. /**
  65557. * Gets the maximum number of particles active at the same time.
  65558. * @returns The max number of active particles.
  65559. */
  65560. getCapacity(): number;
  65561. /**
  65562. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65563. * to override the particles.
  65564. */
  65565. forceDepthWrite: boolean;
  65566. /**
  65567. * Gets or set the number of active particles
  65568. */
  65569. get activeParticleCount(): number;
  65570. set activeParticleCount(value: number);
  65571. private _preWarmDone;
  65572. /**
  65573. * Specifies if the particles are updated in emitter local space or world space.
  65574. */
  65575. isLocal: boolean;
  65576. /**
  65577. * Is this system ready to be used/rendered
  65578. * @return true if the system is ready
  65579. */
  65580. isReady(): boolean;
  65581. /**
  65582. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65583. * @returns True if it has been started, otherwise false.
  65584. */
  65585. isStarted(): boolean;
  65586. /**
  65587. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65588. * @returns True if it has been stopped, otherwise false.
  65589. */
  65590. isStopped(): boolean;
  65591. /**
  65592. * Gets a boolean indicating that the system is stopping
  65593. * @returns true if the system is currently stopping
  65594. */
  65595. isStopping(): boolean;
  65596. /**
  65597. * Gets the number of particles active at the same time.
  65598. * @returns The number of active particles.
  65599. */
  65600. getActiveCount(): number;
  65601. /**
  65602. * Starts the particle system and begins to emit
  65603. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65604. */
  65605. start(delay?: number): void;
  65606. /**
  65607. * Stops the particle system.
  65608. */
  65609. stop(): void;
  65610. /**
  65611. * Remove all active particles
  65612. */
  65613. reset(): void;
  65614. /**
  65615. * Returns the string "GPUParticleSystem"
  65616. * @returns a string containing the class name
  65617. */
  65618. getClassName(): string;
  65619. /**
  65620. * Gets the custom effect used to render the particles
  65621. * @param blendMode Blend mode for which the effect should be retrieved
  65622. * @returns The effect
  65623. */
  65624. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65625. /**
  65626. * Sets the custom effect used to render the particles
  65627. * @param effect The effect to set
  65628. * @param blendMode Blend mode for which the effect should be set
  65629. */
  65630. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65631. /** @hidden */
  65632. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65633. /**
  65634. * Observable that will be called just before the particles are drawn
  65635. */
  65636. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65637. /**
  65638. * Gets the name of the particle vertex shader
  65639. */
  65640. get vertexShaderName(): string;
  65641. private _colorGradientsTexture;
  65642. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65643. /**
  65644. * Adds a new color gradient
  65645. * @param gradient defines the gradient to use (between 0 and 1)
  65646. * @param color1 defines the color to affect to the specified gradient
  65647. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65648. * @returns the current particle system
  65649. */
  65650. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65651. private _refreshColorGradient;
  65652. /** Force the system to rebuild all gradients that need to be resync */
  65653. forceRefreshGradients(): void;
  65654. /**
  65655. * Remove a specific color gradient
  65656. * @param gradient defines the gradient to remove
  65657. * @returns the current particle system
  65658. */
  65659. removeColorGradient(gradient: number): GPUParticleSystem;
  65660. private _angularSpeedGradientsTexture;
  65661. private _sizeGradientsTexture;
  65662. private _velocityGradientsTexture;
  65663. private _limitVelocityGradientsTexture;
  65664. private _dragGradientsTexture;
  65665. private _addFactorGradient;
  65666. /**
  65667. * Adds a new size gradient
  65668. * @param gradient defines the gradient to use (between 0 and 1)
  65669. * @param factor defines the size factor to affect to the specified gradient
  65670. * @returns the current particle system
  65671. */
  65672. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65673. /**
  65674. * Remove a specific size gradient
  65675. * @param gradient defines the gradient to remove
  65676. * @returns the current particle system
  65677. */
  65678. removeSizeGradient(gradient: number): GPUParticleSystem;
  65679. private _refreshFactorGradient;
  65680. /**
  65681. * Adds a new angular speed gradient
  65682. * @param gradient defines the gradient to use (between 0 and 1)
  65683. * @param factor defines the angular speed to affect to the specified gradient
  65684. * @returns the current particle system
  65685. */
  65686. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65687. /**
  65688. * Remove a specific angular speed gradient
  65689. * @param gradient defines the gradient to remove
  65690. * @returns the current particle system
  65691. */
  65692. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65693. /**
  65694. * Adds a new velocity gradient
  65695. * @param gradient defines the gradient to use (between 0 and 1)
  65696. * @param factor defines the velocity to affect to the specified gradient
  65697. * @returns the current particle system
  65698. */
  65699. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65700. /**
  65701. * Remove a specific velocity gradient
  65702. * @param gradient defines the gradient to remove
  65703. * @returns the current particle system
  65704. */
  65705. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65706. /**
  65707. * Adds a new limit velocity gradient
  65708. * @param gradient defines the gradient to use (between 0 and 1)
  65709. * @param factor defines the limit velocity value to affect to the specified gradient
  65710. * @returns the current particle system
  65711. */
  65712. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65713. /**
  65714. * Remove a specific limit velocity gradient
  65715. * @param gradient defines the gradient to remove
  65716. * @returns the current particle system
  65717. */
  65718. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65719. /**
  65720. * Adds a new drag gradient
  65721. * @param gradient defines the gradient to use (between 0 and 1)
  65722. * @param factor defines the drag value to affect to the specified gradient
  65723. * @returns the current particle system
  65724. */
  65725. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65726. /**
  65727. * Remove a specific drag gradient
  65728. * @param gradient defines the gradient to remove
  65729. * @returns the current particle system
  65730. */
  65731. removeDragGradient(gradient: number): GPUParticleSystem;
  65732. /**
  65733. * Not supported by GPUParticleSystem
  65734. * @param gradient defines the gradient to use (between 0 and 1)
  65735. * @param factor defines the emit rate value to affect to the specified gradient
  65736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65737. * @returns the current particle system
  65738. */
  65739. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65740. /**
  65741. * Not supported by GPUParticleSystem
  65742. * @param gradient defines the gradient to remove
  65743. * @returns the current particle system
  65744. */
  65745. removeEmitRateGradient(gradient: number): IParticleSystem;
  65746. /**
  65747. * Not supported by GPUParticleSystem
  65748. * @param gradient defines the gradient to use (between 0 and 1)
  65749. * @param factor defines the start size value to affect to the specified gradient
  65750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65751. * @returns the current particle system
  65752. */
  65753. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65754. /**
  65755. * Not supported by GPUParticleSystem
  65756. * @param gradient defines the gradient to remove
  65757. * @returns the current particle system
  65758. */
  65759. removeStartSizeGradient(gradient: number): IParticleSystem;
  65760. /**
  65761. * Not supported by GPUParticleSystem
  65762. * @param gradient defines the gradient to use (between 0 and 1)
  65763. * @param min defines the color remap minimal range
  65764. * @param max defines the color remap maximal range
  65765. * @returns the current particle system
  65766. */
  65767. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65768. /**
  65769. * Not supported by GPUParticleSystem
  65770. * @param gradient defines the gradient to remove
  65771. * @returns the current particle system
  65772. */
  65773. removeColorRemapGradient(): IParticleSystem;
  65774. /**
  65775. * Not supported by GPUParticleSystem
  65776. * @param gradient defines the gradient to use (between 0 and 1)
  65777. * @param min defines the alpha remap minimal range
  65778. * @param max defines the alpha remap maximal range
  65779. * @returns the current particle system
  65780. */
  65781. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65782. /**
  65783. * Not supported by GPUParticleSystem
  65784. * @param gradient defines the gradient to remove
  65785. * @returns the current particle system
  65786. */
  65787. removeAlphaRemapGradient(): IParticleSystem;
  65788. /**
  65789. * Not supported by GPUParticleSystem
  65790. * @param gradient defines the gradient to use (between 0 and 1)
  65791. * @param color defines the color to affect to the specified gradient
  65792. * @returns the current particle system
  65793. */
  65794. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65795. /**
  65796. * Not supported by GPUParticleSystem
  65797. * @param gradient defines the gradient to remove
  65798. * @returns the current particle system
  65799. */
  65800. removeRampGradient(): IParticleSystem;
  65801. /**
  65802. * Not supported by GPUParticleSystem
  65803. * @returns the list of ramp gradients
  65804. */
  65805. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65806. /**
  65807. * Not supported by GPUParticleSystem
  65808. * Gets or sets a boolean indicating that ramp gradients must be used
  65809. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65810. */
  65811. get useRampGradients(): boolean;
  65812. set useRampGradients(value: boolean);
  65813. /**
  65814. * Not supported by GPUParticleSystem
  65815. * @param gradient defines the gradient to use (between 0 and 1)
  65816. * @param factor defines the life time factor to affect to the specified gradient
  65817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65818. * @returns the current particle system
  65819. */
  65820. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65821. /**
  65822. * Not supported by GPUParticleSystem
  65823. * @param gradient defines the gradient to remove
  65824. * @returns the current particle system
  65825. */
  65826. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65827. /**
  65828. * Instantiates a GPU particle system.
  65829. * 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.
  65830. * @param name The name of the particle system
  65831. * @param options The options used to create the system
  65832. * @param scene The scene the particle system belongs to
  65833. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65834. * @param customEffect a custom effect used to change the way particles are rendered by default
  65835. */
  65836. constructor(name: string, options: Partial<{
  65837. capacity: number;
  65838. randomTextureSize: number;
  65839. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  65840. protected _reset(): void;
  65841. private _createUpdateVAO;
  65842. private _createRenderVAO;
  65843. private _initialize;
  65844. /** @hidden */
  65845. _recreateUpdateEffect(): void;
  65846. private _getEffect;
  65847. /**
  65848. * Fill the defines array according to the current settings of the particle system
  65849. * @param defines Array to be updated
  65850. * @param blendMode blend mode to take into account when updating the array
  65851. */
  65852. fillDefines(defines: Array<string>, blendMode?: number): void;
  65853. /**
  65854. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  65855. * @param uniforms Uniforms array to fill
  65856. * @param attributes Attributes array to fill
  65857. * @param samplers Samplers array to fill
  65858. */
  65859. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  65860. /** @hidden */
  65861. _recreateRenderEffect(): Effect;
  65862. /**
  65863. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65864. * @param preWarm defines if we are in the pre-warmimg phase
  65865. */
  65866. animate(preWarm?: boolean): void;
  65867. private _createFactorGradientTexture;
  65868. private _createSizeGradientTexture;
  65869. private _createAngularSpeedGradientTexture;
  65870. private _createVelocityGradientTexture;
  65871. private _createLimitVelocityGradientTexture;
  65872. private _createDragGradientTexture;
  65873. private _createColorGradientTexture;
  65874. /**
  65875. * Renders the particle system in its current state
  65876. * @param preWarm defines if the system should only update the particles but not render them
  65877. * @returns the current number of particles
  65878. */
  65879. render(preWarm?: boolean): number;
  65880. /**
  65881. * Rebuilds the particle system
  65882. */
  65883. rebuild(): void;
  65884. private _releaseBuffers;
  65885. private _releaseVAOs;
  65886. /**
  65887. * Disposes the particle system and free the associated resources
  65888. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65889. */
  65890. dispose(disposeTexture?: boolean): void;
  65891. /**
  65892. * Clones the particle system.
  65893. * @param name The name of the cloned object
  65894. * @param newEmitter The new emitter to use
  65895. * @returns the cloned particle system
  65896. */
  65897. clone(name: string, newEmitter: any): GPUParticleSystem;
  65898. /**
  65899. * Serializes the particle system to a JSON object
  65900. * @param serializeTexture defines if the texture must be serialized as well
  65901. * @returns the JSON object
  65902. */
  65903. serialize(serializeTexture?: boolean): any;
  65904. /**
  65905. * Parses a JSON object to create a GPU particle system.
  65906. * @param parsedParticleSystem The JSON object to parse
  65907. * @param scene The scene to create the particle system in
  65908. * @param rootUrl The root url to use to load external dependencies like texture
  65909. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65910. * @returns the parsed GPU particle system
  65911. */
  65912. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65913. }
  65914. }
  65915. declare module BABYLON {
  65916. /**
  65917. * Represents a set of particle systems working together to create a specific effect
  65918. */
  65919. export class ParticleSystemSet implements IDisposable {
  65920. /**
  65921. * Gets or sets base Assets URL
  65922. */
  65923. static BaseAssetsUrl: string;
  65924. private _emitterCreationOptions;
  65925. private _emitterNode;
  65926. /**
  65927. * Gets the particle system list
  65928. */
  65929. systems: IParticleSystem[];
  65930. /**
  65931. * Gets the emitter node used with this set
  65932. */
  65933. get emitterNode(): Nullable<TransformNode>;
  65934. /**
  65935. * Creates a new emitter mesh as a sphere
  65936. * @param options defines the options used to create the sphere
  65937. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65938. * @param scene defines the hosting scene
  65939. */
  65940. setEmitterAsSphere(options: {
  65941. diameter: number;
  65942. segments: number;
  65943. color: Color3;
  65944. }, renderingGroupId: number, scene: Scene): void;
  65945. /**
  65946. * Starts all particle systems of the set
  65947. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65948. */
  65949. start(emitter?: AbstractMesh): void;
  65950. /**
  65951. * Release all associated resources
  65952. */
  65953. dispose(): void;
  65954. /**
  65955. * Serialize the set into a JSON compatible object
  65956. * @param serializeTexture defines if the texture must be serialized as well
  65957. * @returns a JSON compatible representation of the set
  65958. */
  65959. serialize(serializeTexture?: boolean): any;
  65960. /**
  65961. * Parse a new ParticleSystemSet from a serialized source
  65962. * @param data defines a JSON compatible representation of the set
  65963. * @param scene defines the hosting scene
  65964. * @param gpu defines if we want GPU particles or CPU particles
  65965. * @returns a new ParticleSystemSet
  65966. */
  65967. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65968. }
  65969. }
  65970. declare module BABYLON {
  65971. /**
  65972. * This class is made for on one-liner static method to help creating particle system set.
  65973. */
  65974. export class ParticleHelper {
  65975. /**
  65976. * Gets or sets base Assets URL
  65977. */
  65978. static BaseAssetsUrl: string;
  65979. /** Define the Url to load snippets */
  65980. static SnippetUrl: string;
  65981. /**
  65982. * Create a default particle system that you can tweak
  65983. * @param emitter defines the emitter to use
  65984. * @param capacity defines the system capacity (default is 500 particles)
  65985. * @param scene defines the hosting scene
  65986. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65987. * @returns the new Particle system
  65988. */
  65989. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65990. /**
  65991. * This is the main static method (one-liner) of this helper to create different particle systems
  65992. * @param type This string represents the type to the particle system to create
  65993. * @param scene The scene where the particle system should live
  65994. * @param gpu If the system will use gpu
  65995. * @returns the ParticleSystemSet created
  65996. */
  65997. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65998. /**
  65999. * Static function used to export a particle system to a ParticleSystemSet variable.
  66000. * Please note that the emitter shape is not exported
  66001. * @param systems defines the particle systems to export
  66002. * @returns the created particle system set
  66003. */
  66004. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66005. /**
  66006. * Creates a particle system from a snippet saved in a remote file
  66007. * @param name defines the name of the particle system to create
  66008. * @param url defines the url to load from
  66009. * @param scene defines the hosting scene
  66010. * @param gpu If the system will use gpu
  66011. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66012. * @returns a promise that will resolve to the new particle system
  66013. */
  66014. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66015. /**
  66016. * Creates a particle system from a snippet saved by the particle system editor
  66017. * @param snippetId defines the snippet to load
  66018. * @param scene defines the hosting scene
  66019. * @param gpu If the system will use gpu
  66020. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66021. * @returns a promise that will resolve to the new particle system
  66022. */
  66023. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66024. }
  66025. }
  66026. declare module BABYLON {
  66027. interface Engine {
  66028. /**
  66029. * Create an effect to use with particle systems.
  66030. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66031. * the particle system for which you want to create a custom effect in the last parameter
  66032. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66033. * @param uniformsNames defines a list of attribute names
  66034. * @param samplers defines an array of string used to represent textures
  66035. * @param defines defines the string containing the defines to use to compile the shaders
  66036. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66037. * @param onCompiled defines a function to call when the effect creation is successful
  66038. * @param onError defines a function to call when the effect creation has failed
  66039. * @param particleSystem the particle system you want to create the effect for
  66040. * @returns the new Effect
  66041. */
  66042. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66043. }
  66044. interface Mesh {
  66045. /**
  66046. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66047. * @returns an array of IParticleSystem
  66048. */
  66049. getEmittedParticleSystems(): IParticleSystem[];
  66050. /**
  66051. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66052. * @returns an array of IParticleSystem
  66053. */
  66054. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66055. }
  66056. /**
  66057. * @hidden
  66058. */
  66059. export var _IDoNeedToBeInTheBuild: number;
  66060. }
  66061. declare module BABYLON {
  66062. /** Defines the 4 color options */
  66063. export enum PointColor {
  66064. /** color value */
  66065. Color = 2,
  66066. /** uv value */
  66067. UV = 1,
  66068. /** random value */
  66069. Random = 0,
  66070. /** stated value */
  66071. Stated = 3
  66072. }
  66073. /**
  66074. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66075. * 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.
  66076. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66077. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66078. *
  66079. * Full documentation here : TO BE ENTERED
  66080. */
  66081. export class PointsCloudSystem implements IDisposable {
  66082. /**
  66083. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66084. * Example : var p = SPS.particles[i];
  66085. */
  66086. particles: CloudPoint[];
  66087. /**
  66088. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66089. */
  66090. nbParticles: number;
  66091. /**
  66092. * This a counter for your own usage. It's not set by any SPS functions.
  66093. */
  66094. counter: number;
  66095. /**
  66096. * The PCS name. This name is also given to the underlying mesh.
  66097. */
  66098. name: string;
  66099. /**
  66100. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66101. */
  66102. mesh: Mesh;
  66103. /**
  66104. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66105. * Please read :
  66106. */
  66107. vars: any;
  66108. /**
  66109. * @hidden
  66110. */
  66111. _size: number;
  66112. private _scene;
  66113. private _promises;
  66114. private _positions;
  66115. private _indices;
  66116. private _normals;
  66117. private _colors;
  66118. private _uvs;
  66119. private _indices32;
  66120. private _positions32;
  66121. private _colors32;
  66122. private _uvs32;
  66123. private _updatable;
  66124. private _isVisibilityBoxLocked;
  66125. private _alwaysVisible;
  66126. private _groups;
  66127. private _groupCounter;
  66128. private _computeParticleColor;
  66129. private _computeParticleTexture;
  66130. private _computeParticleRotation;
  66131. private _computeBoundingBox;
  66132. private _isReady;
  66133. /**
  66134. * Creates a PCS (Points Cloud System) object
  66135. * @param name (String) is the PCS name, this will be the underlying mesh name
  66136. * @param pointSize (number) is the size for each point
  66137. * @param scene (Scene) is the scene in which the PCS is added
  66138. * @param options defines the options of the PCS e.g.
  66139. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66140. */
  66141. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66142. updatable?: boolean;
  66143. });
  66144. /**
  66145. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66146. * If no points were added to the PCS, the returned mesh is just a single point.
  66147. * @returns a promise for the created mesh
  66148. */
  66149. buildMeshAsync(): Promise<Mesh>;
  66150. /**
  66151. * @hidden
  66152. */
  66153. private _buildMesh;
  66154. private _addParticle;
  66155. private _randomUnitVector;
  66156. private _getColorIndicesForCoord;
  66157. private _setPointsColorOrUV;
  66158. private _colorFromTexture;
  66159. private _calculateDensity;
  66160. /**
  66161. * Adds points to the PCS in random positions within a unit sphere
  66162. * @param nb (positive integer) the number of particles to be created from this model
  66163. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66164. * @returns the number of groups in the system
  66165. */
  66166. addPoints(nb: number, pointFunction?: any): number;
  66167. /**
  66168. * Adds points to the PCS from the surface of the model shape
  66169. * @param mesh is any Mesh object that will be used as a surface model for the points
  66170. * @param nb (positive integer) the number of particles to be created from this model
  66171. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66172. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66173. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66174. * @returns the number of groups in the system
  66175. */
  66176. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66177. /**
  66178. * Adds points to the PCS inside the model shape
  66179. * @param mesh is any Mesh object that will be used as a surface model for the points
  66180. * @param nb (positive integer) the number of particles to be created from this model
  66181. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66182. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66183. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66184. * @returns the number of groups in the system
  66185. */
  66186. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66187. /**
  66188. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66189. * This method calls `updateParticle()` for each particle of the SPS.
  66190. * For an animated SPS, it is usually called within the render loop.
  66191. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66192. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66193. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66194. * @returns the PCS.
  66195. */
  66196. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66197. /**
  66198. * Disposes the PCS.
  66199. */
  66200. dispose(): void;
  66201. /**
  66202. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66203. * doc :
  66204. * @returns the PCS.
  66205. */
  66206. refreshVisibleSize(): PointsCloudSystem;
  66207. /**
  66208. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66209. * @param size the size (float) of the visibility box
  66210. * note : this doesn't lock the PCS mesh bounding box.
  66211. * doc :
  66212. */
  66213. setVisibilityBox(size: number): void;
  66214. /**
  66215. * Gets whether the PCS is always visible or not
  66216. * doc :
  66217. */
  66218. get isAlwaysVisible(): boolean;
  66219. /**
  66220. * Sets the PCS as always visible or not
  66221. * doc :
  66222. */
  66223. set isAlwaysVisible(val: boolean);
  66224. /**
  66225. * Tells to `setParticles()` to compute the particle rotations or not
  66226. * Default value : false. The PCS is faster when it's set to false
  66227. * Note : particle rotations are only applied to parent particles
  66228. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66229. */
  66230. set computeParticleRotation(val: boolean);
  66231. /**
  66232. * Tells to `setParticles()` to compute the particle colors or not.
  66233. * Default value : true. The PCS is faster when it's set to false.
  66234. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66235. */
  66236. set computeParticleColor(val: boolean);
  66237. set computeParticleTexture(val: boolean);
  66238. /**
  66239. * Gets if `setParticles()` computes the particle colors or not.
  66240. * Default value : false. The PCS is faster when it's set to false.
  66241. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66242. */
  66243. get computeParticleColor(): boolean;
  66244. /**
  66245. * Gets if `setParticles()` computes the particle textures or not.
  66246. * Default value : false. The PCS is faster when it's set to false.
  66247. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66248. */
  66249. get computeParticleTexture(): boolean;
  66250. /**
  66251. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66252. */
  66253. set computeBoundingBox(val: boolean);
  66254. /**
  66255. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66256. */
  66257. get computeBoundingBox(): boolean;
  66258. /**
  66259. * This function does nothing. It may be overwritten to set all the particle first values.
  66260. * The PCS doesn't call this function, you may have to call it by your own.
  66261. * doc :
  66262. */
  66263. initParticles(): void;
  66264. /**
  66265. * This function does nothing. It may be overwritten to recycle a particle
  66266. * The PCS doesn't call this function, you can to call it
  66267. * doc :
  66268. * @param particle The particle to recycle
  66269. * @returns the recycled particle
  66270. */
  66271. recycleParticle(particle: CloudPoint): CloudPoint;
  66272. /**
  66273. * Updates a particle : this function should be overwritten by the user.
  66274. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66275. * doc :
  66276. * @example : just set a particle position or velocity and recycle conditions
  66277. * @param particle The particle to update
  66278. * @returns the updated particle
  66279. */
  66280. updateParticle(particle: CloudPoint): CloudPoint;
  66281. /**
  66282. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66283. * This does nothing and may be overwritten by the user.
  66284. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66285. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66286. * @param update the boolean update value actually passed to setParticles()
  66287. */
  66288. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66289. /**
  66290. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66291. * This will be passed three parameters.
  66292. * This does nothing and may be overwritten by the user.
  66293. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66294. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66295. * @param update the boolean update value actually passed to setParticles()
  66296. */
  66297. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66298. }
  66299. }
  66300. declare module BABYLON {
  66301. /**
  66302. * Represents one particle of a points cloud system.
  66303. */
  66304. export class CloudPoint {
  66305. /**
  66306. * particle global index
  66307. */
  66308. idx: number;
  66309. /**
  66310. * The color of the particle
  66311. */
  66312. color: Nullable<Color4>;
  66313. /**
  66314. * The world space position of the particle.
  66315. */
  66316. position: Vector3;
  66317. /**
  66318. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66319. */
  66320. rotation: Vector3;
  66321. /**
  66322. * The world space rotation quaternion of the particle.
  66323. */
  66324. rotationQuaternion: Nullable<Quaternion>;
  66325. /**
  66326. * The uv of the particle.
  66327. */
  66328. uv: Nullable<Vector2>;
  66329. /**
  66330. * The current speed of the particle.
  66331. */
  66332. velocity: Vector3;
  66333. /**
  66334. * The pivot point in the particle local space.
  66335. */
  66336. pivot: Vector3;
  66337. /**
  66338. * Must the particle be translated from its pivot point in its local space ?
  66339. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66340. * Default : false
  66341. */
  66342. translateFromPivot: boolean;
  66343. /**
  66344. * Index of this particle in the global "positions" array (Internal use)
  66345. * @hidden
  66346. */
  66347. _pos: number;
  66348. /**
  66349. * @hidden Index of this particle in the global "indices" array (Internal use)
  66350. */
  66351. _ind: number;
  66352. /**
  66353. * Group this particle belongs to
  66354. */
  66355. _group: PointsGroup;
  66356. /**
  66357. * Group id of this particle
  66358. */
  66359. groupId: number;
  66360. /**
  66361. * Index of the particle in its group id (Internal use)
  66362. */
  66363. idxInGroup: number;
  66364. /**
  66365. * @hidden Particle BoundingInfo object (Internal use)
  66366. */
  66367. _boundingInfo: BoundingInfo;
  66368. /**
  66369. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66370. */
  66371. _pcs: PointsCloudSystem;
  66372. /**
  66373. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66374. */
  66375. _stillInvisible: boolean;
  66376. /**
  66377. * @hidden Last computed particle rotation matrix
  66378. */
  66379. _rotationMatrix: number[];
  66380. /**
  66381. * Parent particle Id, if any.
  66382. * Default null.
  66383. */
  66384. parentId: Nullable<number>;
  66385. /**
  66386. * @hidden Internal global position in the PCS.
  66387. */
  66388. _globalPosition: Vector3;
  66389. /**
  66390. * Creates a Point Cloud object.
  66391. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66392. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66393. * @param group (PointsGroup) is the group the particle belongs to
  66394. * @param groupId (integer) is the group identifier in the PCS.
  66395. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66396. * @param pcs defines the PCS it is associated to
  66397. */
  66398. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66399. /**
  66400. * get point size
  66401. */
  66402. get size(): Vector3;
  66403. /**
  66404. * Set point size
  66405. */
  66406. set size(scale: Vector3);
  66407. /**
  66408. * Legacy support, changed quaternion to rotationQuaternion
  66409. */
  66410. get quaternion(): Nullable<Quaternion>;
  66411. /**
  66412. * Legacy support, changed quaternion to rotationQuaternion
  66413. */
  66414. set quaternion(q: Nullable<Quaternion>);
  66415. /**
  66416. * Returns a boolean. True if the particle intersects a mesh, else false
  66417. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66418. * @param target is the object (point or mesh) what the intersection is computed against
  66419. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66420. * @returns true if it intersects
  66421. */
  66422. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66423. /**
  66424. * get the rotation matrix of the particle
  66425. * @hidden
  66426. */
  66427. getRotationMatrix(m: Matrix): void;
  66428. }
  66429. /**
  66430. * Represents a group of points in a points cloud system
  66431. * * PCS internal tool, don't use it manually.
  66432. */
  66433. export class PointsGroup {
  66434. /**
  66435. * The group id
  66436. * @hidden
  66437. */
  66438. groupID: number;
  66439. /**
  66440. * image data for group (internal use)
  66441. * @hidden
  66442. */
  66443. _groupImageData: Nullable<ArrayBufferView>;
  66444. /**
  66445. * Image Width (internal use)
  66446. * @hidden
  66447. */
  66448. _groupImgWidth: number;
  66449. /**
  66450. * Image Height (internal use)
  66451. * @hidden
  66452. */
  66453. _groupImgHeight: number;
  66454. /**
  66455. * Custom position function (internal use)
  66456. * @hidden
  66457. */
  66458. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66459. /**
  66460. * density per facet for surface points
  66461. * @hidden
  66462. */
  66463. _groupDensity: number[];
  66464. /**
  66465. * Only when points are colored by texture carries pointer to texture list array
  66466. * @hidden
  66467. */
  66468. _textureNb: number;
  66469. /**
  66470. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66471. * PCS internal tool, don't use it manually.
  66472. * @hidden
  66473. */
  66474. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66475. }
  66476. }
  66477. declare module BABYLON {
  66478. interface Scene {
  66479. /** @hidden (Backing field) */
  66480. _physicsEngine: Nullable<IPhysicsEngine>;
  66481. /** @hidden */
  66482. _physicsTimeAccumulator: number;
  66483. /**
  66484. * Gets the current physics engine
  66485. * @returns a IPhysicsEngine or null if none attached
  66486. */
  66487. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66488. /**
  66489. * Enables physics to the current scene
  66490. * @param gravity defines the scene's gravity for the physics engine
  66491. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66492. * @return a boolean indicating if the physics engine was initialized
  66493. */
  66494. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66495. /**
  66496. * Disables and disposes the physics engine associated with the scene
  66497. */
  66498. disablePhysicsEngine(): void;
  66499. /**
  66500. * Gets a boolean indicating if there is an active physics engine
  66501. * @returns a boolean indicating if there is an active physics engine
  66502. */
  66503. isPhysicsEnabled(): boolean;
  66504. /**
  66505. * Deletes a physics compound impostor
  66506. * @param compound defines the compound to delete
  66507. */
  66508. deleteCompoundImpostor(compound: any): void;
  66509. /**
  66510. * An event triggered when physic simulation is about to be run
  66511. */
  66512. onBeforePhysicsObservable: Observable<Scene>;
  66513. /**
  66514. * An event triggered when physic simulation has been done
  66515. */
  66516. onAfterPhysicsObservable: Observable<Scene>;
  66517. }
  66518. interface AbstractMesh {
  66519. /** @hidden */
  66520. _physicsImpostor: Nullable<PhysicsImpostor>;
  66521. /**
  66522. * Gets or sets impostor used for physic simulation
  66523. * @see http://doc.babylonjs.com/features/physics_engine
  66524. */
  66525. physicsImpostor: Nullable<PhysicsImpostor>;
  66526. /**
  66527. * Gets the current physics impostor
  66528. * @see http://doc.babylonjs.com/features/physics_engine
  66529. * @returns a physics impostor or null
  66530. */
  66531. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66532. /** Apply a physic impulse to the mesh
  66533. * @param force defines the force to apply
  66534. * @param contactPoint defines where to apply the force
  66535. * @returns the current mesh
  66536. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66537. */
  66538. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66539. /**
  66540. * Creates a physic joint between two meshes
  66541. * @param otherMesh defines the other mesh to use
  66542. * @param pivot1 defines the pivot to use on this mesh
  66543. * @param pivot2 defines the pivot to use on the other mesh
  66544. * @param options defines additional options (can be plugin dependent)
  66545. * @returns the current mesh
  66546. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66547. */
  66548. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66549. /** @hidden */
  66550. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66551. }
  66552. /**
  66553. * Defines the physics engine scene component responsible to manage a physics engine
  66554. */
  66555. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66556. /**
  66557. * The component name helpful to identify the component in the list of scene components.
  66558. */
  66559. readonly name: string;
  66560. /**
  66561. * The scene the component belongs to.
  66562. */
  66563. scene: Scene;
  66564. /**
  66565. * Creates a new instance of the component for the given scene
  66566. * @param scene Defines the scene to register the component in
  66567. */
  66568. constructor(scene: Scene);
  66569. /**
  66570. * Registers the component in a given scene
  66571. */
  66572. register(): void;
  66573. /**
  66574. * Rebuilds the elements related to this component in case of
  66575. * context lost for instance.
  66576. */
  66577. rebuild(): void;
  66578. /**
  66579. * Disposes the component and the associated ressources
  66580. */
  66581. dispose(): void;
  66582. }
  66583. }
  66584. declare module BABYLON {
  66585. /**
  66586. * A helper for physics simulations
  66587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66588. */
  66589. export class PhysicsHelper {
  66590. private _scene;
  66591. private _physicsEngine;
  66592. /**
  66593. * Initializes the Physics helper
  66594. * @param scene Babylon.js scene
  66595. */
  66596. constructor(scene: Scene);
  66597. /**
  66598. * Applies a radial explosion impulse
  66599. * @param origin the origin of the explosion
  66600. * @param radiusOrEventOptions the radius or the options of radial explosion
  66601. * @param strength the explosion strength
  66602. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66603. * @returns A physics radial explosion event, or null
  66604. */
  66605. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66606. /**
  66607. * Applies a radial explosion force
  66608. * @param origin the origin of the explosion
  66609. * @param radiusOrEventOptions the radius or the options of radial explosion
  66610. * @param strength the explosion strength
  66611. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66612. * @returns A physics radial explosion event, or null
  66613. */
  66614. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66615. /**
  66616. * Creates a gravitational field
  66617. * @param origin the origin of the explosion
  66618. * @param radiusOrEventOptions the radius or the options of radial explosion
  66619. * @param strength the explosion strength
  66620. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66621. * @returns A physics gravitational field event, or null
  66622. */
  66623. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66624. /**
  66625. * Creates a physics updraft event
  66626. * @param origin the origin of the updraft
  66627. * @param radiusOrEventOptions the radius or the options of the updraft
  66628. * @param strength the strength of the updraft
  66629. * @param height the height of the updraft
  66630. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66631. * @returns A physics updraft event, or null
  66632. */
  66633. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66634. /**
  66635. * Creates a physics vortex event
  66636. * @param origin the of the vortex
  66637. * @param radiusOrEventOptions the radius or the options of the vortex
  66638. * @param strength the strength of the vortex
  66639. * @param height the height of the vortex
  66640. * @returns a Physics vortex event, or null
  66641. * A physics vortex event or null
  66642. */
  66643. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66644. }
  66645. /**
  66646. * Represents a physics radial explosion event
  66647. */
  66648. class PhysicsRadialExplosionEvent {
  66649. private _scene;
  66650. private _options;
  66651. private _sphere;
  66652. private _dataFetched;
  66653. /**
  66654. * Initializes a radial explosioin event
  66655. * @param _scene BabylonJS scene
  66656. * @param _options The options for the vortex event
  66657. */
  66658. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66659. /**
  66660. * Returns the data related to the radial explosion event (sphere).
  66661. * @returns The radial explosion event data
  66662. */
  66663. getData(): PhysicsRadialExplosionEventData;
  66664. /**
  66665. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66666. * @param impostor A physics imposter
  66667. * @param origin the origin of the explosion
  66668. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66669. */
  66670. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66671. /**
  66672. * Triggers affecterd impostors callbacks
  66673. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66674. */
  66675. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66676. /**
  66677. * Disposes the sphere.
  66678. * @param force Specifies if the sphere should be disposed by force
  66679. */
  66680. dispose(force?: boolean): void;
  66681. /*** Helpers ***/
  66682. private _prepareSphere;
  66683. private _intersectsWithSphere;
  66684. }
  66685. /**
  66686. * Represents a gravitational field event
  66687. */
  66688. class PhysicsGravitationalFieldEvent {
  66689. private _physicsHelper;
  66690. private _scene;
  66691. private _origin;
  66692. private _options;
  66693. private _tickCallback;
  66694. private _sphere;
  66695. private _dataFetched;
  66696. /**
  66697. * Initializes the physics gravitational field event
  66698. * @param _physicsHelper A physics helper
  66699. * @param _scene BabylonJS scene
  66700. * @param _origin The origin position of the gravitational field event
  66701. * @param _options The options for the vortex event
  66702. */
  66703. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66704. /**
  66705. * Returns the data related to the gravitational field event (sphere).
  66706. * @returns A gravitational field event
  66707. */
  66708. getData(): PhysicsGravitationalFieldEventData;
  66709. /**
  66710. * Enables the gravitational field.
  66711. */
  66712. enable(): void;
  66713. /**
  66714. * Disables the gravitational field.
  66715. */
  66716. disable(): void;
  66717. /**
  66718. * Disposes the sphere.
  66719. * @param force The force to dispose from the gravitational field event
  66720. */
  66721. dispose(force?: boolean): void;
  66722. private _tick;
  66723. }
  66724. /**
  66725. * Represents a physics updraft event
  66726. */
  66727. class PhysicsUpdraftEvent {
  66728. private _scene;
  66729. private _origin;
  66730. private _options;
  66731. private _physicsEngine;
  66732. private _originTop;
  66733. private _originDirection;
  66734. private _tickCallback;
  66735. private _cylinder;
  66736. private _cylinderPosition;
  66737. private _dataFetched;
  66738. /**
  66739. * Initializes the physics updraft event
  66740. * @param _scene BabylonJS scene
  66741. * @param _origin The origin position of the updraft
  66742. * @param _options The options for the updraft event
  66743. */
  66744. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66745. /**
  66746. * Returns the data related to the updraft event (cylinder).
  66747. * @returns A physics updraft event
  66748. */
  66749. getData(): PhysicsUpdraftEventData;
  66750. /**
  66751. * Enables the updraft.
  66752. */
  66753. enable(): void;
  66754. /**
  66755. * Disables the updraft.
  66756. */
  66757. disable(): void;
  66758. /**
  66759. * Disposes the cylinder.
  66760. * @param force Specifies if the updraft should be disposed by force
  66761. */
  66762. dispose(force?: boolean): void;
  66763. private getImpostorHitData;
  66764. private _tick;
  66765. /*** Helpers ***/
  66766. private _prepareCylinder;
  66767. private _intersectsWithCylinder;
  66768. }
  66769. /**
  66770. * Represents a physics vortex event
  66771. */
  66772. class PhysicsVortexEvent {
  66773. private _scene;
  66774. private _origin;
  66775. private _options;
  66776. private _physicsEngine;
  66777. private _originTop;
  66778. private _tickCallback;
  66779. private _cylinder;
  66780. private _cylinderPosition;
  66781. private _dataFetched;
  66782. /**
  66783. * Initializes the physics vortex event
  66784. * @param _scene The BabylonJS scene
  66785. * @param _origin The origin position of the vortex
  66786. * @param _options The options for the vortex event
  66787. */
  66788. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66789. /**
  66790. * Returns the data related to the vortex event (cylinder).
  66791. * @returns The physics vortex event data
  66792. */
  66793. getData(): PhysicsVortexEventData;
  66794. /**
  66795. * Enables the vortex.
  66796. */
  66797. enable(): void;
  66798. /**
  66799. * Disables the cortex.
  66800. */
  66801. disable(): void;
  66802. /**
  66803. * Disposes the sphere.
  66804. * @param force
  66805. */
  66806. dispose(force?: boolean): void;
  66807. private getImpostorHitData;
  66808. private _tick;
  66809. /*** Helpers ***/
  66810. private _prepareCylinder;
  66811. private _intersectsWithCylinder;
  66812. }
  66813. /**
  66814. * Options fot the radial explosion event
  66815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66816. */
  66817. export class PhysicsRadialExplosionEventOptions {
  66818. /**
  66819. * The radius of the sphere for the radial explosion.
  66820. */
  66821. radius: number;
  66822. /**
  66823. * The strenth of the explosion.
  66824. */
  66825. strength: number;
  66826. /**
  66827. * The strenght of the force in correspondence to the distance of the affected object
  66828. */
  66829. falloff: PhysicsRadialImpulseFalloff;
  66830. /**
  66831. * Sphere options for the radial explosion.
  66832. */
  66833. sphere: {
  66834. segments: number;
  66835. diameter: number;
  66836. };
  66837. /**
  66838. * Sphere options for the radial explosion.
  66839. */
  66840. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66841. }
  66842. /**
  66843. * Options fot the updraft event
  66844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66845. */
  66846. export class PhysicsUpdraftEventOptions {
  66847. /**
  66848. * The radius of the cylinder for the vortex
  66849. */
  66850. radius: number;
  66851. /**
  66852. * The strenth of the updraft.
  66853. */
  66854. strength: number;
  66855. /**
  66856. * The height of the cylinder for the updraft.
  66857. */
  66858. height: number;
  66859. /**
  66860. * The mode for the the updraft.
  66861. */
  66862. updraftMode: PhysicsUpdraftMode;
  66863. }
  66864. /**
  66865. * Options fot the vortex event
  66866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66867. */
  66868. export class PhysicsVortexEventOptions {
  66869. /**
  66870. * The radius of the cylinder for the vortex
  66871. */
  66872. radius: number;
  66873. /**
  66874. * The strenth of the vortex.
  66875. */
  66876. strength: number;
  66877. /**
  66878. * The height of the cylinder for the vortex.
  66879. */
  66880. height: number;
  66881. /**
  66882. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66883. */
  66884. centripetalForceThreshold: number;
  66885. /**
  66886. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66887. */
  66888. centripetalForceMultiplier: number;
  66889. /**
  66890. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66891. */
  66892. centrifugalForceMultiplier: number;
  66893. /**
  66894. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66895. */
  66896. updraftForceMultiplier: number;
  66897. }
  66898. /**
  66899. * The strenght of the force in correspondence to the distance of the affected object
  66900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66901. */
  66902. export enum PhysicsRadialImpulseFalloff {
  66903. /** Defines that impulse is constant in strength across it's whole radius */
  66904. Constant = 0,
  66905. /** Defines that impulse gets weaker if it's further from the origin */
  66906. Linear = 1
  66907. }
  66908. /**
  66909. * The strength of the force in correspondence to the distance of the affected object
  66910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66911. */
  66912. export enum PhysicsUpdraftMode {
  66913. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66914. Center = 0,
  66915. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66916. Perpendicular = 1
  66917. }
  66918. /**
  66919. * Interface for a physics hit data
  66920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66921. */
  66922. export interface PhysicsHitData {
  66923. /**
  66924. * The force applied at the contact point
  66925. */
  66926. force: Vector3;
  66927. /**
  66928. * The contact point
  66929. */
  66930. contactPoint: Vector3;
  66931. /**
  66932. * The distance from the origin to the contact point
  66933. */
  66934. distanceFromOrigin: number;
  66935. }
  66936. /**
  66937. * Interface for radial explosion event data
  66938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66939. */
  66940. export interface PhysicsRadialExplosionEventData {
  66941. /**
  66942. * A sphere used for the radial explosion event
  66943. */
  66944. sphere: Mesh;
  66945. }
  66946. /**
  66947. * Interface for gravitational field event data
  66948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66949. */
  66950. export interface PhysicsGravitationalFieldEventData {
  66951. /**
  66952. * A sphere mesh used for the gravitational field event
  66953. */
  66954. sphere: Mesh;
  66955. }
  66956. /**
  66957. * Interface for updraft event data
  66958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66959. */
  66960. export interface PhysicsUpdraftEventData {
  66961. /**
  66962. * A cylinder used for the updraft event
  66963. */
  66964. cylinder: Mesh;
  66965. }
  66966. /**
  66967. * Interface for vortex event data
  66968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66969. */
  66970. export interface PhysicsVortexEventData {
  66971. /**
  66972. * A cylinder used for the vortex event
  66973. */
  66974. cylinder: Mesh;
  66975. }
  66976. /**
  66977. * Interface for an affected physics impostor
  66978. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66979. */
  66980. export interface PhysicsAffectedImpostorWithData {
  66981. /**
  66982. * The impostor affected by the effect
  66983. */
  66984. impostor: PhysicsImpostor;
  66985. /**
  66986. * The data about the hit/horce from the explosion
  66987. */
  66988. hitData: PhysicsHitData;
  66989. }
  66990. }
  66991. declare module BABYLON {
  66992. /** @hidden */
  66993. export var blackAndWhitePixelShader: {
  66994. name: string;
  66995. shader: string;
  66996. };
  66997. }
  66998. declare module BABYLON {
  66999. /**
  67000. * Post process used to render in black and white
  67001. */
  67002. export class BlackAndWhitePostProcess extends PostProcess {
  67003. /**
  67004. * Linear about to convert he result to black and white (default: 1)
  67005. */
  67006. degree: number;
  67007. /**
  67008. * Creates a black and white post process
  67009. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67010. * @param name The name of the effect.
  67011. * @param options The required width/height ratio to downsize to before computing the render pass.
  67012. * @param camera The camera to apply the render pass to.
  67013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67014. * @param engine The engine which the post process will be applied. (default: current engine)
  67015. * @param reusable If the post process can be reused on the same frame. (default: false)
  67016. */
  67017. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67018. }
  67019. }
  67020. declare module BABYLON {
  67021. /**
  67022. * This represents a set of one or more post processes in Babylon.
  67023. * A post process can be used to apply a shader to a texture after it is rendered.
  67024. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67025. */
  67026. export class PostProcessRenderEffect {
  67027. private _postProcesses;
  67028. private _getPostProcesses;
  67029. private _singleInstance;
  67030. private _cameras;
  67031. private _indicesForCamera;
  67032. /**
  67033. * Name of the effect
  67034. * @hidden
  67035. */
  67036. _name: string;
  67037. /**
  67038. * Instantiates a post process render effect.
  67039. * A post process can be used to apply a shader to a texture after it is rendered.
  67040. * @param engine The engine the effect is tied to
  67041. * @param name The name of the effect
  67042. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67043. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67044. */
  67045. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67046. /**
  67047. * Checks if all the post processes in the effect are supported.
  67048. */
  67049. get isSupported(): boolean;
  67050. /**
  67051. * Updates the current state of the effect
  67052. * @hidden
  67053. */
  67054. _update(): void;
  67055. /**
  67056. * Attaches the effect on cameras
  67057. * @param cameras The camera to attach to.
  67058. * @hidden
  67059. */
  67060. _attachCameras(cameras: Camera): void;
  67061. /**
  67062. * Attaches the effect on cameras
  67063. * @param cameras The camera to attach to.
  67064. * @hidden
  67065. */
  67066. _attachCameras(cameras: Camera[]): void;
  67067. /**
  67068. * Detaches the effect on cameras
  67069. * @param cameras The camera to detatch from.
  67070. * @hidden
  67071. */
  67072. _detachCameras(cameras: Camera): void;
  67073. /**
  67074. * Detatches the effect on cameras
  67075. * @param cameras The camera to detatch from.
  67076. * @hidden
  67077. */
  67078. _detachCameras(cameras: Camera[]): void;
  67079. /**
  67080. * Enables the effect on given cameras
  67081. * @param cameras The camera to enable.
  67082. * @hidden
  67083. */
  67084. _enable(cameras: Camera): void;
  67085. /**
  67086. * Enables the effect on given cameras
  67087. * @param cameras The camera to enable.
  67088. * @hidden
  67089. */
  67090. _enable(cameras: Nullable<Camera[]>): void;
  67091. /**
  67092. * Disables the effect on the given cameras
  67093. * @param cameras The camera to disable.
  67094. * @hidden
  67095. */
  67096. _disable(cameras: Camera): void;
  67097. /**
  67098. * Disables the effect on the given cameras
  67099. * @param cameras The camera to disable.
  67100. * @hidden
  67101. */
  67102. _disable(cameras: Nullable<Camera[]>): void;
  67103. /**
  67104. * Gets a list of the post processes contained in the effect.
  67105. * @param camera The camera to get the post processes on.
  67106. * @returns The list of the post processes in the effect.
  67107. */
  67108. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67109. }
  67110. }
  67111. declare module BABYLON {
  67112. /** @hidden */
  67113. export var extractHighlightsPixelShader: {
  67114. name: string;
  67115. shader: string;
  67116. };
  67117. }
  67118. declare module BABYLON {
  67119. /**
  67120. * 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.
  67121. */
  67122. export class ExtractHighlightsPostProcess extends PostProcess {
  67123. /**
  67124. * The luminance threshold, pixels below this value will be set to black.
  67125. */
  67126. threshold: number;
  67127. /** @hidden */
  67128. _exposure: number;
  67129. /**
  67130. * Post process which has the input texture to be used when performing highlight extraction
  67131. * @hidden
  67132. */
  67133. _inputPostProcess: Nullable<PostProcess>;
  67134. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67135. }
  67136. }
  67137. declare module BABYLON {
  67138. /** @hidden */
  67139. export var bloomMergePixelShader: {
  67140. name: string;
  67141. shader: string;
  67142. };
  67143. }
  67144. declare module BABYLON {
  67145. /**
  67146. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67147. */
  67148. export class BloomMergePostProcess extends PostProcess {
  67149. /** Weight of the bloom to be added to the original input. */
  67150. weight: number;
  67151. /**
  67152. * Creates a new instance of @see BloomMergePostProcess
  67153. * @param name The name of the effect.
  67154. * @param originalFromInput Post process which's input will be used for the merge.
  67155. * @param blurred Blurred highlights post process which's output will be used.
  67156. * @param weight Weight of the bloom to be added to the original input.
  67157. * @param options The required width/height ratio to downsize to before computing the render pass.
  67158. * @param camera The camera to apply the render pass to.
  67159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67160. * @param engine The engine which the post process will be applied. (default: current engine)
  67161. * @param reusable If the post process can be reused on the same frame. (default: false)
  67162. * @param textureType Type of textures used when performing the post process. (default: 0)
  67163. * @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)
  67164. */
  67165. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67166. /** Weight of the bloom to be added to the original input. */
  67167. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67168. }
  67169. }
  67170. declare module BABYLON {
  67171. /**
  67172. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67173. */
  67174. export class BloomEffect extends PostProcessRenderEffect {
  67175. private bloomScale;
  67176. /**
  67177. * @hidden Internal
  67178. */
  67179. _effects: Array<PostProcess>;
  67180. /**
  67181. * @hidden Internal
  67182. */
  67183. _downscale: ExtractHighlightsPostProcess;
  67184. private _blurX;
  67185. private _blurY;
  67186. private _merge;
  67187. /**
  67188. * The luminance threshold to find bright areas of the image to bloom.
  67189. */
  67190. get threshold(): number;
  67191. set threshold(value: number);
  67192. /**
  67193. * The strength of the bloom.
  67194. */
  67195. get weight(): number;
  67196. set weight(value: number);
  67197. /**
  67198. * Specifies the size of the bloom blur kernel, relative to the final output size
  67199. */
  67200. get kernel(): number;
  67201. set kernel(value: number);
  67202. /**
  67203. * Creates a new instance of @see BloomEffect
  67204. * @param scene The scene the effect belongs to.
  67205. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67206. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67207. * @param bloomWeight The the strength of bloom.
  67208. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67209. * @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)
  67210. */
  67211. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67212. /**
  67213. * Disposes each of the internal effects for a given camera.
  67214. * @param camera The camera to dispose the effect on.
  67215. */
  67216. disposeEffects(camera: Camera): void;
  67217. /**
  67218. * @hidden Internal
  67219. */
  67220. _updateEffects(): void;
  67221. /**
  67222. * Internal
  67223. * @returns if all the contained post processes are ready.
  67224. * @hidden
  67225. */
  67226. _isReady(): boolean;
  67227. }
  67228. }
  67229. declare module BABYLON {
  67230. /** @hidden */
  67231. export var chromaticAberrationPixelShader: {
  67232. name: string;
  67233. shader: string;
  67234. };
  67235. }
  67236. declare module BABYLON {
  67237. /**
  67238. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67239. */
  67240. export class ChromaticAberrationPostProcess extends PostProcess {
  67241. /**
  67242. * The amount of seperation of rgb channels (default: 30)
  67243. */
  67244. aberrationAmount: number;
  67245. /**
  67246. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67247. */
  67248. radialIntensity: number;
  67249. /**
  67250. * 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))
  67251. */
  67252. direction: Vector2;
  67253. /**
  67254. * 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))
  67255. */
  67256. centerPosition: Vector2;
  67257. /**
  67258. * Creates a new instance ChromaticAberrationPostProcess
  67259. * @param name The name of the effect.
  67260. * @param screenWidth The width of the screen to apply the effect on.
  67261. * @param screenHeight The height of the screen to apply the effect on.
  67262. * @param options The required width/height ratio to downsize to before computing the render pass.
  67263. * @param camera The camera to apply the render pass to.
  67264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67265. * @param engine The engine which the post process will be applied. (default: current engine)
  67266. * @param reusable If the post process can be reused on the same frame. (default: false)
  67267. * @param textureType Type of textures used when performing the post process. (default: 0)
  67268. * @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)
  67269. */
  67270. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67271. }
  67272. }
  67273. declare module BABYLON {
  67274. /** @hidden */
  67275. export var circleOfConfusionPixelShader: {
  67276. name: string;
  67277. shader: string;
  67278. };
  67279. }
  67280. declare module BABYLON {
  67281. /**
  67282. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67283. */
  67284. export class CircleOfConfusionPostProcess extends PostProcess {
  67285. /**
  67286. * 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.
  67287. */
  67288. lensSize: number;
  67289. /**
  67290. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67291. */
  67292. fStop: number;
  67293. /**
  67294. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67295. */
  67296. focusDistance: number;
  67297. /**
  67298. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67299. */
  67300. focalLength: number;
  67301. private _depthTexture;
  67302. /**
  67303. * Creates a new instance CircleOfConfusionPostProcess
  67304. * @param name The name of the effect.
  67305. * @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.
  67306. * @param options The required width/height ratio to downsize to before computing the render pass.
  67307. * @param camera The camera to apply the render pass to.
  67308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67309. * @param engine The engine which the post process will be applied. (default: current engine)
  67310. * @param reusable If the post process can be reused on the same frame. (default: false)
  67311. * @param textureType Type of textures used when performing the post process. (default: 0)
  67312. * @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)
  67313. */
  67314. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67315. /**
  67316. * 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.
  67317. */
  67318. set depthTexture(value: RenderTargetTexture);
  67319. }
  67320. }
  67321. declare module BABYLON {
  67322. /** @hidden */
  67323. export var colorCorrectionPixelShader: {
  67324. name: string;
  67325. shader: string;
  67326. };
  67327. }
  67328. declare module BABYLON {
  67329. /**
  67330. *
  67331. * This post-process allows the modification of rendered colors by using
  67332. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67333. *
  67334. * The object needs to be provided an url to a texture containing the color
  67335. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67336. * Use an image editing software to tweak the LUT to match your needs.
  67337. *
  67338. * For an example of a color LUT, see here:
  67339. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67340. * For explanations on color grading, see here:
  67341. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67342. *
  67343. */
  67344. export class ColorCorrectionPostProcess extends PostProcess {
  67345. private _colorTableTexture;
  67346. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67347. }
  67348. }
  67349. declare module BABYLON {
  67350. /** @hidden */
  67351. export var convolutionPixelShader: {
  67352. name: string;
  67353. shader: string;
  67354. };
  67355. }
  67356. declare module BABYLON {
  67357. /**
  67358. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67359. * input texture to perform effects such as edge detection or sharpening
  67360. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67361. */
  67362. export class ConvolutionPostProcess extends PostProcess {
  67363. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67364. kernel: number[];
  67365. /**
  67366. * Creates a new instance ConvolutionPostProcess
  67367. * @param name The name of the effect.
  67368. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67369. * @param options The required width/height ratio to downsize to before computing the render pass.
  67370. * @param camera The camera to apply the render pass to.
  67371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67372. * @param engine The engine which the post process will be applied. (default: current engine)
  67373. * @param reusable If the post process can be reused on the same frame. (default: false)
  67374. * @param textureType Type of textures used when performing the post process. (default: 0)
  67375. */
  67376. constructor(name: string,
  67377. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67378. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67379. /**
  67380. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67381. */
  67382. static EdgeDetect0Kernel: number[];
  67383. /**
  67384. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67385. */
  67386. static EdgeDetect1Kernel: number[];
  67387. /**
  67388. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67389. */
  67390. static EdgeDetect2Kernel: number[];
  67391. /**
  67392. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67393. */
  67394. static SharpenKernel: number[];
  67395. /**
  67396. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67397. */
  67398. static EmbossKernel: number[];
  67399. /**
  67400. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67401. */
  67402. static GaussianKernel: number[];
  67403. }
  67404. }
  67405. declare module BABYLON {
  67406. /**
  67407. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67408. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67409. * based on samples that have a large difference in distance than the center pixel.
  67410. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67411. */
  67412. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67413. direction: Vector2;
  67414. /**
  67415. * Creates a new instance CircleOfConfusionPostProcess
  67416. * @param name The name of the effect.
  67417. * @param scene The scene the effect belongs to.
  67418. * @param direction The direction the blur should be applied.
  67419. * @param kernel The size of the kernel used to blur.
  67420. * @param options The required width/height ratio to downsize to before computing the render pass.
  67421. * @param camera The camera to apply the render pass to.
  67422. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67423. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67425. * @param engine The engine which the post process will be applied. (default: current engine)
  67426. * @param reusable If the post process can be reused on the same frame. (default: false)
  67427. * @param textureType Type of textures used when performing the post process. (default: 0)
  67428. * @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)
  67429. */
  67430. 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);
  67431. }
  67432. }
  67433. declare module BABYLON {
  67434. /** @hidden */
  67435. export var depthOfFieldMergePixelShader: {
  67436. name: string;
  67437. shader: string;
  67438. };
  67439. }
  67440. declare module BABYLON {
  67441. /**
  67442. * Options to be set when merging outputs from the default pipeline.
  67443. */
  67444. export class DepthOfFieldMergePostProcessOptions {
  67445. /**
  67446. * The original image to merge on top of
  67447. */
  67448. originalFromInput: PostProcess;
  67449. /**
  67450. * Parameters to perform the merge of the depth of field effect
  67451. */
  67452. depthOfField?: {
  67453. circleOfConfusion: PostProcess;
  67454. blurSteps: Array<PostProcess>;
  67455. };
  67456. /**
  67457. * Parameters to perform the merge of bloom effect
  67458. */
  67459. bloom?: {
  67460. blurred: PostProcess;
  67461. weight: number;
  67462. };
  67463. }
  67464. /**
  67465. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67466. */
  67467. export class DepthOfFieldMergePostProcess extends PostProcess {
  67468. private blurSteps;
  67469. /**
  67470. * Creates a new instance of DepthOfFieldMergePostProcess
  67471. * @param name The name of the effect.
  67472. * @param originalFromInput Post process which's input will be used for the merge.
  67473. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67474. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67475. * @param options The required width/height ratio to downsize to before computing the render pass.
  67476. * @param camera The camera to apply the render pass to.
  67477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67478. * @param engine The engine which the post process will be applied. (default: current engine)
  67479. * @param reusable If the post process can be reused on the same frame. (default: false)
  67480. * @param textureType Type of textures used when performing the post process. (default: 0)
  67481. * @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)
  67482. */
  67483. 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);
  67484. /**
  67485. * Updates the effect with the current post process compile time values and recompiles the shader.
  67486. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67487. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67488. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67489. * @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
  67490. * @param onCompiled Called when the shader has been compiled.
  67491. * @param onError Called if there is an error when compiling a shader.
  67492. */
  67493. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67494. }
  67495. }
  67496. declare module BABYLON {
  67497. /**
  67498. * Specifies the level of max blur that should be applied when using the depth of field effect
  67499. */
  67500. export enum DepthOfFieldEffectBlurLevel {
  67501. /**
  67502. * Subtle blur
  67503. */
  67504. Low = 0,
  67505. /**
  67506. * Medium blur
  67507. */
  67508. Medium = 1,
  67509. /**
  67510. * Large blur
  67511. */
  67512. High = 2
  67513. }
  67514. /**
  67515. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67516. */
  67517. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67518. private _circleOfConfusion;
  67519. /**
  67520. * @hidden Internal, blurs from high to low
  67521. */
  67522. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67523. private _depthOfFieldBlurY;
  67524. private _dofMerge;
  67525. /**
  67526. * @hidden Internal post processes in depth of field effect
  67527. */
  67528. _effects: Array<PostProcess>;
  67529. /**
  67530. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67531. */
  67532. set focalLength(value: number);
  67533. get focalLength(): number;
  67534. /**
  67535. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67536. */
  67537. set fStop(value: number);
  67538. get fStop(): number;
  67539. /**
  67540. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67541. */
  67542. set focusDistance(value: number);
  67543. get focusDistance(): number;
  67544. /**
  67545. * 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.
  67546. */
  67547. set lensSize(value: number);
  67548. get lensSize(): number;
  67549. /**
  67550. * Creates a new instance DepthOfFieldEffect
  67551. * @param scene The scene the effect belongs to.
  67552. * @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.
  67553. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67554. * @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)
  67555. */
  67556. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67557. /**
  67558. * Get the current class name of the current effet
  67559. * @returns "DepthOfFieldEffect"
  67560. */
  67561. getClassName(): string;
  67562. /**
  67563. * 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.
  67564. */
  67565. set depthTexture(value: RenderTargetTexture);
  67566. /**
  67567. * Disposes each of the internal effects for a given camera.
  67568. * @param camera The camera to dispose the effect on.
  67569. */
  67570. disposeEffects(camera: Camera): void;
  67571. /**
  67572. * @hidden Internal
  67573. */
  67574. _updateEffects(): void;
  67575. /**
  67576. * Internal
  67577. * @returns if all the contained post processes are ready.
  67578. * @hidden
  67579. */
  67580. _isReady(): boolean;
  67581. }
  67582. }
  67583. declare module BABYLON {
  67584. /** @hidden */
  67585. export var displayPassPixelShader: {
  67586. name: string;
  67587. shader: string;
  67588. };
  67589. }
  67590. declare module BABYLON {
  67591. /**
  67592. * DisplayPassPostProcess which produces an output the same as it's input
  67593. */
  67594. export class DisplayPassPostProcess extends PostProcess {
  67595. /**
  67596. * Creates the DisplayPassPostProcess
  67597. * @param name The name of the effect.
  67598. * @param options The required width/height ratio to downsize to before computing the render pass.
  67599. * @param camera The camera to apply the render pass to.
  67600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67601. * @param engine The engine which the post process will be applied. (default: current engine)
  67602. * @param reusable If the post process can be reused on the same frame. (default: false)
  67603. */
  67604. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67605. }
  67606. }
  67607. declare module BABYLON {
  67608. /** @hidden */
  67609. export var filterPixelShader: {
  67610. name: string;
  67611. shader: string;
  67612. };
  67613. }
  67614. declare module BABYLON {
  67615. /**
  67616. * Applies a kernel filter to the image
  67617. */
  67618. export class FilterPostProcess extends PostProcess {
  67619. /** The matrix to be applied to the image */
  67620. kernelMatrix: Matrix;
  67621. /**
  67622. *
  67623. * @param name The name of the effect.
  67624. * @param kernelMatrix The matrix to be applied to the image
  67625. * @param options The required width/height ratio to downsize to before computing the render pass.
  67626. * @param camera The camera to apply the render pass to.
  67627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67628. * @param engine The engine which the post process will be applied. (default: current engine)
  67629. * @param reusable If the post process can be reused on the same frame. (default: false)
  67630. */
  67631. constructor(name: string,
  67632. /** The matrix to be applied to the image */
  67633. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67634. }
  67635. }
  67636. declare module BABYLON {
  67637. /** @hidden */
  67638. export var fxaaPixelShader: {
  67639. name: string;
  67640. shader: string;
  67641. };
  67642. }
  67643. declare module BABYLON {
  67644. /** @hidden */
  67645. export var fxaaVertexShader: {
  67646. name: string;
  67647. shader: string;
  67648. };
  67649. }
  67650. declare module BABYLON {
  67651. /**
  67652. * Fxaa post process
  67653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67654. */
  67655. export class FxaaPostProcess extends PostProcess {
  67656. /** @hidden */
  67657. texelWidth: number;
  67658. /** @hidden */
  67659. texelHeight: number;
  67660. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67661. private _getDefines;
  67662. }
  67663. }
  67664. declare module BABYLON {
  67665. /** @hidden */
  67666. export var grainPixelShader: {
  67667. name: string;
  67668. shader: string;
  67669. };
  67670. }
  67671. declare module BABYLON {
  67672. /**
  67673. * The GrainPostProcess adds noise to the image at mid luminance levels
  67674. */
  67675. export class GrainPostProcess extends PostProcess {
  67676. /**
  67677. * The intensity of the grain added (default: 30)
  67678. */
  67679. intensity: number;
  67680. /**
  67681. * If the grain should be randomized on every frame
  67682. */
  67683. animated: boolean;
  67684. /**
  67685. * Creates a new instance of @see GrainPostProcess
  67686. * @param name The name of the effect.
  67687. * @param options The required width/height ratio to downsize to before computing the render pass.
  67688. * @param camera The camera to apply the render pass to.
  67689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67690. * @param engine The engine which the post process will be applied. (default: current engine)
  67691. * @param reusable If the post process can be reused on the same frame. (default: false)
  67692. * @param textureType Type of textures used when performing the post process. (default: 0)
  67693. * @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)
  67694. */
  67695. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67696. }
  67697. }
  67698. declare module BABYLON {
  67699. /** @hidden */
  67700. export var highlightsPixelShader: {
  67701. name: string;
  67702. shader: string;
  67703. };
  67704. }
  67705. declare module BABYLON {
  67706. /**
  67707. * Extracts highlights from the image
  67708. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67709. */
  67710. export class HighlightsPostProcess extends PostProcess {
  67711. /**
  67712. * Extracts highlights from the image
  67713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67714. * @param name The name of the effect.
  67715. * @param options The required width/height ratio to downsize to before computing the render pass.
  67716. * @param camera The camera to apply the render pass to.
  67717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67718. * @param engine The engine which the post process will be applied. (default: current engine)
  67719. * @param reusable If the post process can be reused on the same frame. (default: false)
  67720. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67721. */
  67722. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67723. }
  67724. }
  67725. declare module BABYLON {
  67726. /** @hidden */
  67727. export var mrtFragmentDeclaration: {
  67728. name: string;
  67729. shader: string;
  67730. };
  67731. }
  67732. declare module BABYLON {
  67733. /** @hidden */
  67734. export var geometryPixelShader: {
  67735. name: string;
  67736. shader: string;
  67737. };
  67738. }
  67739. declare module BABYLON {
  67740. /** @hidden */
  67741. export var geometryVertexShader: {
  67742. name: string;
  67743. shader: string;
  67744. };
  67745. }
  67746. declare module BABYLON {
  67747. /** @hidden */
  67748. interface ISavedTransformationMatrix {
  67749. world: Matrix;
  67750. viewProjection: Matrix;
  67751. }
  67752. /**
  67753. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67754. */
  67755. export class GeometryBufferRenderer {
  67756. /**
  67757. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67758. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67759. */
  67760. static readonly POSITION_TEXTURE_TYPE: number;
  67761. /**
  67762. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67763. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67764. */
  67765. static readonly VELOCITY_TEXTURE_TYPE: number;
  67766. /**
  67767. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67768. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67769. */
  67770. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67771. /**
  67772. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67773. * in order to compute objects velocities when enableVelocity is set to "true"
  67774. * @hidden
  67775. */
  67776. _previousTransformationMatrices: {
  67777. [index: number]: ISavedTransformationMatrix;
  67778. };
  67779. /**
  67780. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67781. * in order to compute objects velocities when enableVelocity is set to "true"
  67782. * @hidden
  67783. */
  67784. _previousBonesTransformationMatrices: {
  67785. [index: number]: Float32Array;
  67786. };
  67787. /**
  67788. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67789. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67790. */
  67791. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67792. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67793. renderTransparentMeshes: boolean;
  67794. private _scene;
  67795. private _multiRenderTarget;
  67796. private _ratio;
  67797. private _enablePosition;
  67798. private _enableVelocity;
  67799. private _enableReflectivity;
  67800. private _positionIndex;
  67801. private _velocityIndex;
  67802. private _reflectivityIndex;
  67803. protected _effect: Effect;
  67804. protected _cachedDefines: string;
  67805. /**
  67806. * Set the render list (meshes to be rendered) used in the G buffer.
  67807. */
  67808. set renderList(meshes: Mesh[]);
  67809. /**
  67810. * Gets wether or not G buffer are supported by the running hardware.
  67811. * This requires draw buffer supports
  67812. */
  67813. get isSupported(): boolean;
  67814. /**
  67815. * Returns the index of the given texture type in the G-Buffer textures array
  67816. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67817. * @returns the index of the given texture type in the G-Buffer textures array
  67818. */
  67819. getTextureIndex(textureType: number): number;
  67820. /**
  67821. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67822. */
  67823. get enablePosition(): boolean;
  67824. /**
  67825. * Sets whether or not objects positions are enabled for the G buffer.
  67826. */
  67827. set enablePosition(enable: boolean);
  67828. /**
  67829. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67830. */
  67831. get enableVelocity(): boolean;
  67832. /**
  67833. * Sets wether or not objects velocities are enabled for the G buffer.
  67834. */
  67835. set enableVelocity(enable: boolean);
  67836. /**
  67837. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67838. */
  67839. get enableReflectivity(): boolean;
  67840. /**
  67841. * Sets wether or not objects roughness are enabled for the G buffer.
  67842. */
  67843. set enableReflectivity(enable: boolean);
  67844. /**
  67845. * Gets the scene associated with the buffer.
  67846. */
  67847. get scene(): Scene;
  67848. /**
  67849. * Gets the ratio used by the buffer during its creation.
  67850. * How big is the buffer related to the main canvas.
  67851. */
  67852. get ratio(): number;
  67853. /** @hidden */
  67854. static _SceneComponentInitialization: (scene: Scene) => void;
  67855. /**
  67856. * Creates a new G Buffer for the scene
  67857. * @param scene The scene the buffer belongs to
  67858. * @param ratio How big is the buffer related to the main canvas.
  67859. */
  67860. constructor(scene: Scene, ratio?: number);
  67861. /**
  67862. * Checks wether everything is ready to render a submesh to the G buffer.
  67863. * @param subMesh the submesh to check readiness for
  67864. * @param useInstances is the mesh drawn using instance or not
  67865. * @returns true if ready otherwise false
  67866. */
  67867. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67868. /**
  67869. * Gets the current underlying G Buffer.
  67870. * @returns the buffer
  67871. */
  67872. getGBuffer(): MultiRenderTarget;
  67873. /**
  67874. * Gets the number of samples used to render the buffer (anti aliasing).
  67875. */
  67876. get samples(): number;
  67877. /**
  67878. * Sets the number of samples used to render the buffer (anti aliasing).
  67879. */
  67880. set samples(value: number);
  67881. /**
  67882. * Disposes the renderer and frees up associated resources.
  67883. */
  67884. dispose(): void;
  67885. protected _createRenderTargets(): void;
  67886. private _copyBonesTransformationMatrices;
  67887. }
  67888. }
  67889. declare module BABYLON {
  67890. interface Scene {
  67891. /** @hidden (Backing field) */
  67892. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67893. /**
  67894. * Gets or Sets the current geometry buffer associated to the scene.
  67895. */
  67896. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67897. /**
  67898. * Enables a GeometryBufferRender and associates it with the scene
  67899. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67900. * @returns the GeometryBufferRenderer
  67901. */
  67902. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67903. /**
  67904. * Disables the GeometryBufferRender associated with the scene
  67905. */
  67906. disableGeometryBufferRenderer(): void;
  67907. }
  67908. /**
  67909. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67910. * in several rendering techniques.
  67911. */
  67912. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67913. /**
  67914. * The component name helpful to identify the component in the list of scene components.
  67915. */
  67916. readonly name: string;
  67917. /**
  67918. * The scene the component belongs to.
  67919. */
  67920. scene: Scene;
  67921. /**
  67922. * Creates a new instance of the component for the given scene
  67923. * @param scene Defines the scene to register the component in
  67924. */
  67925. constructor(scene: Scene);
  67926. /**
  67927. * Registers the component in a given scene
  67928. */
  67929. register(): void;
  67930. /**
  67931. * Rebuilds the elements related to this component in case of
  67932. * context lost for instance.
  67933. */
  67934. rebuild(): void;
  67935. /**
  67936. * Disposes the component and the associated ressources
  67937. */
  67938. dispose(): void;
  67939. private _gatherRenderTargets;
  67940. }
  67941. }
  67942. declare module BABYLON {
  67943. /** @hidden */
  67944. export var motionBlurPixelShader: {
  67945. name: string;
  67946. shader: string;
  67947. };
  67948. }
  67949. declare module BABYLON {
  67950. /**
  67951. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67952. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67953. * As an example, all you have to do is to create the post-process:
  67954. * var mb = new BABYLON.MotionBlurPostProcess(
  67955. * 'mb', // The name of the effect.
  67956. * scene, // The scene containing the objects to blur according to their velocity.
  67957. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67958. * camera // The camera to apply the render pass to.
  67959. * );
  67960. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67961. */
  67962. export class MotionBlurPostProcess extends PostProcess {
  67963. /**
  67964. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67965. */
  67966. motionStrength: number;
  67967. /**
  67968. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67969. */
  67970. get motionBlurSamples(): number;
  67971. /**
  67972. * Sets the number of iterations to be used for motion blur quality
  67973. */
  67974. set motionBlurSamples(samples: number);
  67975. private _motionBlurSamples;
  67976. private _geometryBufferRenderer;
  67977. /**
  67978. * Creates a new instance MotionBlurPostProcess
  67979. * @param name The name of the effect.
  67980. * @param scene The scene containing the objects to blur according to their velocity.
  67981. * @param options The required width/height ratio to downsize to before computing the render pass.
  67982. * @param camera The camera to apply the render pass to.
  67983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67984. * @param engine The engine which the post process will be applied. (default: current engine)
  67985. * @param reusable If the post process can be reused on the same frame. (default: false)
  67986. * @param textureType Type of textures used when performing the post process. (default: 0)
  67987. * @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)
  67988. */
  67989. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67990. /**
  67991. * Excludes the given skinned mesh from computing bones velocities.
  67992. * 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.
  67993. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67994. */
  67995. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67996. /**
  67997. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67998. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67999. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68000. */
  68001. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68002. /**
  68003. * Disposes the post process.
  68004. * @param camera The camera to dispose the post process on.
  68005. */
  68006. dispose(camera?: Camera): void;
  68007. }
  68008. }
  68009. declare module BABYLON {
  68010. /** @hidden */
  68011. export var refractionPixelShader: {
  68012. name: string;
  68013. shader: string;
  68014. };
  68015. }
  68016. declare module BABYLON {
  68017. /**
  68018. * Post process which applies a refractin texture
  68019. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68020. */
  68021. export class RefractionPostProcess extends PostProcess {
  68022. /** the base color of the refraction (used to taint the rendering) */
  68023. color: Color3;
  68024. /** simulated refraction depth */
  68025. depth: number;
  68026. /** the coefficient of the base color (0 to remove base color tainting) */
  68027. colorLevel: number;
  68028. private _refTexture;
  68029. private _ownRefractionTexture;
  68030. /**
  68031. * Gets or sets the refraction texture
  68032. * Please note that you are responsible for disposing the texture if you set it manually
  68033. */
  68034. get refractionTexture(): Texture;
  68035. set refractionTexture(value: Texture);
  68036. /**
  68037. * Initializes the RefractionPostProcess
  68038. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68039. * @param name The name of the effect.
  68040. * @param refractionTextureUrl Url of the refraction texture to use
  68041. * @param color the base color of the refraction (used to taint the rendering)
  68042. * @param depth simulated refraction depth
  68043. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68044. * @param camera The camera to apply the render pass to.
  68045. * @param options The required width/height ratio to downsize to before computing the render pass.
  68046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68047. * @param engine The engine which the post process will be applied. (default: current engine)
  68048. * @param reusable If the post process can be reused on the same frame. (default: false)
  68049. */
  68050. constructor(name: string, refractionTextureUrl: string,
  68051. /** the base color of the refraction (used to taint the rendering) */
  68052. color: Color3,
  68053. /** simulated refraction depth */
  68054. depth: number,
  68055. /** the coefficient of the base color (0 to remove base color tainting) */
  68056. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68057. /**
  68058. * Disposes of the post process
  68059. * @param camera Camera to dispose post process on
  68060. */
  68061. dispose(camera: Camera): void;
  68062. }
  68063. }
  68064. declare module BABYLON {
  68065. /** @hidden */
  68066. export var sharpenPixelShader: {
  68067. name: string;
  68068. shader: string;
  68069. };
  68070. }
  68071. declare module BABYLON {
  68072. /**
  68073. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68074. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68075. */
  68076. export class SharpenPostProcess extends PostProcess {
  68077. /**
  68078. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68079. */
  68080. colorAmount: number;
  68081. /**
  68082. * How much sharpness should be applied (default: 0.3)
  68083. */
  68084. edgeAmount: number;
  68085. /**
  68086. * Creates a new instance ConvolutionPostProcess
  68087. * @param name The name of the effect.
  68088. * @param options The required width/height ratio to downsize to before computing the render pass.
  68089. * @param camera The camera to apply the render pass to.
  68090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68091. * @param engine The engine which the post process will be applied. (default: current engine)
  68092. * @param reusable If the post process can be reused on the same frame. (default: false)
  68093. * @param textureType Type of textures used when performing the post process. (default: 0)
  68094. * @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)
  68095. */
  68096. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68097. }
  68098. }
  68099. declare module BABYLON {
  68100. /**
  68101. * PostProcessRenderPipeline
  68102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68103. */
  68104. export class PostProcessRenderPipeline {
  68105. private engine;
  68106. private _renderEffects;
  68107. private _renderEffectsForIsolatedPass;
  68108. /**
  68109. * List of inspectable custom properties (used by the Inspector)
  68110. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68111. */
  68112. inspectableCustomProperties: IInspectable[];
  68113. /**
  68114. * @hidden
  68115. */
  68116. protected _cameras: Camera[];
  68117. /** @hidden */
  68118. _name: string;
  68119. /**
  68120. * Gets pipeline name
  68121. */
  68122. get name(): string;
  68123. /** Gets the list of attached cameras */
  68124. get cameras(): Camera[];
  68125. /**
  68126. * Initializes a PostProcessRenderPipeline
  68127. * @param engine engine to add the pipeline to
  68128. * @param name name of the pipeline
  68129. */
  68130. constructor(engine: Engine, name: string);
  68131. /**
  68132. * Gets the class name
  68133. * @returns "PostProcessRenderPipeline"
  68134. */
  68135. getClassName(): string;
  68136. /**
  68137. * If all the render effects in the pipeline are supported
  68138. */
  68139. get isSupported(): boolean;
  68140. /**
  68141. * Adds an effect to the pipeline
  68142. * @param renderEffect the effect to add
  68143. */
  68144. addEffect(renderEffect: PostProcessRenderEffect): void;
  68145. /** @hidden */
  68146. _rebuild(): void;
  68147. /** @hidden */
  68148. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68149. /** @hidden */
  68150. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68151. /** @hidden */
  68152. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68153. /** @hidden */
  68154. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68155. /** @hidden */
  68156. _attachCameras(cameras: Camera, unique: boolean): void;
  68157. /** @hidden */
  68158. _attachCameras(cameras: Camera[], unique: boolean): void;
  68159. /** @hidden */
  68160. _detachCameras(cameras: Camera): void;
  68161. /** @hidden */
  68162. _detachCameras(cameras: Nullable<Camera[]>): void;
  68163. /** @hidden */
  68164. _update(): void;
  68165. /** @hidden */
  68166. _reset(): void;
  68167. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68168. /**
  68169. * Disposes of the pipeline
  68170. */
  68171. dispose(): void;
  68172. }
  68173. }
  68174. declare module BABYLON {
  68175. /**
  68176. * PostProcessRenderPipelineManager class
  68177. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68178. */
  68179. export class PostProcessRenderPipelineManager {
  68180. private _renderPipelines;
  68181. /**
  68182. * Initializes a PostProcessRenderPipelineManager
  68183. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68184. */
  68185. constructor();
  68186. /**
  68187. * Gets the list of supported render pipelines
  68188. */
  68189. get supportedPipelines(): PostProcessRenderPipeline[];
  68190. /**
  68191. * Adds a pipeline to the manager
  68192. * @param renderPipeline The pipeline to add
  68193. */
  68194. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68195. /**
  68196. * Attaches a camera to the pipeline
  68197. * @param renderPipelineName The name of the pipeline to attach to
  68198. * @param cameras the camera to attach
  68199. * @param unique if the camera can be attached multiple times to the pipeline
  68200. */
  68201. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68202. /**
  68203. * Detaches a camera from the pipeline
  68204. * @param renderPipelineName The name of the pipeline to detach from
  68205. * @param cameras the camera to detach
  68206. */
  68207. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68208. /**
  68209. * Enables an effect by name on a pipeline
  68210. * @param renderPipelineName the name of the pipeline to enable the effect in
  68211. * @param renderEffectName the name of the effect to enable
  68212. * @param cameras the cameras that the effect should be enabled on
  68213. */
  68214. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68215. /**
  68216. * Disables an effect by name on a pipeline
  68217. * @param renderPipelineName the name of the pipeline to disable the effect in
  68218. * @param renderEffectName the name of the effect to disable
  68219. * @param cameras the cameras that the effect should be disabled on
  68220. */
  68221. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68222. /**
  68223. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68224. */
  68225. update(): void;
  68226. /** @hidden */
  68227. _rebuild(): void;
  68228. /**
  68229. * Disposes of the manager and pipelines
  68230. */
  68231. dispose(): void;
  68232. }
  68233. }
  68234. declare module BABYLON {
  68235. interface Scene {
  68236. /** @hidden (Backing field) */
  68237. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68238. /**
  68239. * Gets the postprocess render pipeline manager
  68240. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68241. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68242. */
  68243. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68244. }
  68245. /**
  68246. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68247. */
  68248. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68249. /**
  68250. * The component name helpfull to identify the component in the list of scene components.
  68251. */
  68252. readonly name: string;
  68253. /**
  68254. * The scene the component belongs to.
  68255. */
  68256. scene: Scene;
  68257. /**
  68258. * Creates a new instance of the component for the given scene
  68259. * @param scene Defines the scene to register the component in
  68260. */
  68261. constructor(scene: Scene);
  68262. /**
  68263. * Registers the component in a given scene
  68264. */
  68265. register(): void;
  68266. /**
  68267. * Rebuilds the elements related to this component in case of
  68268. * context lost for instance.
  68269. */
  68270. rebuild(): void;
  68271. /**
  68272. * Disposes the component and the associated ressources
  68273. */
  68274. dispose(): void;
  68275. private _gatherRenderTargets;
  68276. }
  68277. }
  68278. declare module BABYLON {
  68279. /**
  68280. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68281. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68282. */
  68283. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68284. private _scene;
  68285. private _camerasToBeAttached;
  68286. /**
  68287. * ID of the sharpen post process,
  68288. */
  68289. private readonly SharpenPostProcessId;
  68290. /**
  68291. * @ignore
  68292. * ID of the image processing post process;
  68293. */
  68294. readonly ImageProcessingPostProcessId: string;
  68295. /**
  68296. * @ignore
  68297. * ID of the Fast Approximate Anti-Aliasing post process;
  68298. */
  68299. readonly FxaaPostProcessId: string;
  68300. /**
  68301. * ID of the chromatic aberration post process,
  68302. */
  68303. private readonly ChromaticAberrationPostProcessId;
  68304. /**
  68305. * ID of the grain post process
  68306. */
  68307. private readonly GrainPostProcessId;
  68308. /**
  68309. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68310. */
  68311. sharpen: SharpenPostProcess;
  68312. private _sharpenEffect;
  68313. private bloom;
  68314. /**
  68315. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68316. */
  68317. depthOfField: DepthOfFieldEffect;
  68318. /**
  68319. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68320. */
  68321. fxaa: FxaaPostProcess;
  68322. /**
  68323. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68324. */
  68325. imageProcessing: ImageProcessingPostProcess;
  68326. /**
  68327. * Chromatic aberration post process which will shift rgb colors in the image
  68328. */
  68329. chromaticAberration: ChromaticAberrationPostProcess;
  68330. private _chromaticAberrationEffect;
  68331. /**
  68332. * Grain post process which add noise to the image
  68333. */
  68334. grain: GrainPostProcess;
  68335. private _grainEffect;
  68336. /**
  68337. * Glow post process which adds a glow to emissive areas of the image
  68338. */
  68339. private _glowLayer;
  68340. /**
  68341. * Animations which can be used to tweak settings over a period of time
  68342. */
  68343. animations: Animation[];
  68344. private _imageProcessingConfigurationObserver;
  68345. private _sharpenEnabled;
  68346. private _bloomEnabled;
  68347. private _depthOfFieldEnabled;
  68348. private _depthOfFieldBlurLevel;
  68349. private _fxaaEnabled;
  68350. private _imageProcessingEnabled;
  68351. private _defaultPipelineTextureType;
  68352. private _bloomScale;
  68353. private _chromaticAberrationEnabled;
  68354. private _grainEnabled;
  68355. private _buildAllowed;
  68356. /**
  68357. * Gets active scene
  68358. */
  68359. get scene(): Scene;
  68360. /**
  68361. * Enable or disable the sharpen process from the pipeline
  68362. */
  68363. set sharpenEnabled(enabled: boolean);
  68364. get sharpenEnabled(): boolean;
  68365. private _resizeObserver;
  68366. private _hardwareScaleLevel;
  68367. private _bloomKernel;
  68368. /**
  68369. * Specifies the size of the bloom blur kernel, relative to the final output size
  68370. */
  68371. get bloomKernel(): number;
  68372. set bloomKernel(value: number);
  68373. /**
  68374. * Specifies the weight of the bloom in the final rendering
  68375. */
  68376. private _bloomWeight;
  68377. /**
  68378. * Specifies the luma threshold for the area that will be blurred by the bloom
  68379. */
  68380. private _bloomThreshold;
  68381. private _hdr;
  68382. /**
  68383. * The strength of the bloom.
  68384. */
  68385. set bloomWeight(value: number);
  68386. get bloomWeight(): number;
  68387. /**
  68388. * The strength of the bloom.
  68389. */
  68390. set bloomThreshold(value: number);
  68391. get bloomThreshold(): number;
  68392. /**
  68393. * The scale of the bloom, lower value will provide better performance.
  68394. */
  68395. set bloomScale(value: number);
  68396. get bloomScale(): number;
  68397. /**
  68398. * Enable or disable the bloom from the pipeline
  68399. */
  68400. set bloomEnabled(enabled: boolean);
  68401. get bloomEnabled(): boolean;
  68402. private _rebuildBloom;
  68403. /**
  68404. * If the depth of field is enabled.
  68405. */
  68406. get depthOfFieldEnabled(): boolean;
  68407. set depthOfFieldEnabled(enabled: boolean);
  68408. /**
  68409. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68410. */
  68411. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68412. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68413. /**
  68414. * If the anti aliasing is enabled.
  68415. */
  68416. set fxaaEnabled(enabled: boolean);
  68417. get fxaaEnabled(): boolean;
  68418. private _samples;
  68419. /**
  68420. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68421. */
  68422. set samples(sampleCount: number);
  68423. get samples(): number;
  68424. /**
  68425. * If image processing is enabled.
  68426. */
  68427. set imageProcessingEnabled(enabled: boolean);
  68428. get imageProcessingEnabled(): boolean;
  68429. /**
  68430. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68431. */
  68432. set glowLayerEnabled(enabled: boolean);
  68433. get glowLayerEnabled(): boolean;
  68434. /**
  68435. * Gets the glow layer (or null if not defined)
  68436. */
  68437. get glowLayer(): Nullable<GlowLayer>;
  68438. /**
  68439. * Enable or disable the chromaticAberration process from the pipeline
  68440. */
  68441. set chromaticAberrationEnabled(enabled: boolean);
  68442. get chromaticAberrationEnabled(): boolean;
  68443. /**
  68444. * Enable or disable the grain process from the pipeline
  68445. */
  68446. set grainEnabled(enabled: boolean);
  68447. get grainEnabled(): boolean;
  68448. /**
  68449. * @constructor
  68450. * @param name - The rendering pipeline name (default: "")
  68451. * @param hdr - If high dynamic range textures should be used (default: true)
  68452. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68453. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68454. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68455. */
  68456. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68457. /**
  68458. * Get the class name
  68459. * @returns "DefaultRenderingPipeline"
  68460. */
  68461. getClassName(): string;
  68462. /**
  68463. * Force the compilation of the entire pipeline.
  68464. */
  68465. prepare(): void;
  68466. private _hasCleared;
  68467. private _prevPostProcess;
  68468. private _prevPrevPostProcess;
  68469. private _setAutoClearAndTextureSharing;
  68470. private _depthOfFieldSceneObserver;
  68471. private _buildPipeline;
  68472. private _disposePostProcesses;
  68473. /**
  68474. * Adds a camera to the pipeline
  68475. * @param camera the camera to be added
  68476. */
  68477. addCamera(camera: Camera): void;
  68478. /**
  68479. * Removes a camera from the pipeline
  68480. * @param camera the camera to remove
  68481. */
  68482. removeCamera(camera: Camera): void;
  68483. /**
  68484. * Dispose of the pipeline and stop all post processes
  68485. */
  68486. dispose(): void;
  68487. /**
  68488. * Serialize the rendering pipeline (Used when exporting)
  68489. * @returns the serialized object
  68490. */
  68491. serialize(): any;
  68492. /**
  68493. * Parse the serialized pipeline
  68494. * @param source Source pipeline.
  68495. * @param scene The scene to load the pipeline to.
  68496. * @param rootUrl The URL of the serialized pipeline.
  68497. * @returns An instantiated pipeline from the serialized object.
  68498. */
  68499. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68500. }
  68501. }
  68502. declare module BABYLON {
  68503. /** @hidden */
  68504. export var lensHighlightsPixelShader: {
  68505. name: string;
  68506. shader: string;
  68507. };
  68508. }
  68509. declare module BABYLON {
  68510. /** @hidden */
  68511. export var depthOfFieldPixelShader: {
  68512. name: string;
  68513. shader: string;
  68514. };
  68515. }
  68516. declare module BABYLON {
  68517. /**
  68518. * BABYLON.JS Chromatic Aberration GLSL Shader
  68519. * Author: Olivier Guyot
  68520. * Separates very slightly R, G and B colors on the edges of the screen
  68521. * Inspired by Francois Tarlier & Martins Upitis
  68522. */
  68523. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68524. /**
  68525. * @ignore
  68526. * The chromatic aberration PostProcess id in the pipeline
  68527. */
  68528. LensChromaticAberrationEffect: string;
  68529. /**
  68530. * @ignore
  68531. * The highlights enhancing PostProcess id in the pipeline
  68532. */
  68533. HighlightsEnhancingEffect: string;
  68534. /**
  68535. * @ignore
  68536. * The depth-of-field PostProcess id in the pipeline
  68537. */
  68538. LensDepthOfFieldEffect: string;
  68539. private _scene;
  68540. private _depthTexture;
  68541. private _grainTexture;
  68542. private _chromaticAberrationPostProcess;
  68543. private _highlightsPostProcess;
  68544. private _depthOfFieldPostProcess;
  68545. private _edgeBlur;
  68546. private _grainAmount;
  68547. private _chromaticAberration;
  68548. private _distortion;
  68549. private _highlightsGain;
  68550. private _highlightsThreshold;
  68551. private _dofDistance;
  68552. private _dofAperture;
  68553. private _dofDarken;
  68554. private _dofPentagon;
  68555. private _blurNoise;
  68556. /**
  68557. * @constructor
  68558. *
  68559. * Effect parameters are as follow:
  68560. * {
  68561. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68562. * edge_blur: number; // from 0 to x (1 for realism)
  68563. * distortion: number; // from 0 to x (1 for realism)
  68564. * grain_amount: number; // from 0 to 1
  68565. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68566. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68567. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68568. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68569. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68570. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68571. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68572. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68573. * }
  68574. * Note: if an effect parameter is unset, effect is disabled
  68575. *
  68576. * @param name The rendering pipeline name
  68577. * @param parameters - An object containing all parameters (see above)
  68578. * @param scene The scene linked to this pipeline
  68579. * @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)
  68580. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68581. */
  68582. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68583. /**
  68584. * Get the class name
  68585. * @returns "LensRenderingPipeline"
  68586. */
  68587. getClassName(): string;
  68588. /**
  68589. * Gets associated scene
  68590. */
  68591. get scene(): Scene;
  68592. /**
  68593. * Gets or sets the edge blur
  68594. */
  68595. get edgeBlur(): number;
  68596. set edgeBlur(value: number);
  68597. /**
  68598. * Gets or sets the grain amount
  68599. */
  68600. get grainAmount(): number;
  68601. set grainAmount(value: number);
  68602. /**
  68603. * Gets or sets the chromatic aberration amount
  68604. */
  68605. get chromaticAberration(): number;
  68606. set chromaticAberration(value: number);
  68607. /**
  68608. * Gets or sets the depth of field aperture
  68609. */
  68610. get dofAperture(): number;
  68611. set dofAperture(value: number);
  68612. /**
  68613. * Gets or sets the edge distortion
  68614. */
  68615. get edgeDistortion(): number;
  68616. set edgeDistortion(value: number);
  68617. /**
  68618. * Gets or sets the depth of field distortion
  68619. */
  68620. get dofDistortion(): number;
  68621. set dofDistortion(value: number);
  68622. /**
  68623. * Gets or sets the darken out of focus amount
  68624. */
  68625. get darkenOutOfFocus(): number;
  68626. set darkenOutOfFocus(value: number);
  68627. /**
  68628. * Gets or sets a boolean indicating if blur noise is enabled
  68629. */
  68630. get blurNoise(): boolean;
  68631. set blurNoise(value: boolean);
  68632. /**
  68633. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68634. */
  68635. get pentagonBokeh(): boolean;
  68636. set pentagonBokeh(value: boolean);
  68637. /**
  68638. * Gets or sets the highlight grain amount
  68639. */
  68640. get highlightsGain(): number;
  68641. set highlightsGain(value: number);
  68642. /**
  68643. * Gets or sets the highlight threshold
  68644. */
  68645. get highlightsThreshold(): number;
  68646. set highlightsThreshold(value: number);
  68647. /**
  68648. * Sets the amount of blur at the edges
  68649. * @param amount blur amount
  68650. */
  68651. setEdgeBlur(amount: number): void;
  68652. /**
  68653. * Sets edge blur to 0
  68654. */
  68655. disableEdgeBlur(): void;
  68656. /**
  68657. * Sets the amout of grain
  68658. * @param amount Amount of grain
  68659. */
  68660. setGrainAmount(amount: number): void;
  68661. /**
  68662. * Set grain amount to 0
  68663. */
  68664. disableGrain(): void;
  68665. /**
  68666. * Sets the chromatic aberration amount
  68667. * @param amount amount of chromatic aberration
  68668. */
  68669. setChromaticAberration(amount: number): void;
  68670. /**
  68671. * Sets chromatic aberration amount to 0
  68672. */
  68673. disableChromaticAberration(): void;
  68674. /**
  68675. * Sets the EdgeDistortion amount
  68676. * @param amount amount of EdgeDistortion
  68677. */
  68678. setEdgeDistortion(amount: number): void;
  68679. /**
  68680. * Sets edge distortion to 0
  68681. */
  68682. disableEdgeDistortion(): void;
  68683. /**
  68684. * Sets the FocusDistance amount
  68685. * @param amount amount of FocusDistance
  68686. */
  68687. setFocusDistance(amount: number): void;
  68688. /**
  68689. * Disables depth of field
  68690. */
  68691. disableDepthOfField(): void;
  68692. /**
  68693. * Sets the Aperture amount
  68694. * @param amount amount of Aperture
  68695. */
  68696. setAperture(amount: number): void;
  68697. /**
  68698. * Sets the DarkenOutOfFocus amount
  68699. * @param amount amount of DarkenOutOfFocus
  68700. */
  68701. setDarkenOutOfFocus(amount: number): void;
  68702. private _pentagonBokehIsEnabled;
  68703. /**
  68704. * Creates a pentagon bokeh effect
  68705. */
  68706. enablePentagonBokeh(): void;
  68707. /**
  68708. * Disables the pentagon bokeh effect
  68709. */
  68710. disablePentagonBokeh(): void;
  68711. /**
  68712. * Enables noise blur
  68713. */
  68714. enableNoiseBlur(): void;
  68715. /**
  68716. * Disables noise blur
  68717. */
  68718. disableNoiseBlur(): void;
  68719. /**
  68720. * Sets the HighlightsGain amount
  68721. * @param amount amount of HighlightsGain
  68722. */
  68723. setHighlightsGain(amount: number): void;
  68724. /**
  68725. * Sets the HighlightsThreshold amount
  68726. * @param amount amount of HighlightsThreshold
  68727. */
  68728. setHighlightsThreshold(amount: number): void;
  68729. /**
  68730. * Disables highlights
  68731. */
  68732. disableHighlights(): void;
  68733. /**
  68734. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68735. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68736. */
  68737. dispose(disableDepthRender?: boolean): void;
  68738. private _createChromaticAberrationPostProcess;
  68739. private _createHighlightsPostProcess;
  68740. private _createDepthOfFieldPostProcess;
  68741. private _createGrainTexture;
  68742. }
  68743. }
  68744. declare module BABYLON {
  68745. /** @hidden */
  68746. export var ssao2PixelShader: {
  68747. name: string;
  68748. shader: string;
  68749. };
  68750. }
  68751. declare module BABYLON {
  68752. /** @hidden */
  68753. export var ssaoCombinePixelShader: {
  68754. name: string;
  68755. shader: string;
  68756. };
  68757. }
  68758. declare module BABYLON {
  68759. /**
  68760. * Render pipeline to produce ssao effect
  68761. */
  68762. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68763. /**
  68764. * @ignore
  68765. * The PassPostProcess id in the pipeline that contains the original scene color
  68766. */
  68767. SSAOOriginalSceneColorEffect: string;
  68768. /**
  68769. * @ignore
  68770. * The SSAO PostProcess id in the pipeline
  68771. */
  68772. SSAORenderEffect: string;
  68773. /**
  68774. * @ignore
  68775. * The horizontal blur PostProcess id in the pipeline
  68776. */
  68777. SSAOBlurHRenderEffect: string;
  68778. /**
  68779. * @ignore
  68780. * The vertical blur PostProcess id in the pipeline
  68781. */
  68782. SSAOBlurVRenderEffect: string;
  68783. /**
  68784. * @ignore
  68785. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68786. */
  68787. SSAOCombineRenderEffect: string;
  68788. /**
  68789. * The output strength of the SSAO post-process. Default value is 1.0.
  68790. */
  68791. totalStrength: number;
  68792. /**
  68793. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68794. */
  68795. maxZ: number;
  68796. /**
  68797. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68798. */
  68799. minZAspect: number;
  68800. private _samples;
  68801. /**
  68802. * Number of samples used for the SSAO calculations. Default value is 8
  68803. */
  68804. set samples(n: number);
  68805. get samples(): number;
  68806. private _textureSamples;
  68807. /**
  68808. * Number of samples to use for antialiasing
  68809. */
  68810. set textureSamples(n: number);
  68811. get textureSamples(): number;
  68812. /**
  68813. * Ratio object used for SSAO ratio and blur ratio
  68814. */
  68815. private _ratio;
  68816. /**
  68817. * Dynamically generated sphere sampler.
  68818. */
  68819. private _sampleSphere;
  68820. /**
  68821. * Blur filter offsets
  68822. */
  68823. private _samplerOffsets;
  68824. private _expensiveBlur;
  68825. /**
  68826. * If bilateral blur should be used
  68827. */
  68828. set expensiveBlur(b: boolean);
  68829. get expensiveBlur(): boolean;
  68830. /**
  68831. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68832. */
  68833. radius: number;
  68834. /**
  68835. * The base color of the SSAO post-process
  68836. * The final result is "base + ssao" between [0, 1]
  68837. */
  68838. base: number;
  68839. /**
  68840. * Support test.
  68841. */
  68842. static get IsSupported(): boolean;
  68843. private _scene;
  68844. private _depthTexture;
  68845. private _normalTexture;
  68846. private _randomTexture;
  68847. private _originalColorPostProcess;
  68848. private _ssaoPostProcess;
  68849. private _blurHPostProcess;
  68850. private _blurVPostProcess;
  68851. private _ssaoCombinePostProcess;
  68852. /**
  68853. * Gets active scene
  68854. */
  68855. get scene(): Scene;
  68856. /**
  68857. * @constructor
  68858. * @param name The rendering pipeline name
  68859. * @param scene The scene linked to this pipeline
  68860. * @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 }
  68861. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68862. */
  68863. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68864. /**
  68865. * Get the class name
  68866. * @returns "SSAO2RenderingPipeline"
  68867. */
  68868. getClassName(): string;
  68869. /**
  68870. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68871. */
  68872. dispose(disableGeometryBufferRenderer?: boolean): void;
  68873. private _createBlurPostProcess;
  68874. /** @hidden */
  68875. _rebuild(): void;
  68876. private _bits;
  68877. private _radicalInverse_VdC;
  68878. private _hammersley;
  68879. private _hemisphereSample_uniform;
  68880. private _generateHemisphere;
  68881. private _createSSAOPostProcess;
  68882. private _createSSAOCombinePostProcess;
  68883. private _createRandomTexture;
  68884. /**
  68885. * Serialize the rendering pipeline (Used when exporting)
  68886. * @returns the serialized object
  68887. */
  68888. serialize(): any;
  68889. /**
  68890. * Parse the serialized pipeline
  68891. * @param source Source pipeline.
  68892. * @param scene The scene to load the pipeline to.
  68893. * @param rootUrl The URL of the serialized pipeline.
  68894. * @returns An instantiated pipeline from the serialized object.
  68895. */
  68896. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68897. }
  68898. }
  68899. declare module BABYLON {
  68900. /** @hidden */
  68901. export var ssaoPixelShader: {
  68902. name: string;
  68903. shader: string;
  68904. };
  68905. }
  68906. declare module BABYLON {
  68907. /**
  68908. * Render pipeline to produce ssao effect
  68909. */
  68910. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68911. /**
  68912. * @ignore
  68913. * The PassPostProcess id in the pipeline that contains the original scene color
  68914. */
  68915. SSAOOriginalSceneColorEffect: string;
  68916. /**
  68917. * @ignore
  68918. * The SSAO PostProcess id in the pipeline
  68919. */
  68920. SSAORenderEffect: string;
  68921. /**
  68922. * @ignore
  68923. * The horizontal blur PostProcess id in the pipeline
  68924. */
  68925. SSAOBlurHRenderEffect: string;
  68926. /**
  68927. * @ignore
  68928. * The vertical blur PostProcess id in the pipeline
  68929. */
  68930. SSAOBlurVRenderEffect: string;
  68931. /**
  68932. * @ignore
  68933. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68934. */
  68935. SSAOCombineRenderEffect: string;
  68936. /**
  68937. * The output strength of the SSAO post-process. Default value is 1.0.
  68938. */
  68939. totalStrength: number;
  68940. /**
  68941. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68942. */
  68943. radius: number;
  68944. /**
  68945. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68946. * Must not be equal to fallOff and superior to fallOff.
  68947. * Default value is 0.0075
  68948. */
  68949. area: number;
  68950. /**
  68951. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68952. * Must not be equal to area and inferior to area.
  68953. * Default value is 0.000001
  68954. */
  68955. fallOff: number;
  68956. /**
  68957. * The base color of the SSAO post-process
  68958. * The final result is "base + ssao" between [0, 1]
  68959. */
  68960. base: number;
  68961. private _scene;
  68962. private _depthTexture;
  68963. private _randomTexture;
  68964. private _originalColorPostProcess;
  68965. private _ssaoPostProcess;
  68966. private _blurHPostProcess;
  68967. private _blurVPostProcess;
  68968. private _ssaoCombinePostProcess;
  68969. private _firstUpdate;
  68970. /**
  68971. * Gets active scene
  68972. */
  68973. get scene(): Scene;
  68974. /**
  68975. * @constructor
  68976. * @param name - The rendering pipeline name
  68977. * @param scene - The scene linked to this pipeline
  68978. * @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 }
  68979. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68980. */
  68981. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68982. /**
  68983. * Get the class name
  68984. * @returns "SSAORenderingPipeline"
  68985. */
  68986. getClassName(): string;
  68987. /**
  68988. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68989. */
  68990. dispose(disableDepthRender?: boolean): void;
  68991. private _createBlurPostProcess;
  68992. /** @hidden */
  68993. _rebuild(): void;
  68994. private _createSSAOPostProcess;
  68995. private _createSSAOCombinePostProcess;
  68996. private _createRandomTexture;
  68997. }
  68998. }
  68999. declare module BABYLON {
  69000. /** @hidden */
  69001. export var screenSpaceReflectionPixelShader: {
  69002. name: string;
  69003. shader: string;
  69004. };
  69005. }
  69006. declare module BABYLON {
  69007. /**
  69008. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69009. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69010. */
  69011. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69012. /**
  69013. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69014. */
  69015. threshold: number;
  69016. /**
  69017. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69018. */
  69019. strength: number;
  69020. /**
  69021. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69022. */
  69023. reflectionSpecularFalloffExponent: number;
  69024. /**
  69025. * 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]
  69026. */
  69027. step: number;
  69028. /**
  69029. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69030. */
  69031. roughnessFactor: number;
  69032. private _geometryBufferRenderer;
  69033. private _enableSmoothReflections;
  69034. private _reflectionSamples;
  69035. private _smoothSteps;
  69036. /**
  69037. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69038. * @param name The name of the effect.
  69039. * @param scene The scene containing the objects to calculate reflections.
  69040. * @param options The required width/height ratio to downsize to before computing the render pass.
  69041. * @param camera The camera to apply the render pass to.
  69042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69043. * @param engine The engine which the post process will be applied. (default: current engine)
  69044. * @param reusable If the post process can be reused on the same frame. (default: false)
  69045. * @param textureType Type of textures used when performing the post process. (default: 0)
  69046. * @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)
  69047. */
  69048. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69049. /**
  69050. * Gets wether or not smoothing reflections is enabled.
  69051. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69052. */
  69053. get enableSmoothReflections(): boolean;
  69054. /**
  69055. * Sets wether or not smoothing reflections is enabled.
  69056. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69057. */
  69058. set enableSmoothReflections(enabled: boolean);
  69059. /**
  69060. * Gets the number of samples taken while computing reflections. More samples count is high,
  69061. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69062. */
  69063. get reflectionSamples(): number;
  69064. /**
  69065. * Sets the number of samples taken while computing reflections. More samples count is high,
  69066. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69067. */
  69068. set reflectionSamples(samples: number);
  69069. /**
  69070. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69071. * more the post-process will require GPU power and can generate a drop in FPS.
  69072. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69073. */
  69074. get smoothSteps(): number;
  69075. set smoothSteps(steps: number);
  69076. private _updateEffectDefines;
  69077. }
  69078. }
  69079. declare module BABYLON {
  69080. /** @hidden */
  69081. export var standardPixelShader: {
  69082. name: string;
  69083. shader: string;
  69084. };
  69085. }
  69086. declare module BABYLON {
  69087. /**
  69088. * Standard rendering pipeline
  69089. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69090. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69091. */
  69092. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69093. /**
  69094. * Public members
  69095. */
  69096. /**
  69097. * Post-process which contains the original scene color before the pipeline applies all the effects
  69098. */
  69099. originalPostProcess: Nullable<PostProcess>;
  69100. /**
  69101. * Post-process used to down scale an image x4
  69102. */
  69103. downSampleX4PostProcess: Nullable<PostProcess>;
  69104. /**
  69105. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69106. */
  69107. brightPassPostProcess: Nullable<PostProcess>;
  69108. /**
  69109. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69110. */
  69111. blurHPostProcesses: PostProcess[];
  69112. /**
  69113. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69114. */
  69115. blurVPostProcesses: PostProcess[];
  69116. /**
  69117. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69118. */
  69119. textureAdderPostProcess: Nullable<PostProcess>;
  69120. /**
  69121. * Post-process used to create volumetric lighting effect
  69122. */
  69123. volumetricLightPostProcess: Nullable<PostProcess>;
  69124. /**
  69125. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69126. */
  69127. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69128. /**
  69129. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69130. */
  69131. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69132. /**
  69133. * Post-process used to merge the volumetric light effect and the real scene color
  69134. */
  69135. volumetricLightMergePostProces: Nullable<PostProcess>;
  69136. /**
  69137. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69138. */
  69139. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69140. /**
  69141. * Base post-process used to calculate the average luminance of the final image for HDR
  69142. */
  69143. luminancePostProcess: Nullable<PostProcess>;
  69144. /**
  69145. * Post-processes used to create down sample post-processes in order to get
  69146. * the average luminance of the final image for HDR
  69147. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69148. */
  69149. luminanceDownSamplePostProcesses: PostProcess[];
  69150. /**
  69151. * Post-process used to create a HDR effect (light adaptation)
  69152. */
  69153. hdrPostProcess: Nullable<PostProcess>;
  69154. /**
  69155. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69156. */
  69157. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69158. /**
  69159. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69160. */
  69161. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69162. /**
  69163. * Post-process used to merge the final HDR post-process and the real scene color
  69164. */
  69165. hdrFinalPostProcess: Nullable<PostProcess>;
  69166. /**
  69167. * Post-process used to create a lens flare effect
  69168. */
  69169. lensFlarePostProcess: Nullable<PostProcess>;
  69170. /**
  69171. * Post-process that merges the result of the lens flare post-process and the real scene color
  69172. */
  69173. lensFlareComposePostProcess: Nullable<PostProcess>;
  69174. /**
  69175. * Post-process used to create a motion blur effect
  69176. */
  69177. motionBlurPostProcess: Nullable<PostProcess>;
  69178. /**
  69179. * Post-process used to create a depth of field effect
  69180. */
  69181. depthOfFieldPostProcess: Nullable<PostProcess>;
  69182. /**
  69183. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69184. */
  69185. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69186. /**
  69187. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69188. */
  69189. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69190. /**
  69191. * Represents the brightness threshold in order to configure the illuminated surfaces
  69192. */
  69193. brightThreshold: number;
  69194. /**
  69195. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69196. */
  69197. blurWidth: number;
  69198. /**
  69199. * Sets if the blur for highlighted surfaces must be only horizontal
  69200. */
  69201. horizontalBlur: boolean;
  69202. /**
  69203. * Gets the overall exposure used by the pipeline
  69204. */
  69205. get exposure(): number;
  69206. /**
  69207. * Sets the overall exposure used by the pipeline
  69208. */
  69209. set exposure(value: number);
  69210. /**
  69211. * Texture used typically to simulate "dirty" on camera lens
  69212. */
  69213. lensTexture: Nullable<Texture>;
  69214. /**
  69215. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69216. */
  69217. volumetricLightCoefficient: number;
  69218. /**
  69219. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69220. */
  69221. volumetricLightPower: number;
  69222. /**
  69223. * Used the set the blur intensity to smooth the volumetric lights
  69224. */
  69225. volumetricLightBlurScale: number;
  69226. /**
  69227. * Light (spot or directional) used to generate the volumetric lights rays
  69228. * The source light must have a shadow generate so the pipeline can get its
  69229. * depth map
  69230. */
  69231. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69232. /**
  69233. * For eye adaptation, represents the minimum luminance the eye can see
  69234. */
  69235. hdrMinimumLuminance: number;
  69236. /**
  69237. * For eye adaptation, represents the decrease luminance speed
  69238. */
  69239. hdrDecreaseRate: number;
  69240. /**
  69241. * For eye adaptation, represents the increase luminance speed
  69242. */
  69243. hdrIncreaseRate: number;
  69244. /**
  69245. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69246. */
  69247. get hdrAutoExposure(): boolean;
  69248. /**
  69249. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69250. */
  69251. set hdrAutoExposure(value: boolean);
  69252. /**
  69253. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69254. */
  69255. lensColorTexture: Nullable<Texture>;
  69256. /**
  69257. * The overall strengh for the lens flare effect
  69258. */
  69259. lensFlareStrength: number;
  69260. /**
  69261. * Dispersion coefficient for lens flare ghosts
  69262. */
  69263. lensFlareGhostDispersal: number;
  69264. /**
  69265. * Main lens flare halo width
  69266. */
  69267. lensFlareHaloWidth: number;
  69268. /**
  69269. * Based on the lens distortion effect, defines how much the lens flare result
  69270. * is distorted
  69271. */
  69272. lensFlareDistortionStrength: number;
  69273. /**
  69274. * Configures the blur intensity used for for lens flare (halo)
  69275. */
  69276. lensFlareBlurWidth: number;
  69277. /**
  69278. * Lens star texture must be used to simulate rays on the flares and is available
  69279. * in the documentation
  69280. */
  69281. lensStarTexture: Nullable<Texture>;
  69282. /**
  69283. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69284. * flare effect by taking account of the dirt texture
  69285. */
  69286. lensFlareDirtTexture: Nullable<Texture>;
  69287. /**
  69288. * Represents the focal length for the depth of field effect
  69289. */
  69290. depthOfFieldDistance: number;
  69291. /**
  69292. * Represents the blur intensity for the blurred part of the depth of field effect
  69293. */
  69294. depthOfFieldBlurWidth: number;
  69295. /**
  69296. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69297. */
  69298. get motionStrength(): number;
  69299. /**
  69300. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69301. */
  69302. set motionStrength(strength: number);
  69303. /**
  69304. * Gets wether or not the motion blur post-process is object based or screen based.
  69305. */
  69306. get objectBasedMotionBlur(): boolean;
  69307. /**
  69308. * Sets wether or not the motion blur post-process should be object based or screen based
  69309. */
  69310. set objectBasedMotionBlur(value: boolean);
  69311. /**
  69312. * List of animations for the pipeline (IAnimatable implementation)
  69313. */
  69314. animations: Animation[];
  69315. /**
  69316. * Private members
  69317. */
  69318. private _scene;
  69319. private _currentDepthOfFieldSource;
  69320. private _basePostProcess;
  69321. private _fixedExposure;
  69322. private _currentExposure;
  69323. private _hdrAutoExposure;
  69324. private _hdrCurrentLuminance;
  69325. private _motionStrength;
  69326. private _isObjectBasedMotionBlur;
  69327. private _floatTextureType;
  69328. private _camerasToBeAttached;
  69329. private _ratio;
  69330. private _bloomEnabled;
  69331. private _depthOfFieldEnabled;
  69332. private _vlsEnabled;
  69333. private _lensFlareEnabled;
  69334. private _hdrEnabled;
  69335. private _motionBlurEnabled;
  69336. private _fxaaEnabled;
  69337. private _screenSpaceReflectionsEnabled;
  69338. private _motionBlurSamples;
  69339. private _volumetricLightStepsCount;
  69340. private _samples;
  69341. /**
  69342. * @ignore
  69343. * Specifies if the bloom pipeline is enabled
  69344. */
  69345. get BloomEnabled(): boolean;
  69346. set BloomEnabled(enabled: boolean);
  69347. /**
  69348. * @ignore
  69349. * Specifies if the depth of field pipeline is enabed
  69350. */
  69351. get DepthOfFieldEnabled(): boolean;
  69352. set DepthOfFieldEnabled(enabled: boolean);
  69353. /**
  69354. * @ignore
  69355. * Specifies if the lens flare pipeline is enabed
  69356. */
  69357. get LensFlareEnabled(): boolean;
  69358. set LensFlareEnabled(enabled: boolean);
  69359. /**
  69360. * @ignore
  69361. * Specifies if the HDR pipeline is enabled
  69362. */
  69363. get HDREnabled(): boolean;
  69364. set HDREnabled(enabled: boolean);
  69365. /**
  69366. * @ignore
  69367. * Specifies if the volumetric lights scattering effect is enabled
  69368. */
  69369. get VLSEnabled(): boolean;
  69370. set VLSEnabled(enabled: boolean);
  69371. /**
  69372. * @ignore
  69373. * Specifies if the motion blur effect is enabled
  69374. */
  69375. get MotionBlurEnabled(): boolean;
  69376. set MotionBlurEnabled(enabled: boolean);
  69377. /**
  69378. * Specifies if anti-aliasing is enabled
  69379. */
  69380. get fxaaEnabled(): boolean;
  69381. set fxaaEnabled(enabled: boolean);
  69382. /**
  69383. * Specifies if screen space reflections are enabled.
  69384. */
  69385. get screenSpaceReflectionsEnabled(): boolean;
  69386. set screenSpaceReflectionsEnabled(enabled: boolean);
  69387. /**
  69388. * Specifies the number of steps used to calculate the volumetric lights
  69389. * Typically in interval [50, 200]
  69390. */
  69391. get volumetricLightStepsCount(): number;
  69392. set volumetricLightStepsCount(count: number);
  69393. /**
  69394. * Specifies the number of samples used for the motion blur effect
  69395. * Typically in interval [16, 64]
  69396. */
  69397. get motionBlurSamples(): number;
  69398. set motionBlurSamples(samples: number);
  69399. /**
  69400. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69401. */
  69402. get samples(): number;
  69403. set samples(sampleCount: number);
  69404. /**
  69405. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69406. * @constructor
  69407. * @param name The rendering pipeline name
  69408. * @param scene The scene linked to this pipeline
  69409. * @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)
  69410. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69411. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69412. */
  69413. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69414. private _buildPipeline;
  69415. private _createDownSampleX4PostProcess;
  69416. private _createBrightPassPostProcess;
  69417. private _createBlurPostProcesses;
  69418. private _createTextureAdderPostProcess;
  69419. private _createVolumetricLightPostProcess;
  69420. private _createLuminancePostProcesses;
  69421. private _createHdrPostProcess;
  69422. private _createLensFlarePostProcess;
  69423. private _createDepthOfFieldPostProcess;
  69424. private _createMotionBlurPostProcess;
  69425. private _getDepthTexture;
  69426. private _disposePostProcesses;
  69427. /**
  69428. * Dispose of the pipeline and stop all post processes
  69429. */
  69430. dispose(): void;
  69431. /**
  69432. * Serialize the rendering pipeline (Used when exporting)
  69433. * @returns the serialized object
  69434. */
  69435. serialize(): any;
  69436. /**
  69437. * Parse the serialized pipeline
  69438. * @param source Source pipeline.
  69439. * @param scene The scene to load the pipeline to.
  69440. * @param rootUrl The URL of the serialized pipeline.
  69441. * @returns An instantiated pipeline from the serialized object.
  69442. */
  69443. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69444. /**
  69445. * Luminance steps
  69446. */
  69447. static LuminanceSteps: number;
  69448. }
  69449. }
  69450. declare module BABYLON {
  69451. /** @hidden */
  69452. export var stereoscopicInterlacePixelShader: {
  69453. name: string;
  69454. shader: string;
  69455. };
  69456. }
  69457. declare module BABYLON {
  69458. /**
  69459. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69460. */
  69461. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69462. private _stepSize;
  69463. private _passedProcess;
  69464. /**
  69465. * Initializes a StereoscopicInterlacePostProcessI
  69466. * @param name The name of the effect.
  69467. * @param rigCameras The rig cameras to be appled to the post process
  69468. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69469. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69471. * @param engine The engine which the post process will be applied. (default: current engine)
  69472. * @param reusable If the post process can be reused on the same frame. (default: false)
  69473. */
  69474. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69475. }
  69476. /**
  69477. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69478. */
  69479. export class StereoscopicInterlacePostProcess extends PostProcess {
  69480. private _stepSize;
  69481. private _passedProcess;
  69482. /**
  69483. * Initializes a StereoscopicInterlacePostProcess
  69484. * @param name The name of the effect.
  69485. * @param rigCameras The rig cameras to be appled to the post process
  69486. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69488. * @param engine The engine which the post process will be applied. (default: current engine)
  69489. * @param reusable If the post process can be reused on the same frame. (default: false)
  69490. */
  69491. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69492. }
  69493. }
  69494. declare module BABYLON {
  69495. /** @hidden */
  69496. export var tonemapPixelShader: {
  69497. name: string;
  69498. shader: string;
  69499. };
  69500. }
  69501. declare module BABYLON {
  69502. /** Defines operator used for tonemapping */
  69503. export enum TonemappingOperator {
  69504. /** Hable */
  69505. Hable = 0,
  69506. /** Reinhard */
  69507. Reinhard = 1,
  69508. /** HejiDawson */
  69509. HejiDawson = 2,
  69510. /** Photographic */
  69511. Photographic = 3
  69512. }
  69513. /**
  69514. * Defines a post process to apply tone mapping
  69515. */
  69516. export class TonemapPostProcess extends PostProcess {
  69517. private _operator;
  69518. /** Defines the required exposure adjustement */
  69519. exposureAdjustment: number;
  69520. /**
  69521. * Creates a new TonemapPostProcess
  69522. * @param name defines the name of the postprocess
  69523. * @param _operator defines the operator to use
  69524. * @param exposureAdjustment defines the required exposure adjustement
  69525. * @param camera defines the camera to use (can be null)
  69526. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69527. * @param engine defines the hosting engine (can be ignore if camera is set)
  69528. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69529. */
  69530. constructor(name: string, _operator: TonemappingOperator,
  69531. /** Defines the required exposure adjustement */
  69532. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69533. }
  69534. }
  69535. declare module BABYLON {
  69536. /** @hidden */
  69537. export var volumetricLightScatteringPixelShader: {
  69538. name: string;
  69539. shader: string;
  69540. };
  69541. }
  69542. declare module BABYLON {
  69543. /** @hidden */
  69544. export var volumetricLightScatteringPassVertexShader: {
  69545. name: string;
  69546. shader: string;
  69547. };
  69548. }
  69549. declare module BABYLON {
  69550. /** @hidden */
  69551. export var volumetricLightScatteringPassPixelShader: {
  69552. name: string;
  69553. shader: string;
  69554. };
  69555. }
  69556. declare module BABYLON {
  69557. /**
  69558. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69559. */
  69560. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69561. private _volumetricLightScatteringPass;
  69562. private _volumetricLightScatteringRTT;
  69563. private _viewPort;
  69564. private _screenCoordinates;
  69565. private _cachedDefines;
  69566. /**
  69567. * If not undefined, the mesh position is computed from the attached node position
  69568. */
  69569. attachedNode: {
  69570. position: Vector3;
  69571. };
  69572. /**
  69573. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69574. */
  69575. customMeshPosition: Vector3;
  69576. /**
  69577. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69578. */
  69579. useCustomMeshPosition: boolean;
  69580. /**
  69581. * If the post-process should inverse the light scattering direction
  69582. */
  69583. invert: boolean;
  69584. /**
  69585. * The internal mesh used by the post-process
  69586. */
  69587. mesh: Mesh;
  69588. /**
  69589. * @hidden
  69590. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69591. */
  69592. get useDiffuseColor(): boolean;
  69593. set useDiffuseColor(useDiffuseColor: boolean);
  69594. /**
  69595. * Array containing the excluded meshes not rendered in the internal pass
  69596. */
  69597. excludedMeshes: AbstractMesh[];
  69598. /**
  69599. * Controls the overall intensity of the post-process
  69600. */
  69601. exposure: number;
  69602. /**
  69603. * Dissipates each sample's contribution in range [0, 1]
  69604. */
  69605. decay: number;
  69606. /**
  69607. * Controls the overall intensity of each sample
  69608. */
  69609. weight: number;
  69610. /**
  69611. * Controls the density of each sample
  69612. */
  69613. density: number;
  69614. /**
  69615. * @constructor
  69616. * @param name The post-process name
  69617. * @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)
  69618. * @param camera The camera that the post-process will be attached to
  69619. * @param mesh The mesh used to create the light scattering
  69620. * @param samples The post-process quality, default 100
  69621. * @param samplingModeThe post-process filtering mode
  69622. * @param engine The babylon engine
  69623. * @param reusable If the post-process is reusable
  69624. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69625. */
  69626. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69627. /**
  69628. * Returns the string "VolumetricLightScatteringPostProcess"
  69629. * @returns "VolumetricLightScatteringPostProcess"
  69630. */
  69631. getClassName(): string;
  69632. private _isReady;
  69633. /**
  69634. * Sets the new light position for light scattering effect
  69635. * @param position The new custom light position
  69636. */
  69637. setCustomMeshPosition(position: Vector3): void;
  69638. /**
  69639. * Returns the light position for light scattering effect
  69640. * @return Vector3 The custom light position
  69641. */
  69642. getCustomMeshPosition(): Vector3;
  69643. /**
  69644. * Disposes the internal assets and detaches the post-process from the camera
  69645. */
  69646. dispose(camera: Camera): void;
  69647. /**
  69648. * Returns the render target texture used by the post-process
  69649. * @return the render target texture used by the post-process
  69650. */
  69651. getPass(): RenderTargetTexture;
  69652. private _meshExcluded;
  69653. private _createPass;
  69654. private _updateMeshScreenCoordinates;
  69655. /**
  69656. * Creates a default mesh for the Volumeric Light Scattering post-process
  69657. * @param name The mesh name
  69658. * @param scene The scene where to create the mesh
  69659. * @return the default mesh
  69660. */
  69661. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69662. }
  69663. }
  69664. declare module BABYLON {
  69665. interface Scene {
  69666. /** @hidden (Backing field) */
  69667. _boundingBoxRenderer: BoundingBoxRenderer;
  69668. /** @hidden (Backing field) */
  69669. _forceShowBoundingBoxes: boolean;
  69670. /**
  69671. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69672. */
  69673. forceShowBoundingBoxes: boolean;
  69674. /**
  69675. * Gets the bounding box renderer associated with the scene
  69676. * @returns a BoundingBoxRenderer
  69677. */
  69678. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69679. }
  69680. interface AbstractMesh {
  69681. /** @hidden (Backing field) */
  69682. _showBoundingBox: boolean;
  69683. /**
  69684. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69685. */
  69686. showBoundingBox: boolean;
  69687. }
  69688. /**
  69689. * Component responsible of rendering the bounding box of the meshes in a scene.
  69690. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69691. */
  69692. export class BoundingBoxRenderer implements ISceneComponent {
  69693. /**
  69694. * The component name helpfull to identify the component in the list of scene components.
  69695. */
  69696. readonly name: string;
  69697. /**
  69698. * The scene the component belongs to.
  69699. */
  69700. scene: Scene;
  69701. /**
  69702. * Color of the bounding box lines placed in front of an object
  69703. */
  69704. frontColor: Color3;
  69705. /**
  69706. * Color of the bounding box lines placed behind an object
  69707. */
  69708. backColor: Color3;
  69709. /**
  69710. * Defines if the renderer should show the back lines or not
  69711. */
  69712. showBackLines: boolean;
  69713. /**
  69714. * Observable raised before rendering a bounding box
  69715. */
  69716. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69717. /**
  69718. * Observable raised after rendering a bounding box
  69719. */
  69720. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69721. /**
  69722. * @hidden
  69723. */
  69724. renderList: SmartArray<BoundingBox>;
  69725. private _colorShader;
  69726. private _vertexBuffers;
  69727. private _indexBuffer;
  69728. private _fillIndexBuffer;
  69729. private _fillIndexData;
  69730. /**
  69731. * Instantiates a new bounding box renderer in a scene.
  69732. * @param scene the scene the renderer renders in
  69733. */
  69734. constructor(scene: Scene);
  69735. /**
  69736. * Registers the component in a given scene
  69737. */
  69738. register(): void;
  69739. private _evaluateSubMesh;
  69740. private _activeMesh;
  69741. private _prepareRessources;
  69742. private _createIndexBuffer;
  69743. /**
  69744. * Rebuilds the elements related to this component in case of
  69745. * context lost for instance.
  69746. */
  69747. rebuild(): void;
  69748. /**
  69749. * @hidden
  69750. */
  69751. reset(): void;
  69752. /**
  69753. * Render the bounding boxes of a specific rendering group
  69754. * @param renderingGroupId defines the rendering group to render
  69755. */
  69756. render(renderingGroupId: number): void;
  69757. /**
  69758. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69759. * @param mesh Define the mesh to render the occlusion bounding box for
  69760. */
  69761. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69762. /**
  69763. * Dispose and release the resources attached to this renderer.
  69764. */
  69765. dispose(): void;
  69766. }
  69767. }
  69768. declare module BABYLON {
  69769. interface Scene {
  69770. /** @hidden (Backing field) */
  69771. _depthRenderer: {
  69772. [id: string]: DepthRenderer;
  69773. };
  69774. /**
  69775. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69776. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69777. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69778. * @returns the created depth renderer
  69779. */
  69780. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69781. /**
  69782. * Disables a depth renderer for a given camera
  69783. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69784. */
  69785. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69786. }
  69787. /**
  69788. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69789. * in several rendering techniques.
  69790. */
  69791. export class DepthRendererSceneComponent implements ISceneComponent {
  69792. /**
  69793. * The component name helpfull to identify the component in the list of scene components.
  69794. */
  69795. readonly name: string;
  69796. /**
  69797. * The scene the component belongs to.
  69798. */
  69799. scene: Scene;
  69800. /**
  69801. * Creates a new instance of the component for the given scene
  69802. * @param scene Defines the scene to register the component in
  69803. */
  69804. constructor(scene: Scene);
  69805. /**
  69806. * Registers the component in a given scene
  69807. */
  69808. register(): void;
  69809. /**
  69810. * Rebuilds the elements related to this component in case of
  69811. * context lost for instance.
  69812. */
  69813. rebuild(): void;
  69814. /**
  69815. * Disposes the component and the associated ressources
  69816. */
  69817. dispose(): void;
  69818. private _gatherRenderTargets;
  69819. private _gatherActiveCameraRenderTargets;
  69820. }
  69821. }
  69822. declare module BABYLON {
  69823. /** @hidden */
  69824. export var outlinePixelShader: {
  69825. name: string;
  69826. shader: string;
  69827. };
  69828. }
  69829. declare module BABYLON {
  69830. /** @hidden */
  69831. export var outlineVertexShader: {
  69832. name: string;
  69833. shader: string;
  69834. };
  69835. }
  69836. declare module BABYLON {
  69837. interface Scene {
  69838. /** @hidden */
  69839. _outlineRenderer: OutlineRenderer;
  69840. /**
  69841. * Gets the outline renderer associated with the scene
  69842. * @returns a OutlineRenderer
  69843. */
  69844. getOutlineRenderer(): OutlineRenderer;
  69845. }
  69846. interface AbstractMesh {
  69847. /** @hidden (Backing field) */
  69848. _renderOutline: boolean;
  69849. /**
  69850. * Gets or sets a boolean indicating if the outline must be rendered as well
  69851. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69852. */
  69853. renderOutline: boolean;
  69854. /** @hidden (Backing field) */
  69855. _renderOverlay: boolean;
  69856. /**
  69857. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69858. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69859. */
  69860. renderOverlay: boolean;
  69861. }
  69862. /**
  69863. * This class is responsible to draw bothe outline/overlay of meshes.
  69864. * It should not be used directly but through the available method on mesh.
  69865. */
  69866. export class OutlineRenderer implements ISceneComponent {
  69867. /**
  69868. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69869. */
  69870. private static _StencilReference;
  69871. /**
  69872. * The name of the component. Each component must have a unique name.
  69873. */
  69874. name: string;
  69875. /**
  69876. * The scene the component belongs to.
  69877. */
  69878. scene: Scene;
  69879. /**
  69880. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69881. */
  69882. zOffset: number;
  69883. private _engine;
  69884. private _effect;
  69885. private _cachedDefines;
  69886. private _savedDepthWrite;
  69887. /**
  69888. * Instantiates a new outline renderer. (There could be only one per scene).
  69889. * @param scene Defines the scene it belongs to
  69890. */
  69891. constructor(scene: Scene);
  69892. /**
  69893. * Register the component to one instance of a scene.
  69894. */
  69895. register(): void;
  69896. /**
  69897. * Rebuilds the elements related to this component in case of
  69898. * context lost for instance.
  69899. */
  69900. rebuild(): void;
  69901. /**
  69902. * Disposes the component and the associated ressources.
  69903. */
  69904. dispose(): void;
  69905. /**
  69906. * Renders the outline in the canvas.
  69907. * @param subMesh Defines the sumesh to render
  69908. * @param batch Defines the batch of meshes in case of instances
  69909. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69910. */
  69911. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69912. /**
  69913. * Returns whether or not the outline renderer is ready for a given submesh.
  69914. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69915. * @param subMesh Defines the submesh to check readyness for
  69916. * @param useInstances Defines wheter wee are trying to render instances or not
  69917. * @returns true if ready otherwise false
  69918. */
  69919. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69920. private _beforeRenderingMesh;
  69921. private _afterRenderingMesh;
  69922. }
  69923. }
  69924. declare module BABYLON {
  69925. /**
  69926. * Defines the basic options interface of a Sprite Frame Source Size.
  69927. */
  69928. export interface ISpriteJSONSpriteSourceSize {
  69929. /**
  69930. * number of the original width of the Frame
  69931. */
  69932. w: number;
  69933. /**
  69934. * number of the original height of the Frame
  69935. */
  69936. h: number;
  69937. }
  69938. /**
  69939. * Defines the basic options interface of a Sprite Frame Data.
  69940. */
  69941. export interface ISpriteJSONSpriteFrameData {
  69942. /**
  69943. * number of the x offset of the Frame
  69944. */
  69945. x: number;
  69946. /**
  69947. * number of the y offset of the Frame
  69948. */
  69949. y: number;
  69950. /**
  69951. * number of the width of the Frame
  69952. */
  69953. w: number;
  69954. /**
  69955. * number of the height of the Frame
  69956. */
  69957. h: number;
  69958. }
  69959. /**
  69960. * Defines the basic options interface of a JSON Sprite.
  69961. */
  69962. export interface ISpriteJSONSprite {
  69963. /**
  69964. * string name of the Frame
  69965. */
  69966. filename: string;
  69967. /**
  69968. * ISpriteJSONSpriteFrame basic object of the frame data
  69969. */
  69970. frame: ISpriteJSONSpriteFrameData;
  69971. /**
  69972. * boolean to flag is the frame was rotated.
  69973. */
  69974. rotated: boolean;
  69975. /**
  69976. * boolean to flag is the frame was trimmed.
  69977. */
  69978. trimmed: boolean;
  69979. /**
  69980. * ISpriteJSONSpriteFrame basic object of the source data
  69981. */
  69982. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69983. /**
  69984. * ISpriteJSONSpriteFrame basic object of the source data
  69985. */
  69986. sourceSize: ISpriteJSONSpriteSourceSize;
  69987. }
  69988. /**
  69989. * Defines the basic options interface of a JSON atlas.
  69990. */
  69991. export interface ISpriteJSONAtlas {
  69992. /**
  69993. * Array of objects that contain the frame data.
  69994. */
  69995. frames: Array<ISpriteJSONSprite>;
  69996. /**
  69997. * object basic object containing the sprite meta data.
  69998. */
  69999. meta?: object;
  70000. }
  70001. }
  70002. declare module BABYLON {
  70003. /** @hidden */
  70004. export var spriteMapPixelShader: {
  70005. name: string;
  70006. shader: string;
  70007. };
  70008. }
  70009. declare module BABYLON {
  70010. /** @hidden */
  70011. export var spriteMapVertexShader: {
  70012. name: string;
  70013. shader: string;
  70014. };
  70015. }
  70016. declare module BABYLON {
  70017. /**
  70018. * Defines the basic options interface of a SpriteMap
  70019. */
  70020. export interface ISpriteMapOptions {
  70021. /**
  70022. * Vector2 of the number of cells in the grid.
  70023. */
  70024. stageSize?: Vector2;
  70025. /**
  70026. * Vector2 of the size of the output plane in World Units.
  70027. */
  70028. outputSize?: Vector2;
  70029. /**
  70030. * Vector3 of the position of the output plane in World Units.
  70031. */
  70032. outputPosition?: Vector3;
  70033. /**
  70034. * Vector3 of the rotation of the output plane.
  70035. */
  70036. outputRotation?: Vector3;
  70037. /**
  70038. * number of layers that the system will reserve in resources.
  70039. */
  70040. layerCount?: number;
  70041. /**
  70042. * number of max animation frames a single cell will reserve in resources.
  70043. */
  70044. maxAnimationFrames?: number;
  70045. /**
  70046. * number cell index of the base tile when the system compiles.
  70047. */
  70048. baseTile?: number;
  70049. /**
  70050. * boolean flip the sprite after its been repositioned by the framing data.
  70051. */
  70052. flipU?: boolean;
  70053. /**
  70054. * Vector3 scalar of the global RGB values of the SpriteMap.
  70055. */
  70056. colorMultiply?: Vector3;
  70057. }
  70058. /**
  70059. * Defines the IDisposable interface in order to be cleanable from resources.
  70060. */
  70061. export interface ISpriteMap extends IDisposable {
  70062. /**
  70063. * String name of the SpriteMap.
  70064. */
  70065. name: string;
  70066. /**
  70067. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70068. */
  70069. atlasJSON: ISpriteJSONAtlas;
  70070. /**
  70071. * Texture of the SpriteMap.
  70072. */
  70073. spriteSheet: Texture;
  70074. /**
  70075. * The parameters to initialize the SpriteMap with.
  70076. */
  70077. options: ISpriteMapOptions;
  70078. }
  70079. /**
  70080. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70081. */
  70082. export class SpriteMap implements ISpriteMap {
  70083. /** The Name of the spriteMap */
  70084. name: string;
  70085. /** The JSON file with the frame and meta data */
  70086. atlasJSON: ISpriteJSONAtlas;
  70087. /** The systems Sprite Sheet Texture */
  70088. spriteSheet: Texture;
  70089. /** Arguments passed with the Constructor */
  70090. options: ISpriteMapOptions;
  70091. /** Public Sprite Storage array, parsed from atlasJSON */
  70092. sprites: Array<ISpriteJSONSprite>;
  70093. /** Returns the Number of Sprites in the System */
  70094. get spriteCount(): number;
  70095. /** Returns the Position of Output Plane*/
  70096. get position(): Vector3;
  70097. /** Returns the Position of Output Plane*/
  70098. set position(v: Vector3);
  70099. /** Returns the Rotation of Output Plane*/
  70100. get rotation(): Vector3;
  70101. /** Returns the Rotation of Output Plane*/
  70102. set rotation(v: Vector3);
  70103. /** Sets the AnimationMap*/
  70104. get animationMap(): RawTexture;
  70105. /** Sets the AnimationMap*/
  70106. set animationMap(v: RawTexture);
  70107. /** Scene that the SpriteMap was created in */
  70108. private _scene;
  70109. /** Texture Buffer of Float32 that holds tile frame data*/
  70110. private _frameMap;
  70111. /** Texture Buffers of Float32 that holds tileMap data*/
  70112. private _tileMaps;
  70113. /** Texture Buffer of Float32 that holds Animation Data*/
  70114. private _animationMap;
  70115. /** Custom ShaderMaterial Central to the System*/
  70116. private _material;
  70117. /** Custom ShaderMaterial Central to the System*/
  70118. private _output;
  70119. /** Systems Time Ticker*/
  70120. private _time;
  70121. /**
  70122. * Creates a new SpriteMap
  70123. * @param name defines the SpriteMaps Name
  70124. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70125. * @param spriteSheet is the Texture that the Sprites are on.
  70126. * @param options a basic deployment configuration
  70127. * @param scene The Scene that the map is deployed on
  70128. */
  70129. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70130. /**
  70131. * Returns tileID location
  70132. * @returns Vector2 the cell position ID
  70133. */
  70134. getTileID(): Vector2;
  70135. /**
  70136. * Gets the UV location of the mouse over the SpriteMap.
  70137. * @returns Vector2 the UV position of the mouse interaction
  70138. */
  70139. getMousePosition(): Vector2;
  70140. /**
  70141. * Creates the "frame" texture Buffer
  70142. * -------------------------------------
  70143. * Structure of frames
  70144. * "filename": "Falling-Water-2.png",
  70145. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70146. * "rotated": true,
  70147. * "trimmed": true,
  70148. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70149. * "sourceSize": {"w":32,"h":32}
  70150. * @returns RawTexture of the frameMap
  70151. */
  70152. private _createFrameBuffer;
  70153. /**
  70154. * Creates the tileMap texture Buffer
  70155. * @param buffer normally and array of numbers, or a false to generate from scratch
  70156. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70157. * @returns RawTexture of the tileMap
  70158. */
  70159. private _createTileBuffer;
  70160. /**
  70161. * Modifies the data of the tileMaps
  70162. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70163. * @param pos is the iVector2 Coordinates of the Tile
  70164. * @param tile The SpriteIndex of the new Tile
  70165. */
  70166. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70167. /**
  70168. * Creates the animationMap texture Buffer
  70169. * @param buffer normally and array of numbers, or a false to generate from scratch
  70170. * @returns RawTexture of the animationMap
  70171. */
  70172. private _createTileAnimationBuffer;
  70173. /**
  70174. * Modifies the data of the animationMap
  70175. * @param cellID is the Index of the Sprite
  70176. * @param _frame is the target Animation frame
  70177. * @param toCell is the Target Index of the next frame of the animation
  70178. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70179. * @param speed is a global scalar of the time variable on the map.
  70180. */
  70181. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70182. /**
  70183. * Exports the .tilemaps file
  70184. */
  70185. saveTileMaps(): void;
  70186. /**
  70187. * Imports the .tilemaps file
  70188. * @param url of the .tilemaps file
  70189. */
  70190. loadTileMaps(url: string): void;
  70191. /**
  70192. * Release associated resources
  70193. */
  70194. dispose(): void;
  70195. }
  70196. }
  70197. declare module BABYLON {
  70198. /**
  70199. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70200. * @see http://doc.babylonjs.com/babylon101/sprites
  70201. */
  70202. export class SpritePackedManager extends SpriteManager {
  70203. /** defines the packed manager's name */
  70204. name: string;
  70205. /**
  70206. * Creates a new sprite manager from a packed sprite sheet
  70207. * @param name defines the manager's name
  70208. * @param imgUrl defines the sprite sheet url
  70209. * @param capacity defines the maximum allowed number of sprites
  70210. * @param scene defines the hosting scene
  70211. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70212. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70213. * @param samplingMode defines the smapling mode to use with spritesheet
  70214. * @param fromPacked set to true; do not alter
  70215. */
  70216. constructor(
  70217. /** defines the packed manager's name */
  70218. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70219. }
  70220. }
  70221. declare module BABYLON {
  70222. /**
  70223. * Defines the list of states available for a task inside a AssetsManager
  70224. */
  70225. export enum AssetTaskState {
  70226. /**
  70227. * Initialization
  70228. */
  70229. INIT = 0,
  70230. /**
  70231. * Running
  70232. */
  70233. RUNNING = 1,
  70234. /**
  70235. * Done
  70236. */
  70237. DONE = 2,
  70238. /**
  70239. * Error
  70240. */
  70241. ERROR = 3
  70242. }
  70243. /**
  70244. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70245. */
  70246. export abstract class AbstractAssetTask {
  70247. /**
  70248. * Task name
  70249. */ name: string;
  70250. /**
  70251. * Callback called when the task is successful
  70252. */
  70253. onSuccess: (task: any) => void;
  70254. /**
  70255. * Callback called when the task is not successful
  70256. */
  70257. onError: (task: any, message?: string, exception?: any) => void;
  70258. /**
  70259. * Creates a new AssetsManager
  70260. * @param name defines the name of the task
  70261. */
  70262. constructor(
  70263. /**
  70264. * Task name
  70265. */ name: string);
  70266. private _isCompleted;
  70267. private _taskState;
  70268. private _errorObject;
  70269. /**
  70270. * Get if the task is completed
  70271. */
  70272. get isCompleted(): boolean;
  70273. /**
  70274. * Gets the current state of the task
  70275. */
  70276. get taskState(): AssetTaskState;
  70277. /**
  70278. * Gets the current error object (if task is in error)
  70279. */
  70280. get errorObject(): {
  70281. message?: string;
  70282. exception?: any;
  70283. };
  70284. /**
  70285. * Internal only
  70286. * @hidden
  70287. */
  70288. _setErrorObject(message?: string, exception?: any): void;
  70289. /**
  70290. * Execute the current task
  70291. * @param scene defines the scene where you want your assets to be loaded
  70292. * @param onSuccess is a callback called when the task is successfully executed
  70293. * @param onError is a callback called if an error occurs
  70294. */
  70295. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70296. /**
  70297. * Execute the current task
  70298. * @param scene defines the scene where you want your assets to be loaded
  70299. * @param onSuccess is a callback called when the task is successfully executed
  70300. * @param onError is a callback called if an error occurs
  70301. */
  70302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70303. /**
  70304. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70305. * This can be used with failed tasks that have the reason for failure fixed.
  70306. */
  70307. reset(): void;
  70308. private onErrorCallback;
  70309. private onDoneCallback;
  70310. }
  70311. /**
  70312. * Define the interface used by progress events raised during assets loading
  70313. */
  70314. export interface IAssetsProgressEvent {
  70315. /**
  70316. * Defines the number of remaining tasks to process
  70317. */
  70318. remainingCount: number;
  70319. /**
  70320. * Defines the total number of tasks
  70321. */
  70322. totalCount: number;
  70323. /**
  70324. * Defines the task that was just processed
  70325. */
  70326. task: AbstractAssetTask;
  70327. }
  70328. /**
  70329. * Class used to share progress information about assets loading
  70330. */
  70331. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70332. /**
  70333. * Defines the number of remaining tasks to process
  70334. */
  70335. remainingCount: number;
  70336. /**
  70337. * Defines the total number of tasks
  70338. */
  70339. totalCount: number;
  70340. /**
  70341. * Defines the task that was just processed
  70342. */
  70343. task: AbstractAssetTask;
  70344. /**
  70345. * Creates a AssetsProgressEvent
  70346. * @param remainingCount defines the number of remaining tasks to process
  70347. * @param totalCount defines the total number of tasks
  70348. * @param task defines the task that was just processed
  70349. */
  70350. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70351. }
  70352. /**
  70353. * Define a task used by AssetsManager to load meshes
  70354. */
  70355. export class MeshAssetTask extends AbstractAssetTask {
  70356. /**
  70357. * Defines the name of the task
  70358. */
  70359. name: string;
  70360. /**
  70361. * Defines the list of mesh's names you want to load
  70362. */
  70363. meshesNames: any;
  70364. /**
  70365. * Defines the root url to use as a base to load your meshes and associated resources
  70366. */
  70367. rootUrl: string;
  70368. /**
  70369. * Defines the filename or File of the scene to load from
  70370. */
  70371. sceneFilename: string | File;
  70372. /**
  70373. * Gets the list of loaded meshes
  70374. */
  70375. loadedMeshes: Array<AbstractMesh>;
  70376. /**
  70377. * Gets the list of loaded particle systems
  70378. */
  70379. loadedParticleSystems: Array<IParticleSystem>;
  70380. /**
  70381. * Gets the list of loaded skeletons
  70382. */
  70383. loadedSkeletons: Array<Skeleton>;
  70384. /**
  70385. * Gets the list of loaded animation groups
  70386. */
  70387. loadedAnimationGroups: Array<AnimationGroup>;
  70388. /**
  70389. * Callback called when the task is successful
  70390. */
  70391. onSuccess: (task: MeshAssetTask) => void;
  70392. /**
  70393. * Callback called when the task is successful
  70394. */
  70395. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70396. /**
  70397. * Creates a new MeshAssetTask
  70398. * @param name defines the name of the task
  70399. * @param meshesNames defines the list of mesh's names you want to load
  70400. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70401. * @param sceneFilename defines the filename or File of the scene to load from
  70402. */
  70403. constructor(
  70404. /**
  70405. * Defines the name of the task
  70406. */
  70407. name: string,
  70408. /**
  70409. * Defines the list of mesh's names you want to load
  70410. */
  70411. meshesNames: any,
  70412. /**
  70413. * Defines the root url to use as a base to load your meshes and associated resources
  70414. */
  70415. rootUrl: string,
  70416. /**
  70417. * Defines the filename or File of the scene to load from
  70418. */
  70419. sceneFilename: string | File);
  70420. /**
  70421. * Execute the current task
  70422. * @param scene defines the scene where you want your assets to be loaded
  70423. * @param onSuccess is a callback called when the task is successfully executed
  70424. * @param onError is a callback called if an error occurs
  70425. */
  70426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70427. }
  70428. /**
  70429. * Define a task used by AssetsManager to load text content
  70430. */
  70431. export class TextFileAssetTask extends AbstractAssetTask {
  70432. /**
  70433. * Defines the name of the task
  70434. */
  70435. name: string;
  70436. /**
  70437. * Defines the location of the file to load
  70438. */
  70439. url: string;
  70440. /**
  70441. * Gets the loaded text string
  70442. */
  70443. text: string;
  70444. /**
  70445. * Callback called when the task is successful
  70446. */
  70447. onSuccess: (task: TextFileAssetTask) => void;
  70448. /**
  70449. * Callback called when the task is successful
  70450. */
  70451. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70452. /**
  70453. * Creates a new TextFileAssetTask object
  70454. * @param name defines the name of the task
  70455. * @param url defines the location of the file to load
  70456. */
  70457. constructor(
  70458. /**
  70459. * Defines the name of the task
  70460. */
  70461. name: string,
  70462. /**
  70463. * Defines the location of the file to load
  70464. */
  70465. url: string);
  70466. /**
  70467. * Execute the current task
  70468. * @param scene defines the scene where you want your assets to be loaded
  70469. * @param onSuccess is a callback called when the task is successfully executed
  70470. * @param onError is a callback called if an error occurs
  70471. */
  70472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70473. }
  70474. /**
  70475. * Define a task used by AssetsManager to load binary data
  70476. */
  70477. export class BinaryFileAssetTask extends AbstractAssetTask {
  70478. /**
  70479. * Defines the name of the task
  70480. */
  70481. name: string;
  70482. /**
  70483. * Defines the location of the file to load
  70484. */
  70485. url: string;
  70486. /**
  70487. * Gets the lodaded data (as an array buffer)
  70488. */
  70489. data: ArrayBuffer;
  70490. /**
  70491. * Callback called when the task is successful
  70492. */
  70493. onSuccess: (task: BinaryFileAssetTask) => void;
  70494. /**
  70495. * Callback called when the task is successful
  70496. */
  70497. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70498. /**
  70499. * Creates a new BinaryFileAssetTask object
  70500. * @param name defines the name of the new task
  70501. * @param url defines the location of the file to load
  70502. */
  70503. constructor(
  70504. /**
  70505. * Defines the name of the task
  70506. */
  70507. name: string,
  70508. /**
  70509. * Defines the location of the file to load
  70510. */
  70511. url: string);
  70512. /**
  70513. * Execute the current task
  70514. * @param scene defines the scene where you want your assets to be loaded
  70515. * @param onSuccess is a callback called when the task is successfully executed
  70516. * @param onError is a callback called if an error occurs
  70517. */
  70518. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70519. }
  70520. /**
  70521. * Define a task used by AssetsManager to load images
  70522. */
  70523. export class ImageAssetTask extends AbstractAssetTask {
  70524. /**
  70525. * Defines the name of the task
  70526. */
  70527. name: string;
  70528. /**
  70529. * Defines the location of the image to load
  70530. */
  70531. url: string;
  70532. /**
  70533. * Gets the loaded images
  70534. */
  70535. image: HTMLImageElement;
  70536. /**
  70537. * Callback called when the task is successful
  70538. */
  70539. onSuccess: (task: ImageAssetTask) => void;
  70540. /**
  70541. * Callback called when the task is successful
  70542. */
  70543. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70544. /**
  70545. * Creates a new ImageAssetTask
  70546. * @param name defines the name of the task
  70547. * @param url defines the location of the image to load
  70548. */
  70549. constructor(
  70550. /**
  70551. * Defines the name of the task
  70552. */
  70553. name: string,
  70554. /**
  70555. * Defines the location of the image to load
  70556. */
  70557. url: string);
  70558. /**
  70559. * Execute the current task
  70560. * @param scene defines the scene where you want your assets to be loaded
  70561. * @param onSuccess is a callback called when the task is successfully executed
  70562. * @param onError is a callback called if an error occurs
  70563. */
  70564. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70565. }
  70566. /**
  70567. * Defines the interface used by texture loading tasks
  70568. */
  70569. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70570. /**
  70571. * Gets the loaded texture
  70572. */
  70573. texture: TEX;
  70574. }
  70575. /**
  70576. * Define a task used by AssetsManager to load 2D textures
  70577. */
  70578. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70579. /**
  70580. * Defines the name of the task
  70581. */
  70582. name: string;
  70583. /**
  70584. * Defines the location of the file to load
  70585. */
  70586. url: string;
  70587. /**
  70588. * Defines if mipmap should not be generated (default is false)
  70589. */
  70590. noMipmap?: boolean | undefined;
  70591. /**
  70592. * Defines if texture must be inverted on Y axis (default is true)
  70593. */
  70594. invertY: boolean;
  70595. /**
  70596. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70597. */
  70598. samplingMode: number;
  70599. /**
  70600. * Gets the loaded texture
  70601. */
  70602. texture: Texture;
  70603. /**
  70604. * Callback called when the task is successful
  70605. */
  70606. onSuccess: (task: TextureAssetTask) => void;
  70607. /**
  70608. * Callback called when the task is successful
  70609. */
  70610. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70611. /**
  70612. * Creates a new TextureAssetTask object
  70613. * @param name defines the name of the task
  70614. * @param url defines the location of the file to load
  70615. * @param noMipmap defines if mipmap should not be generated (default is false)
  70616. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70617. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70618. */
  70619. constructor(
  70620. /**
  70621. * Defines the name of the task
  70622. */
  70623. name: string,
  70624. /**
  70625. * Defines the location of the file to load
  70626. */
  70627. url: string,
  70628. /**
  70629. * Defines if mipmap should not be generated (default is false)
  70630. */
  70631. noMipmap?: boolean | undefined,
  70632. /**
  70633. * Defines if texture must be inverted on Y axis (default is true)
  70634. */
  70635. invertY?: boolean,
  70636. /**
  70637. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70638. */
  70639. samplingMode?: number);
  70640. /**
  70641. * Execute the current task
  70642. * @param scene defines the scene where you want your assets to be loaded
  70643. * @param onSuccess is a callback called when the task is successfully executed
  70644. * @param onError is a callback called if an error occurs
  70645. */
  70646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70647. }
  70648. /**
  70649. * Define a task used by AssetsManager to load cube textures
  70650. */
  70651. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70652. /**
  70653. * Defines the name of the task
  70654. */
  70655. name: string;
  70656. /**
  70657. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70658. */
  70659. url: string;
  70660. /**
  70661. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70662. */
  70663. extensions?: string[] | undefined;
  70664. /**
  70665. * Defines if mipmaps should not be generated (default is false)
  70666. */
  70667. noMipmap?: boolean | undefined;
  70668. /**
  70669. * Defines the explicit list of files (undefined by default)
  70670. */
  70671. files?: string[] | undefined;
  70672. /**
  70673. * Gets the loaded texture
  70674. */
  70675. texture: CubeTexture;
  70676. /**
  70677. * Callback called when the task is successful
  70678. */
  70679. onSuccess: (task: CubeTextureAssetTask) => void;
  70680. /**
  70681. * Callback called when the task is successful
  70682. */
  70683. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70684. /**
  70685. * Creates a new CubeTextureAssetTask
  70686. * @param name defines the name of the task
  70687. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70688. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70689. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70690. * @param files defines the explicit list of files (undefined by default)
  70691. */
  70692. constructor(
  70693. /**
  70694. * Defines the name of the task
  70695. */
  70696. name: string,
  70697. /**
  70698. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70699. */
  70700. url: string,
  70701. /**
  70702. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70703. */
  70704. extensions?: string[] | undefined,
  70705. /**
  70706. * Defines if mipmaps should not be generated (default is false)
  70707. */
  70708. noMipmap?: boolean | undefined,
  70709. /**
  70710. * Defines the explicit list of files (undefined by default)
  70711. */
  70712. files?: string[] | undefined);
  70713. /**
  70714. * Execute the current task
  70715. * @param scene defines the scene where you want your assets to be loaded
  70716. * @param onSuccess is a callback called when the task is successfully executed
  70717. * @param onError is a callback called if an error occurs
  70718. */
  70719. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70720. }
  70721. /**
  70722. * Define a task used by AssetsManager to load HDR cube textures
  70723. */
  70724. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70725. /**
  70726. * Defines the name of the task
  70727. */
  70728. name: string;
  70729. /**
  70730. * Defines the location of the file to load
  70731. */
  70732. url: string;
  70733. /**
  70734. * Defines the desired size (the more it increases the longer the generation will be)
  70735. */
  70736. size: number;
  70737. /**
  70738. * Defines if mipmaps should not be generated (default is false)
  70739. */
  70740. noMipmap: boolean;
  70741. /**
  70742. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70743. */
  70744. generateHarmonics: boolean;
  70745. /**
  70746. * 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)
  70747. */
  70748. gammaSpace: boolean;
  70749. /**
  70750. * Internal Use Only
  70751. */
  70752. reserved: boolean;
  70753. /**
  70754. * Gets the loaded texture
  70755. */
  70756. texture: HDRCubeTexture;
  70757. /**
  70758. * Callback called when the task is successful
  70759. */
  70760. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70761. /**
  70762. * Callback called when the task is successful
  70763. */
  70764. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70765. /**
  70766. * Creates a new HDRCubeTextureAssetTask object
  70767. * @param name defines the name of the task
  70768. * @param url defines the location of the file to load
  70769. * @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.
  70770. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70771. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70772. * @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)
  70773. * @param reserved Internal use only
  70774. */
  70775. constructor(
  70776. /**
  70777. * Defines the name of the task
  70778. */
  70779. name: string,
  70780. /**
  70781. * Defines the location of the file to load
  70782. */
  70783. url: string,
  70784. /**
  70785. * Defines the desired size (the more it increases the longer the generation will be)
  70786. */
  70787. size: number,
  70788. /**
  70789. * Defines if mipmaps should not be generated (default is false)
  70790. */
  70791. noMipmap?: boolean,
  70792. /**
  70793. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70794. */
  70795. generateHarmonics?: boolean,
  70796. /**
  70797. * 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)
  70798. */
  70799. gammaSpace?: boolean,
  70800. /**
  70801. * Internal Use Only
  70802. */
  70803. reserved?: boolean);
  70804. /**
  70805. * Execute the current task
  70806. * @param scene defines the scene where you want your assets to be loaded
  70807. * @param onSuccess is a callback called when the task is successfully executed
  70808. * @param onError is a callback called if an error occurs
  70809. */
  70810. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70811. }
  70812. /**
  70813. * Define a task used by AssetsManager to load Equirectangular cube textures
  70814. */
  70815. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70816. /**
  70817. * Defines the name of the task
  70818. */
  70819. name: string;
  70820. /**
  70821. * Defines the location of the file to load
  70822. */
  70823. url: string;
  70824. /**
  70825. * Defines the desired size (the more it increases the longer the generation will be)
  70826. */
  70827. size: number;
  70828. /**
  70829. * Defines if mipmaps should not be generated (default is false)
  70830. */
  70831. noMipmap: boolean;
  70832. /**
  70833. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70834. * but the standard material would require them in Gamma space) (default is true)
  70835. */
  70836. gammaSpace: boolean;
  70837. /**
  70838. * Gets the loaded texture
  70839. */
  70840. texture: EquiRectangularCubeTexture;
  70841. /**
  70842. * Callback called when the task is successful
  70843. */
  70844. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70845. /**
  70846. * Callback called when the task is successful
  70847. */
  70848. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70849. /**
  70850. * Creates a new EquiRectangularCubeTextureAssetTask object
  70851. * @param name defines the name of the task
  70852. * @param url defines the location of the file to load
  70853. * @param size defines the desired size (the more it increases the longer the generation will be)
  70854. * If the size is omitted this implies you are using a preprocessed cubemap.
  70855. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70856. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70857. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70858. * (default is true)
  70859. */
  70860. constructor(
  70861. /**
  70862. * Defines the name of the task
  70863. */
  70864. name: string,
  70865. /**
  70866. * Defines the location of the file to load
  70867. */
  70868. url: string,
  70869. /**
  70870. * Defines the desired size (the more it increases the longer the generation will be)
  70871. */
  70872. size: number,
  70873. /**
  70874. * Defines if mipmaps should not be generated (default is false)
  70875. */
  70876. noMipmap?: boolean,
  70877. /**
  70878. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70879. * but the standard material would require them in Gamma space) (default is true)
  70880. */
  70881. gammaSpace?: boolean);
  70882. /**
  70883. * Execute the current task
  70884. * @param scene defines the scene where you want your assets to be loaded
  70885. * @param onSuccess is a callback called when the task is successfully executed
  70886. * @param onError is a callback called if an error occurs
  70887. */
  70888. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70889. }
  70890. /**
  70891. * This class can be used to easily import assets into a scene
  70892. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70893. */
  70894. export class AssetsManager {
  70895. private _scene;
  70896. private _isLoading;
  70897. protected _tasks: AbstractAssetTask[];
  70898. protected _waitingTasksCount: number;
  70899. protected _totalTasksCount: number;
  70900. /**
  70901. * Callback called when all tasks are processed
  70902. */
  70903. onFinish: (tasks: AbstractAssetTask[]) => void;
  70904. /**
  70905. * Callback called when a task is successful
  70906. */
  70907. onTaskSuccess: (task: AbstractAssetTask) => void;
  70908. /**
  70909. * Callback called when a task had an error
  70910. */
  70911. onTaskError: (task: AbstractAssetTask) => void;
  70912. /**
  70913. * Callback called when a task is done (whatever the result is)
  70914. */
  70915. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70916. /**
  70917. * Observable called when all tasks are processed
  70918. */
  70919. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70920. /**
  70921. * Observable called when a task had an error
  70922. */
  70923. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70924. /**
  70925. * Observable called when all tasks were executed
  70926. */
  70927. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70928. /**
  70929. * Observable called when a task is done (whatever the result is)
  70930. */
  70931. onProgressObservable: Observable<IAssetsProgressEvent>;
  70932. /**
  70933. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70934. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70935. */
  70936. useDefaultLoadingScreen: boolean;
  70937. /**
  70938. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70939. * when all assets have been downloaded.
  70940. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70941. */
  70942. autoHideLoadingUI: boolean;
  70943. /**
  70944. * Creates a new AssetsManager
  70945. * @param scene defines the scene to work on
  70946. */
  70947. constructor(scene: Scene);
  70948. /**
  70949. * Add a MeshAssetTask to the list of active tasks
  70950. * @param taskName defines the name of the new task
  70951. * @param meshesNames defines the name of meshes to load
  70952. * @param rootUrl defines the root url to use to locate files
  70953. * @param sceneFilename defines the filename of the scene file
  70954. * @returns a new MeshAssetTask object
  70955. */
  70956. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70957. /**
  70958. * Add a TextFileAssetTask to the list of active tasks
  70959. * @param taskName defines the name of the new task
  70960. * @param url defines the url of the file to load
  70961. * @returns a new TextFileAssetTask object
  70962. */
  70963. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70964. /**
  70965. * Add a BinaryFileAssetTask to the list of active tasks
  70966. * @param taskName defines the name of the new task
  70967. * @param url defines the url of the file to load
  70968. * @returns a new BinaryFileAssetTask object
  70969. */
  70970. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70971. /**
  70972. * Add a ImageAssetTask to the list of active tasks
  70973. * @param taskName defines the name of the new task
  70974. * @param url defines the url of the file to load
  70975. * @returns a new ImageAssetTask object
  70976. */
  70977. addImageTask(taskName: string, url: string): ImageAssetTask;
  70978. /**
  70979. * Add a TextureAssetTask to the list of active tasks
  70980. * @param taskName defines the name of the new task
  70981. * @param url defines the url of the file to load
  70982. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70983. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  70984. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70985. * @returns a new TextureAssetTask object
  70986. */
  70987. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  70988. /**
  70989. * Add a CubeTextureAssetTask to the list of active tasks
  70990. * @param taskName defines the name of the new task
  70991. * @param url defines the url of the file to load
  70992. * @param extensions defines the extension to use to load the cube map (can be null)
  70993. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70994. * @param files defines the list of files to load (can be null)
  70995. * @returns a new CubeTextureAssetTask object
  70996. */
  70997. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  70998. /**
  70999. *
  71000. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71001. * @param taskName defines the name of the new task
  71002. * @param url defines the url of the file to load
  71003. * @param size defines the size you want for the cubemap (can be null)
  71004. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71005. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71006. * @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)
  71007. * @param reserved Internal use only
  71008. * @returns a new HDRCubeTextureAssetTask object
  71009. */
  71010. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71011. /**
  71012. *
  71013. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71014. * @param taskName defines the name of the new task
  71015. * @param url defines the url of the file to load
  71016. * @param size defines the size you want for the cubemap (can be null)
  71017. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71018. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71019. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71020. * @returns a new EquiRectangularCubeTextureAssetTask object
  71021. */
  71022. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71023. /**
  71024. * Remove a task from the assets manager.
  71025. * @param task the task to remove
  71026. */
  71027. removeTask(task: AbstractAssetTask): void;
  71028. private _decreaseWaitingTasksCount;
  71029. private _runTask;
  71030. /**
  71031. * Reset the AssetsManager and remove all tasks
  71032. * @return the current instance of the AssetsManager
  71033. */
  71034. reset(): AssetsManager;
  71035. /**
  71036. * Start the loading process
  71037. * @return the current instance of the AssetsManager
  71038. */
  71039. load(): AssetsManager;
  71040. /**
  71041. * Start the loading process as an async operation
  71042. * @return a promise returning the list of failed tasks
  71043. */
  71044. loadAsync(): Promise<void>;
  71045. }
  71046. }
  71047. declare module BABYLON {
  71048. /**
  71049. * Wrapper class for promise with external resolve and reject.
  71050. */
  71051. export class Deferred<T> {
  71052. /**
  71053. * The promise associated with this deferred object.
  71054. */
  71055. readonly promise: Promise<T>;
  71056. private _resolve;
  71057. private _reject;
  71058. /**
  71059. * The resolve method of the promise associated with this deferred object.
  71060. */
  71061. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71062. /**
  71063. * The reject method of the promise associated with this deferred object.
  71064. */
  71065. get reject(): (reason?: any) => void;
  71066. /**
  71067. * Constructor for this deferred object.
  71068. */
  71069. constructor();
  71070. }
  71071. }
  71072. declare module BABYLON {
  71073. /**
  71074. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71075. */
  71076. export class MeshExploder {
  71077. private _centerMesh;
  71078. private _meshes;
  71079. private _meshesOrigins;
  71080. private _toCenterVectors;
  71081. private _scaledDirection;
  71082. private _newPosition;
  71083. private _centerPosition;
  71084. /**
  71085. * Explodes meshes from a center mesh.
  71086. * @param meshes The meshes to explode.
  71087. * @param centerMesh The mesh to be center of explosion.
  71088. */
  71089. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71090. private _setCenterMesh;
  71091. /**
  71092. * Get class name
  71093. * @returns "MeshExploder"
  71094. */
  71095. getClassName(): string;
  71096. /**
  71097. * "Exploded meshes"
  71098. * @returns Array of meshes with the centerMesh at index 0.
  71099. */
  71100. getMeshes(): Array<Mesh>;
  71101. /**
  71102. * Explodes meshes giving a specific direction
  71103. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71104. */
  71105. explode(direction?: number): void;
  71106. }
  71107. }
  71108. declare module BABYLON {
  71109. /**
  71110. * Class used to help managing file picking and drag'n'drop
  71111. */
  71112. export class FilesInput {
  71113. /**
  71114. * List of files ready to be loaded
  71115. */
  71116. static get FilesToLoad(): {
  71117. [key: string]: File;
  71118. };
  71119. /**
  71120. * Callback called when a file is processed
  71121. */
  71122. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71123. private _engine;
  71124. private _currentScene;
  71125. private _sceneLoadedCallback;
  71126. private _progressCallback;
  71127. private _additionalRenderLoopLogicCallback;
  71128. private _textureLoadingCallback;
  71129. private _startingProcessingFilesCallback;
  71130. private _onReloadCallback;
  71131. private _errorCallback;
  71132. private _elementToMonitor;
  71133. private _sceneFileToLoad;
  71134. private _filesToLoad;
  71135. /**
  71136. * Creates a new FilesInput
  71137. * @param engine defines the rendering engine
  71138. * @param scene defines the hosting scene
  71139. * @param sceneLoadedCallback callback called when scene is loaded
  71140. * @param progressCallback callback called to track progress
  71141. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71142. * @param textureLoadingCallback callback called when a texture is loading
  71143. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71144. * @param onReloadCallback callback called when a reload is requested
  71145. * @param errorCallback callback call if an error occurs
  71146. */
  71147. 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);
  71148. private _dragEnterHandler;
  71149. private _dragOverHandler;
  71150. private _dropHandler;
  71151. /**
  71152. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71153. * @param elementToMonitor defines the DOM element to track
  71154. */
  71155. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71156. /**
  71157. * Release all associated resources
  71158. */
  71159. dispose(): void;
  71160. private renderFunction;
  71161. private drag;
  71162. private drop;
  71163. private _traverseFolder;
  71164. private _processFiles;
  71165. /**
  71166. * Load files from a drop event
  71167. * @param event defines the drop event to use as source
  71168. */
  71169. loadFiles(event: any): void;
  71170. private _processReload;
  71171. /**
  71172. * Reload the current scene from the loaded files
  71173. */
  71174. reload(): void;
  71175. }
  71176. }
  71177. declare module BABYLON {
  71178. /**
  71179. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71180. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71181. */
  71182. export class SceneOptimization {
  71183. /**
  71184. * Defines the priority of this optimization (0 by default which means first in the list)
  71185. */
  71186. priority: number;
  71187. /**
  71188. * Gets a string describing the action executed by the current optimization
  71189. * @returns description string
  71190. */
  71191. getDescription(): string;
  71192. /**
  71193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71194. * @param scene defines the current scene where to apply this optimization
  71195. * @param optimizer defines the current optimizer
  71196. * @returns true if everything that can be done was applied
  71197. */
  71198. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71199. /**
  71200. * Creates the SceneOptimization object
  71201. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71202. * @param desc defines the description associated with the optimization
  71203. */
  71204. constructor(
  71205. /**
  71206. * Defines the priority of this optimization (0 by default which means first in the list)
  71207. */
  71208. priority?: number);
  71209. }
  71210. /**
  71211. * Defines an optimization used to reduce the size of render target textures
  71212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71213. */
  71214. export class TextureOptimization extends SceneOptimization {
  71215. /**
  71216. * Defines the priority of this optimization (0 by default which means first in the list)
  71217. */
  71218. priority: number;
  71219. /**
  71220. * 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
  71221. */
  71222. maximumSize: number;
  71223. /**
  71224. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71225. */
  71226. step: number;
  71227. /**
  71228. * Gets a string describing the action executed by the current optimization
  71229. * @returns description string
  71230. */
  71231. getDescription(): string;
  71232. /**
  71233. * Creates the TextureOptimization object
  71234. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71235. * @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
  71236. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71237. */
  71238. constructor(
  71239. /**
  71240. * Defines the priority of this optimization (0 by default which means first in the list)
  71241. */
  71242. priority?: number,
  71243. /**
  71244. * 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
  71245. */
  71246. maximumSize?: number,
  71247. /**
  71248. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71249. */
  71250. step?: number);
  71251. /**
  71252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71253. * @param scene defines the current scene where to apply this optimization
  71254. * @param optimizer defines the current optimizer
  71255. * @returns true if everything that can be done was applied
  71256. */
  71257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71258. }
  71259. /**
  71260. * Defines an optimization used to increase or decrease the rendering resolution
  71261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71262. */
  71263. export class HardwareScalingOptimization extends SceneOptimization {
  71264. /**
  71265. * Defines the priority of this optimization (0 by default which means first in the list)
  71266. */
  71267. priority: number;
  71268. /**
  71269. * Defines the maximum scale to use (2 by default)
  71270. */
  71271. maximumScale: number;
  71272. /**
  71273. * Defines the step to use between two passes (0.5 by default)
  71274. */
  71275. step: number;
  71276. private _currentScale;
  71277. private _directionOffset;
  71278. /**
  71279. * Gets a string describing the action executed by the current optimization
  71280. * @return description string
  71281. */
  71282. getDescription(): string;
  71283. /**
  71284. * Creates the HardwareScalingOptimization object
  71285. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71286. * @param maximumScale defines the maximum scale to use (2 by default)
  71287. * @param step defines the step to use between two passes (0.5 by default)
  71288. */
  71289. constructor(
  71290. /**
  71291. * Defines the priority of this optimization (0 by default which means first in the list)
  71292. */
  71293. priority?: number,
  71294. /**
  71295. * Defines the maximum scale to use (2 by default)
  71296. */
  71297. maximumScale?: number,
  71298. /**
  71299. * Defines the step to use between two passes (0.5 by default)
  71300. */
  71301. step?: number);
  71302. /**
  71303. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71304. * @param scene defines the current scene where to apply this optimization
  71305. * @param optimizer defines the current optimizer
  71306. * @returns true if everything that can be done was applied
  71307. */
  71308. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71309. }
  71310. /**
  71311. * Defines an optimization used to remove shadows
  71312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71313. */
  71314. export class ShadowsOptimization extends SceneOptimization {
  71315. /**
  71316. * Gets a string describing the action executed by the current optimization
  71317. * @return description string
  71318. */
  71319. getDescription(): string;
  71320. /**
  71321. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71322. * @param scene defines the current scene where to apply this optimization
  71323. * @param optimizer defines the current optimizer
  71324. * @returns true if everything that can be done was applied
  71325. */
  71326. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71327. }
  71328. /**
  71329. * Defines an optimization used to turn post-processes off
  71330. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71331. */
  71332. export class PostProcessesOptimization extends SceneOptimization {
  71333. /**
  71334. * Gets a string describing the action executed by the current optimization
  71335. * @return description string
  71336. */
  71337. getDescription(): string;
  71338. /**
  71339. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71340. * @param scene defines the current scene where to apply this optimization
  71341. * @param optimizer defines the current optimizer
  71342. * @returns true if everything that can be done was applied
  71343. */
  71344. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71345. }
  71346. /**
  71347. * Defines an optimization used to turn lens flares off
  71348. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71349. */
  71350. export class LensFlaresOptimization extends SceneOptimization {
  71351. /**
  71352. * Gets a string describing the action executed by the current optimization
  71353. * @return description string
  71354. */
  71355. getDescription(): string;
  71356. /**
  71357. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71358. * @param scene defines the current scene where to apply this optimization
  71359. * @param optimizer defines the current optimizer
  71360. * @returns true if everything that can be done was applied
  71361. */
  71362. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71363. }
  71364. /**
  71365. * Defines an optimization based on user defined callback.
  71366. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71367. */
  71368. export class CustomOptimization extends SceneOptimization {
  71369. /**
  71370. * Callback called to apply the custom optimization.
  71371. */
  71372. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71373. /**
  71374. * Callback called to get custom description
  71375. */
  71376. onGetDescription: () => string;
  71377. /**
  71378. * Gets a string describing the action executed by the current optimization
  71379. * @returns description string
  71380. */
  71381. getDescription(): string;
  71382. /**
  71383. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71384. * @param scene defines the current scene where to apply this optimization
  71385. * @param optimizer defines the current optimizer
  71386. * @returns true if everything that can be done was applied
  71387. */
  71388. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71389. }
  71390. /**
  71391. * Defines an optimization used to turn particles off
  71392. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71393. */
  71394. export class ParticlesOptimization extends SceneOptimization {
  71395. /**
  71396. * Gets a string describing the action executed by the current optimization
  71397. * @return description string
  71398. */
  71399. getDescription(): string;
  71400. /**
  71401. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71402. * @param scene defines the current scene where to apply this optimization
  71403. * @param optimizer defines the current optimizer
  71404. * @returns true if everything that can be done was applied
  71405. */
  71406. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71407. }
  71408. /**
  71409. * Defines an optimization used to turn render targets off
  71410. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71411. */
  71412. export class RenderTargetsOptimization extends SceneOptimization {
  71413. /**
  71414. * Gets a string describing the action executed by the current optimization
  71415. * @return description string
  71416. */
  71417. getDescription(): string;
  71418. /**
  71419. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71420. * @param scene defines the current scene where to apply this optimization
  71421. * @param optimizer defines the current optimizer
  71422. * @returns true if everything that can be done was applied
  71423. */
  71424. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71425. }
  71426. /**
  71427. * Defines an optimization used to merge meshes with compatible materials
  71428. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71429. */
  71430. export class MergeMeshesOptimization extends SceneOptimization {
  71431. private static _UpdateSelectionTree;
  71432. /**
  71433. * Gets or sets a boolean which defines if optimization octree has to be updated
  71434. */
  71435. static get UpdateSelectionTree(): boolean;
  71436. /**
  71437. * Gets or sets a boolean which defines if optimization octree has to be updated
  71438. */
  71439. static set UpdateSelectionTree(value: boolean);
  71440. /**
  71441. * Gets a string describing the action executed by the current optimization
  71442. * @return description string
  71443. */
  71444. getDescription(): string;
  71445. private _canBeMerged;
  71446. /**
  71447. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71448. * @param scene defines the current scene where to apply this optimization
  71449. * @param optimizer defines the current optimizer
  71450. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71451. * @returns true if everything that can be done was applied
  71452. */
  71453. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71454. }
  71455. /**
  71456. * Defines a list of options used by SceneOptimizer
  71457. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71458. */
  71459. export class SceneOptimizerOptions {
  71460. /**
  71461. * Defines the target frame rate to reach (60 by default)
  71462. */
  71463. targetFrameRate: number;
  71464. /**
  71465. * Defines the interval between two checkes (2000ms by default)
  71466. */
  71467. trackerDuration: number;
  71468. /**
  71469. * Gets the list of optimizations to apply
  71470. */
  71471. optimizations: SceneOptimization[];
  71472. /**
  71473. * Creates a new list of options used by SceneOptimizer
  71474. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71475. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71476. */
  71477. constructor(
  71478. /**
  71479. * Defines the target frame rate to reach (60 by default)
  71480. */
  71481. targetFrameRate?: number,
  71482. /**
  71483. * Defines the interval between two checkes (2000ms by default)
  71484. */
  71485. trackerDuration?: number);
  71486. /**
  71487. * Add a new optimization
  71488. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71489. * @returns the current SceneOptimizerOptions
  71490. */
  71491. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71492. /**
  71493. * Add a new custom optimization
  71494. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71495. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71496. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71497. * @returns the current SceneOptimizerOptions
  71498. */
  71499. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71500. /**
  71501. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71502. * @param targetFrameRate defines the target frame rate (60 by default)
  71503. * @returns a SceneOptimizerOptions object
  71504. */
  71505. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71506. /**
  71507. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71508. * @param targetFrameRate defines the target frame rate (60 by default)
  71509. * @returns a SceneOptimizerOptions object
  71510. */
  71511. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71512. /**
  71513. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71514. * @param targetFrameRate defines the target frame rate (60 by default)
  71515. * @returns a SceneOptimizerOptions object
  71516. */
  71517. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71518. }
  71519. /**
  71520. * Class used to run optimizations in order to reach a target frame rate
  71521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71522. */
  71523. export class SceneOptimizer implements IDisposable {
  71524. private _isRunning;
  71525. private _options;
  71526. private _scene;
  71527. private _currentPriorityLevel;
  71528. private _targetFrameRate;
  71529. private _trackerDuration;
  71530. private _currentFrameRate;
  71531. private _sceneDisposeObserver;
  71532. private _improvementMode;
  71533. /**
  71534. * Defines an observable called when the optimizer reaches the target frame rate
  71535. */
  71536. onSuccessObservable: Observable<SceneOptimizer>;
  71537. /**
  71538. * Defines an observable called when the optimizer enables an optimization
  71539. */
  71540. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71541. /**
  71542. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71543. */
  71544. onFailureObservable: Observable<SceneOptimizer>;
  71545. /**
  71546. * Gets a boolean indicating if the optimizer is in improvement mode
  71547. */
  71548. get isInImprovementMode(): boolean;
  71549. /**
  71550. * Gets the current priority level (0 at start)
  71551. */
  71552. get currentPriorityLevel(): number;
  71553. /**
  71554. * Gets the current frame rate checked by the SceneOptimizer
  71555. */
  71556. get currentFrameRate(): number;
  71557. /**
  71558. * Gets or sets the current target frame rate (60 by default)
  71559. */
  71560. get targetFrameRate(): number;
  71561. /**
  71562. * Gets or sets the current target frame rate (60 by default)
  71563. */
  71564. set targetFrameRate(value: number);
  71565. /**
  71566. * Gets or sets the current interval between two checks (every 2000ms by default)
  71567. */
  71568. get trackerDuration(): number;
  71569. /**
  71570. * Gets or sets the current interval between two checks (every 2000ms by default)
  71571. */
  71572. set trackerDuration(value: number);
  71573. /**
  71574. * Gets the list of active optimizations
  71575. */
  71576. get optimizations(): SceneOptimization[];
  71577. /**
  71578. * Creates a new SceneOptimizer
  71579. * @param scene defines the scene to work on
  71580. * @param options defines the options to use with the SceneOptimizer
  71581. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71582. * @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)
  71583. */
  71584. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71585. /**
  71586. * Stops the current optimizer
  71587. */
  71588. stop(): void;
  71589. /**
  71590. * Reset the optimizer to initial step (current priority level = 0)
  71591. */
  71592. reset(): void;
  71593. /**
  71594. * Start the optimizer. By default it will try to reach a specific framerate
  71595. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71596. */
  71597. start(): void;
  71598. private _checkCurrentState;
  71599. /**
  71600. * Release all resources
  71601. */
  71602. dispose(): void;
  71603. /**
  71604. * Helper function to create a SceneOptimizer with one single line of code
  71605. * @param scene defines the scene to work on
  71606. * @param options defines the options to use with the SceneOptimizer
  71607. * @param onSuccess defines a callback to call on success
  71608. * @param onFailure defines a callback to call on failure
  71609. * @returns the new SceneOptimizer object
  71610. */
  71611. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71612. }
  71613. }
  71614. declare module BABYLON {
  71615. /**
  71616. * Class used to serialize a scene into a string
  71617. */
  71618. export class SceneSerializer {
  71619. /**
  71620. * Clear cache used by a previous serialization
  71621. */
  71622. static ClearCache(): void;
  71623. /**
  71624. * Serialize a scene into a JSON compatible object
  71625. * @param scene defines the scene to serialize
  71626. * @returns a JSON compatible object
  71627. */
  71628. static Serialize(scene: Scene): any;
  71629. /**
  71630. * Serialize a mesh into a JSON compatible object
  71631. * @param toSerialize defines the mesh to serialize
  71632. * @param withParents defines if parents must be serialized as well
  71633. * @param withChildren defines if children must be serialized as well
  71634. * @returns a JSON compatible object
  71635. */
  71636. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71637. }
  71638. }
  71639. declare module BABYLON {
  71640. /**
  71641. * Class used to host texture specific utilities
  71642. */
  71643. export class TextureTools {
  71644. /**
  71645. * Uses the GPU to create a copy texture rescaled at a given size
  71646. * @param texture Texture to copy from
  71647. * @param width defines the desired width
  71648. * @param height defines the desired height
  71649. * @param useBilinearMode defines if bilinear mode has to be used
  71650. * @return the generated texture
  71651. */
  71652. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71653. }
  71654. }
  71655. declare module BABYLON {
  71656. /**
  71657. * This represents the different options available for the video capture.
  71658. */
  71659. export interface VideoRecorderOptions {
  71660. /** Defines the mime type of the video. */
  71661. mimeType: string;
  71662. /** Defines the FPS the video should be recorded at. */
  71663. fps: number;
  71664. /** Defines the chunk size for the recording data. */
  71665. recordChunckSize: number;
  71666. /** The audio tracks to attach to the recording. */
  71667. audioTracks?: MediaStreamTrack[];
  71668. }
  71669. /**
  71670. * This can help with recording videos from BabylonJS.
  71671. * This is based on the available WebRTC functionalities of the browser.
  71672. *
  71673. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71674. */
  71675. export class VideoRecorder {
  71676. private static readonly _defaultOptions;
  71677. /**
  71678. * Returns whether or not the VideoRecorder is available in your browser.
  71679. * @param engine Defines the Babylon Engine.
  71680. * @returns true if supported otherwise false.
  71681. */
  71682. static IsSupported(engine: Engine): boolean;
  71683. private readonly _options;
  71684. private _canvas;
  71685. private _mediaRecorder;
  71686. private _recordedChunks;
  71687. private _fileName;
  71688. private _resolve;
  71689. private _reject;
  71690. /**
  71691. * True when a recording is already in progress.
  71692. */
  71693. get isRecording(): boolean;
  71694. /**
  71695. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71696. * @param engine Defines the BabylonJS Engine you wish to record.
  71697. * @param options Defines options that can be used to customize the capture.
  71698. */
  71699. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71700. /**
  71701. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71702. */
  71703. stopRecording(): void;
  71704. /**
  71705. * Starts recording the canvas for a max duration specified in parameters.
  71706. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71707. * If null no automatic download will start and you can rely on the promise to get the data back.
  71708. * @param maxDuration Defines the maximum recording time in seconds.
  71709. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71710. * @return A promise callback at the end of the recording with the video data in Blob.
  71711. */
  71712. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71713. /**
  71714. * Releases internal resources used during the recording.
  71715. */
  71716. dispose(): void;
  71717. private _handleDataAvailable;
  71718. private _handleError;
  71719. private _handleStop;
  71720. }
  71721. }
  71722. declare module BABYLON {
  71723. /**
  71724. * Class containing a set of static utilities functions for screenshots
  71725. */
  71726. export class ScreenshotTools {
  71727. /**
  71728. * Captures a screenshot of the current rendering
  71729. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71730. * @param engine defines the rendering engine
  71731. * @param camera defines the source camera
  71732. * @param size This parameter can be set to a single number or to an object with the
  71733. * following (optional) properties: precision, width, height. If a single number is passed,
  71734. * it will be used for both width and height. If an object is passed, the screenshot size
  71735. * will be derived from the parameters. The precision property is a multiplier allowing
  71736. * rendering at a higher or lower resolution
  71737. * @param successCallback defines the callback receives a single parameter which contains the
  71738. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71739. * src parameter of an <img> to display it
  71740. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71741. * Check your browser for supported MIME types
  71742. */
  71743. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71744. /**
  71745. * Captures a screenshot of the current rendering
  71746. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71747. * @param engine defines the rendering engine
  71748. * @param camera defines the source camera
  71749. * @param size This parameter can be set to a single number or to an object with the
  71750. * following (optional) properties: precision, width, height. If a single number is passed,
  71751. * it will be used for both width and height. If an object is passed, the screenshot size
  71752. * will be derived from the parameters. The precision property is a multiplier allowing
  71753. * rendering at a higher or lower resolution
  71754. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71755. * Check your browser for supported MIME types
  71756. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71757. * to the src parameter of an <img> to display it
  71758. */
  71759. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71760. /**
  71761. * Generates an image screenshot from the specified camera.
  71762. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71763. * @param engine The engine to use for rendering
  71764. * @param camera The camera to use for rendering
  71765. * @param size This parameter can be set to a single number or to an object with the
  71766. * following (optional) properties: precision, width, height. If a single number is passed,
  71767. * it will be used for both width and height. If an object is passed, the screenshot size
  71768. * will be derived from the parameters. The precision property is a multiplier allowing
  71769. * rendering at a higher or lower resolution
  71770. * @param successCallback The callback receives a single parameter which contains the
  71771. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71772. * src parameter of an <img> to display it
  71773. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71774. * Check your browser for supported MIME types
  71775. * @param samples Texture samples (default: 1)
  71776. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71777. * @param fileName A name for for the downloaded file.
  71778. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71779. */
  71780. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  71781. /**
  71782. * Generates an image screenshot from the specified camera.
  71783. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71784. * @param engine The engine to use for rendering
  71785. * @param camera The camera to use for rendering
  71786. * @param size This parameter can be set to a single number or to an object with the
  71787. * following (optional) properties: precision, width, height. If a single number is passed,
  71788. * it will be used for both width and height. If an object is passed, the screenshot size
  71789. * will be derived from the parameters. The precision property is a multiplier allowing
  71790. * rendering at a higher or lower resolution
  71791. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71792. * Check your browser for supported MIME types
  71793. * @param samples Texture samples (default: 1)
  71794. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71795. * @param fileName A name for for the downloaded file.
  71796. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71797. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71798. * to the src parameter of an <img> to display it
  71799. */
  71800. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  71801. /**
  71802. * Gets height and width for screenshot size
  71803. * @private
  71804. */
  71805. private static _getScreenshotSize;
  71806. }
  71807. }
  71808. declare module BABYLON {
  71809. /**
  71810. * Interface for a data buffer
  71811. */
  71812. export interface IDataBuffer {
  71813. /**
  71814. * Reads bytes from the data buffer.
  71815. * @param byteOffset The byte offset to read
  71816. * @param byteLength The byte length to read
  71817. * @returns A promise that resolves when the bytes are read
  71818. */
  71819. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71820. /**
  71821. * The byte length of the buffer.
  71822. */
  71823. readonly byteLength: number;
  71824. }
  71825. /**
  71826. * Utility class for reading from a data buffer
  71827. */
  71828. export class DataReader {
  71829. /**
  71830. * The data buffer associated with this data reader.
  71831. */
  71832. readonly buffer: IDataBuffer;
  71833. /**
  71834. * The current byte offset from the beginning of the data buffer.
  71835. */
  71836. byteOffset: number;
  71837. private _dataView;
  71838. private _dataByteOffset;
  71839. /**
  71840. * Constructor
  71841. * @param buffer The buffer to read
  71842. */
  71843. constructor(buffer: IDataBuffer);
  71844. /**
  71845. * Loads the given byte length.
  71846. * @param byteLength The byte length to load
  71847. * @returns A promise that resolves when the load is complete
  71848. */
  71849. loadAsync(byteLength: number): Promise<void>;
  71850. /**
  71851. * Read a unsigned 32-bit integer from the currently loaded data range.
  71852. * @returns The 32-bit integer read
  71853. */
  71854. readUint32(): number;
  71855. /**
  71856. * Read a byte array from the currently loaded data range.
  71857. * @param byteLength The byte length to read
  71858. * @returns The byte array read
  71859. */
  71860. readUint8Array(byteLength: number): Uint8Array;
  71861. /**
  71862. * Read a string from the currently loaded data range.
  71863. * @param byteLength The byte length to read
  71864. * @returns The string read
  71865. */
  71866. readString(byteLength: number): string;
  71867. /**
  71868. * Skips the given byte length the currently loaded data range.
  71869. * @param byteLength The byte length to skip
  71870. */
  71871. skipBytes(byteLength: number): void;
  71872. }
  71873. }
  71874. declare module BABYLON {
  71875. /**
  71876. * Class for storing data to local storage if available or in-memory storage otherwise
  71877. */
  71878. export class DataStorage {
  71879. private static _Storage;
  71880. private static _GetStorage;
  71881. /**
  71882. * Reads a string from the data storage
  71883. * @param key The key to read
  71884. * @param defaultValue The value if the key doesn't exist
  71885. * @returns The string value
  71886. */
  71887. static ReadString(key: string, defaultValue: string): string;
  71888. /**
  71889. * Writes a string to the data storage
  71890. * @param key The key to write
  71891. * @param value The value to write
  71892. */
  71893. static WriteString(key: string, value: string): void;
  71894. /**
  71895. * Reads a boolean from the data storage
  71896. * @param key The key to read
  71897. * @param defaultValue The value if the key doesn't exist
  71898. * @returns The boolean value
  71899. */
  71900. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  71901. /**
  71902. * Writes a boolean to the data storage
  71903. * @param key The key to write
  71904. * @param value The value to write
  71905. */
  71906. static WriteBoolean(key: string, value: boolean): void;
  71907. /**
  71908. * Reads a number from the data storage
  71909. * @param key The key to read
  71910. * @param defaultValue The value if the key doesn't exist
  71911. * @returns The number value
  71912. */
  71913. static ReadNumber(key: string, defaultValue: number): number;
  71914. /**
  71915. * Writes a number to the data storage
  71916. * @param key The key to write
  71917. * @param value The value to write
  71918. */
  71919. static WriteNumber(key: string, value: number): void;
  71920. }
  71921. }
  71922. declare module BABYLON {
  71923. /**
  71924. * Options used for hit testing
  71925. */
  71926. export interface IWebXRLegacyHitTestOptions {
  71927. /**
  71928. * Only test when user interacted with the scene. Default - hit test every frame
  71929. */
  71930. testOnPointerDownOnly?: boolean;
  71931. /**
  71932. * The node to use to transform the local results to world coordinates
  71933. */
  71934. worldParentNode?: TransformNode;
  71935. }
  71936. /**
  71937. * Interface defining the babylon result of raycasting/hit-test
  71938. */
  71939. export interface IWebXRLegacyHitResult {
  71940. /**
  71941. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71942. */
  71943. transformationMatrix: Matrix;
  71944. /**
  71945. * The native hit test result
  71946. */
  71947. xrHitResult: XRHitResult | XRHitTestResult;
  71948. }
  71949. /**
  71950. * The currently-working hit-test module.
  71951. * Hit test (or Ray-casting) is used to interact with the real world.
  71952. * For further information read here - https://github.com/immersive-web/hit-test
  71953. */
  71954. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  71955. /**
  71956. * options to use when constructing this feature
  71957. */
  71958. readonly options: IWebXRLegacyHitTestOptions;
  71959. private _direction;
  71960. private _mat;
  71961. private _onSelectEnabled;
  71962. private _origin;
  71963. /**
  71964. * The module's name
  71965. */
  71966. static readonly Name: string;
  71967. /**
  71968. * The (Babylon) version of this module.
  71969. * This is an integer representing the implementation version.
  71970. * This number does not correspond to the WebXR specs version
  71971. */
  71972. static readonly Version: number;
  71973. /**
  71974. * Populated with the last native XR Hit Results
  71975. */
  71976. lastNativeXRHitResults: XRHitResult[];
  71977. /**
  71978. * Triggered when new babylon (transformed) hit test results are available
  71979. */
  71980. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  71981. /**
  71982. * Creates a new instance of the (legacy version) hit test feature
  71983. * @param _xrSessionManager an instance of WebXRSessionManager
  71984. * @param options options to use when constructing this feature
  71985. */
  71986. constructor(_xrSessionManager: WebXRSessionManager,
  71987. /**
  71988. * options to use when constructing this feature
  71989. */
  71990. options?: IWebXRLegacyHitTestOptions);
  71991. /**
  71992. * execute a hit test with an XR Ray
  71993. *
  71994. * @param xrSession a native xrSession that will execute this hit test
  71995. * @param xrRay the ray (position and direction) to use for ray-casting
  71996. * @param referenceSpace native XR reference space to use for the hit-test
  71997. * @param filter filter function that will filter the results
  71998. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71999. */
  72000. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72001. /**
  72002. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72003. * @param event the (select) event to use to select with
  72004. * @param referenceSpace the reference space to use for this hit test
  72005. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72006. */
  72007. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72008. /**
  72009. * attach this feature
  72010. * Will usually be called by the features manager
  72011. *
  72012. * @returns true if successful.
  72013. */
  72014. attach(): boolean;
  72015. /**
  72016. * detach this feature.
  72017. * Will usually be called by the features manager
  72018. *
  72019. * @returns true if successful.
  72020. */
  72021. detach(): boolean;
  72022. /**
  72023. * Dispose this feature and all of the resources attached
  72024. */
  72025. dispose(): void;
  72026. protected _onXRFrame(frame: XRFrame): void;
  72027. private _onHitTestResults;
  72028. private _onSelect;
  72029. }
  72030. }
  72031. declare module BABYLON {
  72032. /**
  72033. * Options used in the plane detector module
  72034. */
  72035. export interface IWebXRPlaneDetectorOptions {
  72036. /**
  72037. * The node to use to transform the local results to world coordinates
  72038. */
  72039. worldParentNode?: TransformNode;
  72040. }
  72041. /**
  72042. * A babylon interface for a WebXR plane.
  72043. * A Plane is actually a polygon, built from N points in space
  72044. *
  72045. * Supported in chrome 79, not supported in canary 81 ATM
  72046. */
  72047. export interface IWebXRPlane {
  72048. /**
  72049. * a babylon-assigned ID for this polygon
  72050. */
  72051. id: number;
  72052. /**
  72053. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72054. */
  72055. polygonDefinition: Array<Vector3>;
  72056. /**
  72057. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72058. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72059. */
  72060. transformationMatrix: Matrix;
  72061. /**
  72062. * the native xr-plane object
  72063. */
  72064. xrPlane: XRPlane;
  72065. }
  72066. /**
  72067. * The plane detector is used to detect planes in the real world when in AR
  72068. * For more information see https://github.com/immersive-web/real-world-geometry/
  72069. */
  72070. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72071. private _options;
  72072. private _detectedPlanes;
  72073. private _enabled;
  72074. private _lastFrameDetected;
  72075. /**
  72076. * The module's name
  72077. */
  72078. static readonly Name: string;
  72079. /**
  72080. * The (Babylon) version of this module.
  72081. * This is an integer representing the implementation version.
  72082. * This number does not correspond to the WebXR specs version
  72083. */
  72084. static readonly Version: number;
  72085. /**
  72086. * Observers registered here will be executed when a new plane was added to the session
  72087. */
  72088. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72089. /**
  72090. * Observers registered here will be executed when a plane is no longer detected in the session
  72091. */
  72092. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72093. /**
  72094. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72095. * This can execute N times every frame
  72096. */
  72097. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72098. /**
  72099. * construct a new Plane Detector
  72100. * @param _xrSessionManager an instance of xr Session manager
  72101. * @param _options configuration to use when constructing this feature
  72102. */
  72103. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72104. /**
  72105. * Dispose this feature and all of the resources attached
  72106. */
  72107. dispose(): void;
  72108. protected _onXRFrame(frame: XRFrame): void;
  72109. private _init;
  72110. private _updatePlaneWithXRPlane;
  72111. /**
  72112. * avoiding using Array.find for global support.
  72113. * @param xrPlane the plane to find in the array
  72114. */
  72115. private findIndexInPlaneArray;
  72116. }
  72117. }
  72118. declare module BABYLON {
  72119. /**
  72120. * Configuration options of the anchor system
  72121. */
  72122. export interface IWebXRAnchorSystemOptions {
  72123. /**
  72124. * Should a new anchor be added every time a select event is triggered
  72125. */
  72126. addAnchorOnSelect?: boolean;
  72127. /**
  72128. * should the anchor system use plane detection.
  72129. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72130. */
  72131. usePlaneDetection?: boolean;
  72132. /**
  72133. * a node that will be used to convert local to world coordinates
  72134. */
  72135. worldParentNode?: TransformNode;
  72136. }
  72137. /**
  72138. * A babylon container for an XR Anchor
  72139. */
  72140. export interface IWebXRAnchor {
  72141. /**
  72142. * A babylon-assigned ID for this anchor
  72143. */
  72144. id: number;
  72145. /**
  72146. * Transformation matrix to apply to an object attached to this anchor
  72147. */
  72148. transformationMatrix: Matrix;
  72149. /**
  72150. * The native anchor object
  72151. */
  72152. xrAnchor: XRAnchor;
  72153. }
  72154. /**
  72155. * An implementation of the anchor system of WebXR.
  72156. * Note that the current documented implementation is not available in any browser. Future implementations
  72157. * will use the frame to create an anchor and not the session or a detected plane
  72158. * For further information see https://github.com/immersive-web/anchors/
  72159. */
  72160. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72161. private _options;
  72162. private _enabled;
  72163. private _hitTestModule;
  72164. private _lastFrameDetected;
  72165. private _onSelect;
  72166. private _planeDetector;
  72167. private _trackedAnchors;
  72168. /**
  72169. * The module's name
  72170. */
  72171. static readonly Name: string;
  72172. /**
  72173. * The (Babylon) version of this module.
  72174. * This is an integer representing the implementation version.
  72175. * This number does not correspond to the WebXR specs version
  72176. */
  72177. static readonly Version: number;
  72178. /**
  72179. * Observers registered here will be executed when a new anchor was added to the session
  72180. */
  72181. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72182. /**
  72183. * Observers registered here will be executed when an anchor was removed from the session
  72184. */
  72185. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72186. /**
  72187. * Observers registered here will be executed when an existing anchor updates
  72188. * This can execute N times every frame
  72189. */
  72190. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72191. /**
  72192. * constructs a new anchor system
  72193. * @param _xrSessionManager an instance of WebXRSessionManager
  72194. * @param _options configuration object for this feature
  72195. */
  72196. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72197. /**
  72198. * Add anchor at a specific XR point.
  72199. *
  72200. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72201. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72202. * @returns a promise the fulfills when the anchor was created
  72203. */
  72204. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72205. /**
  72206. * attach this feature
  72207. * Will usually be called by the features manager
  72208. *
  72209. * @returns true if successful.
  72210. */
  72211. attach(): boolean;
  72212. /**
  72213. * detach this feature.
  72214. * Will usually be called by the features manager
  72215. *
  72216. * @returns true if successful.
  72217. */
  72218. detach(): boolean;
  72219. /**
  72220. * Dispose this feature and all of the resources attached
  72221. */
  72222. dispose(): void;
  72223. /**
  72224. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72225. * @param hitTestModule the hit-test module to use.
  72226. */
  72227. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72228. /**
  72229. * set the plane detector to use in order to create anchors from frames
  72230. * @param planeDetector the plane-detector module to use
  72231. * @param enable enable plane-anchors. default is true
  72232. */
  72233. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72234. protected _onXRFrame(frame: XRFrame): void;
  72235. /**
  72236. * avoiding using Array.find for global support.
  72237. * @param xrAnchor the plane to find in the array
  72238. */
  72239. private _findIndexInAnchorArray;
  72240. private _updateAnchorWithXRFrame;
  72241. }
  72242. }
  72243. declare module BABYLON {
  72244. /**
  72245. * Options interface for the background remover plugin
  72246. */
  72247. export interface IWebXRBackgroundRemoverOptions {
  72248. /**
  72249. * Further background meshes to disable when entering AR
  72250. */
  72251. backgroundMeshes?: AbstractMesh[];
  72252. /**
  72253. * flags to configure the removal of the environment helper.
  72254. * If not set, the entire background will be removed. If set, flags should be set as well.
  72255. */
  72256. environmentHelperRemovalFlags?: {
  72257. /**
  72258. * Should the skybox be removed (default false)
  72259. */
  72260. skyBox?: boolean;
  72261. /**
  72262. * Should the ground be removed (default false)
  72263. */
  72264. ground?: boolean;
  72265. };
  72266. /**
  72267. * don't disable the environment helper
  72268. */
  72269. ignoreEnvironmentHelper?: boolean;
  72270. }
  72271. /**
  72272. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72273. */
  72274. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72275. /**
  72276. * read-only options to be used in this module
  72277. */
  72278. readonly options: IWebXRBackgroundRemoverOptions;
  72279. /**
  72280. * The module's name
  72281. */
  72282. static readonly Name: string;
  72283. /**
  72284. * The (Babylon) version of this module.
  72285. * This is an integer representing the implementation version.
  72286. * This number does not correspond to the WebXR specs version
  72287. */
  72288. static readonly Version: number;
  72289. /**
  72290. * registered observers will be triggered when the background state changes
  72291. */
  72292. onBackgroundStateChangedObservable: Observable<boolean>;
  72293. /**
  72294. * constructs a new background remover module
  72295. * @param _xrSessionManager the session manager for this module
  72296. * @param options read-only options to be used in this module
  72297. */
  72298. constructor(_xrSessionManager: WebXRSessionManager,
  72299. /**
  72300. * read-only options to be used in this module
  72301. */
  72302. options?: IWebXRBackgroundRemoverOptions);
  72303. /**
  72304. * attach this feature
  72305. * Will usually be called by the features manager
  72306. *
  72307. * @returns true if successful.
  72308. */
  72309. attach(): boolean;
  72310. /**
  72311. * detach this feature.
  72312. * Will usually be called by the features manager
  72313. *
  72314. * @returns true if successful.
  72315. */
  72316. detach(): boolean;
  72317. /**
  72318. * Dispose this feature and all of the resources attached
  72319. */
  72320. dispose(): void;
  72321. protected _onXRFrame(_xrFrame: XRFrame): void;
  72322. private _setBackgroundState;
  72323. }
  72324. }
  72325. declare module BABYLON {
  72326. /**
  72327. * Options for the controller physics feature
  72328. */
  72329. export class IWebXRControllerPhysicsOptions {
  72330. /**
  72331. * Should the headset get its own impostor
  72332. */
  72333. enableHeadsetImpostor?: boolean;
  72334. /**
  72335. * Optional parameters for the headset impostor
  72336. */
  72337. headsetImpostorParams?: {
  72338. /**
  72339. * The type of impostor to create. Default is sphere
  72340. */
  72341. impostorType: number;
  72342. /**
  72343. * the size of the impostor. Defaults to 10cm
  72344. */
  72345. impostorSize?: number | {
  72346. width: number;
  72347. height: number;
  72348. depth: number;
  72349. };
  72350. /**
  72351. * Friction definitions
  72352. */
  72353. friction?: number;
  72354. /**
  72355. * Restitution
  72356. */
  72357. restitution?: number;
  72358. };
  72359. /**
  72360. * The physics properties of the future impostors
  72361. */
  72362. physicsProperties?: {
  72363. /**
  72364. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72365. * Note that this requires a physics engine that supports mesh impostors!
  72366. */
  72367. useControllerMesh?: boolean;
  72368. /**
  72369. * The type of impostor to create. Default is sphere
  72370. */
  72371. impostorType?: number;
  72372. /**
  72373. * the size of the impostor. Defaults to 10cm
  72374. */
  72375. impostorSize?: number | {
  72376. width: number;
  72377. height: number;
  72378. depth: number;
  72379. };
  72380. /**
  72381. * Friction definitions
  72382. */
  72383. friction?: number;
  72384. /**
  72385. * Restitution
  72386. */
  72387. restitution?: number;
  72388. };
  72389. /**
  72390. * the xr input to use with this pointer selection
  72391. */
  72392. xrInput: WebXRInput;
  72393. }
  72394. /**
  72395. * Add physics impostor to your webxr controllers,
  72396. * including naive calculation of their linear and angular velocity
  72397. */
  72398. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72399. private readonly _options;
  72400. private _attachController;
  72401. private _controllers;
  72402. private _debugMode;
  72403. private _delta;
  72404. private _headsetImpostor?;
  72405. private _headsetMesh?;
  72406. private _lastTimestamp;
  72407. private _tmpQuaternion;
  72408. private _tmpVector;
  72409. /**
  72410. * The module's name
  72411. */
  72412. static readonly Name: string;
  72413. /**
  72414. * The (Babylon) version of this module.
  72415. * This is an integer representing the implementation version.
  72416. * This number does not correspond to the webxr specs version
  72417. */
  72418. static readonly Version: number;
  72419. /**
  72420. * Construct a new Controller Physics Feature
  72421. * @param _xrSessionManager the corresponding xr session manager
  72422. * @param _options options to create this feature with
  72423. */
  72424. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72425. /**
  72426. * @hidden
  72427. * enable debugging - will show console outputs and the impostor mesh
  72428. */
  72429. _enablePhysicsDebug(): void;
  72430. /**
  72431. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72432. * @param xrController the controller to add
  72433. */
  72434. addController(xrController: WebXRInputSource): void;
  72435. /**
  72436. * attach this feature
  72437. * Will usually be called by the features manager
  72438. *
  72439. * @returns true if successful.
  72440. */
  72441. attach(): boolean;
  72442. /**
  72443. * detach this feature.
  72444. * Will usually be called by the features manager
  72445. *
  72446. * @returns true if successful.
  72447. */
  72448. detach(): boolean;
  72449. /**
  72450. * Get the headset impostor, if enabled
  72451. * @returns the impostor
  72452. */
  72453. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72454. /**
  72455. * Get the physics impostor of a specific controller.
  72456. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72457. * @param controller the controller or the controller id of which to get the impostor
  72458. * @returns the impostor or null
  72459. */
  72460. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72461. /**
  72462. * Update the physics properties provided in the constructor
  72463. * @param newProperties the new properties object
  72464. */
  72465. setPhysicsProperties(newProperties: {
  72466. impostorType?: number;
  72467. impostorSize?: number | {
  72468. width: number;
  72469. height: number;
  72470. depth: number;
  72471. };
  72472. friction?: number;
  72473. restitution?: number;
  72474. }): void;
  72475. protected _onXRFrame(_xrFrame: any): void;
  72476. private _detachController;
  72477. }
  72478. }
  72479. declare module BABYLON {
  72480. /**
  72481. * Options used for hit testing (version 2)
  72482. */
  72483. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72484. /**
  72485. * Do not create a permanent hit test. Will usually be used when only
  72486. * transient inputs are needed.
  72487. */
  72488. disablePermanentHitTest?: boolean;
  72489. /**
  72490. * Enable transient (for example touch-based) hit test inspections
  72491. */
  72492. enableTransientHitTest?: boolean;
  72493. /**
  72494. * Offset ray for the permanent hit test
  72495. */
  72496. offsetRay?: Vector3;
  72497. /**
  72498. * Offset ray for the transient hit test
  72499. */
  72500. transientOffsetRay?: Vector3;
  72501. /**
  72502. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72503. */
  72504. useReferenceSpace?: boolean;
  72505. }
  72506. /**
  72507. * Interface defining the babylon result of hit-test
  72508. */
  72509. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72510. /**
  72511. * The input source that generated this hit test (if transient)
  72512. */
  72513. inputSource?: XRInputSource;
  72514. /**
  72515. * Is this a transient hit test
  72516. */
  72517. isTransient?: boolean;
  72518. /**
  72519. * Position of the hit test result
  72520. */
  72521. position: Vector3;
  72522. /**
  72523. * Rotation of the hit test result
  72524. */
  72525. rotationQuaternion: Quaternion;
  72526. }
  72527. /**
  72528. * The currently-working hit-test module.
  72529. * Hit test (or Ray-casting) is used to interact with the real world.
  72530. * For further information read here - https://github.com/immersive-web/hit-test
  72531. *
  72532. * Tested on chrome (mobile) 80.
  72533. */
  72534. export class WebXRHitTest extends WebXRAbstractFeature {
  72535. /**
  72536. * options to use when constructing this feature
  72537. */
  72538. readonly options: IWebXRHitTestOptions;
  72539. private _tmpMat;
  72540. private _tmpPos;
  72541. private _tmpQuat;
  72542. private _transientXrHitTestSource;
  72543. private _xrHitTestSource;
  72544. private initHitTestSource;
  72545. /**
  72546. * The module's name
  72547. */
  72548. static readonly Name: string;
  72549. /**
  72550. * The (Babylon) version of this module.
  72551. * This is an integer representing the implementation version.
  72552. * This number does not correspond to the WebXR specs version
  72553. */
  72554. static readonly Version: number;
  72555. /**
  72556. * When set to true, each hit test will have its own position/rotation objects
  72557. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72558. * the developers will clone them or copy them as they see fit.
  72559. */
  72560. autoCloneTransformation: boolean;
  72561. /**
  72562. * Populated with the last native XR Hit Results
  72563. */
  72564. lastNativeXRHitResults: XRHitResult[];
  72565. /**
  72566. * Triggered when new babylon (transformed) hit test results are available
  72567. */
  72568. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72569. /**
  72570. * Use this to temporarily pause hit test checks.
  72571. */
  72572. paused: boolean;
  72573. /**
  72574. * Creates a new instance of the hit test feature
  72575. * @param _xrSessionManager an instance of WebXRSessionManager
  72576. * @param options options to use when constructing this feature
  72577. */
  72578. constructor(_xrSessionManager: WebXRSessionManager,
  72579. /**
  72580. * options to use when constructing this feature
  72581. */
  72582. options?: IWebXRHitTestOptions);
  72583. /**
  72584. * attach this feature
  72585. * Will usually be called by the features manager
  72586. *
  72587. * @returns true if successful.
  72588. */
  72589. attach(): boolean;
  72590. /**
  72591. * detach this feature.
  72592. * Will usually be called by the features manager
  72593. *
  72594. * @returns true if successful.
  72595. */
  72596. detach(): boolean;
  72597. /**
  72598. * Dispose this feature and all of the resources attached
  72599. */
  72600. dispose(): void;
  72601. protected _onXRFrame(frame: XRFrame): void;
  72602. private _processWebXRHitTestResult;
  72603. }
  72604. }
  72605. declare module BABYLON {
  72606. /**
  72607. * The motion controller class for all microsoft mixed reality controllers
  72608. */
  72609. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72610. protected readonly _mapping: {
  72611. defaultButton: {
  72612. valueNodeName: string;
  72613. unpressedNodeName: string;
  72614. pressedNodeName: string;
  72615. };
  72616. defaultAxis: {
  72617. valueNodeName: string;
  72618. minNodeName: string;
  72619. maxNodeName: string;
  72620. };
  72621. buttons: {
  72622. "xr-standard-trigger": {
  72623. rootNodeName: string;
  72624. componentProperty: string;
  72625. states: string[];
  72626. };
  72627. "xr-standard-squeeze": {
  72628. rootNodeName: string;
  72629. componentProperty: string;
  72630. states: string[];
  72631. };
  72632. "xr-standard-touchpad": {
  72633. rootNodeName: string;
  72634. labelAnchorNodeName: string;
  72635. touchPointNodeName: string;
  72636. };
  72637. "xr-standard-thumbstick": {
  72638. rootNodeName: string;
  72639. componentProperty: string;
  72640. states: string[];
  72641. };
  72642. };
  72643. axes: {
  72644. "xr-standard-touchpad": {
  72645. "x-axis": {
  72646. rootNodeName: string;
  72647. };
  72648. "y-axis": {
  72649. rootNodeName: string;
  72650. };
  72651. };
  72652. "xr-standard-thumbstick": {
  72653. "x-axis": {
  72654. rootNodeName: string;
  72655. };
  72656. "y-axis": {
  72657. rootNodeName: string;
  72658. };
  72659. };
  72660. };
  72661. };
  72662. /**
  72663. * The base url used to load the left and right controller models
  72664. */
  72665. static MODEL_BASE_URL: string;
  72666. /**
  72667. * The name of the left controller model file
  72668. */
  72669. static MODEL_LEFT_FILENAME: string;
  72670. /**
  72671. * The name of the right controller model file
  72672. */
  72673. static MODEL_RIGHT_FILENAME: string;
  72674. profileId: string;
  72675. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72676. protected _getFilenameAndPath(): {
  72677. filename: string;
  72678. path: string;
  72679. };
  72680. protected _getModelLoadingConstraints(): boolean;
  72681. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72682. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72683. protected _updateModel(): void;
  72684. }
  72685. }
  72686. declare module BABYLON {
  72687. /**
  72688. * The motion controller class for oculus touch (quest, rift).
  72689. * This class supports legacy mapping as well the standard xr mapping
  72690. */
  72691. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72692. private _forceLegacyControllers;
  72693. private _modelRootNode;
  72694. /**
  72695. * The base url used to load the left and right controller models
  72696. */
  72697. static MODEL_BASE_URL: string;
  72698. /**
  72699. * The name of the left controller model file
  72700. */
  72701. static MODEL_LEFT_FILENAME: string;
  72702. /**
  72703. * The name of the right controller model file
  72704. */
  72705. static MODEL_RIGHT_FILENAME: string;
  72706. /**
  72707. * Base Url for the Quest controller model.
  72708. */
  72709. static QUEST_MODEL_BASE_URL: string;
  72710. profileId: string;
  72711. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72712. protected _getFilenameAndPath(): {
  72713. filename: string;
  72714. path: string;
  72715. };
  72716. protected _getModelLoadingConstraints(): boolean;
  72717. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72718. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72719. protected _updateModel(): void;
  72720. /**
  72721. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72722. * between the touch and touch 2.
  72723. */
  72724. private _isQuest;
  72725. }
  72726. }
  72727. declare module BABYLON {
  72728. /**
  72729. * The motion controller class for the standard HTC-Vive controllers
  72730. */
  72731. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72732. private _modelRootNode;
  72733. /**
  72734. * The base url used to load the left and right controller models
  72735. */
  72736. static MODEL_BASE_URL: string;
  72737. /**
  72738. * File name for the controller model.
  72739. */
  72740. static MODEL_FILENAME: string;
  72741. profileId: string;
  72742. /**
  72743. * Create a new Vive motion controller object
  72744. * @param scene the scene to use to create this controller
  72745. * @param gamepadObject the corresponding gamepad object
  72746. * @param handedness the handedness of the controller
  72747. */
  72748. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72749. protected _getFilenameAndPath(): {
  72750. filename: string;
  72751. path: string;
  72752. };
  72753. protected _getModelLoadingConstraints(): boolean;
  72754. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72755. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72756. protected _updateModel(): void;
  72757. }
  72758. }
  72759. declare module BABYLON {
  72760. /**
  72761. * A cursor which tracks a point on a path
  72762. */
  72763. export class PathCursor {
  72764. private path;
  72765. /**
  72766. * Stores path cursor callbacks for when an onchange event is triggered
  72767. */
  72768. private _onchange;
  72769. /**
  72770. * The value of the path cursor
  72771. */
  72772. value: number;
  72773. /**
  72774. * The animation array of the path cursor
  72775. */
  72776. animations: Animation[];
  72777. /**
  72778. * Initializes the path cursor
  72779. * @param path The path to track
  72780. */
  72781. constructor(path: Path2);
  72782. /**
  72783. * Gets the cursor point on the path
  72784. * @returns A point on the path cursor at the cursor location
  72785. */
  72786. getPoint(): Vector3;
  72787. /**
  72788. * Moves the cursor ahead by the step amount
  72789. * @param step The amount to move the cursor forward
  72790. * @returns This path cursor
  72791. */
  72792. moveAhead(step?: number): PathCursor;
  72793. /**
  72794. * Moves the cursor behind by the step amount
  72795. * @param step The amount to move the cursor back
  72796. * @returns This path cursor
  72797. */
  72798. moveBack(step?: number): PathCursor;
  72799. /**
  72800. * Moves the cursor by the step amount
  72801. * If the step amount is greater than one, an exception is thrown
  72802. * @param step The amount to move the cursor
  72803. * @returns This path cursor
  72804. */
  72805. move(step: number): PathCursor;
  72806. /**
  72807. * Ensures that the value is limited between zero and one
  72808. * @returns This path cursor
  72809. */
  72810. private ensureLimits;
  72811. /**
  72812. * Runs onchange callbacks on change (used by the animation engine)
  72813. * @returns This path cursor
  72814. */
  72815. private raiseOnChange;
  72816. /**
  72817. * Executes a function on change
  72818. * @param f A path cursor onchange callback
  72819. * @returns This path cursor
  72820. */
  72821. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72822. }
  72823. }
  72824. declare module BABYLON {
  72825. /** @hidden */
  72826. export class ShaderCodeInliner {
  72827. static readonly InlineToken: string;
  72828. static readonly RegexpFindFunctionNameAndType: RegExp;
  72829. private _sourceCode;
  72830. private _functionDescr;
  72831. private _numMaxIterations;
  72832. debug: boolean;
  72833. get code(): string;
  72834. constructor(sourceCode: string, numMaxIterations?: number);
  72835. processCode(): void;
  72836. private _collectFunctions;
  72837. private _processInlining;
  72838. private _extractBetweenMarkers;
  72839. private _skipWhitespaces;
  72840. private _removeComments;
  72841. private _replaceFunctionCallsByCode;
  72842. private _findBackward;
  72843. private _escapeRegExp;
  72844. private _replaceNames;
  72845. }
  72846. }
  72847. declare module BABYLON {
  72848. /** @hidden */
  72849. export var blurPixelShader: {
  72850. name: string;
  72851. shader: string;
  72852. };
  72853. }
  72854. declare module BABYLON {
  72855. /** @hidden */
  72856. export var pointCloudVertexDeclaration: {
  72857. name: string;
  72858. shader: string;
  72859. };
  72860. }
  72861. // Mixins
  72862. interface Window {
  72863. mozIndexedDB: IDBFactory;
  72864. webkitIndexedDB: IDBFactory;
  72865. msIndexedDB: IDBFactory;
  72866. webkitURL: typeof URL;
  72867. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  72868. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  72869. WebGLRenderingContext: WebGLRenderingContext;
  72870. MSGesture: MSGesture;
  72871. CANNON: any;
  72872. AudioContext: AudioContext;
  72873. webkitAudioContext: AudioContext;
  72874. PointerEvent: any;
  72875. Math: Math;
  72876. Uint8Array: Uint8ArrayConstructor;
  72877. Float32Array: Float32ArrayConstructor;
  72878. mozURL: typeof URL;
  72879. msURL: typeof URL;
  72880. VRFrameData: any; // WebVR, from specs 1.1
  72881. DracoDecoderModule: any;
  72882. setImmediate(handler: (...args: any[]) => void): number;
  72883. }
  72884. interface HTMLCanvasElement {
  72885. requestPointerLock(): void;
  72886. msRequestPointerLock?(): void;
  72887. mozRequestPointerLock?(): void;
  72888. webkitRequestPointerLock?(): void;
  72889. /** Track wether a record is in progress */
  72890. isRecording: boolean;
  72891. /** Capture Stream method defined by some browsers */
  72892. captureStream(fps?: number): MediaStream;
  72893. }
  72894. interface CanvasRenderingContext2D {
  72895. msImageSmoothingEnabled: boolean;
  72896. }
  72897. interface MouseEvent {
  72898. mozMovementX: number;
  72899. mozMovementY: number;
  72900. webkitMovementX: number;
  72901. webkitMovementY: number;
  72902. msMovementX: number;
  72903. msMovementY: number;
  72904. }
  72905. interface Navigator {
  72906. mozGetVRDevices: (any: any) => any;
  72907. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72908. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72909. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72910. webkitGetGamepads(): Gamepad[];
  72911. msGetGamepads(): Gamepad[];
  72912. webkitGamepads(): Gamepad[];
  72913. }
  72914. interface HTMLVideoElement {
  72915. mozSrcObject: any;
  72916. }
  72917. interface Math {
  72918. fround(x: number): number;
  72919. imul(a: number, b: number): number;
  72920. }
  72921. interface WebGLRenderingContext {
  72922. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  72923. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  72924. vertexAttribDivisor(index: number, divisor: number): void;
  72925. createVertexArray(): any;
  72926. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  72927. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  72928. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  72929. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  72930. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  72931. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  72932. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  72933. // Queries
  72934. createQuery(): WebGLQuery;
  72935. deleteQuery(query: WebGLQuery): void;
  72936. beginQuery(target: number, query: WebGLQuery): void;
  72937. endQuery(target: number): void;
  72938. getQueryParameter(query: WebGLQuery, pname: number): any;
  72939. getQuery(target: number, pname: number): any;
  72940. MAX_SAMPLES: number;
  72941. RGBA8: number;
  72942. READ_FRAMEBUFFER: number;
  72943. DRAW_FRAMEBUFFER: number;
  72944. UNIFORM_BUFFER: number;
  72945. HALF_FLOAT_OES: number;
  72946. RGBA16F: number;
  72947. RGBA32F: number;
  72948. R32F: number;
  72949. RG32F: number;
  72950. RGB32F: number;
  72951. R16F: number;
  72952. RG16F: number;
  72953. RGB16F: number;
  72954. RED: number;
  72955. RG: number;
  72956. R8: number;
  72957. RG8: number;
  72958. UNSIGNED_INT_24_8: number;
  72959. DEPTH24_STENCIL8: number;
  72960. MIN: number;
  72961. MAX: number;
  72962. /* Multiple Render Targets */
  72963. drawBuffers(buffers: number[]): void;
  72964. readBuffer(src: number): void;
  72965. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  72966. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  72967. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  72968. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  72969. // Occlusion Query
  72970. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  72971. ANY_SAMPLES_PASSED: number;
  72972. QUERY_RESULT_AVAILABLE: number;
  72973. QUERY_RESULT: number;
  72974. }
  72975. interface WebGLProgram {
  72976. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  72977. }
  72978. interface EXT_disjoint_timer_query {
  72979. QUERY_COUNTER_BITS_EXT: number;
  72980. TIME_ELAPSED_EXT: number;
  72981. TIMESTAMP_EXT: number;
  72982. GPU_DISJOINT_EXT: number;
  72983. QUERY_RESULT_EXT: number;
  72984. QUERY_RESULT_AVAILABLE_EXT: number;
  72985. queryCounterEXT(query: WebGLQuery, target: number): void;
  72986. createQueryEXT(): WebGLQuery;
  72987. beginQueryEXT(target: number, query: WebGLQuery): void;
  72988. endQueryEXT(target: number): void;
  72989. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  72990. deleteQueryEXT(query: WebGLQuery): void;
  72991. }
  72992. interface WebGLUniformLocation {
  72993. _currentState: any;
  72994. }
  72995. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  72996. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  72997. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  72998. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72999. interface WebGLRenderingContext {
  73000. readonly RASTERIZER_DISCARD: number;
  73001. readonly DEPTH_COMPONENT24: number;
  73002. readonly TEXTURE_3D: number;
  73003. readonly TEXTURE_2D_ARRAY: number;
  73004. readonly TEXTURE_COMPARE_FUNC: number;
  73005. readonly TEXTURE_COMPARE_MODE: number;
  73006. readonly COMPARE_REF_TO_TEXTURE: number;
  73007. readonly TEXTURE_WRAP_R: number;
  73008. readonly HALF_FLOAT: number;
  73009. readonly RGB8: number;
  73010. readonly RED_INTEGER: number;
  73011. readonly RG_INTEGER: number;
  73012. readonly RGB_INTEGER: number;
  73013. readonly RGBA_INTEGER: number;
  73014. readonly R8_SNORM: number;
  73015. readonly RG8_SNORM: number;
  73016. readonly RGB8_SNORM: number;
  73017. readonly RGBA8_SNORM: number;
  73018. readonly R8I: number;
  73019. readonly RG8I: number;
  73020. readonly RGB8I: number;
  73021. readonly RGBA8I: number;
  73022. readonly R8UI: number;
  73023. readonly RG8UI: number;
  73024. readonly RGB8UI: number;
  73025. readonly RGBA8UI: number;
  73026. readonly R16I: number;
  73027. readonly RG16I: number;
  73028. readonly RGB16I: number;
  73029. readonly RGBA16I: number;
  73030. readonly R16UI: number;
  73031. readonly RG16UI: number;
  73032. readonly RGB16UI: number;
  73033. readonly RGBA16UI: number;
  73034. readonly R32I: number;
  73035. readonly RG32I: number;
  73036. readonly RGB32I: number;
  73037. readonly RGBA32I: number;
  73038. readonly R32UI: number;
  73039. readonly RG32UI: number;
  73040. readonly RGB32UI: number;
  73041. readonly RGBA32UI: number;
  73042. readonly RGB10_A2UI: number;
  73043. readonly R11F_G11F_B10F: number;
  73044. readonly RGB9_E5: number;
  73045. readonly RGB10_A2: number;
  73046. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73047. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73048. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73049. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73050. readonly DEPTH_COMPONENT32F: number;
  73051. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73052. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73053. 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;
  73054. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73055. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73056. readonly TRANSFORM_FEEDBACK: number;
  73057. readonly INTERLEAVED_ATTRIBS: number;
  73058. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73059. createTransformFeedback(): WebGLTransformFeedback;
  73060. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73061. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73062. beginTransformFeedback(primitiveMode: number): void;
  73063. endTransformFeedback(): void;
  73064. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73065. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73066. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73067. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73068. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73069. }
  73070. interface ImageBitmap {
  73071. readonly width: number;
  73072. readonly height: number;
  73073. close(): void;
  73074. }
  73075. interface WebGLQuery extends WebGLObject {
  73076. }
  73077. declare var WebGLQuery: {
  73078. prototype: WebGLQuery;
  73079. new(): WebGLQuery;
  73080. };
  73081. interface WebGLSampler extends WebGLObject {
  73082. }
  73083. declare var WebGLSampler: {
  73084. prototype: WebGLSampler;
  73085. new(): WebGLSampler;
  73086. };
  73087. interface WebGLSync extends WebGLObject {
  73088. }
  73089. declare var WebGLSync: {
  73090. prototype: WebGLSync;
  73091. new(): WebGLSync;
  73092. };
  73093. interface WebGLTransformFeedback extends WebGLObject {
  73094. }
  73095. declare var WebGLTransformFeedback: {
  73096. prototype: WebGLTransformFeedback;
  73097. new(): WebGLTransformFeedback;
  73098. };
  73099. interface WebGLVertexArrayObject extends WebGLObject {
  73100. }
  73101. declare var WebGLVertexArrayObject: {
  73102. prototype: WebGLVertexArrayObject;
  73103. new(): WebGLVertexArrayObject;
  73104. };
  73105. // Type definitions for WebVR API
  73106. // Project: https://w3c.github.io/webvr/
  73107. // Definitions by: six a <https://github.com/lostfictions>
  73108. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73109. interface VRDisplay extends EventTarget {
  73110. /**
  73111. * Dictionary of capabilities describing the VRDisplay.
  73112. */
  73113. readonly capabilities: VRDisplayCapabilities;
  73114. /**
  73115. * z-depth defining the far plane of the eye view frustum
  73116. * enables mapping of values in the render target depth
  73117. * attachment to scene coordinates. Initially set to 10000.0.
  73118. */
  73119. depthFar: number;
  73120. /**
  73121. * z-depth defining the near plane of the eye view frustum
  73122. * enables mapping of values in the render target depth
  73123. * attachment to scene coordinates. Initially set to 0.01.
  73124. */
  73125. depthNear: number;
  73126. /**
  73127. * An identifier for this distinct VRDisplay. Used as an
  73128. * association point in the Gamepad API.
  73129. */
  73130. readonly displayId: number;
  73131. /**
  73132. * A display name, a user-readable name identifying it.
  73133. */
  73134. readonly displayName: string;
  73135. readonly isConnected: boolean;
  73136. readonly isPresenting: boolean;
  73137. /**
  73138. * If this VRDisplay supports room-scale experiences, the optional
  73139. * stage attribute contains details on the room-scale parameters.
  73140. */
  73141. readonly stageParameters: VRStageParameters | null;
  73142. /**
  73143. * Passing the value returned by `requestAnimationFrame` to
  73144. * `cancelAnimationFrame` will unregister the callback.
  73145. * @param handle Define the hanle of the request to cancel
  73146. */
  73147. cancelAnimationFrame(handle: number): void;
  73148. /**
  73149. * Stops presenting to the VRDisplay.
  73150. * @returns a promise to know when it stopped
  73151. */
  73152. exitPresent(): Promise<void>;
  73153. /**
  73154. * Return the current VREyeParameters for the given eye.
  73155. * @param whichEye Define the eye we want the parameter for
  73156. * @returns the eye parameters
  73157. */
  73158. getEyeParameters(whichEye: string): VREyeParameters;
  73159. /**
  73160. * Populates the passed VRFrameData with the information required to render
  73161. * the current frame.
  73162. * @param frameData Define the data structure to populate
  73163. * @returns true if ok otherwise false
  73164. */
  73165. getFrameData(frameData: VRFrameData): boolean;
  73166. /**
  73167. * Get the layers currently being presented.
  73168. * @returns the list of VR layers
  73169. */
  73170. getLayers(): VRLayer[];
  73171. /**
  73172. * Return a VRPose containing the future predicted pose of the VRDisplay
  73173. * when the current frame will be presented. The value returned will not
  73174. * change until JavaScript has returned control to the browser.
  73175. *
  73176. * The VRPose will contain the position, orientation, velocity,
  73177. * and acceleration of each of these properties.
  73178. * @returns the pose object
  73179. */
  73180. getPose(): VRPose;
  73181. /**
  73182. * Return the current instantaneous pose of the VRDisplay, with no
  73183. * prediction applied.
  73184. * @returns the current instantaneous pose
  73185. */
  73186. getImmediatePose(): VRPose;
  73187. /**
  73188. * The callback passed to `requestAnimationFrame` will be called
  73189. * any time a new frame should be rendered. When the VRDisplay is
  73190. * presenting the callback will be called at the native refresh
  73191. * rate of the HMD. When not presenting this function acts
  73192. * identically to how window.requestAnimationFrame acts. Content should
  73193. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73194. * asynchronously from other displays and at differing refresh rates.
  73195. * @param callback Define the eaction to run next frame
  73196. * @returns the request handle it
  73197. */
  73198. requestAnimationFrame(callback: FrameRequestCallback): number;
  73199. /**
  73200. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73201. * Repeat calls while already presenting will update the VRLayers being displayed.
  73202. * @param layers Define the list of layer to present
  73203. * @returns a promise to know when the request has been fulfilled
  73204. */
  73205. requestPresent(layers: VRLayer[]): Promise<void>;
  73206. /**
  73207. * Reset the pose for this display, treating its current position and
  73208. * orientation as the "origin/zero" values. VRPose.position,
  73209. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73210. * updated when calling resetPose(). This should be called in only
  73211. * sitting-space experiences.
  73212. */
  73213. resetPose(): void;
  73214. /**
  73215. * The VRLayer provided to the VRDisplay will be captured and presented
  73216. * in the HMD. Calling this function has the same effect on the source
  73217. * canvas as any other operation that uses its source image, and canvases
  73218. * created without preserveDrawingBuffer set to true will be cleared.
  73219. * @param pose Define the pose to submit
  73220. */
  73221. submitFrame(pose?: VRPose): void;
  73222. }
  73223. declare var VRDisplay: {
  73224. prototype: VRDisplay;
  73225. new(): VRDisplay;
  73226. };
  73227. interface VRLayer {
  73228. leftBounds?: number[] | Float32Array | null;
  73229. rightBounds?: number[] | Float32Array | null;
  73230. source?: HTMLCanvasElement | null;
  73231. }
  73232. interface VRDisplayCapabilities {
  73233. readonly canPresent: boolean;
  73234. readonly hasExternalDisplay: boolean;
  73235. readonly hasOrientation: boolean;
  73236. readonly hasPosition: boolean;
  73237. readonly maxLayers: number;
  73238. }
  73239. interface VREyeParameters {
  73240. /** @deprecated */
  73241. readonly fieldOfView: VRFieldOfView;
  73242. readonly offset: Float32Array;
  73243. readonly renderHeight: number;
  73244. readonly renderWidth: number;
  73245. }
  73246. interface VRFieldOfView {
  73247. readonly downDegrees: number;
  73248. readonly leftDegrees: number;
  73249. readonly rightDegrees: number;
  73250. readonly upDegrees: number;
  73251. }
  73252. interface VRFrameData {
  73253. readonly leftProjectionMatrix: Float32Array;
  73254. readonly leftViewMatrix: Float32Array;
  73255. readonly pose: VRPose;
  73256. readonly rightProjectionMatrix: Float32Array;
  73257. readonly rightViewMatrix: Float32Array;
  73258. readonly timestamp: number;
  73259. }
  73260. interface VRPose {
  73261. readonly angularAcceleration: Float32Array | null;
  73262. readonly angularVelocity: Float32Array | null;
  73263. readonly linearAcceleration: Float32Array | null;
  73264. readonly linearVelocity: Float32Array | null;
  73265. readonly orientation: Float32Array | null;
  73266. readonly position: Float32Array | null;
  73267. readonly timestamp: number;
  73268. }
  73269. interface VRStageParameters {
  73270. sittingToStandingTransform?: Float32Array;
  73271. sizeX?: number;
  73272. sizeY?: number;
  73273. }
  73274. interface Navigator {
  73275. getVRDisplays(): Promise<VRDisplay[]>;
  73276. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73277. }
  73278. interface Window {
  73279. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73280. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73281. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73282. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73283. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73284. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73285. }
  73286. interface Gamepad {
  73287. readonly displayId: number;
  73288. }
  73289. type XRSessionMode =
  73290. | "inline"
  73291. | "immersive-vr"
  73292. | "immersive-ar";
  73293. type XRReferenceSpaceType =
  73294. | "viewer"
  73295. | "local"
  73296. | "local-floor"
  73297. | "bounded-floor"
  73298. | "unbounded";
  73299. type XREnvironmentBlendMode =
  73300. | "opaque"
  73301. | "additive"
  73302. | "alpha-blend";
  73303. type XRVisibilityState =
  73304. | "visible"
  73305. | "visible-blurred"
  73306. | "hidden";
  73307. type XRHandedness =
  73308. | "none"
  73309. | "left"
  73310. | "right";
  73311. type XRTargetRayMode =
  73312. | "gaze"
  73313. | "tracked-pointer"
  73314. | "screen";
  73315. type XREye =
  73316. | "none"
  73317. | "left"
  73318. | "right";
  73319. type XREventType =
  73320. | "devicechange"
  73321. | "visibilitychange"
  73322. | "end"
  73323. | "inputsourceschange"
  73324. | "select"
  73325. | "selectstart"
  73326. | "selectend"
  73327. | "squeeze"
  73328. | "squeezestart"
  73329. | "squeezeend"
  73330. | "reset";
  73331. interface XRSpace extends EventTarget {
  73332. }
  73333. interface XRRenderState {
  73334. depthNear?: number;
  73335. depthFar?: number;
  73336. inlineVerticalFieldOfView?: number;
  73337. baseLayer?: XRWebGLLayer;
  73338. }
  73339. interface XRInputSource {
  73340. handedness: XRHandedness;
  73341. targetRayMode: XRTargetRayMode;
  73342. targetRaySpace: XRSpace;
  73343. gripSpace: XRSpace | undefined;
  73344. gamepad: Gamepad | undefined;
  73345. profiles: Array<string>;
  73346. }
  73347. interface XRSessionInit {
  73348. optionalFeatures?: string[];
  73349. requiredFeatures?: string[];
  73350. }
  73351. interface XRSession extends XRAnchorCreator {
  73352. addEventListener: Function;
  73353. removeEventListener: Function;
  73354. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73355. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73356. requestAnimationFrame: Function;
  73357. end(): Promise<void>;
  73358. renderState: XRRenderState;
  73359. inputSources: Array<XRInputSource>;
  73360. // hit test
  73361. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73362. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73363. // legacy AR hit test
  73364. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73365. // legacy plane detection
  73366. updateWorldTrackingState(options: {
  73367. planeDetectionState?: { enabled: boolean; }
  73368. }): void;
  73369. }
  73370. interface XRReferenceSpace extends XRSpace {
  73371. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73372. onreset: any;
  73373. }
  73374. type XRPlaneSet = Set<XRPlane>;
  73375. type XRAnchorSet = Set<XRAnchor>;
  73376. interface XRFrame {
  73377. session: XRSession;
  73378. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73379. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73380. // AR
  73381. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73382. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73383. // Anchors
  73384. trackedAnchors?: XRAnchorSet;
  73385. // Planes
  73386. worldInformation: {
  73387. detectedPlanes?: XRPlaneSet;
  73388. };
  73389. }
  73390. interface XRViewerPose extends XRPose {
  73391. views: Array<XRView>;
  73392. }
  73393. interface XRPose {
  73394. transform: XRRigidTransform;
  73395. emulatedPosition: boolean;
  73396. }
  73397. interface XRWebGLLayerOptions {
  73398. antialias?: boolean;
  73399. depth?: boolean;
  73400. stencil?: boolean;
  73401. alpha?: boolean;
  73402. multiview?: boolean;
  73403. framebufferScaleFactor?: number;
  73404. }
  73405. declare var XRWebGLLayer: {
  73406. prototype: XRWebGLLayer;
  73407. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73408. };
  73409. interface XRWebGLLayer {
  73410. framebuffer: WebGLFramebuffer;
  73411. framebufferWidth: number;
  73412. framebufferHeight: number;
  73413. getViewport: Function;
  73414. }
  73415. declare class XRRigidTransform {
  73416. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73417. position: DOMPointReadOnly;
  73418. orientation: DOMPointReadOnly;
  73419. matrix: Float32Array;
  73420. inverse: XRRigidTransform;
  73421. }
  73422. interface XRView {
  73423. eye: XREye;
  73424. projectionMatrix: Float32Array;
  73425. transform: XRRigidTransform;
  73426. }
  73427. interface XRInputSourceChangeEvent {
  73428. session: XRSession;
  73429. removed: Array<XRInputSource>;
  73430. added: Array<XRInputSource>;
  73431. }
  73432. interface XRInputSourceEvent extends Event {
  73433. readonly frame: XRFrame;
  73434. readonly inputSource: XRInputSource;
  73435. }
  73436. // Experimental(er) features
  73437. declare class XRRay {
  73438. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73439. origin: DOMPointReadOnly;
  73440. direction: DOMPointReadOnly;
  73441. matrix: Float32Array;
  73442. }
  73443. declare enum XRHitTestTrackableType {
  73444. "point",
  73445. "plane"
  73446. }
  73447. interface XRHitResult {
  73448. hitMatrix: Float32Array;
  73449. }
  73450. interface XRTransientInputHitTestResult {
  73451. readonly inputSource: XRInputSource;
  73452. readonly results: Array<XRHitTestResult>;
  73453. }
  73454. interface XRHitTestResult {
  73455. getPose(baseSpace: XRSpace): XRPose | undefined;
  73456. }
  73457. interface XRHitTestSource {
  73458. cancel(): void;
  73459. }
  73460. interface XRTransientInputHitTestSource {
  73461. cancel(): void;
  73462. }
  73463. interface XRHitTestOptionsInit {
  73464. space: XRSpace;
  73465. entityTypes?: Array<XRHitTestTrackableType>;
  73466. offsetRay?: XRRay;
  73467. }
  73468. interface XRTransientInputHitTestOptionsInit {
  73469. profile: string;
  73470. entityTypes?: Array<XRHitTestTrackableType>;
  73471. offsetRay?: XRRay;
  73472. }
  73473. interface XRAnchor {
  73474. // remove?
  73475. id?: string;
  73476. anchorSpace: XRSpace;
  73477. lastChangedTime: number;
  73478. detach(): void;
  73479. }
  73480. interface XRPlane extends XRAnchorCreator {
  73481. orientation: "Horizontal" | "Vertical";
  73482. planeSpace: XRSpace;
  73483. polygon: Array<DOMPointReadOnly>;
  73484. lastChangedTime: number;
  73485. }
  73486. interface XRAnchorCreator {
  73487. // AR Anchors
  73488. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  73489. }